Fix Ailment Buildup UI

This commit is contained in:
GreenComfyTea
2022-11-23 13:35:16 +02:00
parent 2dde202501
commit 673bf28451
4 changed files with 27 additions and 17 deletions

View File

@@ -21,6 +21,8 @@ local get_total_damage_method = enemy_calc_damage_info_type_def:get_method("get_
local get_physical_damage_method = enemy_calc_damage_info_type_def:get_method("get_PhysicalDamage"); local get_physical_damage_method = enemy_calc_damage_info_type_def:get_method("get_PhysicalDamage");
local get_elemental_damage_method = enemy_calc_damage_info_type_def:get_method("get_ElementDamage"); local get_elemental_damage_method = enemy_calc_damage_info_type_def:get_method("get_ElementDamage");
local stun_damage_field = enemy_calc_damage_info_type_def:get_field("<StunDamage>k__BackingField");
local get_condition_damage_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamage"); local get_condition_damage_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamage");
local get_condition_type_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamageType"); local get_condition_type_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamageType");
local get_condition_damage2_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamage2"); local get_condition_damage2_method = enemy_calc_damage_info_type_def:get_method("get_ConditionDamage2");
@@ -174,18 +176,17 @@ function damage_hook.update_damage(enemy, enemy_calc_damage_info)
monster = small_monster.get_monster(enemy); monster = small_monster.get_monster(enemy);
end end
local stun_damage = enemy_calc_damage_info:get_field("<StunDamage>k__BackingField"); local stun_damage = stun_damage_field:get_data(enemy_calc_damage_info);
if stun_damage ~= 0 and stun_damage ~= nil then if attacking_player ~= nil then
ailments.apply_ailment_buildup(monster, attacker_id, ailments.stun_id, stun_damage); ailments.apply_ailment_buildup(monster, attacker_id, ailments.stun_id, stun_damage);
end
ailments.apply_ailment_buildup(monster, attacker_id, condition_type, condition_damage); ailments.apply_ailment_buildup(monster, attacker_id, condition_type, condition_damage);
ailments.apply_ailment_buildup(monster, attacker_id, condition_type2, condition_damage2); ailments.apply_ailment_buildup(monster, attacker_id, condition_type2, condition_damage2);
ailments.apply_ailment_buildup(monster, attacker_id, condition_type3, condition_damage3); ailments.apply_ailment_buildup(monster, attacker_id, condition_type3, condition_damage3);
end
player.update_damage(player.total, damage_source_type, is_large_monster, damage_object); player.update_damage(player.total, damage_source_type, is_large_monster, damage_object);
player.update_damage(attacking_player, damage_source_type, is_large_monster, damage_object); player.update_damage(attacking_player, damage_source_type, is_large_monster, damage_object);
end end
--function damage_hook.on_mystery_core_break(enemy) --function damage_hook.on_mystery_core_break(enemy)

View File

@@ -116,7 +116,6 @@ function ailment_buildup.draw(monster, ailment_buildup_UI, cached_config, ailmen
}; };
ailment_buildup_UI_entity.draw(_player, ailment_buildup_UI, cached_config, ailment_buildup_position_on_screen, opacity_scale, top_buildup); ailment_buildup_UI_entity.draw(_player, ailment_buildup_UI, cached_config, ailment_buildup_position_on_screen, opacity_scale, top_buildup);
last_j = j; last_j = j;
end end

View File

@@ -595,11 +595,15 @@ end
function ailments.apply_ailment_buildup(monster, attacker_id, ailment_type, ailment_buildup) function ailments.apply_ailment_buildup(monster, attacker_id, ailment_type, ailment_buildup)
if monster == nil or player == nil or if monster == nil or
(ailment_type ~= ailments.poison_id and ailment_type ~= ailments.blast_id and ailment_type ~= ailments.stun_id) then (ailment_type ~= ailments.poison_id and ailment_type ~= ailments.blast_id and ailment_type ~= ailments.stun_id) then
return; return;
end end
if ailment_buildup == 0 or ailment_buildup == nil then
return;
end
-- get the buildup accumulator for this type -- get the buildup accumulator for this type
if monster.ailments[ailment_type].buildup == nil then if monster.ailments[ailment_type].buildup == nil then
monster.ailments[ailment_type].buildup = {}; monster.ailments[ailment_type].buildup = {};

View File

@@ -55,28 +55,34 @@ function ailment_buildup_UI_entity.new(buildup_bar, highlighted_buildup_bar, ail
return entity; return entity;
end end
function ailment_buildup_UI_entity.draw(_player, ailment_buildup_UI, cached_config, position_on_screen, opacity_scale, top_buildup) function ailment_buildup_UI_entity.draw(_player_buildup, ailment_buildup_UI, cached_config, position_on_screen, opacity_scale, top_buildup)
local player_buildup_bar_percentage = 0; local player_buildup_bar_percentage = 0;
if cached_config.settings.buildup_bar_relative_to == "Total Buildup" then if cached_config.settings.buildup_bar_relative_to == "Total Buildup" then
player_buildup_bar_percentage = _player.buildup_share; player_buildup_bar_percentage = _player_buildup.buildup_share;
else else
if top_buildup ~= 0 then if top_buildup ~= 0 then
player_buildup_bar_percentage = _player.buildup / top_buildup; player_buildup_bar_percentage = _player_buildup.buildup / top_buildup;
end end
end end
if _player.id == player.myself.id and cached_config.settings.highlighted_bar == "Me" then if _player_buildup.id == player.myself.id and cached_config.settings.highlighted_bar == "Me" then
drawing.draw_bar(ailment_buildup_UI.highlighted_buildup_bar, position_on_screen, opacity_scale, player_buildup_bar_percentage); drawing.draw_bar(ailment_buildup_UI.highlighted_buildup_bar, position_on_screen, opacity_scale, player_buildup_bar_percentage);
elseif cached_config.settings.highlighted_bar == "Top Buildup" and _player.buildup == top_buildup then elseif cached_config.settings.highlighted_bar == "Top Buildup" and _player_buildup.buildup == top_buildup then
drawing.draw_bar(ailment_buildup_UI.highlighted_buildup_bar, position_on_screen, opacity_scale, player_buildup_bar_percentage); drawing.draw_bar(ailment_buildup_UI.highlighted_buildup_bar, position_on_screen, opacity_scale, player_buildup_bar_percentage);
else else
drawing.draw_bar(ailment_buildup_UI.buildup_bar, position_on_screen, opacity_scale, player_buildup_bar_percentage); drawing.draw_bar(ailment_buildup_UI.buildup_bar, position_on_screen, opacity_scale, player_buildup_bar_percentage);
end end
drawing.draw_label(ailment_buildup_UI.player_name_label, position_on_screen, opacity_scale, player.get_player(_player.id).name); local _player = player.get_player(_player_buildup.id);
drawing.draw_label(ailment_buildup_UI.buildup_value_label, position_on_screen, opacity_scale, _player.buildup); local player_name = "Player " .. tostring(_player_buildup.id);
drawing.draw_label(ailment_buildup_UI.buildup_percentage_label, position_on_screen, opacity_scale, 100 * _player.buildup_share); if _player ~= nil then
player_name = _player.name;
end
drawing.draw_label(ailment_buildup_UI.player_name_label, position_on_screen, opacity_scale, player_name);
drawing.draw_label(ailment_buildup_UI.buildup_value_label, position_on_screen, opacity_scale, _player_buildup.buildup);
drawing.draw_label(ailment_buildup_UI.buildup_percentage_label, position_on_screen, opacity_scale, 100 * _player_buildup.buildup_share);
end end
function ailment_buildup_UI_entity.init_module() function ailment_buildup_UI_entity.init_module()