diff --git a/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua b/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua index 1ef0a95..b6f1636 100644 --- a/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua +++ b/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua @@ -140,7 +140,7 @@ function singletons.init_game_keyboard() --log.error("[MHR Overlay] No game keyboard"); end - return singletons.ggame_keyboard; + return singletons.game_keyboard; end function singletons.init_scene_manager() diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailments.lua b/reframework/autorun/MHR_Overlay/Monsters/ailments.lua index 0e944cc..30e592d 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailments.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailments.lua @@ -44,6 +44,7 @@ ailments.shock_trap_id = 13; ailments.capture_id = 14 --tranq bomb ailments.koyashi_id = 15; --dung bomb ailments.steel_fang_id = 16; + ailments.fall_quick_sand_id = 17; ailments.fall_otomo_trap_id = 18; ailments.shock_otomo_trap_id = 19; @@ -134,9 +135,9 @@ function ailments.init_ailments() ailments.new(_ailments, ailments.capture_id); --tranq bomb ailments.new(_ailments, ailments.koyashi_id); --dung bomb ailments.new(_ailments, ailments.steel_fang_id); - ailments.new(_ailments, ailments.fall_quick_sand_id); - ailments.new(_ailments, ailments.fall_otomo_trap_id); - ailments.new(_ailments, ailments.shock_otomo_trap_id); + --ailments.new(_ailments, ailments.fall_quick_sand_id); + --ailments.new(_ailments, ailments.fall_otomo_trap_id); + --ailments.new(_ailments, ailments.shock_otomo_trap_id); _ailments[ailments.poison_id].buildup = {}; _ailments[ailments.poison_id].buildup_share = {}; @@ -174,15 +175,17 @@ local get_limit_method = enemy_condition_damage_param_base_type_def:get_method(" local get_active_time_method = enemy_condition_damage_param_base_type_def:get_method("get_ActiveTime"); local get_active_timer_method = enemy_condition_damage_param_base_type_def:get_method("get_ActiveTimer"); - local poison_damage_field = poison_param_type:get_field("k__BackingField"); local poison_get_is_damage_method = poison_param_type:get_method("get_IsDamage"); -function ailments.update_ailments(enemy, monster) +local system_array_type_def = sdk.find_type_definition("System.Array"); +local length_method = system_array_type_def:get_method("GetLength"); +local get_value_method = system_array_type_def:get_method("GetValue(System.Int32)"); + +function ailments.update_ailments(enemy, monster, is_init) if enemy == nil then return; end - local damage_param = damage_param_field:get_data(enemy); if damage_param == nil then return; @@ -200,27 +203,28 @@ function ailments.update_ailments(enemy, monster) return; end - local condition_param = get_condition_param_method:call(damage_param); + local condition_param_array = get_condition_param_method:call(damage_param); - if condition_param == nil then + if condition_param_array == nil then return; end - local condition_param_table = condition_param:get_elements(); - - if condition_param == nil then + local condition_param_array_size = condition_param_array:get_size(); + if condition_param_array_size == nil then return; end - - for index, ailment_param in ipairs(condition_param_table) do - local id = index - 1; + for id = 0, condition_param_array_size - 1 do if id == ailments.stun_id or id == ailments.poison_id or id == ailments.blast_id then goto continue end - ailments.update_ailment(monster, ailment_param, id); + local ailment_param = condition_param_array[id]; + if ailment_param == nil then + goto continue + end + ailments.update_ailment(monster, ailment_param, id, is_init); ::continue:: end end @@ -242,26 +246,86 @@ function ailments.update_stun_poison_blast_ailments(monster, damage_param) end end -function ailments.update_ailment(monster, ailment_param, id) +function ailments.update_ailment(monster, ailment_param, id, is_init) local is_enable = get_is_enable_method:call(ailment_param); - local activate_count = get_activate_count_method:call(ailment_param):get_element(0):get_field("mValue") or 0; - local buildup = get_stock_method:call(ailment_param):get_element(0):get_field("mValue"); - local buildup_limit = get_limit_method:call(ailment_param):get_element(0):get_field("mValue"); + local activate_count_array = get_activate_count_method:call(ailment_param); + local buildup_array = get_stock_method:call(ailment_param); + local buildup_limit_array = get_limit_method:call(ailment_param); local timer = get_active_timer_method:call(ailment_param); local duration = get_active_time_method:call(ailment_param); local is_active = get_is_active_method:call(ailment_param); + local activate_count = -999; + local buildup = -999; + local buildup_limit = 9999; + + if activate_count_array ~= nil then + local activate_count_array_size = activate_count_array:get_size(); + + if activate_count_array_size ~= nil then + + if activate_count_array_size > 0 then + local activate_count_valuetype = activate_count_array[0]; + + if activate_count_valuetype ~= nil then + local _activate_count = activate_count_valuetype:get_field("mValue"); + + if _activate_count ~= nil then + activate_count = _activate_count; + end + end + end + end + end + + if buildup_array ~= nil then + local buildup_array_size = buildup_array:get_size(); + + if buildup_array_size ~= nil then + + if buildup_array_size > 0 then + local buildup_valuetype = buildup_array[0]; + + if buildup_valuetype ~= nil then + local _buildup = buildup_valuetype:get_field("mValue"); + + if _buildup ~= nil then + buildup = _buildup; + end + end + end + end + end + + if buildup_limit_array ~= nil then + local buildup_limit_array_size = buildup_limit_array:get_size(); + + if buildup_limit_array_size ~= nil then + + if buildup_limit_array_size > 0 then + local buildup_limit_valuetype = buildup_limit_array[0]; + + if buildup_limit_valuetype ~= nil then + local _buildup_limit = buildup_limit_valuetype:get_field("mValue"); + + if _buildup_limit ~= nil then + buildup_limit = _buildup_limit; + end + end + end + end + end + if is_enable == nil then is_enable = true; end - - + if is_enable ~= monster.ailments[id].is_enable then ailments.update_last_change_time(monster, id); end - + monster.ailments[id].is_enable = is_enable; - + if activate_count ~= nil then if activate_count ~= monster.ailments[id].activate_count then ailments.update_last_change_time(monster, id); @@ -273,7 +337,7 @@ function ailments.update_ailment(monster, ailment_param, id) monster.ailments[id].activate_count = activate_count; end - + if buildup ~= nil then if buildup ~= monster.ailments[id].total_buildup then ailments.update_last_change_time(monster, id); @@ -281,7 +345,7 @@ function ailments.update_ailment(monster, ailment_param, id) monster.ailments[id].total_buildup = buildup; end - + if buildup_limit ~= nil then if buildup_limit ~= monster.ailments[id].buildup_limit then ailments.update_last_change_time(monster, id); @@ -289,11 +353,11 @@ function ailments.update_ailment(monster, ailment_param, id) monster.ailments[id].buildup_limit = buildup_limit; end - + if buildup ~= nil and buildup_limit ~= nil and buildup_limit ~= 0 then monster.ailments[id].buildup_percentage = buildup / buildup_limit; end - + if timer ~= nil then if timer ~= monster.ailments[id].timer then ailments.update_last_change_time(monster, id); @@ -301,7 +365,7 @@ function ailments.update_ailment(monster, ailment_param, id) monster.ailments[id].timer = timer; end - + if is_active ~= nil then if is_active ~= monster.ailments[id].is_active then ailments.update_last_change_time(monster, id); @@ -309,7 +373,7 @@ function ailments.update_ailment(monster, ailment_param, id) monster.ailments[id].is_active = is_active; end - + if duration ~= nil and not monster.ailments[id].is_active then if duration ~= monster.ailments[id].duration then ailments.update_last_change_time(monster, id); @@ -317,11 +381,11 @@ function ailments.update_ailment(monster, ailment_param, id) monster.ailments[id].duration = duration; end - + if duration ~= 0 and duration ~= nil then monster.ailments[id].timer_percentage = timer / monster.ailments[id].duration; end - + if is_active then if timer < 0 then timer = 0; @@ -542,8 +606,7 @@ function ailments.apply_ailment_buildup(monster, attacker_id, ailment_type, ailm end -- accumulate this buildup for this attacker - monster.ailments[ailment_type].buildup[attacker_id] = (monster.ailments[ailment_type].buildup[attacker_id] or 0) + - ailment_buildup; + monster.ailments[ailment_type].buildup[attacker_id] = (monster.ailments[ailment_type].buildup[attacker_id] or 0) + ailment_buildup; ailments.calculate_ailment_contribution(monster, ailment_type); end diff --git a/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua b/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua index 5fabf1f..afdc0d4 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua @@ -94,20 +94,24 @@ function large_monster.new(enemy) large_monster.init_UI(monster, monster.static_UI, config.current_config.large_monster_UI.static); large_monster.init_UI(monster, monster.highlighted_UI, config.current_config.large_monster_UI.highlighted); + large_monster.update_position(enemy, monster); + + local physical_param = large_monster.update_health(enemy, monster); + + + large_monster.update_stamina(enemy, monster, nil); + large_monster.update_stamina_timer(enemy, monster, nil); + + large_monster.update_rage(enemy, monster, nil); + large_monster.update_rage_timer(enemy, monster, nil); + + large_monster.update(enemy, monster, true); + pcall(large_monster.update_parts, enemy, monster, physical_param); + if large_monster.list[enemy] == nil then large_monster.list[enemy] = monster; end - large_monster.update_position(enemy, monster); - large_monster.update(enemy, monster); - - local physical_param = large_monster.update_health(enemy, monster); - large_monster.update_parts(enemy, monster, physical_param); - large_monster.update_stamina(enemy, monster, nil); - large_monster.update_stamina_timer(enemy, monster, nil); - large_monster.update_rage(enemy, monster, nil); - large_monster.update_rage_timer(enemy, monster, nil); - return monster; end @@ -346,7 +350,7 @@ function large_monster.update_all_riders() end -function large_monster.update(enemy, monster) +function large_monster.update(enemy, monster, is_init) local cached_config = config.current_config.large_monster_UI; if not cached_config.dynamic.enabled @@ -356,12 +360,16 @@ function large_monster.update(enemy, monster) end local dead_or_captured = check_die_method:call(enemy); - monster.dead_or_captured = (dead_or_captured == nil and false) or dead_or_captured; + if dead_or_captured ~= nil then + monster.dead_or_captured = dead_or_captured; + end + local is_disp_icon_mini_map = is_disp_icon_mini_map_method:call(enemy); - monster.is_disp_icon_mini_map = (is_disp_icon_mini_map == nil and false) or is_disp_icon_mini_map; - - ailments.update_ailments(enemy, monster); + if is_disp_icon_mini_map ~= nil then + monster.is_disp_icon_mini_map = is_disp_icon_mini_map; + end + pcall(ailments.update_ailments, enemy, monster, is_init); end function large_monster.update_health(enemy, monster) @@ -620,6 +628,9 @@ function large_monster.update_parts(enemy, monster, physical_param) end local enemy_parts_info_array_size = enemy_parts_info_array:get_size(); + if enemy_parts_info_array_size == nil then + return; + end local part_id = 1; for i = 0, enemy_parts_info_array_size - 1 do @@ -734,8 +745,6 @@ function large_monster.draw(monster, type, cached_config, position_on_screen, op monster_UI.health_UI.bar.colors = monster_UI.health_UI.bar.normal_colors; end - drawing.draw_label(monster_UI.monster_name_label, position_on_screen, opacity_scale, monster_name_text); - local health_position_on_screen = { x = position_on_screen.x + cached_config.health.offset.x * global_scale_modifier, y = position_on_screen.y + cached_config.health.offset.y * global_scale_modifier @@ -784,6 +793,8 @@ function large_monster.draw(monster, type, cached_config, position_on_screen, op ailments.draw(monster, monster_UI.ailment_UI, cached_config, ailments_position_on_screen, opacity_scale); ailment_buildup.draw(monster, monster_UI.ailment_buildup_UI, cached_config, ailment_buildups_position_on_screen, opacity_scale); + + drawing.draw_label(monster_UI.monster_name_label, position_on_screen, opacity_scale, monster_name_text); end function large_monster.init_list() diff --git a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua index aac2cc6..d7d69f3 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua @@ -115,14 +115,15 @@ function monster_hook.update_large_monster(enemy) updated_monsters[enemy] = true; end - large_monster.update(enemy, monster); large_monster.update_stamina_timer(enemy, monster, nil); large_monster.update_rage_timer(enemy, monster, nil); if quest_status.is_online and player.myself.id ~= 0 then local physical_param = large_monster.update_health(enemy, monster); - large_monster.update_parts(enemy, monster, physical_param); + pcall(large_monster.update_parts, enemy, monster, physical_param); end + + large_monster.update(enemy, monster, false); end function monster_hook.update_small_monster(enemy) @@ -169,7 +170,6 @@ function monster_hook.update_health(enemy_damage_stock_param) end local is_large = is_boss_enemy_method:call(enemy); - if is_large == nil then return; end @@ -178,8 +178,7 @@ function monster_hook.update_health(enemy_damage_stock_param) local monster = large_monster.get_monster(enemy); local physical_param = large_monster.update_health(enemy, monster); - large_monster.update_parts(enemy, monster, physical_param); - + pcall(large_monster.update_parts, enemy, monster, physical_param); else local monster = small_monster.get_monster(enemy); small_monster.update_health(enemy, monster); diff --git a/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua b/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua index 02aea95..6d24249 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua @@ -36,14 +36,14 @@ function small_monster.new(enemy) small_monster.init(monster, enemy); small_monster.init_UI(monster); + small_monster.update_position(enemy, monster); + small_monster.update_health(enemy, monster); + small_monster.update(enemy, monster); + if small_monster.list[enemy] == nil then small_monster.list[enemy] = monster; end - small_monster.update_position(enemy, monster); - small_monster.update(enemy, monster); - small_monster.update_health(enemy, monster); - return monster; end @@ -153,9 +153,12 @@ function small_monster.update(enemy, monster) end local dead_or_captured = check_die_method:call(enemy); - monster.dead_or_captured = (dead_or_captured == nil and false) or dead_or_captured; + if dead_or_captured ~= nil then + monster.dead_or_captured = dead_or_captured; + end - ailments.update_ailments(enemy, monster); + --do return end; + pcall(ailments.update_ailments, enemy, monster, false); end function small_monster.update_health(enemy, monster)