diff --git a/reframework/autorun/MHR_Overlay.lua b/reframework/autorun/MHR_Overlay.lua index 12ef30b..c117942 100644 --- a/reframework/autorun/MHR_Overlay.lua +++ b/reframework/autorun/MHR_Overlay.lua @@ -35,6 +35,7 @@ local quest_status = require("MHR_Overlay.Game_Handler.quest_status"); local screen = require("MHR_Overlay.Game_Handler.screen"); local singletons = require("MHR_Overlay.Game_Handler.singletons"); local time = require("MHR_Overlay.Game_Handler.time"); +local error_handler = require("MHR_Overlay.Misc.error_handler"); local config = require("MHR_Overlay.Misc.config"); local language = require("MHR_Overlay.Misc.language"); @@ -95,6 +96,7 @@ local drawing = require("MHR_Overlay.UI.drawing"); ------------------------INIT MODULES------------------------- -- #region +error_handler.init_dependencies(); screen.init_dependencies(); singletons.init_dependencies(); utils.init_dependencies(); @@ -162,6 +164,7 @@ keyboard.init_dependencies(); ------------------------------------------------------------ +error_handler.init_module(); language.init_module(); config.init_module(); part_names.init_module(); @@ -238,7 +241,7 @@ local function draw_modules(module_visibility_config, flow_state_name) if module_visibility_config.small_monster_UI and config.current_config.small_monster_UI.enabled then local success = pcall(small_monster_UI.draw); if not success then - customization_menu.status = string.format("[%s] Small Monster UI Drawing Function threw an Exception", flow_state_name); + error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Small Monster UI Drawing Function threw an Exception", flow_state_name)); end end @@ -254,41 +257,40 @@ local function draw_modules(module_visibility_config, flow_state_name) if dynamic_enabled or static_enabled or highlighted_enabled then local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled); if not success then - customization_menu.status = string.format("[%s] Large Monster UI Drawing Function threw an Exception", flow_state_name); + error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Large Monster UI Drawing Function threw an Exception", flow_state_name)); end end if config.current_config.time_UI.enabled and module_visibility_config.time_UI then local success = pcall(time_UI.draw); if not success then - customization_menu.status = string.format("[%s] Time UI Drawing Function threw an Exception", flow_state_name); + error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Time UI Drawing Function threw an Exception", flow_state_name)); end end if config.current_config.damage_meter_UI.enabled and module_visibility_config.damage_meter_UI then local success = pcall(damage_meter_UI.draw); if not success then - customization_menu.status = string.format("[%s] Damage Meter UI Drawing Function threw an Exception", flow_state_name); + error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Damage Meter UI Drawing Function threw an Exception", flow_state_name)); end end if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then local success = pcall(env_creature_UI.draw); if not success then - customization_menu.status = string.format("[%s] Endemic Life UI Drawing Function threw an Exception", flow_state_name); + error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Endemic Life UI Drawing Function threw an Exception", flow_state_name)); end end if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then local success = pcall(buff_UI.draw); if not success then - customization_menu.status = string.format("[%s] Buff UI Drawing Function threw an Exception", flow_state_name); + error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Buff UI Drawing Function threw an Exception", flow_state_name)); end end end local function main_loop() - customization_menu.status = "OK"; time.update_timers(); if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then @@ -303,28 +305,28 @@ local function main_loop() if dynamic_enabled or static_enabled or highlighted_enabled then local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled); if not success then - customization_menu.status = "[In Training Area] Large Monster UI Drawing Function threw an Exception"; + error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Large Monster UI Drawing Function threw an Exception"); end end if config.current_config.damage_meter_UI.enabled and module_visibility_config.damage_meter_UI then local success = pcall(damage_meter_UI.draw); if not success then - customization_menu.status = "[In Training Area] Damage Meter UI Drawing Function threw an Exception"; + error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Damage Meter UI Drawing Function threw an Exception"); end end if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then local success = pcall(env_creature_UI.draw); if not success then - customization_menu.status = "[In Training Area] Endemic Life UI Drawing Function threw an Exception"; + error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Endemic Life UI Drawing Function threw an Exception"); end end if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then local success = pcall(buff_UI.draw); if not success then - customization_menu.status = "[In Training Area] Buff UI Drawing Function threw an Exception"; + error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Buff UI Drawing Function threw an Exception"); end end diff --git a/reframework/autorun/MHR_Overlay/Buffs/buffs.lua b/reframework/autorun/MHR_Overlay/Buffs/buffs.lua index a6e13da..eb7e05c 100644 --- a/reframework/autorun/MHR_Overlay/Buffs/buffs.lua +++ b/reframework/autorun/MHR_Overlay/Buffs/buffs.lua @@ -10,6 +10,7 @@ local utils; local language; local time; local quest_status; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -112,6 +113,11 @@ function this.init_names() end function this.update() + if singletons.player_manager == nil then + error_handler.report("buffs.update", "Failed to Access Data: player_manager"); + return; + end + if quest_status.flow_state == quest_status.flow_states.IN_LOBBY or quest_status.flow_state >= quest_status.flow_states.QUEST_END_ANIMATION then return; @@ -119,12 +125,15 @@ function this.update() local master_player = find_master_player_method:call(singletons.player_manager); if master_player == nil then + error_handler.report("buffs.update", "Failed to Access Data: master_player"); return; end local master_player_data = get_player_data_method:call(master_player); if master_player_data ~= nil then consumables.update(master_player_data); + else + error_handler.report("buffs.update", "Failed to Access Data: master_player_data"); end local music_data_array = music_data_field:get_data(master_player); @@ -135,6 +144,7 @@ function this.update() for i = 0, length do local music_data = get_value_method:call(music_data_array, i); if music_data == nil then + error_handler.report("buffs.update", "Failed to Access Data: music_data No." .. tostring(i)); music_data = ""; end @@ -142,6 +152,8 @@ function this.update() end melody_effects.update(music_data_table); + else + error_handler.report("buffs.update", "Failed to Access Data: music_data_array"); end end @@ -176,6 +188,7 @@ function this.init_dependencies() language = require("MHR_Overlay.Misc.language"); time = require("MHR_Overlay.Game_Handler.time"); quest_status = require("MHR_Overlay.Game_Handler.quest_status"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Buffs/consumables.lua b/reframework/autorun/MHR_Overlay/Buffs/consumables.lua index 212c152..5f10018 100644 --- a/reframework/autorun/MHR_Overlay/Buffs/consumables.lua +++ b/reframework/autorun/MHR_Overlay/Buffs/consumables.lua @@ -7,6 +7,7 @@ local singletons; local players; local utils; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -99,6 +100,7 @@ local get_value_method = system_array_type_def:get_method("GetValue(System.Int32 function this.update(player_data) local item_parameter = get_ref_item_parameter_method:call(singletons.player_manager); if item_parameter == nil then + error_handler.report("consumables.update", "Failed to Access Data: item_parameter"); return; end @@ -113,13 +115,13 @@ function this.update(player_data) end function this.update_demondrug(player_data, item_parameter) - local demondrug = atk_up_alive_field:get_data(player_data); - if demondrug == nil then + local demondrug_value = atk_up_alive_field:get_data(player_data); + if demondrug_value == nil then + error_handler.report("consumables.update_demondrug", "Failed to Access Data: demondrug_value"); return; end - - if demondrug == 0 then + if demondrug_value == 0 then this.list.demondrug = nil; this.list.mega_demondrug = nil; return; @@ -127,46 +129,47 @@ function this.update_demondrug(player_data, item_parameter) local demondrug_const_value = demondrug_atk_up_field:get_data(item_parameter); if demondrug_const_value == nil then + error_handler.report("consumables.update_demondrug", "Failed to Access Data: demondrug_const_value"); return; end local mega_demondrug_const_value = great_demondrug_atk_up_field:get_data(item_parameter); if mega_demondrug_const_value == nil then + error_handler.report("consumables.update_demondrug", "Failed to Access Data: mega_demondrug_const_value"); return; end - if demondrug == demondrug_const_value then + if demondrug_value == demondrug_const_value then local buff = this.list.demondrug; - if buff ~= nil and buff.value == demondrug then + if buff ~= nil and buff.value == demondrug_value then return; end local name = language.current_language.consumables.demondrug; - - - this.list.demondrug = buffs.new(buffs.types.consumable, "demondrug", name, demondrug); + this.list.demondrug = buffs.new(buffs.types.consumable, "demondrug", name, demondrug_value); this.list.mega_demondrug = nil; - elseif demondrug == mega_demondrug_const_value then + elseif demondrug_value == mega_demondrug_const_value then local buff = this.list.mega_demondrug; - if buff ~= nil and buff.value == demondrug then + if buff ~= nil and buff.value == demondrug_value then return; end local name = language.current_language.consumables.mega_demondrug; this.list.demondrug = nil; - this.list.mega_demondrug = buffs.new(buffs.types.consumable, "mega_demondrug", name, demondrug); + this.list.mega_demondrug = buffs.new(buffs.types.consumable, "mega_demondrug", name, demondrug_value); end end function this.update_armorskin(player_data, item_parameter) - local armorskin = def_up_alive_field:get_data(player_data); - if armorskin == nil then + local armorskin_value = def_up_alive_field:get_data(player_data); + if armorskin_value == nil then + error_handler.report("consumables.update_armorskin", "Failed to Access Data: armorskin_value"); return; end - if armorskin == 0 then + if armorskin_value == 0 then this.list.armorskin = nil; this.list.mega_armorskin = nil; return; @@ -174,51 +177,55 @@ function this.update_armorskin(player_data, item_parameter) local armorskin_const_value = armorskin_def_up_field:get_data(item_parameter); if armorskin_const_value == nil then + error_handler.report("consumables.update_armorskin", "Failed to Access Data: armorskin_const_value"); return; end local mega_armorskin_const_value = great_armorskin_def_up_field:get_data(item_parameter); if mega_armorskin_const_value == nil then + error_handler.report("consumables.update_armorskin", "Failed to Access Data: mega_armorskin_const_value"); return; end - if armorskin == armorskin_const_value then + if armorskin_value == armorskin_const_value then local buff = this.list.armorskin; - if buff ~= nil and buff.value == armorskin then + if buff ~= nil and buff.value == armorskin_value then return; end local name = language.current_language.consumables.armorskin; - this.list.armorskin = buffs.new(buffs.types.consumable, "armorskin", name, armorskin); + this.list.armorskin = buffs.new(buffs.types.consumable, "armorskin", name, armorskin_value); this.list.mega_armorskin = nil; - elseif armorskin == mega_armorskin_const_value then + elseif armorskin_value == mega_armorskin_const_value then local buff = this.list.mega_armorskin; - if buff ~= nil and buff.value == armorskin then + if buff ~= nil and buff.value == armorskin_value then return; end local name = language.current_language.consumables.mega_armorskin; this.list.armorskin = nil; - this.list.mega_armorskin = buffs.new(buffs.types.consumable, "mega_armorskin", name, armorskin); + this.list.mega_armorskin = buffs.new(buffs.types.consumable, "mega_armorskin", name, armorskin_value); end end function this.update_might_seed(player_data, item_parameter) - local might_seed = atk_up_buff_second_field:get_data(player_data); - if might_seed == nil then + local might_seed_value = atk_up_buff_second_field:get_data(player_data); + if might_seed_value == nil then + error_handler.report("consumables.update_might_seed", "Failed to Access Data: might_seed_value"); return; end - if might_seed == 0 then + if might_seed_value == 0 then this.list.might_seed = nil; return; end local might_seed_timer = atk_up_buff_second_timer_field:get_data(player_data); if might_seed_timer == nil then + error_handler.report("consumables.update_might_seed", "Failed to Access Data: might_seed_timer"); return; end @@ -226,32 +233,35 @@ function this.update_might_seed(player_data, item_parameter) if buff == nil then local might_seed_timer_const_value = might_seed_timer_field:get_data(item_parameter); if might_seed_timer_const_value == nil then + error_handler.report("consumables.update_might_seed", "Failed to Access Data: might_seed_timer_const_value"); return; end local name = language.current_language.consumables.might_seed; - buff = buffs.new(buffs.types.consumable, "might_seed", name, might_seed, might_seed_timer_const_value); + buff = buffs.new(buffs.types.consumable, "might_seed", name, might_seed_value, might_seed_timer_const_value); this.list.might_seed = buff; else - buff.value = might_seed; + buff.value = might_seed_value; buffs.update_timer(buff, might_seed_timer / 60); end end function this.update_adamant_seed(player_data, item_parameter) - local adamant_seed = def_up_buff_second_field:get_data(player_data); - if adamant_seed == nil then + local adamant_seed_value = def_up_buff_second_field:get_data(player_data); + if adamant_seed_value == nil then + error_handler.report("consumables.update_adamant_seed", "Failed to Access Data: adamant_seed_value"); return; end - if adamant_seed == 0 then + if adamant_seed_value == 0 then this.list.adamant_seed = nil; return; end local adamant_seed_timer = def_up_buff_second_timer_field:get_data(player_data); if adamant_seed_timer == nil then + error_handler.report("consumables.update_adamant_seed", "Failed to Access Data: adamant_seed_timer"); return; end @@ -259,32 +269,35 @@ function this.update_adamant_seed(player_data, item_parameter) if buff == nil then local adamant_seed_timer_const_value = adamant_seed_timer_field:get_data(item_parameter); if adamant_seed_timer_const_value == nil then + error_handler.report("consumables.update_adamant_seed", "Failed to Access Data: adamant_seed_timer_const_value"); return; end local name = language.current_language.consumables.adamant_seed; - buff = buffs.new(buffs.types.consumable, "adamant_seed", name, adamant_seed, adamant_seed_timer_const_value); + buff = buffs.new(buffs.types.consumable, "adamant_seed", name, adamant_seed_value, adamant_seed_timer_const_value); this.list.adamant_seed = buff; else - buff.value = adamant_seed; + buff.value = adamant_seed_value; buffs.update_timer(buff, adamant_seed_timer / 60); end end function this.update_demon_powder(player_data, item_parameter) - local demon_powder = atk_up_item_second_field:get_data(player_data); - if demon_powder == nil then + local demon_powder_value = atk_up_item_second_field:get_data(player_data); + if demon_powder_value == nil then + error_handler.report("consumables.update_demon_powder", "Failed to Access Data: demon_powder_value"); return; end - if demon_powder == 0 then + if demon_powder_value == 0 then this.list.demon_powder = nil; return; end local demon_powder_timer = atk_up_item_second_timer_field:get_data(player_data); if demon_powder_timer == nil then + error_handler.report("consumables.update_demon_powder", "Failed to Access Data: demon_powder_timer"); return; end @@ -292,32 +305,35 @@ function this.update_demon_powder(player_data, item_parameter) if buff == nil then local demon_powder_timer_const_value = demondrug_powder_timer_field:get_data(item_parameter); if demon_powder_timer_const_value == nil then + error_handler.report("consumables.update_demon_powder", "Failed to Access Data: demon_powder_timer_const_value"); return; end local name = language.current_language.consumables.demon_powder; - buff = buffs.new(buffs.types.consumable, "demon_powder", name, demon_powder, demon_powder_timer_const_value); + buff = buffs.new(buffs.types.consumable, "demon_powder", name, demon_powder_value, demon_powder_timer_const_value); this.list.demon_powder = buff; else - buff.value = demon_powder; + buff.value = demon_powder_value; buffs.update_timer(buff, demon_powder_timer / 60); end end function this.update_hardshell_powder(player_data, item_parameter) - local hardshell_powder = def_up_item_second_field:get_data(player_data); - if hardshell_powder == nil then + local hardshell_powder_value = def_up_item_second_field:get_data(player_data); + if hardshell_powder_value == nil then + error_handler.report("consumables.update_hardshell_powder", "Failed to Access Data: hardshell_powder_value"); return; end - if hardshell_powder == 0 then + if hardshell_powder_value == 0 then this.list.hardshell_powder = nil; return; end local hardshell_powder_timer = def_up_item_second_timer_field:get_data(player_data); if hardshell_powder_timer == nil then + error_handler.report("consumables.update_hardshell_powder", "Failed to Access Data: hardshell_powder_timer"); return; end @@ -325,15 +341,16 @@ function this.update_hardshell_powder(player_data, item_parameter) if buff == nil then local demon_powder_timer_const_value = armorskin_powder_timer_field:get_data(item_parameter); if demon_powder_timer_const_value == nil then + error_handler.report("consumables.update_hardshell_powder", "Failed to Access Data: demon_powder_timer_const_value"); return; end local name = language.current_language.consumables.hardshell_powder; - buff = buffs.new(buffs.types.consumable, "hardshell_powder", name, hardshell_powder, demon_powder_timer_const_value); + buff = buffs.new(buffs.types.consumable, "hardshell_powder", name, hardshell_powder_value, demon_powder_timer_const_value); this.list.hardshell_powder = buff; else - buff.value = hardshell_powder; + buff.value = hardshell_powder_value; buffs.update_timer(buff, hardshell_powder_timer / 60); end end @@ -341,6 +358,7 @@ end function this.update_immunizer(player_data, item_parameter) local immunizer_timer = vitalizer_timer_field:get_data(player_data); if immunizer_timer == nil then + error_handler.report("consumables.update_immunizer", "Failed to Access Data: immunizer_timer"); return; end @@ -353,6 +371,7 @@ function this.update_immunizer(player_data, item_parameter) if buff == nil then local immunizer_timer_const_value = vitalizer_timer_const_field:get_data(item_parameter); if immunizer_timer_const_value == nil then + error_handler.report("consumables.update_immunizer", "Failed to Access Data: immunizer_timer_const_value"); return; end @@ -367,8 +386,8 @@ end function this.update_dash_juice(player_data, item_parameter) local dash_juice_timer = stamina_up_buff_second_timer_field:get_data(player_data); - if dash_juice_timer == nil then + error_handler.report("consumables.update_dash_juice", "Failed to Access Data: dash_juice_timer"); return; end @@ -382,6 +401,7 @@ function this.update_dash_juice(player_data, item_parameter) if buff == nil then local dash_juice_timer_const_value = stamina_up_buff_second_field:get_data(item_parameter); if dash_juice_timer_const_value == nil then + error_handler.report("consumables.update_dash_juice", "Failed to Access Data: dash_juice_timer"); return; end @@ -408,6 +428,7 @@ function this.init_dependencies() singletons = require("MHR_Overlay.Game_Handler.singletons"); players = require("MHR_Overlay.Damage_Meter.players"); language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Buffs/melody_effects.lua b/reframework/autorun/MHR_Overlay/Buffs/melody_effects.lua index 1053234..b33c51c 100644 --- a/reframework/autorun/MHR_Overlay/Buffs/melody_effects.lua +++ b/reframework/autorun/MHR_Overlay/Buffs/melody_effects.lua @@ -7,6 +7,7 @@ local singletons; local players; local utils; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -115,6 +116,7 @@ function this.update(melody_data_table) local melody_timer = time_field:get_data(melody_data); if melody_timer == nil then + error_handler.report("melody_effects.update", "Failed to Access Data: melody_timer No. " .. tostring(lua_index - 1)); goto continue; end @@ -153,6 +155,7 @@ function this.init_dependencies() singletons = require("MHR_Overlay.Game_Handler.singletons"); players = require("MHR_Overlay.Damage_Meter.players"); language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Damage_Meter/damage_hook.lua b/reframework/autorun/MHR_Overlay/Damage_Meter/damage_hook.lua index 602e6af..4f18211 100644 --- a/reframework/autorun/MHR_Overlay/Damage_Meter/damage_hook.lua +++ b/reframework/autorun/MHR_Overlay/Damage_Meter/damage_hook.lua @@ -8,6 +8,7 @@ local ailments; local singletons; local non_players; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -106,11 +107,13 @@ function this.update_damage(enemy, enemy_calc_damage_info) local is_large_monster = is_boss_enemy_method:call(enemy); if is_large_monster == nil then + error_handler.report("damage_hook.update_damage", "Failed to Access Data: is_large_monster"); return; end local dead_or_captured = check_die_method:call(enemy); if dead_or_captured == nil then + error_handler.report("damage_hook.update_damage", "Failed to Access Data: dead_or_captured"); return; end @@ -263,6 +266,7 @@ function this.cart(dead_player_id, flag_cat_skill_insurance) local player = players.list[dead_player_id]; if player == nil then + error_handler.report("damage_hook.cart", "No Dead Player Found"); return; end @@ -296,6 +300,7 @@ function this.on_stock_direct_marionette_finish_shoot_hit_parts_damage(enemy, da end if player == nil then + error_handler.report("damage_hook.on_stock_direct_marionette_finish_shoot_hit_parts_damage", "Failed to Create Player Entry"); return; end @@ -355,11 +360,13 @@ function this.on_anomaly_core_break(anomaly_core_part) end if anomaly_monster == nil then + error_handler.report("damage_hook.on_anomaly_core_break", "No Anomaly Monster Found"); return; end local anomaly_core_break_damage_rate = get_mystery_core_break_damage_rate_method:call(anomaly_monster.enemy); if anomaly_core_break_damage_rate == nil then + error_handler.report("damage_hook.on_anomaly_core_break", "Failed to Access Data: anomaly_core_break_damage_rate"); return; end @@ -383,10 +390,10 @@ function this.init_dependencies() singletons = require("MHR_Overlay.Game_Handler.singletons"); non_players = require("MHR_Overlay.Damage_Meter.non_players"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() - sdk.hook(stock_direct_marionette_finish_shoot_hit_parts_damage_method, function(args) local enemy = sdk.to_managed_object(args[2]); local damage_rate = sdk.to_float(args[3]); diff --git a/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua b/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua index 2484aca..ba465d0 100644 --- a/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua +++ b/reframework/autorun/MHR_Overlay/Damage_Meter/non_players.lua @@ -9,6 +9,7 @@ local quest_status; local drawing; local language; local players; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -132,17 +133,19 @@ function this.update_servant_list() local cached_config = config.current_config.damage_meter_UI; if singletons.servant_manager == nil then + error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_manager"); return; end local quest_servant_id_list = get_quest_servant_id_list_method:call(singletons.servant_manager); if quest_servant_id_list == nil then + error_handler.report("non_players.update_servant_list", "Failed to Access Data: quest_servant_id_list"); return; end local servant_count = servant_get_count_method:call(quest_servant_id_list); if servant_count == nil then - customization_menu.status = "No quest servant id list count"; + error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_count"); return; end @@ -150,19 +153,20 @@ function this.update_servant_list() for i = 0, servant_count - 1 do local servant_id = servant_get_item_method:call(quest_servant_id_list, i); if servant_id == nil then + error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_id No." .. tostring(i)); goto continue; end local ai_control = get_ai_control_by_servant_id_method:call(singletons.servant_manager, servant_id); if ai_control == nil then - customization_menu.status = "No quest servant ai control"; + error_handler.report("non_players.update_servant_list", "Failed to Access Data: ai_control No." .. tostring(i)); goto continue; end local servant_info = get_servant_info_method:call(ai_control); if servant_info == nil then - customization_menu.status = "No quest servant info"; + error_handler.report("non_players.update_servant_list", "Failed to Access Data: servant_info No." .. tostring(i)); goto continue; end @@ -213,8 +217,14 @@ function this.update_my_otomos() local cached_config = config.current_config.damage_meter_UI; local first_otomo = get_master_otomo_info_method:call(singletons.otomo_manager, 0); - if first_otomo ~= nil then + if first_otomo == nil then + error_handler.report("non_players.update_my_otomos", "Failed to Access Data: first_otomo"); + else local name = otomo_create_data_name_field:get_data(first_otomo); + if name == nil then + error_handler.report("non_players.update_my_otomos", "Failed to Access Data: first_otomo -> name"); + end + if name ~= nil and name ~= "" then local level = otomo_create_data_level_field:get_data(first_otomo) or 0; @@ -230,8 +240,14 @@ function this.update_my_otomos() end local second_otomo = get_master_otomo_info_method:call(singletons.otomo_manager, 1); - if second_otomo ~= nil then + if second_otomo == nil then + error_handler.report("non_players.update_my_otomos", "Failed to Access Data: second_otomo"); + else local name = otomo_create_data_name_field:get_data(second_otomo); + if name == nil then + error_handler.report("non_players.update_my_otomos", "Failed to Access Data: second_otomo -> name"); + end + if name ~= nil and name ~= "" then local level = otomo_create_data_level_field:get_data(second_otomo) or 0; @@ -252,19 +268,20 @@ function this.update_servant_otomos() local servant_otomo_list = get_servant_otomo_list_method:call(singletons.otomo_manager); if servant_otomo_list == nil then - customization_menu.status = "No servant otomo list"; + error_handler.report("non_players.update_servant_otomos", "Failed to Access Data: servant_otomo_list"); return; end local count = otomo_get_count_method:call(servant_otomo_list); if count == nil then - customization_menu.status = "No servant otomo list count"; + error_handler.report("non_players.update_servant_otomos", "Failed to Access Data: servant_otomo_list -> count"); return; end for i = 0, count - 1 do local servant_otomo = otomo_get_item_method:call(servant_otomo_list, i); if servant_otomo == nil then + error_handler.report("non_players.update_servant_otomos", "Failed to Access Data: servant_otomo No. " .. tostring(i)); goto continue end @@ -275,6 +292,7 @@ function this.update_servant_otomos() local member_id = otomo_create_data:get_field("MemberID"); if name == nil then + error_handler.report("non_players.update_servant_otomos", string.format("Failed to Access Data: servant_otomo No. %d -> name", i)); goto continue; end @@ -296,30 +314,33 @@ function this.update_otomos(otomo_info_field_) local cached_config = config.current_config.damage_meter_UI; if singletons.lobby_manager == nil then + error_handler.report("non_players.update_otomos", "Failed to Access Data: lobby_manager"); return; end -- other players local otomo_info_list = otomo_info_field_:get_data(singletons.lobby_manager); if otomo_info_list == nil then - customization_menu.status = "No otomo info list"; + error_handler.report("non_players.update_otomos", "Failed to Access Data: otomo_info_list"); return; end local count = otomo_info_get_count_method:call(otomo_info_list); if count == nil then - customization_menu.status = "No otomo info list count"; + error_handler.report("non_players.update_otomos", "Failed to Access Data: otomo_info_list -> count"); return; end for id = 0, count - 1 do local otomo_info = otomo_info_get_item_method:call(otomo_info_list, id); if otomo_info == nil then + error_handler.report("non_players.update_otomos", "Failed to Access Data: otomo_info No. " .. tostring(id)); goto continue; end local name = otomo_info_name_field:get_data(otomo_info); if name == nil then + error_handler.report("non_players.update_otomos", string.format("Failed to Access Data: otomo_info No. %d -> name", id)); goto continue; end @@ -387,6 +408,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); language = require("MHR_Overlay.Misc.language"); players = require("MHR_Overlay.Damage_Meter.players"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua b/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua index 603cf1b..bb57fed 100644 --- a/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua +++ b/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua @@ -10,6 +10,7 @@ local drawing; local language; local non_players; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -137,6 +138,7 @@ end function this.update_damage(player, damage_source_type, is_large_monster, damage_object) if player == nil then + error_handler.report("players.update_damage", "Missing Parameter: player"); return; end @@ -155,6 +157,7 @@ end function this.update_display(player) if player == nil then + error_handler.report("players.update_display", "Missing Parameter: player"); return; end @@ -450,20 +453,22 @@ local get_pos_field = player_base_type_def:get_method("get_Pos"); function this.update_myself_position() if singletons.player_manager == nil then - customization_menu.status = "No player manager"; + error_handler.report("players.update_myself_position", "Failed to Access Data: player_manager"); return; end local master_player = find_master_player_method:call(singletons.player_manager); if master_player == nil then - customization_menu.status = "No master player"; + error_handler.report("players.update_myself_position", "Failed to Access Data: master_player"); return; end local position = get_pos_field:call(master_player); - if position ~= nil then - this.myself_position = position; + if position == nil then + error_handler.report("players.update_myself_position", "Failed to Access Data: position"); end + + this.myself_position = position; end function this.init() @@ -512,23 +517,25 @@ function this.update_player_list_(hunter_info_field_) local cached_config = config.current_config.damage_meter_UI; if singletons.lobby_manager == nil then + error_handler.report("players.update_player_list_", "Failed to Access Data: lobby_manager"); return; end if singletons.progress_manager == nil then + error_handler.report("players.update_player_list_", "Failed to Access Data: progress_manager"); return; end -- myself player local myself_player_info = my_hunter_info_field:get_data(singletons.lobby_manager); if myself_player_info == nil then - customization_menu.status = "No myself player info list"; + error_handler.report("players.update_player_list_", "Failed to Access Data: myself_player_info"); return; end local myself_player_name = name_field:get_data(myself_player_info); if myself_player_name == nil then - customization_menu.status = "No myself player name"; + error_handler.report("players.update_player_list_", "Failed to Access Data: myself_player_name"); return; end @@ -538,7 +545,7 @@ function this.update_player_list_(hunter_info_field_) local myself_id = get_master_player_id_method:call(singletons.player_manager); if myself_id == nil then - customization_menu.status = "No myself player id"; + error_handler.report("players.update_player_list_", "Failed to Access Data: myself_id"); return; end @@ -551,25 +558,26 @@ function this.update_player_list_(hunter_info_field_) -- other players local player_info_list = hunter_info_field_:get_data(singletons.lobby_manager); if player_info_list == nil then - customization_menu.status = "No player info list"; + error_handler.report("players.update_player_list_", "Failed to Access Data: player_info_list"); return; end local count = get_count_method:call(player_info_list); if count == nil then - customization_menu.status = "No player info list count"; + error_handler.report("players.update_player_list_", "Failed to Access Data: player_info_list -> count"); return; end for i = 0, count - 1 do local player_info = get_item_method:call(player_info_list, i); if player_info == nil then + error_handler.report("players.update_player_list_", "Failed to Access Data: player_info No. " .. tostring(i)); goto continue end local id = member_index_field:get_data(player_info); - if id == nil then + error_handler.report("players.update_player_list_", string.format("Failed to Access Data: player_info No. %d -> id", i)); goto continue end @@ -578,13 +586,13 @@ function this.update_player_list_(hunter_info_field_) local name = name_field:get_data(player_info); if name == nil then + error_handler.report("players.update_player_list_", string.format("Failed to Access Data: player_info No. %d -> name", i)); goto continue end local player = this.list[id]; if player == nil then - if name == this.myself.name then player = this.new(id, name, master_rank, hunter_rank, this.types.myself); this.myself = player; @@ -647,7 +655,7 @@ function this.init_dependencies() language = require("MHR_Overlay.Misc.language"); non_players = require("MHR_Overlay.Damage_Meter.non_players"); utils = require("MHR_Overlay.Misc.utils"); - + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua index 8dfb75a..8b5cd0b 100644 --- a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua +++ b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature.lua @@ -5,6 +5,7 @@ local customization_menu; local singletons; local config; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -80,13 +81,13 @@ local get_pos_method = environment_creature_base_type_def:get_method("get_Pos"); function this.init(creature, REcreature) local creature_type = creature_type_field:get_data(REcreature); if creature_type == nil then - customization_menu.status = "No env creature type"; + error_handler.report("env_creature.init", "Failed to Access Data: creature_type"); return; end - local creature_name = get_env_creature_name_message_method:call(singletons.message_manager, - creature_type); + local creature_name = get_env_creature_name_message_method:call(singletons.message_manager, creature_type); if creature_name ~= nil then + error_handler.report("env_creature.init", "Failed to Access Data: creature_name"); creature.name = creature_name; end end @@ -110,9 +111,11 @@ function this.update_position(REcreature, creature) end local position = get_pos_method:call(REcreature); - if position ~= nil then - creature.position = position; + if position == nil then + error_handler.report("env_creature.update_position", "Failed to Access Data: position"); end + + creature.position = position; end function this.update(REcreature, creature) @@ -125,9 +128,11 @@ function this.update(REcreature, creature) end local is_inactive = creature_is_inactive_field:get_data(REcreature); - if is_inactive ~= nil then - creature.is_inactive = is_inactive; + if is_inactive == nil then + error_handler.report("env_creature.update", "Failed to Access Data: is_inactive"); end + + creature.is_inactive = is_inactive; end function this.draw(creature, position_on_screen, opacity_scale) @@ -154,6 +159,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); --ailments = require("MHR_Overlay.Monsters.ailments"); --ailment_UI_entity = require("MHR_Overlay.UI.UI_Entities.ailment_UI_entity"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua index a448a72..81424ff 100644 --- a/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua +++ b/reframework/autorun/MHR_Overlay/Endemic_Life/env_creature_hook.lua @@ -3,6 +3,7 @@ local this = {}; local env_creature; local config; local time; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -49,6 +50,7 @@ function this.init_dependencies() config = require("MHR_Overlay.Misc.config"); env_creature = require("MHR_Overlay.Endemic_Life.env_creature"); time = require("MHR_Overlay.Game_Handler.time"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Game_Handler/keyboard.lua b/reframework/autorun/MHR_Overlay/Game_Handler/keyboard.lua index 4e80e87..43be77d 100644 --- a/reframework/autorun/MHR_Overlay/Game_Handler/keyboard.lua +++ b/reframework/autorun/MHR_Overlay/Game_Handler/keyboard.lua @@ -8,6 +8,7 @@ local small_monster; local large_monster; local damage_meter_UI; local time; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -333,16 +334,15 @@ this.keys = { --[254] = "Clear" }; - function this.update() if singletons.game_keyboard == nil then - customization_menu.status = "No game keyboard"; + error_handler.report("keyboard.update", "Failed to Access Data: game_keyboard"); return; end local hard_keyboard = hard_keyboard_field:get_data(singletons.game_keyboard); if hard_keyboard == nil then - customization_menu.status = "No hard keyboard"; + error_handler.report("keyboard.update", "Failed to Access Data: hard_keyboard"); return; end @@ -350,8 +350,6 @@ function this.update() local new_hotkey_registered = this.register_hotkey(hard_keyboard); - - if new_hotkey_registered then config.save_current(); else @@ -491,10 +489,15 @@ function this.check_hotkeys(hard_keyboard) local cached_config = config.current_config.global_settings.hotkeys_with_modifiers; if not (cached_config.all_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.all_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.all_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, math.tointeger(cached_config.all_UI.key)) then + and not (cached_config.all_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.all_UI.alt and not this.hotkey_modifiers_down.alt) then + local all_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.all_UI.key)); + + if all_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: all_UI_key_release"); + + elseif all_UI_key_release then local is_any_enabled = config.current_config.time_UI.enabled or config.current_config.small_monster_UI.enabled or config.current_config.large_monster_UI.dynamic.enabled @@ -512,17 +515,29 @@ function this.check_hotkeys(hard_keyboard) end if not (cached_config.small_monster_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.small_monster_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.small_monster_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, math.tointeger(cached_config.small_monster_UI.key)) then + and not (cached_config.small_monster_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.small_monster_UI.alt and not this.hotkey_modifiers_down.alt) then + + local small_monster_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.small_monster_UI.key)); + + if small_monster_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: small_monster_UI_key_release"); + + elseif small_monster_UI_key_release then config.current_config.small_monster_UI.enabled = not config.current_config.small_monster_UI.enabled; end end if not (cached_config.large_monster_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.large_monster_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.large_monster_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_UI.key)) then + and not (cached_config.large_monster_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.large_monster_UI.alt and not this.hotkey_modifiers_down.alt) then + + local large_monster_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_UI.key)); + + if large_monster_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_UI_key_release"); + + elseif large_monster_UI_key_release then local is_any_enabled = config.current_config.large_monster_UI.dynamic.enabled or config.current_config.large_monster_UI.static.enabled or config.current_config.large_monster_UI.highlighted.enabled; @@ -534,53 +549,85 @@ function this.check_hotkeys(hard_keyboard) end if not (cached_config.large_monster_dynamic_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.large_monster_dynamic_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.large_monster_dynamic_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, - math.tointeger(cached_config.large_monster_dynamic_UI.key)) then + and not (cached_config.large_monster_dynamic_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.large_monster_dynamic_UI.alt and not this.hotkey_modifiers_down.alt) then + + local large_monster_dynamic_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_dynamic_UI.key)); + + if large_monster_dynamic_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_dynamic_UI_key_release"); + + elseif large_monster_dynamic_UI_key_release then config.current_config.large_monster_UI.dynamic.enabled = not config.current_config.large_monster_UI.dynamic.enabled; end end if not (cached_config.large_monster_static_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.large_monster_static_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.large_monster_static_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, - math.tointeger(cached_config.large_monster_static_UI.key)) then + and not (cached_config.large_monster_static_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.large_monster_static_UI.alt and not this.hotkey_modifiers_down.alt) then + + local large_monster_static_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_static_UI.key)); + + if large_monster_static_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_static_UI_key_release"); + + elseif large_monster_static_UI_key_release then config.current_config.large_monster_UI.static.enabled = not config.current_config.large_monster_UI.static.enabled; end end if not (cached_config.large_monster_highlighted_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.large_monster_highlighted_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.large_monster_highlighted_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, - math.tointeger(cached_config.large_monster_highlighted_UI.key)) then - config.current_config.large_monster_UI.highlighted.enabled = not - config.current_config.large_monster_UI.highlighted.enabled; + and not (cached_config.large_monster_highlighted_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.large_monster_highlighted_UI.alt and not this.hotkey_modifiers_down.alt) then + + local large_monster_highlighted_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_highlighted_UI.key)); + + if large_monster_highlighted_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_highlighted_UI_key_release"); + + elseif large_monster_highlighted_UI_key_release then + config.current_config.large_monster_UI.highlighted.enabled = not config.current_config.large_monster_UI.highlighted.enabled; end end if not (cached_config.time_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.time_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.time_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, math.tointeger(cached_config.time_UI.key)) then + and not (cached_config.time_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.time_UI.alt and not this.hotkey_modifiers_down.alt) then + + local time_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.time_UI.key)); + + if time_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: time_UI_key_release"); + + elseif time_UI_key_release then config.current_config.time_UI.enabled = not config.current_config.time_UI.enabled; end end if not (cached_config.damage_meter_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.damage_meter_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.damage_meter_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, math.tointeger(cached_config.damage_meter_UI.key)) then + and not (cached_config.damage_meter_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.damage_meter_UI.alt and not this.hotkey_modifiers_down.alt) then + + local damage_meter_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.damage_meter_UI.key)); + + if damage_meter_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: damage_meter_UI_key_release"); + + elseif damage_meter_UI_key_release then config.current_config.damage_meter_UI.enabled = not config.current_config.damage_meter_UI.enabled; end end if not (cached_config.endemic_life_UI.ctrl and not this.hotkey_modifiers_down.ctrl) - and not (cached_config.endemic_life_UI.shift and not this.hotkey_modifiers_down.shift) - and not (cached_config.endemic_life_UI.alt and not this.hotkey_modifiers_down.alt) then - if get_release_method:call(hard_keyboard, math.tointeger(cached_config.endemic_life_UI.key)) then + and not (cached_config.endemic_life_UI.shift and not this.hotkey_modifiers_down.shift) + and not (cached_config.endemic_life_UI.alt and not this.hotkey_modifiers_down.alt) then + + local endemic_life_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.endemic_life_UI.key)); + + if endemic_life_UI_key_release == nil then + error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: endemic_life_UI_key_release"); + + elseif endemic_life_UI_key_release then config.current_config.endemic_life_UI.enabled = not config.current_config.endemic_life_UI.enabled; end end @@ -613,9 +660,10 @@ function this.init_dependencies() large_monster = require("MHR_Overlay.Monsters.large_monster"); damage_meter_UI = require("MHR_Overlay.UI.Modules.damage_meter_UI"); time = require("MHR_Overlay.Game_Handler.time"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() end -return this; +return this; \ No newline at end of file diff --git a/reframework/autorun/MHR_Overlay/Game_Handler/quest_status.lua b/reframework/autorun/MHR_Overlay/Game_Handler/quest_status.lua index 4be7d18..89856f2 100644 --- a/reframework/autorun/MHR_Overlay/Game_Handler/quest_status.lua +++ b/reframework/autorun/MHR_Overlay/Game_Handler/quest_status.lua @@ -9,6 +9,7 @@ local damage_meter_UI; local time; local env_creature; local non_players; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -153,16 +154,20 @@ end function this.get_cart_count() local death_num = get_death_num_method:call(singletons.quest_manager); - if death_num ~= nil then - this.cart_count = death_num; + if death_num == nil then + error_handler.report("quest_status.get_cart_count", "Failed to Access Data: death_num"); end + + this.cart_count = death_num; end function this.get_max_cart_count() local quest_life = get_quest_life_method:call(singletons.quest_manager); - if quest_life ~= nil then - this.max_cart_count = quest_life; + if quest_life == nil then + error_handler.report("quest_status.get_max_cart_count", "Failed to Access Data: quest_life"); end + + this.max_cart_count = quest_life; end --type 2 = quest start @@ -170,6 +175,7 @@ end --type 5 = end screen function this.on_demo_request_activation(request_data_base) if request_data_base == nil then + error_handler.report("quest_status.on_demo_request_activation", "Missing Parameter: request_data_base"); return; end @@ -179,6 +185,7 @@ function this.on_demo_request_activation(request_data_base) local request_data_type = request_data_base:call("get_Type"); if request_data_type == nil then + error_handler.report("quest_status.on_demo_request_activation", "Failed to Access Data: request_data_type"); return; end @@ -278,6 +285,7 @@ end function this.on_village_fast_travel(area) if area == nil then + error_handler.report("quest_status.on_village_fast_travel", "Missing Parameter: area"); return; end @@ -289,6 +297,11 @@ function this.on_village_fast_travel(area) end function this.on_changed_game_status(new_quest_status) + if new_quest_status == nil then + error_handler.report("quest_status.on_changed_game_status", "Missing Parameter: new_quest_status"); + return; + end + this.index = new_quest_status; if this.index == 0 then @@ -304,12 +317,13 @@ end function this.init() if singletons.quest_manager == nil then + error_handler.report("quest_status.init", "Failed to Access Data: quest_manager"); return; end local new_quest_status = get_status_method:call(singletons.game_manager); if new_quest_status == nil then - customization_menu.status = "No quest status"; + error_handler.report("quest_status.init", "Failed to Access Data: new_quest_status"); return; end @@ -330,11 +344,13 @@ end function this.update_is_online() if singletons.lobby_manager == nil then + error_handler.report("quest_status.update_is_online", "Failed to Access Data: lobby_manager"); return; end local is_quest_online = is_quest_online_method:call(singletons.lobby_manager); if is_quest_online == nil then + error_handler.report("quest_status.update_is_online", "Failed to Access Data: is_quest_online"); return; end @@ -343,11 +359,13 @@ end --[[function quest_status.update_is_quest_host() if singletons.lobby_manager == nil then + error_handler.report("quest_status.update_is_quest_host", "Failed to Access Data: lobby_manager"); return; end local is_quest_host = is_quest_host_method:call(singletons.lobby_manager, true); if is_quest_host == nil then + error_handler.report("quest_status.update_is_quest_host", "Failed to Access Data: is_quest_host"); return; end @@ -356,16 +374,17 @@ end--]] function this.update_is_training_area() if singletons.village_area_manager == nil then - customization_menu.status = "No village area manager"; + error_handler.report("quest_status.update_is_training_area", "Failed to Access Data: village_area_manager"); return; end - local _is_training_area = check_current_area_training_area_method:call(singletons.village_area_manager); - if _is_training_area == nil then + local is_training_area = check_current_area_training_area_method:call(singletons.village_area_manager); + if is_training_area == nil then + error_handler.report("quest_status.update_is_training_area", "Failed to Access Data: is_training_area"); return; end - if _is_training_area then + if is_training_area then this.set_flow_state(this.flow_states.IN_TRAINING_AREA); end end @@ -380,6 +399,7 @@ function this.init_dependencies() time = require("MHR_Overlay.Game_Handler.time"); env_creature = require("MHR_Overlay.Endemic_Life.env_creature"); non_players = require("MHR_Overlay.Damage_Meter.non_players"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Game_Handler/screen.lua b/reframework/autorun/MHR_Overlay/Game_Handler/screen.lua index 75f1d03..d72bc0b 100644 --- a/reframework/autorun/MHR_Overlay/Game_Handler/screen.lua +++ b/reframework/autorun/MHR_Overlay/Game_Handler/screen.lua @@ -4,6 +4,7 @@ local config; local singletons; local utils; local time; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -72,26 +73,26 @@ function this.get_game_window_size() scene_view = sdk.call_native_func(singletons.scene_manager, sdk.find_type_definition("via.SceneManager") , "get_MainView"); if scene_view == nil then - --log.error("[MHR_Overlay.lua] No scene view"); + error_handler.report("screen.get_game_window_size", "Failed to Access Data: scene_view"); return; end end local size = get_size_method:call(scene_view); if size == nil then - --log.error("[MHR_Overlay.lua] No scene view size"); + error_handler.report("screen.get_game_window_size", "Failed to Access Data: size"); return; end local screen_width = width_field:get_data(size); if screen_width == nil then - --log.error("[MHR_Overlay.lua] No screen width"); + error_handler.report("screen.get_game_window_size", "Failed to Access Data: screen_width"); return; end local screen_height = height_field:get_data(size); if screen_height == nil then - --log.error("[MHR_Overlay.lua] No screen height"); + error_handler.report("screen.get_game_window_size", "Failed to Access Data: screen_height"); return; end @@ -138,6 +139,7 @@ function this.init_dependencies() singletons = require("MHR_Overlay.Game_Handler.singletons"); time = require("MHR_Overlay.Game_Handler.time"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua b/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua index b68c458..40e9d54 100644 --- a/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua +++ b/reframework/autorun/MHR_Overlay/Game_Handler/singletons.lua @@ -2,6 +2,7 @@ local this = {}; local time; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -70,7 +71,7 @@ function this.init_message_manager() this.message_manager = sdk.get_managed_singleton("snow.gui.MessageManager"); if this.message_manager == nil then - --log.error("[MHR Overlay] No message manager"); + error_handler.report("singletons.init_message_manager", "Failed to Access Data: message_manager"); end return this.message_manager; @@ -83,7 +84,7 @@ function this.init_enemy_manager() this.enemy_manager = sdk.get_managed_singleton("snow.enemy.EnemyManager"); if this.enemy_manager == nil then - --log.error("[MHR Overlay] No enemy manager"); + error_handler.report("singletons.init_enemy_manager", "Failed to Access Data: enemy_manager"); end return this.enemy_manager; @@ -96,7 +97,7 @@ function this.init_lobby_manager() this.lobby_manager = sdk.get_managed_singleton("snow.LobbyManager"); if this.lobby_manager == nil then - --log.error("[MHR Overlay] No lobby manager"); + error_handler.report("singletons.init_lobby_manager", "Failed to Access Data: lobby_manager"); return false; end @@ -110,7 +111,7 @@ function this.init_progress_manager() this.progress_manager = sdk.get_managed_singleton("snow.progress.ProgressManager"); if this.progress_manager == nil then - --log.error("[MHR Overlay] No progress manager"); + error_handler.report("singletons.init_lobby_manager", "Failed to Access Data: progress_manager"); return false; end @@ -124,7 +125,7 @@ function this.init_quest_manager() this.quest_manager = sdk.get_managed_singleton("snow.QuestManager"); if this.quest_manager == nil then - --log.error("[MHR Overlay] No quest manager"); + error_handler.report("singletons.init_quest_manager", "Failed to Access Data: quest_manager"); end return this.quest_manager; @@ -137,7 +138,7 @@ function this.init_player_manager() this.player_manager = sdk.get_managed_singleton("snow.player.PlayerManager"); if this.player_manager == nil then - --log.error("[MHR Overlay] No player manager"); + error_handler.report("singletons.init_player_manager", "Failed to Access Data: player_manager"); end return this.player_manager; @@ -150,7 +151,7 @@ function this.init_village_area_manager() this.village_area_manager = sdk.get_managed_singleton("snow.VillageAreaManager"); if this.village_area_manager == nil then - --log.error("[MHR Overlay] No village area manager"); + error_handler.report("singletons.init_village_area_manager", "Failed to Access Data: village_area_manager"); end return this.village_area_manager; @@ -163,7 +164,7 @@ function this.init_gui_manager() this.gui_manager = sdk.get_managed_singleton("snow.gui.GuiManager"); if this.gui_manager == nil then - --log.error("[MHR Overlay] No gui manager"); + error_handler.report("singletons.init_gui_manager", "Failed to Access Data: gui_manager"); end return this.gui_manager; @@ -176,7 +177,7 @@ function this.init_game_keyboard() this.game_keyboard = sdk.get_managed_singleton("snow.GameKeyboard"); if this.game_keyboard == nil then - --log.error("[MHR Overlay] No game keyboard"); + error_handler.report("singletons.init_game_keyboard", "Failed to Access Data: game_keyboard"); end return this.game_keyboard; @@ -189,7 +190,7 @@ function this.init_scene_manager() this.scene_manager = sdk.get_native_singleton("via.SceneManager"); if this.scene_manager == nil then - --log.error("[MHR Overlay] No enemy manager"); + error_handler.report("singletons.init_scene_manager", "Failed to Access Data: scene_manager"); end return this.scene_manager; @@ -202,7 +203,7 @@ function this.init_game_manager() this.game_manager = sdk.get_managed_singleton("snow.SnowGameManager"); if this.game_manager == nil then - --log.error("[MHR Overlay] No enemy manager"); + error_handler.report("singletons.init_game_manager", "Failed to Access Data: game_manager"); end return this.game_manager; @@ -215,7 +216,7 @@ function this.init_servant_manager() this.servant_manager = sdk.get_managed_singleton("snow.ai.ServantManager"); if this.servant_manager == nil then - --log.error("[MHR Overlay] No enemy manager"); + error_handler.report("singletons.init_servant_manager", "Failed to Access Data: servant_manager"); end return this.servant_manager; @@ -228,7 +229,7 @@ function this.init_otomo_manager() this.otomo_manager = sdk.get_managed_singleton("snow.otomo.OtomoManager"); if this.otomo_manager == nil then - --log.error("[MHR Overlay] No enemy manager"); + error_handler.report("singletons.init_otomo_manager", "Failed to Access Data: otomo_manager"); end return this.otomo_manager; @@ -237,6 +238,7 @@ end function this.init_dependencies() time = require("MHR_Overlay.Game_Handler.time"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Game_Handler/time.lua b/reframework/autorun/MHR_Overlay/Game_Handler/time.lua index 134b4d9..11f4820 100644 --- a/reframework/autorun/MHR_Overlay/Game_Handler/time.lua +++ b/reframework/autorun/MHR_Overlay/Game_Handler/time.lua @@ -8,6 +8,7 @@ local non_players; local config; local small_monster; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -50,7 +51,6 @@ this.elapsed_minutes = 0; this.elapsed_seconds = 0; this.total_elapsed_script_seconds = 0; -this.last_elapsed_script_seconds = 0; this.list = {}; @@ -60,7 +60,6 @@ function this.new_timer(callback, cooldown_seconds, start_offset_seconds) if callback == nil or cooldown_seconds == nil then return; end - local timer = {}; timer.callback = callback; timer.cooldown = cooldown_seconds; @@ -69,7 +68,6 @@ function this.new_timer(callback, cooldown_seconds, start_offset_seconds) table.insert(this.list, timer); - callback(); end function this.update_timers() @@ -99,14 +97,14 @@ function this.update_quest_time() local quest_time_elapsed_minutes = get_quest_elapsed_time_min_method:call(singletons.quest_manager); if quest_time_elapsed_minutes == nil then - customization_menu.status = "No quest time elapsed minutes"; + error_handler.report("time.update_quest_time", "Failed to Access Data: quest_time_elapsed_minutes"); else this.elapsed_minutes = quest_time_elapsed_minutes; end local quest_time_total_elapsed_seconds = get_quest_elapsed_time_sec_method:call(singletons.quest_manager); if quest_time_total_elapsed_seconds == nil then - customization_menu.status = "No quest time total elapsed seconds"; + error_handler.report("time.update_quest_time", "Failed to Access Data: quest_time_total_elapsed_seconds"); else this.total_elapsed_seconds = quest_time_total_elapsed_seconds; end @@ -123,6 +121,7 @@ function this.init_dependencies() quest_status = require("MHR_Overlay.Game_Handler.quest_status"); non_players = require("MHR_Overlay.Damage_Meter.non_players"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Misc/config.lua b/reframework/autorun/MHR_Overlay/Misc/config.lua index ae953f4..0fa9027 100644 --- a/reframework/autorun/MHR_Overlay/Misc/config.lua +++ b/reframework/autorun/MHR_Overlay/Misc/config.lua @@ -2,6 +2,7 @@ local this = {}; local utils; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -7564,6 +7565,10 @@ function this.init_default() outline = 0xC0000000 } } + }, + + debug = { + history_size = 64 } }; end @@ -7572,7 +7577,7 @@ function this.load_current_config_value() local loaded_config = json.load_file(this.current_config_value_file_name); if loaded_config ~= nil then if loaded_config.config == nil then - log.info("[MHR Overlay] old config.json loaded successfully"); + log.info("[MHR Overlay] Old config.json Loaded Successfully"); local config_save = { config = this.current_config_name @@ -7590,11 +7595,12 @@ function this.load_current_config_value() is_old_config_transferred = true; else - log.info("[MHR Overlay] config.json loaded successfully"); + log.info("[MHR Overlay] config.json Loaded Successfully"); this.current_config_name = loaded_config.config; end else - log.error("[MHR Overlay] Failed to load config.json"); + log.error("[MHR Overlay] Failed to Load config.json"); + error_handler.report("config.load_current_config_value", "Failed to Load config.json"); end end @@ -7615,8 +7621,7 @@ function this.load_configs() local loaded_config = json.load_file(config_file_name); if loaded_config ~= nil then - log.info("[MHR Overlay] " .. config_name .. ".json loaded successfully"); - + log.info(string.format("[MHR Overlay] %s.json Loaded Successfully", config_name)); local merged_config = utils.table.merge(this.default_config, loaded_config); merged_config.version = this.version; @@ -7630,7 +7635,8 @@ function this.load_configs() this.current_config = merged_config; end else - log.error("[MHR Overlay] Failed to load " .. config_name .. ".json"); + log.error(string.format("[MHR Overlay] Failed to Load %s.json", config_name)); + error_handler.report("config.load_configs", string.format("Failed to Load %s.json", config_name)); end ::continue:: @@ -7664,7 +7670,8 @@ function this.save(file_name, config_table) if success then log.info("[MHR Overlay] " .. file_name .. " saved successfully"); else - log.error("[MHR Overlay] Failed to save " .. file_name); + error_handler.report("config.load_configs", string.format("Failed to Save %s", file_name)); + log.error(string.format("[MHR Overlay] Failed to Save %s", file_name)); end end @@ -7719,6 +7726,7 @@ end function this.init_dependencies() utils = require("MHR_Overlay.Misc.utils"); language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Misc/error_handler.lua b/reframework/autorun/MHR_Overlay/Misc/error_handler.lua new file mode 100644 index 0000000..e499fee --- /dev/null +++ b/reframework/autorun/MHR_Overlay/Misc/error_handler.lua @@ -0,0 +1,88 @@ +local this = {}; + +local time; +local utils; +local config; + +local sdk = sdk; +local tostring = tostring; +local pairs = pairs; +local ipairs = ipairs; +local tonumber = tonumber; +local require = require; +local pcall = pcall; +local table = table; +local string = string; +local Vector3f = Vector3f; +local d2d = d2d; +local math = math; +local json = json; +local log = log; +local fs = fs; +local next = next; +local type = type; +local setmetatable = setmetatable; +local getmetatable = getmetatable; +local assert = assert; +local select = select; +local coroutine = coroutine; +local utf8 = utf8; +local re = re; +local imgui = imgui; +local draw = draw; +local Vector2f = Vector2f; +local reframework = reframework; +local os = os; +local ValueType = ValueType; +local package = package; + +this.list = {}; +this.is_empty = true; + +this.history = {}; + +function this.report(error_key, error_message) + if error_key == nil or error_key == "" + or error_message == nil or error_message == "" then + return; + end + + local error_time = time.total_elapsed_script_seconds; + + local error = { + key = error_key, + time = error_time, + message = error_message + }; + + this.list[error_key] = error; + this.is_empty = false; + + this.add_to_history(error_key, error); +end + +function this.add_to_history(error_key, error) + this.clear_history(); + + table.insert(this.history, error); +end + +function this.clear_history() + local history_size = config.current_config.debug.history_size; + + while #this.history >= history_size do + table.remove(this.history, 1); + end +end + +function this.init_dependencies() + time = require("MHR_Overlay.Game_Handler.time"); + utils = require("MHR_Overlay.Misc.utils"); + config = require("MHR_Overlay.Misc.config"); +end + +function this.init_module() + +end + +return this; \ No newline at end of file diff --git a/reframework/autorun/MHR_Overlay/Misc/language.lua b/reframework/autorun/MHR_Overlay/Misc/language.lua index 78bc4db..81990e2 100644 --- a/reframework/autorun/MHR_Overlay/Misc/language.lua +++ b/reframework/autorun/MHR_Overlay/Misc/language.lua @@ -1,6 +1,7 @@ local this = {}; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -607,7 +608,12 @@ this.default_language = { top_to_bottom = "Top to Bottom", bottom_to_top = "Bottom to Top", - right_alignment_shift = "Right Alignment Shift" + right_alignment_shift = "Right Alignment Shift", + + debug = "Debug", + everything_seems_to_be_ok = "Everything seems to be OK!", + error_history = "Error History", + history_size = "History Size" } }; @@ -626,18 +632,17 @@ function this.load() local loaded_language = json.load_file(language_file_name); if loaded_language ~= nil then + log.info(string.format("[MHR Overlay] %s.json Loaded Successfully", language_file_name)); - log.info("[MHR Overlay] " .. language_file_name .. ".json loaded successfully"); table.insert(this.language_names, language_name); local merged_language = utils.table.merge(this.default_language, loaded_language); table.insert(this.languages, merged_language); this.save(language_file_name, merged_language); - - else - log.error("[MHR Overlay] Failed to load " .. language_file_name .. ".json"); + error_handler.report("language.load", string.format("Failed to load %s.json", language_file_name)); + log.error(string.format("[MHR Overlay] Failed to Load %s.json", language_file_name)); end end end @@ -645,9 +650,10 @@ end function this.save(file_name, language_table) local success = json.dump_file(file_name, language_table); if success then - log.info("[MHR Overlay] " .. file_name .. " saved successfully"); + log.info(string.format("[MHR Overlay] %s Saved Successfully", file_name)); else - log.error("[MHR Overlay] Failed to save " .. file_name); + error_handler.report("language.save", string.format("[MHR Overlay] Failed to Save %s", file_name)); + log.error(string.format("[MHR Overlay] Failed to Save %s", file_name)); end end @@ -661,6 +667,7 @@ end function this.init_dependencies() utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Misc/part_names.lua b/reframework/autorun/MHR_Overlay/Misc/part_names.lua index 7b9d644..4e7d840 100644 --- a/reframework/autorun/MHR_Overlay/Misc/part_names.lua +++ b/reframework/autorun/MHR_Overlay/Misc/part_names.lua @@ -1,6 +1,7 @@ local this = {}; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -956,6 +957,7 @@ end function this.init_dependencies() language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Misc/utils.lua b/reframework/autorun/MHR_Overlay/Misc/utils.lua index 1b0e587..681956a 100644 --- a/reframework/autorun/MHR_Overlay/Misc/utils.lua +++ b/reframework/autorun/MHR_Overlay/Misc/utils.lua @@ -1,5 +1,7 @@ local this = {}; +local error_handler; + local sdk = sdk; local tostring = tostring; local pairs = pairs; @@ -414,6 +416,7 @@ function this.unicode.sub(str, i, j) end function this.init_dependencies() + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua b/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua index c64ddbc..e020768 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailment_buildup.lua @@ -9,6 +9,7 @@ local time; local small_monster; local large_monster; local drawing; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -52,7 +53,6 @@ function this.draw(monster, ailment_buildup_UI, cached_config, ailment_buildups_ return; end - for id, ailment in pairs(monster.ailments) do if id == ailments.stun_id then if not cached_config.filter.stun then @@ -239,6 +239,7 @@ function this.init_dependencies() small_monster = require("MHR_Overlay.Monsters.small_monster"); large_monster = require("MHR_Overlay.Monsters.large_monster"); drawing = require("MHR_Overlay.UI.drawing"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua b/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua index 5ce2063..d6f6d23 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailment_hook.lua @@ -4,6 +4,7 @@ local small_monster; local large_monster; local config; local ailments; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -62,16 +63,19 @@ local blast_adjust_rate_method = blast_param_type:get_method("get_BlastDamageAdj function this.poison_proc(poison_param) if poison_param == nil then + error_handler.report("ailment_hook.poison_proc", "Missing Parameter: poison_param"); return; end local enemy = get_enemy_method:call(poison_param); if enemy == nil then + error_handler.report("ailment_hook.poison_proc", "Failed to Access Data: enemy"); return; end local is_large = is_boss_enemy_method:call(enemy); if is_large == nil then + error_handler.report("ailment_hook.poison_proc", "Failed to Access Data: is_large"); return; end @@ -90,16 +94,19 @@ end function this.blast_proc(blast_param) if blast_param == nil then + error_handler.report("ailment_hook.blast_proc", "Missing Parameter: blast_param"); return; end local enemy = get_enemy_method:call(blast_param); if enemy == nil then + error_handler.report("ailment_hook.blast_proc", "Failed to Access Data: enemy"); return; end local is_large = is_boss_enemy_method:call(enemy); if is_large == nil then + error_handler.report("ailment_hook.blast_proc", "Failed to Access Data: is_large"); return; end @@ -122,10 +129,15 @@ function this.stock_damage() for enemy, monster in pairs(large_monster.list) do local damage_param = get_damage_param_method:call(enemy); if damage_param == nil then - goto continue + error_handler.report("ailment_hook.stock_damage", "Failed to Access Data: large_monster -> damage_param"); + goto continue; end local poison_param = poison_param_field:get_data(damage_param); + if poison_param == nil then + error_handler.report("ailment_hook.stock_damage", "Failed to Access Data: large_monster -> poison_param"); + goto continue; + end ailments.update_poison(monster, poison_param); ::continue:: @@ -134,10 +146,15 @@ function this.stock_damage() for enemy, monster in pairs(small_monster.list) do local damage_param = get_damage_param_method:call(enemy); if damage_param == nil then + error_handler.report("ailment_hook.stock_damage", "Failed to Access Data: small_monster -> damage_param"); goto continue end local poison_param = poison_param_field:get_data(damage_param); + if poison_param == nil then + error_handler.report("ailment_hook.stock_damage", "Failed to Access Data: small_monster -> poison_param"); + goto continue; + end ailments.update_poison(monster, poison_param); ::continue:: @@ -149,6 +166,7 @@ function this.init_dependencies() large_monster = require("MHR_Overlay.Monsters.large_monster"); config = require("MHR_Overlay.Misc.config"); ailments = require("MHR_Overlay.Monsters.ailments"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/ailments.lua b/reframework/autorun/MHR_Overlay/Monsters/ailments.lua index 4496a41..5e3ce05 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/ailments.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/ailments.lua @@ -9,6 +9,7 @@ local time; local small_monster; local large_monster; local non_players; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -247,8 +248,6 @@ end local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase"); local get_damage_param_method = enemy_character_base_type_def:get_method("get_DamageParam"); - - local damage_param_type_def = get_damage_param_method:get_return_type(); local get_condition_param_method = damage_param_type_def:get_method("get_ConditionParam"); @@ -277,10 +276,13 @@ local get_value_method = system_array_type_def:get_method("GetValue(System.Int32 function this.update_ailments(enemy, monster) if enemy == nil then + error_handler.report("ailments.update_ailments", "Missing Parameter: enemy"); return; end + local damage_param = get_damage_param_method:call(enemy); if damage_param == nil then + error_handler.report("ailments.update_ailments", "Failed to Access Data: damage_param"); return; end @@ -297,13 +299,14 @@ function this.update_ailments(enemy, monster) end local condition_param_array = get_condition_param_method:call(damage_param); - if condition_param_array == nil then + error_handler.report("ailments.update_ailments", "Failed to Access Data: condition_param_array"); return; end local condition_param_array_length = length_method:call(condition_param_array); if condition_param_array_length == nil then + error_handler.report("ailments.update_ailments", "Failed to Access Data: condition_param_array_length"); return; end @@ -314,6 +317,7 @@ function this.update_ailments(enemy, monster) local ailment_param = get_value_method:call(condition_param_array, id); if ailment_param == nil then + error_handler.report("ailments.update_ailments", "Failed to Access Data: ailment_param No. " .. tostring(id)); goto continue end @@ -326,16 +330,22 @@ function this.update_stun_poison_blast_ailments(monster, damage_param) local stun_param = stun_param_field:get_data(damage_param); if stun_param ~= nil then this.update_ailment(monster, stun_param, this.stun_id); + else + error_handler.report("ailments.update_stun_poison_blast_ailments", "Failed to Access Data: stun_param"); end local poison_param = poison_param_field:get_data(damage_param); if poison_param ~= nil then this.update_ailment(monster, poison_param, this.poison_id); + else + error_handler.report("ailments.update_stun_poison_blast_ailments", "Failed to Access Data: poison_param"); end local blast_param = blast_param_field:get_data(damage_param); if blast_param ~= nil then this.update_ailment(monster, blast_param, this.blast_id); + else + error_handler.report("ailments.update_stun_poison_blast_ailments", "Failed to Access Data: blast_param"); end end @@ -348,9 +358,9 @@ function this.update_ailment(monster, ailment_param, id) 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; + local activate_count = nil; + local buildup = nil; + local buildup_limit = nil; if activate_count_array ~= nil then local activate_count_array_length = length_method:call(activate_count_array); @@ -361,14 +371,16 @@ function this.update_ailment(monster, ailment_param, id) local activate_count_valuetype = get_value_method:call(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 + activate_count = activate_count_valuetype:get_field("mValue"); + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: activate_count_valuetype"); end end + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: activate_count_array_length"); end + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: activate_count_array"); end if buildup_array ~= nil then @@ -380,14 +392,16 @@ function this.update_ailment(monster, ailment_param, id) local buildup_valuetype = get_value_method:call(buildup_array, 0); if buildup_valuetype ~= nil then - local _buildup = buildup_valuetype:get_field("mValue"); - - if _buildup ~= nil then - buildup = _buildup; - end + buildup = buildup_valuetype:get_field("mValue"); + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_valuetype"); end end + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_array_length"); end + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_array"); end if buildup_limit_array ~= nil then @@ -399,14 +413,16 @@ function this.update_ailment(monster, ailment_param, id) local buildup_limit_valuetype = get_value_method:call(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 + buildup_limit = buildup_limit_valuetype:get_field("mValue"); + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_limit_valuetype"); end end + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_limit_array_length"); end + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_limit_array"); end if is_enable == nil then @@ -429,6 +445,8 @@ function this.update_ailment(monster, ailment_param, id) end monster.ailments[id].activate_count = activate_count; + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: activate_count"); end if buildup ~= nil then @@ -437,6 +455,8 @@ function this.update_ailment(monster, ailment_param, id) end monster.ailments[id].total_buildup = buildup; + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup"); end if buildup_limit ~= nil then @@ -445,6 +465,8 @@ function this.update_ailment(monster, ailment_param, id) end monster.ailments[id].buildup_limit = buildup_limit; + else + error_handler.report("ailments.update_ailment", "Failed to Access Data: buildup_limit"); end if buildup ~= nil and buildup_limit ~= nil and buildup_limit ~= 0 then @@ -503,18 +525,29 @@ end -- Code by coavins function this.update_poison(monster, poison_param) if monster == nil then + error_handler.report("ailments.update_poison", "Missing Parameter: monster"); return; end - if poison_param ~= nil then - --if poison tick, apply damage - local is_damage = poison_get_is_damage_method:call(poison_param); - if is_damage then - local poison_damage = poison_damage_field:get_data(poison_param); - - this.apply_ailment_damage(monster, this.poison_id, poison_damage); - end + if poison_param == nil then + error_handler.report("ailments.update_poison", "Missing Parameter: poison_param"); + return; end + + --if poison tick, apply damage + local is_damage = poison_get_is_damage_method:call(poison_param); + if is_damage == nil then + error_handler.report("ailments.update_poison", "Failed to Access Data: is_damage"); + return; + end + + local poison_damage = poison_damage_field:get_data(poison_param); + if poison_damage == nil then + error_handler.report("ailments.update_poison", "Failed to Access Data: poison_damage"); + return; + end + + this.apply_ailment_damage(monster, this.poison_id, poison_damage); end function this.draw(monster, ailment_UI, cached_config, ailments_position_on_screen, opacity_scale) @@ -608,14 +641,17 @@ function this.draw(monster, ailment_UI, cached_config, ailments_position_on_scre goto continue end - if cached_config.settings.hide_ailments_with_zero_buildup and ailment.total_buildup == 0 and - ailment.buildup_limit ~= 0 - and ailment.activate_count == 0 and not ailment.is_active then + if cached_config.settings.hide_ailments_with_zero_buildup + and ailment.total_buildup == 0 + and ailment.buildup_limit ~= 0 + and ailment.activate_count == 0 + and not ailment.is_active then goto continue end - if cached_config.settings.hide_inactive_ailments_with_no_buildup_support and ailment.buildup_limit == 0 and - not ailment.is_active then + if cached_config.settings.hide_inactive_ailments_with_no_buildup_support + and ailment.buildup_limit == 0 + and not ailment.is_active then goto continue end @@ -631,9 +667,9 @@ function this.draw(monster, ailment_UI, cached_config, ailments_position_on_scre goto continue end - if cached_config.settings.time_limit ~= 0 and - time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit and - not ailment.is_active then + if cached_config.settings.time_limit ~= 0 + and time.total_elapsed_script_seconds - ailment.last_change_time > cached_config.settings.time_limit + and not ailment.is_active then goto continue end @@ -682,14 +718,21 @@ function this.draw(monster, ailment_UI, cached_config, ailments_position_on_scre ailment_UI_entity.draw(ailment, ailment_UI, cached_config, ailment_position_on_screen, opacity_scale); end - - end function this.apply_ailment_buildup(monster, player, otomo, ailment_type, ailment_buildup) - if monster == nil or - (ailment_type ~= this.poison_id and ailment_type ~= this.blast_id and ailment_type ~= this.stun_id) - or (ailment_buildup == 0 or ailment_buildup == nil) then + if monster == nil then + error_handler.report("ailments.apply_ailment_buildup", "Missing Parameter: monster"); + return; + end + + if ailment_buildup == nil then + error_handler.report("ailments.apply_ailment_buildup", "Missing Parameter: ailment_buildup"); + return; + end + + if (ailment_type ~= this.poison_id and ailment_type ~= this.blast_id and ailment_type ~= this.stun_id) + or ailment_buildup == 0 then return; end @@ -709,7 +752,6 @@ function this.apply_ailment_buildup(monster, player, otomo, ailment_type, ailmen monster.ailments[ailment_type].otomo_buildup[otomo] = (monster.ailments[ailment_type].otomo_buildup[otomo] or 0) + ailment_buildup; end - this.calculate_ailment_contribution(monster, ailment_type); end @@ -751,7 +793,17 @@ end -- Code by coavins function this.apply_ailment_damage(monster, ailment_type, ailment_damage) -- we only track poison and blast for now - if ailment_type == nil or ailment_damage == nil then + if monster == nil then + error_handler.report("ailments.apply_ailment_damage", "Missing Parameter: monster"); + end + + if ailment_type == nil then + error_handler.report("ailments.apply_ailment_damage", "Missing Parameter: ailment_type"); + return; + end + + if ailment_damage == nil then + error_handler.report("ailments.apply_ailment_damage", "Missing Parameter: ailment_damage"); return; end @@ -824,6 +876,7 @@ function this.init_dependencies() time = require("MHR_Overlay.Game_Handler.time"); small_monster = require("MHR_Overlay.Monsters.small_monster"); large_monster = require("MHR_Overlay.Monsters.large_monster"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/body_part.lua b/reframework/autorun/MHR_Overlay/Monsters/body_part.lua index 28a32f4..75c2a53 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/body_part.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/body_part.lua @@ -12,6 +12,7 @@ local drawing; local part_names; local time; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -50,7 +51,6 @@ this.list = {}; function this.new(id, name) local part = {}; - part.id = id; part.name = name; @@ -475,6 +475,7 @@ function this.init_dependencies() part_names = require("MHR_Overlay.Misc.part_names"); time = require("MHR_Overlay.Game_Handler.time"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua b/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua index 7f4d7f5..637ea9c 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua @@ -19,6 +19,7 @@ local players; local time; local body_part; local part_names; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -56,6 +57,7 @@ this.list = {}; function this.new(enemy) local monster = {}; + monster.enemy = enemy; monster.is_large = true; @@ -259,7 +261,7 @@ local on_break_method = enemy_mystery_core_parts_type_def:get_method("onBreak"); function this.init(monster, enemy) local enemy_type = enemy_type_field:get_data(enemy); if enemy_type == nil then - customization_menu.status = "No enemy type"; + error_handler.report("large_monster.init", "Failed to Access Data: enemy_type"); return; end @@ -272,6 +274,8 @@ function this.init(monster, enemy) local enemy_name = get_enemy_name_message_method:call(singletons.message_manager, enemy_type); if enemy_name ~= nil then monster.name = enemy_name; + else + error_handler.report("large_monster.init", "Failed to Access Data: enemy_name"); end local set_info = get_set_info_method:call(enemy); @@ -279,7 +283,11 @@ function this.init(monster, enemy) local unique_id = get_unique_id_method:call(set_info); if unique_id ~= nil then monster.unique_id = unique_id; + else + error_handler.report("large_monster.init", "Failed to Access Data: unique_id"); end + else + error_handler.report("large_monster.init", "Failed to Access Data: set_info"); end local size_info = find_enemy_size_info_method:call(singletons.enemy_manager, enemy_type); @@ -292,18 +300,26 @@ function this.init(monster, enemy) if small_border ~= nil then monster.small_border = small_border; + else + error_handler.report("large_monster.init", "Failed to Access Data: small_border"); end if big_border ~= nil then monster.big_border = big_border; + else + error_handler.report("large_monster.init", "Failed to Access Data: big_border"); end if king_border ~= nil then monster.king_border = king_border; + else + error_handler.report("large_monster.init", "Failed to Access Data: king_border"); end if size ~= nil then monster.size = size; + else + error_handler.report("large_monster.init", "Failed to Access Data: size"); end if monster.size <= monster.small_border then @@ -313,6 +329,8 @@ function this.init(monster, enemy) elseif monster.size >= monster.big_border then monster.crown = language.current_language.UI.silver; end + else + error_handler.report("large_monster.init", "Failed to Access Data: size_info"); end local is_capture_enable = true; @@ -325,12 +343,19 @@ function this.init(monster, enemy) local is_capture_enable_ = capture_param:call("get_IsEnable"); if is_capture_enable_ ~= nil then is_capture_enable = is_capture_enable_; + else + error_handler.report("large_monster.init", "Failed to Access Data: is_capture_enable_"); end + else + error_handler.report("large_monster.init", "Failed to Access Data: capture_param"); end + else + error_handler.report("large_monster.init", "Failed to Access Data: damage_param"); end --local curia_param = enemy:get_field("k__BackingField"); local mystery_param = get_mystery_param_method:call(enemy); + local is_anomaly = mystery_param ~= nil; monster.is_anomaly = is_anomaly; @@ -426,15 +451,17 @@ function this.init_UI(monster, monster_UI, cached_config) end function this.update_position(enemy, monster) - if not config.current_config.large_monster_UI.dynamic.enabled and - config.current_config.large_monster_UI.static.sorting.type ~= "Distance" then + if not config.current_config.large_monster_UI.dynamic.enabled + and config.current_config.large_monster_UI.static.sorting.type ~= "Distance" then return; end local position = get_pos_field:call(enemy); - if position ~= nil then - monster.position = position; + if position == nil then + error_handler.report("large_monster.update_position", "Failed to Access Data: position"); end + + monster.position = position; end -- Code by coavins @@ -442,26 +469,31 @@ function this.update_all_riders() for enemy, monster in pairs(this.list) do -- get marionette rider local mario_param = get_mario_param_method:call(enemy); - if mario_param ~= nil then - local is_marionette = get_is_marionette_method:call(mario_param); + if mario_param == nil then + error_handler.report("large_monster.update_all_riders", "Failed to Access Data: mario_param"); + goto continue; + end - if is_marionette == nil then + local is_marionette = get_is_marionette_method:call(mario_param); + if is_marionette == nil then + error_handler.report("large_monster.update_all_riders", "Failed to Access Data: is_marionette"); + goto continue; + end + + if is_marionette then + local player_id = get_mario_player_index_method:call(mario_param); + if player_id == nil then + error_handler.report("large_monster.update_all_riders", "Failed to Access Data: player_id"); goto continue; end - - if is_marionette then - local player_id = get_mario_player_index_method:call(mario_param); - if player_id ~= nil then - monster.rider_id = player_id; - end - else - monster.rider_id = -1; - end + + monster.rider_id = player_id; + else + monster.rider_id = -1; end ::continue:: end - end function this.update(enemy, monster) @@ -476,11 +508,15 @@ function this.update(enemy, monster) local dead_or_captured = check_die_method:call(enemy); if dead_or_captured ~= nil then monster.dead_or_captured = dead_or_captured; + else + error_handler.report("large_monster.update", "Failed to Access Data: dead_or_captured"); end local is_disp_icon_mini_map = is_disp_icon_mini_map_method:call(enemy); if is_disp_icon_mini_map ~= nil then monster.is_disp_icon_mini_map = is_disp_icon_mini_map; + else + error_handler.report("large_monster.update", "Failed to Access Data: is_disp_icon_mini_map"); end if monster.id == 549 or monster.id == 25 or monster.id == 2073 then @@ -491,23 +527,29 @@ function this.update(enemy, monster) -- Lucent Nargacuga if monster.id == 549 then local is_stealth = is_stealth_method:call(enemy); - if is_stealth ~= nil then + if is_stealth == nil then monster.is_stealth = is_stealth; + else + error_handler.report("large_monster.update", "Failed to Access Data: is_stealth"); end + -- Chameleos and Risen Chameleos elseif monster.id == 25 or monster.id == 2073 then local stealth_controller = get_stealth_ctrl_method:call(enemy); if stealth_controller ~= nil then local status = get_current_status_method:call(stealth_controller); - if status >= 2 then + if status == nil then + error_handler.report("large_monster.update", "Failed to Access Data: status"); + elseif status >= 2 then monster.is_stealth = true; else monster.is_stealth = false; end + else + error_handler.report("large_monster.update", "Failed to Access Data: stealth_controller"); end end - end pcall(ailments.update_ailments, enemy, monster); @@ -530,24 +572,41 @@ function this.update_health(enemy, monster) local physical_param = get_physical_param_method:call(enemy); if physical_param == nil then - customization_menu.status = "No physical param"; + error_handler.report("large_monster.update_health", "Failed to Access Data: physical_param"); return nil; end local vital_param = get_vital_method:call(physical_param, 0, 0); if vital_param == nil then - customization_menu.status = "No vital param"; + error_handler.report("large_monster.update_health", "Failed to Access Data: vital_param"); return nil; end - monster.health = get_current_method:call(vital_param) or monster.health; - monster.max_health = get_max_method:call(vital_param) or monster.max_health; - monster.capture_health = get_capture_hp_vital_method:call(physical_param) or monster.capture_health; + local health = get_current_method:call(vital_param); + if health ~= nil then + monster.health = health; + else + error_handler.report("large_monster.update_health", "Failed to Access Data: health"); + end - monster.missing_health = monster.max_health - monster.health; + local max_health = get_max_method:call(vital_param); + if max_health ~= nil then + monster.max_health = max_health; + else + error_handler.report("large_monster.update_health", "Failed to Access Data: max_health"); + end + + local capture_health = get_capture_hp_vital_method:call(physical_param); + if capture_health ~= nil then + monster.capture_health = capture_health; + else + error_handler.report("large_monster.update_health", "Failed to Access Data: capture_health"); + end + + monster.missing_health = max_health - health; if monster.max_health ~= 0 then - monster.health_percentage = monster.health / monster.max_health; - monster.capture_percentage = monster.capture_health / monster.max_health; + monster.health_percentage = health / max_health; + monster.capture_percentage = capture_health / max_health; end return physical_param; @@ -569,9 +628,9 @@ function this.update_stamina(enemy, monster, stamina_param) end if stamina_param == nil then - stamina_param =get_stamina_param_method:call(enemy); + stamina_param = get_stamina_param_method:call(enemy); if stamina_param == nil then - customization_menu.status = "No stamina param"; + error_handler.report("large_monster.update_stamina", "Failed to Access Data: stamina_param"); return; end end @@ -579,14 +638,34 @@ function this.update_stamina(enemy, monster, stamina_param) local is_tired = is_tired_method:call(stamina_param, false); if is_tired ~= nil then monster.is_tired = is_tired; + else + error_handler.report("large_monster.update_stamina", "Failed to Access Data: is_tired"); + return; end - monster.stamina = get_stamina_method:call(stamina_param) or monster.stamina; - monster.max_stamina = get_max_stamina_method:call(stamina_param) or monster.max_stamina; + if is_tired then + return; + end - monster.missing_stamina = monster.max_stamina - monster.stamina; - if monster.max_stamina ~= 0 then - monster.stamina_percentage = monster.stamina / monster.max_stamina; + local stamina = get_stamina_method:call(stamina_param); + if stamina ~= nil then + monster.stamina = stamina; + else + error_handler.report("large_monster.update_stamina", "Failed to Access Data: stamina"); + return; + end + + local max_stamina = get_max_stamina_method:call(stamina_param); + if max_stamina ~= nil then + monster.max_stamina = max_stamina; + else + error_handler.report("large_monster.update_stamina", "Failed to Access Data: max_stamina"); + return; + end + + monster.missing_stamina = max_stamina - stamina; + if max_stamina ~= 0 then + monster.stamina_percentage = stamina / max_stamina; end end @@ -608,7 +687,7 @@ function this.update_stamina_timer(enemy, monster, stamina_param) if stamina_param == nil then stamina_param = get_stamina_param_method:call(enemy); if stamina_param == nil then - customization_menu.status = "No stamina param"; + error_handler.report("large_monster.update_stamina_timer", "Failed to Access Data: stamina_param"); return; end end @@ -616,24 +695,41 @@ function this.update_stamina_timer(enemy, monster, stamina_param) local is_tired = is_tired_method:call(stamina_param, false); if is_tired ~= nil then monster.is_tired = is_tired; + else + error_handler.report("large_monster.update_stamina_timer", "Failed to Access Data: is_tired"); + return; + end + + if not is_tired then + return; end + local tired_timer = get_remaining_tired_time_method:call(stamina_param); + if tired_timer ~= nil then + monster.tired_timer = tired_timer; + else + error_handler.report("large_monster.update_stamina_timer", "Failed to Access Data: tired_timer"); + return; + end - monster.tired_timer = get_remaining_tired_time_method:call(stamina_param) or monster.tired_timer; - monster.tired_duration = get_total_tired_time_method:call(stamina_param) or monster.tired_duration; + local tired_duration = get_total_tired_time_method:call(stamina_param); + if tired_duration ~= nil then + monster.tired_duration = tired_duration; + else + error_handler.report("large_monster.update_stamina_timer", "Failed to Access Data: tired_duration"); + return; + end - if monster.is_tired then - monster.tired_total_seconds_left = monster.tired_timer; - if monster.tired_total_seconds_left < 0 then - monster.tired_total_seconds_left = 0; - end + monster.tired_total_seconds_left = tired_timer; + if monster.tired_total_seconds_left < 0 then + monster.tired_total_seconds_left = 0; + end - monster.tired_minutes_left = math.floor(monster.tired_total_seconds_left / 60); - monster.tired_seconds_left = monster.tired_total_seconds_left - 60 * monster.tired_minutes_left; + monster.tired_minutes_left = math.floor(monster.tired_total_seconds_left / 60); + monster.tired_seconds_left = monster.tired_total_seconds_left - 60 * monster.tired_minutes_left; - if monster.tired_duration ~= 0 then - monster.tired_timer_percentage = monster.tired_total_seconds_left / monster.tired_duration; - end + if tired_duration ~= 0 then + monster.tired_timer_percentage = monster.tired_total_seconds_left / tired_duration; end end @@ -655,17 +751,41 @@ function this.update_rage(enemy, monster, anger_param) if anger_param == nil then anger_param = get_anger_param_method:call(enemy); if anger_param == nil then - customization_menu.status = "No anger param"; + error_handler.report("large_monster.update_rage", "Failed to Access Data: anger_param"); return; end end + local is_in_rage = is_anger_method:call(anger_param); + if is_in_rage ~= nil then + monster.is_in_rage = is_in_rage; + else + error_handler.report("large_monster.update_rage", "Failed to Access Data: is_in_rage"); + return; + end - monster.rage_point = get_anger_point_method:call(anger_param) or monster.rage_point; - monster.rage_limit = get_limit_anger_method:call(anger_param) or monster.rage_limit; + if is_in_rage then + return; + end + + local rage_point = get_anger_point_method:call(anger_param); + if rage_point ~= nil then + monster.rage_point = rage_point; + else + error_handler.report("large_monster.update_rage", "Failed to Access Data: rage_point"); + return; + end - if monster.rage_limit ~= 0 then - monster.rage_percentage = monster.rage_point / monster.rage_limit; + local rage_limit = get_limit_anger_method:call(anger_param); + if rage_limit ~= nil then + monster.rage_limit = rage_limit; + else + error_handler.report("large_monster.update_rage", "Failed to Access Data: rage_limit"); + return; + end + + if rage_limit ~= 0 then + monster.rage_percentage = rage_point / rage_limit; end end @@ -687,7 +807,7 @@ function this.update_rage_timer(enemy, monster, anger_param) if anger_param == nil then anger_param = get_anger_param_method:call(enemy); if anger_param == nil then - customization_menu.status = "No anger param"; + error_handler.report("large_monster.update_rage_timer", "Failed to Access Data: anger_param"); return; end end @@ -695,23 +815,41 @@ function this.update_rage_timer(enemy, monster, anger_param) local is_in_rage = is_anger_method:call(anger_param); if is_in_rage ~= nil then monster.is_in_rage = is_in_rage; + else + error_handler.report("large_monster.update_rage_timer", "Failed to Access Data: is_in_rage"); + return; end - monster.rage_timer = get_remaining_anger_time_method:call(anger_param) or monster.rage_timer; - monster.rage_duration = get_total_anger_time_method:call(anger_param) or monster.rage_duration; + if not is_in_rage then + return; + end - if monster.is_in_rage then - monster.rage_total_seconds_left = monster.rage_timer; - if monster.rage_total_seconds_left < 0 then - monster.rage_total_seconds_left = 0; - end + local rage_timer = get_remaining_anger_time_method:call(anger_param); + if rage_timer ~= nil then + monster.rage_timer = rage_timer; + else + error_handler.report("large_monster.update_rage_timer", "Failed to Access Data: rage_timer"); + return; + end - monster.rage_minutes_left = math.floor(monster.rage_total_seconds_left / 60); - monster.rage_seconds_left = monster.rage_total_seconds_left - 60 * monster.rage_minutes_left; + local rage_duration = get_total_anger_time_method:call(anger_param); + if rage_duration ~= nil then + monster.rage_duration = rage_duration; + else + error_handler.report("large_monster.update_rage_timer", "Failed to Access Data: rage_duration"); + return; + end - if monster.rage_duration ~= 0 then - monster.rage_timer_percentage = monster.rage_total_seconds_left / monster.rage_duration; - end + monster.rage_total_seconds_left = rage_timer; + if monster.rage_total_seconds_left < 0 then + monster.rage_total_seconds_left = 0; + end + + monster.rage_minutes_left = math.floor(monster.rage_total_seconds_left / 60); + monster.rage_seconds_left = monster.rage_total_seconds_left - 60 * monster.rage_minutes_left; + + if rage_duration ~= 0 then + monster.rage_timer_percentage = monster.rage_total_seconds_left / rage_duration; end end @@ -745,31 +883,32 @@ function this.update_parts(enemy, monster, physical_param) if physical_param == nil then physical_param = get_physical_param_method:call(enemy); if physical_param == nil then - customization_menu.status = "No physical param"; + error_handler.report("large_monster.update_parts", "Failed to Access Data: physical_param"); return; end end local damage_param = get_damage_param_method:call(enemy); if damage_param == nil then - customization_menu.status = "No damage param"; + error_handler.report("large_monster.update_parts", "Failed to Access Data: damage_param"); return; end local enemy_parts_damage_info = enemy_parts_damage_info_field:get_data(damage_param); if enemy_parts_damage_info == nil then - customization_menu.status = "No parts damage info"; + error_handler.report("large_monster.update_parts", "Failed to Access Data: enemy_parts_damage_info"); return; end local core_parts_array = get_part_info_array_method:call(enemy_parts_damage_info); if core_parts_array == nil then - customization_menu.status = "No parts damage info array"; + error_handler.report("large_monster.update_parts", "Failed to Access Data: core_parts_array"); return; end local core_parts_array_length = length_method:call(core_parts_array); if core_parts_array_length == nil then + error_handler.report("large_monster.update_parts", "Failed to Access Data: core_parts_array_length"); return; end @@ -778,7 +917,8 @@ function this.update_parts(enemy, monster, physical_param) local enemy_parts_info = get_value_method:call(core_parts_array, i); if enemy_parts_info == nil then - goto continue + error_handler.report("large_monster.update_parts", "Failed to Access Data: enemy_parts_info No. " .. tostring(i)); + goto continue; end local part = monster.parts[part_id]; @@ -795,52 +935,90 @@ function this.update_parts(enemy, monster, physical_param) if cached_config.dynamic.body_parts.part_health.visibility or cached_config.static.body_parts.part_health.visibility or cached_config.highlighted.body_parts.part_health.visibility then + local part_vital = get_vital_method:call(physical_param, 1, i); if part_vital ~= nil then - local part_current = get_current_method:call(part_vital) or -1; - local part_max = get_max_method:call(part_vital) or -1; - body_part.update_flinch(part, part_current, part_max); + local part_current = get_current_method:call(part_vital); + if part_current == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_current", i)); + end + local part_max = get_max_method:call(part_vital); + if part_max == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_max", i)); + end + + if part_current ~= nil and part_max ~= nil then + body_part.update_flinch(part, part_current, part_max); + end + else + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_vital", i)); end end if cached_config.dynamic.body_parts.part_break.visibility or cached_config.static.body_parts.part_break.visibility or cached_config.highlighted.body_parts.part_break.visibility then + local part_break_vital = get_vital_method:call(physical_param, 2, i); if part_break_vital ~= nil then - local part_break_current = get_current_method:call(part_break_vital) or -1; - local part_break_max = get_max_method:call(part_break_vital) or -1; - local part_break_count = -1; - local part_break_max_count = -1; - if enemy_parts_info ~= nil then - part_break_count = get_parts_break_damage_level_method:call(enemy_parts_info) or part_break_count; - part_break_max_count = get_parts_break_damage_max_level_method:call(enemy_parts_info) or part_break_max_count; + local part_break_current = get_current_method:call(part_break_vital); + if part_break_current == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_break_current", i)); end - body_part.update_break(part, part_break_current, part_break_max, part_break_count, part_break_max_count) + local part_break_max = get_max_method:call(part_break_vital); + if part_break_max == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_break_max", i)); + end + + local part_break_count = get_parts_break_damage_level_method:call(enemy_parts_info); + if part_break_count == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_break_count", i)); + end + + local part_break_max_count = get_parts_break_damage_max_level_method:call(enemy_parts_info); + if part_break_max_count == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_break_max_count", i)); + end + + if part_break_current ~= nil and part_break_max ~= nil and part_break_count ~= nil and part_break_max_count ~= nil then + body_part.update_break(part, part_break_current, part_break_max, part_break_count, part_break_max_count); + end + else + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_break_vital", i)); end end if cached_config.dynamic.body_parts.part_loss.visibility or cached_config.static.body_parts.part_loss.visibility or cached_config.highlighted.body_parts.part_loss.visibility then + local part_loss_vital = get_vital_method:call(physical_param, 3, i); if part_loss_vital ~= nil then - local part_loss_current = get_current_method:call(part_loss_vital) or -1; - local part_loss_max = get_max_method:call(part_loss_vital) or -1; - local is_severed = false; - if enemy_parts_info ~= nil then - local _is_severed = get_parts_loss_state_method:call(enemy_parts_info); - if _is_severed ~= nil then - is_severed = _is_severed; - end + local part_loss_current = get_current_method:call(part_loss_vital); + if part_loss_current == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_loss_current", i)); end - body_part.update_loss(part, part_loss_current, part_loss_max, is_severed); + local part_loss_max = get_max_method:call(part_loss_vital); + if part_loss_max == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_loss_max", i)); + end + + local is_severed = get_parts_loss_state_method:call(enemy_parts_info); + if is_severed == nil then + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> is_severed", i)); + end + + if part_loss_current ~= nil and part_loss_max ~= nil and is_severed ~= nil then + body_part.update_loss(part, part_loss_current, part_loss_max, is_severed); + end + else + error_handler.report("large_monster.update_parts", string.format("Failed to Access Data: enemy_parts_info No. %d -> part_loss_vital", i)); end end @@ -878,12 +1056,13 @@ function this.update_anomaly_parts(enemy, monster, mystery_param) local core_parts_array = core_parts_array_field:get_data(mystery_param); if core_parts_array == nil then - customization_menu.status = "No core parts array"; + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: core_parts_array"); return; end local core_parts_array_length = length_method:call(core_parts_array); if core_parts_array_length == nil then + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: core_parts_array_length"); return; end @@ -892,7 +1071,8 @@ function this.update_anomaly_parts(enemy, monster, mystery_param) local core_part = get_value_method:call(core_parts_array, i); if core_part == nil then - goto continue + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: core_part No. " .. tostring(i)); + goto continue; end local part = monster.parts[part_id]; @@ -907,27 +1087,43 @@ function this.update_anomaly_parts(enemy, monster, mystery_param) end local part_vital = core_parts_get_vital_method:call(core_part); + if part_vital == nil then + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: part_vital No. " .. tostring(i)); + return; + end + local part_is_active = core_parts_get_is_active_method:call(core_part); + if part_is_active == nil then + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: part_is_active No. " .. tostring(i)); + return; + end + --local part_dying_vital_threshold = core_parts_get_dying_vital_threashold_method:call(core_part); - if part_is_active == nil then - part_is_active = false; + local part_current = get_current_method:call(part_vital); + if part_current == nil then + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: part_current No. " .. tostring(i)); + goto continue; end - if part_vital ~= nil then - local part_current = get_current_method:call(part_vital) or -1; - local part_max = get_max_method:call(part_vital) or -1; - local part_is_enabled = is_enable_method:call(part_vital); - - - if not part_is_enabled then - goto continue; - end - - body_part.update_anomaly(part, core_part, part_current, part_max, part_is_active); - + local part_max = get_max_method:call(part_vital); + if part_max == nil then + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: part_max No. " .. tostring(i)); + goto continue; end + local part_is_enabled = is_enable_method:call(part_vital); + if part_is_enabled == nil then + error_handler.report("large_monster.update_anomaly_parts", "Failed to Access Data: part_is_enabled No. " .. tostring(i)); + goto continue; + end + + if not part_is_enabled then + goto continue; + end + + body_part.update_anomaly(part, core_part, part_current, part_max, part_is_active); + ::continue:: end end @@ -1054,6 +1250,7 @@ function this.init_dependencies() players = require("MHR_Overlay.Damage_Meter.players"); time = require("MHR_Overlay.Game_Handler.time"); ailment_buildup = require("MHR_Overlay.Monsters.ailment_buildup"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua index ec798f9..64bfa73 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua @@ -6,6 +6,7 @@ local config; local ailments; local players; local quest_status; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -118,8 +119,8 @@ function this.update_large_monster(enemy) local cached_config = config.current_config.large_monster_UI; if not cached_config.dynamic.enabled and - not cached_config.static.enabled and - not cached_config.highlighted.enabled then + not cached_config.static.enabled and + not cached_config.highlighted.enabled then return; end @@ -202,11 +203,13 @@ end function this.update_health(enemy_damage_check) local enemy = get_ref_enemy:call(enemy_damage_check); if enemy == nil then + error_handler.report("monster_hook.update_health", "Failed to Access Data: enemy"); return; end local is_large = is_boss_enemy_method:call(enemy); if is_large == nil then + error_handler.report("monster_hook.update_health", "Failed to Access Data: is_large"); return; end @@ -229,6 +232,7 @@ function this.update_stamina(stamina_param, stamina_sub) local enemy = get_enemy_method:call(stamina_param); if enemy == nil then + error_handler.report("monster_hook.update_stamina", "Failed to Access Data: enemy"); return; end @@ -262,6 +266,7 @@ function this.init_dependencies() ailments = require("MHR_Overlay.Monsters.ailments"); players = require("MHR_Overlay.Damage_Meter.players"); quest_status = require("MHR_Overlay.Game_Handler.quest_status"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua b/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua index e5384a6..5a79250 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/small_monster.lua @@ -12,6 +12,7 @@ local ailments; local ailment_UI_entity; local ailment_buildup; local ailment_buildup_UI_entity; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -98,16 +99,18 @@ local get_enemy_name_message_method = message_manager_type_def:get_method("getEn function this.init(monster, enemy) local enemy_type = enemy_type_field:get_data(enemy); if enemy_type == nil then - customization_menu.status = "No enemy type"; + error_handler.report("small_monster.init", "Failed to Access Data: enemy_type"); return; end monster.id = enemy_type; local enemy_name = get_enemy_name_message_method:call(singletons.message_manager, enemy_type); - if enemy_name ~= nil then - monster.name = enemy_name; + if enemy_name == nil then + error_handler.report("small_monster.init", "Failed to Access Data: enemy_name"); end + + monster.name = enemy_name; end function this.init_UI(monster) @@ -175,9 +178,11 @@ function this.update_position(enemy, monster) end local position = get_pos_field:call(enemy); - if position ~= nil then - monster.position = position; + if position == nil then + error_handler.report("small_monster.update_position", "Failed to Access Data: position"); end + + monster.position = position; end function this.update(enemy, monster) @@ -188,6 +193,8 @@ function this.update(enemy, monster) local dead_or_captured = check_die_method:call(enemy); if dead_or_captured ~= nil then monster.dead_or_captured = dead_or_captured; + else + error_handler.report("small_monster.update", "Failed to Access Data: dead_or_captured"); end pcall(ailments.update_ailments, enemy, monster); @@ -200,23 +207,35 @@ function this.update_health(enemy, monster) local physical_param = get_physical_param_method:call(enemy); if physical_param == nil then - customization_menu.status = "No physical param"; + error_handler.report("small_monster.update_health", "Failed to Access Data: physical_param"); return; end local vital_param = get_vital_method:call(physical_param, 0, 0); if vital_param == nil then - customization_menu.status = "No vital param"; + error_handler.report("small_monster.update_health", "Failed to Access Data: vital_param"); return; end - monster.health = get_current_method:call(vital_param) or monster.health; - monster.max_health = get_max_method:call(vital_param) or monster.max_health; + local health = get_current_method:call(vital_param); + if health ~= nil then + monster.health = health; + else + error_handler.report("small_monster.update_health", "Failed to Access Data: health"); + return; + end - monster.missing_health = monster.max_health - monster.health; - if monster.max_health ~= 0 then - monster.health_percentage = monster.health / monster.max_health; - monster.capture_percentage = monster.capture_health / monster.max_health; + local max_health = get_max_method:call(vital_param); + if max_health ~= nil then + monster.max_health = max_health; + else + error_handler.report("small_monster.update_health", "Failed to Access Data: max_health"); + return; + end + + monster.missing_health = max_health - health; + if max_health ~= 0 then + monster.health_percentage = health / max_health; end end @@ -262,6 +281,7 @@ function this.init_dependencies() ailment_UI_entity = require("MHR_Overlay.UI.UI_Entities.ailment_UI_entity"); ailment_buildup = require("MHR_Overlay.Monsters.ailment_buildup"); ailment_buildup_UI_entity = require("MHR_Overlay.UI.UI_Entities.ailment_buildup_UI_entity"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/ailment_buildups_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/ailment_buildups_customization.lua index 2d0cefe..2543a33 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/ailment_buildups_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/ailment_buildups_customization.lua @@ -14,6 +14,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -271,6 +272,7 @@ function this.init_dependencies() label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/ailments_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/ailments_customization.lua index 788f0a7..0fbdd38 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/ailments_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/ailments_customization.lua @@ -14,6 +14,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -401,6 +402,7 @@ function this.init_dependencies() customization_menu = require("MHR_Overlay.UI.customization_menu"); label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/bar_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/bar_customization.lua index a4a4e48..120bb67 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/bar_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/bar_customization.lua @@ -13,6 +13,7 @@ local time_UI; local keyboard; local customization_menu; local line_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -257,6 +258,7 @@ function this.init_dependencies() keyboard = require("MHR_Overlay.Game_Handler.keyboard"); customization_menu = require("MHR_Overlay.UI.customization_menu"); line_customization = require("MHR_Overlay.UI.Customizations.line_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/body_parts_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/body_parts_customization.lua index 566a233..df9fa98 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/body_parts_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/body_parts_customization.lua @@ -14,6 +14,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -526,6 +527,7 @@ function this.init_dependencies() customization_menu = require("MHR_Overlay.UI.customization_menu"); label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/health_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/health_customization.lua index b4a3e98..9541263 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/health_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/health_customization.lua @@ -13,6 +13,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -102,6 +103,7 @@ function this.init_dependencies() customization_menu = require("MHR_Overlay.UI.customization_menu"); label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/label_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/label_customization.lua index 26c6d52..6d98a7f 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/label_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/label_customization.lua @@ -11,6 +11,7 @@ local part_names; local time_UI; local keyboard; local customization_menu; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -134,6 +135,7 @@ function this.init_dependencies() time_UI = require("MHR_Overlay.UI.Modules.time_UI"); keyboard = require("MHR_Overlay.Game_Handler.keyboard"); customization_menu = require("MHR_Overlay.UI.customization_menu"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/large_monster_UI_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/large_monster_UI_customization.lua index dda5772..ebe0ec1 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/large_monster_UI_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/large_monster_UI_customization.lua @@ -11,6 +11,7 @@ local part_names; local time_UI; local keyboard; local customization_menu; +local error_handler; local label_customization; local bar_customization; @@ -93,9 +94,10 @@ function this.init_dependencies() time_UI = require("MHR_Overlay.UI.Modules.time_UI"); keyboard = require("MHR_Overlay.Game_Handler.keyboard"); customization_menu = require("MHR_Overlay.UI.customization_menu"); + error_handler = require("MHR_Overlay.Misc.error_handler"); + label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); - health_customization = require("MHR_Overlay.UI.Customizations.health_customization"); stamina_customization = require("MHR_Overlay.UI.Customizations.stamina_customization"); rage_customization = require("MHR_Overlay.UI.Customizations.rage_customization"); diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/line_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/line_customization.lua index b3fd159..7a785d2 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/line_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/line_customization.lua @@ -11,6 +11,7 @@ local part_names; local time_UI; local keyboard; local customization_menu; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -107,6 +108,7 @@ function this.init_dependencies() time_UI = require("MHR_Overlay.UI.Modules.time_UI"); keyboard = require("MHR_Overlay.Game_Handler.keyboard"); customization_menu = require("MHR_Overlay.UI.customization_menu"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/module_visibility_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/module_visibility_customization.lua index 2c2e818..4c9b58c 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/module_visibility_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/module_visibility_customization.lua @@ -13,6 +13,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -113,6 +114,7 @@ function this.init_dependencies() time_UI = require("MHR_Overlay.UI.Modules.time_UI"); keyboard = require("MHR_Overlay.Game_Handler.keyboard"); customization_menu = require("MHR_Overlay.UI.customization_menu"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/rage_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/rage_customization.lua index 0243761..7a0a334 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/rage_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/rage_customization.lua @@ -13,6 +13,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -105,6 +106,7 @@ function this.init_dependencies() customization_menu = require("MHR_Overlay.UI.customization_menu"); label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Customizations/stamina_customization.lua b/reframework/autorun/MHR_Overlay/UI/Customizations/stamina_customization.lua index 467fd98..b0e94de 100644 --- a/reframework/autorun/MHR_Overlay/UI/Customizations/stamina_customization.lua +++ b/reframework/autorun/MHR_Overlay/UI/Customizations/stamina_customization.lua @@ -13,6 +13,7 @@ local keyboard; local customization_menu; local label_customization; local bar_customization; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -105,6 +106,7 @@ function this.init_dependencies() customization_menu = require("MHR_Overlay.UI.customization_menu"); label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua index 03db777..d5a3809 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua @@ -7,6 +7,7 @@ local consumables; local melody_effects; local screen; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -49,23 +50,23 @@ function this.draw() for key, consumable in pairs(consumables.list) do if not consumable.is_active then - goto continue2; + goto continue; end table.insert(displayed_buffs, consumable); - ::continue2:: + ::continue:: end for _, melody_effect in pairs(melody_effects.list) do if not melody_effect.is_active then - goto continue3; + goto continue2; end table.insert(displayed_buffs, melody_effect); - ::continue3:: + ::continue2:: end -- sort @@ -107,7 +108,7 @@ function this.draw() for _, buff in ipairs(displayed_buffs) do if not buff.is_active then - goto continue4; + goto continue3; end buffs.draw(buff, buff.buff_UI, position_on_screen, 1); @@ -118,7 +119,7 @@ function this.draw() position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier; end - ::continue4:: + ::continue3:: end end @@ -137,6 +138,7 @@ function this.init_dependencies() screen = require("MHR_Overlay.Game_Handler.screen"); --drawing = require("MHR_Overlay.UI.drawing"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua index c9ef634..5333aa7 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua @@ -10,6 +10,7 @@ local screen; local drawing; local language; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -46,17 +47,6 @@ local package = package; this.last_displayed_players = {}; this.freeze_displayed_players = false; -local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager"); -local quest_hunter_info_field = lobby_manager_type_def:get_field("_questHunterInfo"); -local hunter_info_field = lobby_manager_type_def:get_field("_hunterInfo"); - -local quest_hunter_info_type_def = quest_hunter_info_field:get_type(); -local get_count_method = quest_hunter_info_type_def:get_method("get_Count"); -local get_item_method = quest_hunter_info_type_def:get_method("get_Item"); - -local hunter_info_type_def = sdk.find_type_definition("snow.LobbyManager.HunterInfo"); -local member_index_field = hunter_info_type_def:get_field("_memberIndex"); - function this.draw() local cached_config = config.current_config.damage_meter_UI; local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier; @@ -116,32 +106,32 @@ function this.draw() for _, player in ipairs(quest_players) do if player.display.total_damage == 0 and cached_config.settings.hide_player_if_player_damage_is_zero then - goto continue + goto continue; end if player.type == players.types.myself then if cached_config.settings.hide_myself then - goto continue + goto continue; end elseif player.type == players.types.servant then if cached_config.settings.hide_servants then - goto continue + goto continue; end elseif player.type == players.types.other_player then if cached_config.settings.hide_other_players then - goto continue + goto continue; end elseif player.type == players.types.my_otomo then if not cached_config.settings.show_my_otomos_separately then - goto continue + goto continue; end elseif player.type == players.types.other_player_otomo then if not cached_config.settings.show_other_player_otomos_separately then - goto continue + goto continue; end elseif player.type == players.types.servant_otomo then if not cached_config.settings.show_servant_otomos_separately then - goto continue + goto continue; end end @@ -154,7 +144,6 @@ function this.draw() end ::continue:: - end -- draw total damage @@ -186,6 +175,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); language = require("MHR_Overlay.Misc.language"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua index edd2e44..7ee99e6 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/env_creature_UI.lua @@ -11,6 +11,7 @@ local health_UI_entity; local stamina_UI_entity; local rage_UI_entity; local env_creature; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -44,8 +45,6 @@ local os = os; local ValueType = ValueType; local package = package; -local enemy_manager_type_def = sdk.find_type_definition("snow.enemy.EnemyManager"); - function this.draw() if singletons.enemy_manager == nil then return; @@ -57,11 +56,11 @@ function this.draw() for REcreature, creature in pairs(env_creature.list) do if cached_config.settings.max_distance == 0 then - break + break; end if cached_config.settings.hide_inactive_creatures and creature.is_inactive then - goto continue + goto continue; end local position_on_screen = {}; @@ -72,7 +71,7 @@ function this.draw() position_on_screen = draw.world_to_screen(creature.position + world_offset); if position_on_screen == nil then - goto continue + goto continue; end position_on_screen.x = position_on_screen.x + cached_config.viewport_offset.x * global_scale_modifier; @@ -82,7 +81,7 @@ function this.draw() local opacity_scale = 1; if creature.distance > cached_config.settings.max_distance then - goto continue + goto continue; end if cached_config.settings.opacity_falloff then @@ -106,6 +105,7 @@ function this.init_dependencies() stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity"); rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity"); env_creature = require("MHR_Overlay.Endemic_Life.env_creature"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua index dd2fe82..195e2db 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/large_monster_UI.lua @@ -10,6 +10,7 @@ local drawing; local health_UI_entity; local stamina_UI_entity; local rage_UI_entity; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -78,6 +79,7 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled) highlighted_id = get_targeting_enemy_index_field:get_data(gui_hud_target_camera); if highlighted_id == nil then + error_handler.report("large_monster_UI.draw", "Failed to Access Data: highlighted_id"); highlighted_id = -1; end end @@ -85,20 +87,21 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled) local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager); if enemy_count == nil then + error_handler.report("large_monster_UI.draw", "Failed to Access Data: enemy_count"); return; end for i = 0, enemy_count - 1 do local enemy = get_boss_enemy_method:call(singletons.enemy_manager, i); if enemy == nil then - customization_menu.status = "No enemy"; - goto continue + error_handler.report("large_monster_UI.draw", "Failed to Access Data: enemy No. " .. tostring(i)); + goto continue; end local monster = large_monster.list[enemy]; if monster == nil then - customization_menu.status = "No large monster entry"; - goto continue + error_handler.report("large_monster_UI.draw", "Missing Entry: monster No. " .. tostring(i)); + goto continue; end if update_distance then @@ -155,21 +158,21 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled) if dynamic_enabled then local success = pcall(this.draw_dynamic, displayed_monsters, highlighted_monster, cached_config); if not success then - customization_menu.status = string.format("[%s] Dynamic Large Monster drawing function threw an exception"); + error_handler.report("large_monster_UI.draw", "Dynamic Large Monster drawing function threw an exception"); end end if highlighted_enabled then local success = pcall(this.draw_highlighted, highlighted_monster, cached_config); if not success then - customization_menu.status = string.format("[%s] Highlighted Large Monster drawing function threw an exception"); + error_handler.report("large_monster_UI.draw", "Highlighted Large Monster drawing function threw an exception"); end end if static_enabled then local success = pcall(this.draw_static, displayed_monsters, highlighted_monster, cached_config); if not success then - customization_menu.status = string.format("[%s] Static Large Monster drawing function threw an exception"); + error_handler.report("large_monster_UI.draw", "Static Large Monster drawing function threw an exception"); end end end @@ -181,24 +184,24 @@ function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_confi local i = 0; for _, monster in ipairs(displayed_monsters) do if cached_config.settings.max_distance == 0 then - break + break; end if monster.is_stealth then - goto continue + goto continue; end if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then - goto continue + goto continue; end if monster == highlighted_monster then if not cached_config.settings.render_highlighted_monster then - goto continue + goto continue; end else if not cached_config.settings.render_not_highlighted_monsters then - goto continue + goto continue; end end @@ -281,16 +284,16 @@ function this.draw_static(displayed_monsters, highlighted_monster, cached_config local i = 0; for _, monster in ipairs(displayed_monsters) do if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then - goto continue + goto continue; end if monster == highlighted_monster then if not cached_config.settings.render_highlighted_monster then - goto continue + goto continue; end else if not cached_config.settings.render_not_highlighted_monsters then - goto continue + goto continue; end end @@ -339,6 +342,7 @@ function this.init_dependencies() health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity"); stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity"); rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua index 14da957..25a55ca 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/small_monster_UI.lua @@ -9,6 +9,7 @@ local players; local drawing; local health_UI_entity; local stamina_UI_entity; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -57,33 +58,33 @@ function this.draw() local enemy_count = get_zako_enemy_count_method:call(singletons.enemy_manager); if enemy_count == nil then - customization_menu.status = "No enemy count"; + error_handler.report("small_monster_UI.draw", "Failed to Access Data: enemy_count"); return; end for i = 0, enemy_count - 1 do local enemy = get_zako_enemy_method:call(singletons.enemy_manager, i); if enemy == nil then - customization_menu.status = "No enemy"; - goto continue + error_handler.report("small_monster_UI.draw", "Failed to Access Data: enemy No. " .. tostring(i)); + goto continue; end local monster = small_monster.list[enemy]; if monster == nil then - customization_menu.status = "No small monster entry"; - goto continue + error_handler.report("small_monster_UI.draw", "Missing Entry: monster No. " .. tostring(i)); + goto continue; end if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then - goto continue - end + goto continue; + end; table.insert(displayed_monsters, monster); ::continue:: end if cached_config.dynamic_positioning.enabled - or (not cached_config.dynamic_positioning.enabled and cached_config.static_sorting.type == "Distance") then + or (not cached_config.dynamic_positioning.enabled and cached_config.static_sorting.type == "Distance") then for _, monster in ipairs(displayed_monsters) do monster.distance = (players.myself_position - monster.position):length(); end @@ -159,9 +160,6 @@ function this.draw() end end - - - local opacity_scale = 1; if cached_config.dynamic_positioning.enabled then if cached_config.dynamic_positioning.max_distance == 0 then @@ -177,8 +175,6 @@ function this.draw() end end - - small_monster.draw(monster, cached_config, position_on_screen, opacity_scale); i = i + 1; @@ -196,6 +192,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity"); stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/time_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/time_UI.lua index 00d828e..c9f09c1 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/time_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/time_UI.lua @@ -5,6 +5,7 @@ local screen; local config; local drawing; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -68,6 +69,7 @@ function this.init_dependencies() config = require("MHR_Overlay.Misc.config"); drawing = require("MHR_Overlay.UI.drawing"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_UI_entity.lua index 9876be1..c7259e1 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_UI_entity.lua @@ -4,6 +4,7 @@ local config; local utils; local drawing; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -123,6 +124,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); config = require("MHR_Overlay.Misc.config"); language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_buildup_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_buildup_UI_entity.lua index 5159e8d..56ae594 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_buildup_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/ailment_buildup_UI_entity.lua @@ -5,6 +5,7 @@ local drawing; local config; local players; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -123,6 +124,7 @@ function this.init_dependencies() config = require("MHR_Overlay.Misc.config"); players = require("MHR_Overlay.Damage_Meter.players"); language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/body_part_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/body_part_UI_entity.lua index 91510db..a91ce73 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/body_part_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/body_part_UI_entity.lua @@ -3,6 +3,7 @@ local this = {}; local config; local utils; local drawing; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -306,6 +307,7 @@ function this.init_dependencies() utils = require("MHR_Overlay.Misc.utils"); drawing = require("MHR_Overlay.UI.drawing"); config = require("MHR_Overlay.Misc.config"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/buff_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/buff_UI_entity.lua index 441cad5..f344ba9 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/buff_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/buff_UI_entity.lua @@ -4,6 +4,7 @@ local config; local utils; local drawing; local language; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -86,6 +87,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); config = require("MHR_Overlay.Misc.config"); language = require("MHR_Overlay.Misc.language"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua index 41a0e7b..26d694e 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua @@ -7,6 +7,7 @@ local players; local language; local quest_status; local non_players; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -241,6 +242,7 @@ function this.init_dependencies() language = require("MHR_Overlay.Misc.language"); quest_status = require("MHR_Overlay.Game_Handler.quest_status"); non_players = require("MHR_Overlay.Damage_Meter.non_players"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/health_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/health_UI_entity.lua index cacc06b..6859eeb 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/health_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/health_UI_entity.lua @@ -4,6 +4,7 @@ local utils; local drawing; local language; local config; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -96,6 +97,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); language = require("MHR_Overlay.Misc.language"); config = require("MHR_Overlay.Misc.config"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/rage_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/rage_UI_entity.lua index f5bc101..e35ec1a 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/rage_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/rage_UI_entity.lua @@ -4,6 +4,7 @@ local utils; local drawing; local language; local config; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -110,6 +111,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); language = require("MHR_Overlay.Misc.language"); config = require("MHR_Overlay.Misc.config"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/stamina_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/stamina_UI_entity.lua index 29942bd..9e86f85 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/stamina_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/stamina_UI_entity.lua @@ -4,6 +4,7 @@ local utils; local drawing; local language; local config; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -107,6 +108,7 @@ function this.init_dependencies() drawing = require("MHR_Overlay.UI.drawing"); language = require("MHR_Overlay.Misc.language"); config = require("MHR_Overlay.Misc.config"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/autorun/MHR_Overlay/UI/customization_menu.lua b/reframework/autorun/MHR_Overlay/UI/customization_menu.lua index e37ec1c..f8faaf0 100644 --- a/reframework/autorun/MHR_Overlay/UI/customization_menu.lua +++ b/reframework/autorun/MHR_Overlay/UI/customization_menu.lua @@ -14,6 +14,8 @@ local keyboard; local non_players; local quest_status; local buffs; +local error_handler; +local time; local label_customization; local bar_customization; @@ -64,7 +66,6 @@ local package = package; this.font = nil; this.full_font_range = {0x1, 0xFFFF, 0}; this.is_opened = false; -this.status = "OK"; this.window_position = Vector2f.new(480, 200); this.window_pivot = Vector2f.new(0, 0); @@ -353,12 +354,9 @@ function this.draw() local damage_meter_UI_changed = false; local endemic_life_UI_changed = false; local buff_UI_changed = false; + local debug_changed = false; local apply_font_requested = false; - local status_string = tostring(this.status); - - imgui.text(language.current_language.customization_menu.status .. ": " .. status_string); - config_changed, apply_font_requested = this.draw_config(); modules_changed = this.draw_modules(); this.draw_hotkeys(); @@ -376,6 +374,9 @@ function this.draw() damage_meter_UI_changed = this.draw_damage_meter_UI(); endemic_life_UI_changed = this.draw_endemic_life_UI() buff_UI_changed = this.draw_buff_UI(); + + imgui.new_line(); + debug_changed = this.draw_debug(); imgui.pop_font(); imgui.end_window(); @@ -447,7 +448,7 @@ function this.draw() if modules_changed or global_settings_changed or small_monster_UI_changed or large_monster_dynamic_UI_changed or large_monster_static_UI_changed or large_monster_highlighted_UI_changed or time_UI_changed or damage_meter_UI_changed or - endemic_life_UI_changed or buff_UI_changed or modifiers_changed or config_changed then + endemic_life_UI_changed or buff_UI_changed or modifiers_changed or config_changed or debug_changed then config.save_current(); end end @@ -2264,6 +2265,63 @@ function this.draw_buff_UI() return config_changed; end +function this.draw_debug() + local cached_config = config.current_config.debug; + + local changed = false; + local config_changed = false; + + if imgui.tree_node(language.current_language.customization_menu.debug) then + + if error_handler.is_empty then + imgui.text(language.current_language.customization_menu.everything_seems_to_be_ok); + else + imgui.text_colored("Current Script Time:", 0xFFAAAA66); + imgui.same_line(); + imgui.text(string.format("%.3fs", time.total_elapsed_script_seconds)); + + for error_key, error in pairs(error_handler.list) do + + imgui.button(string.format("%.3fs", error.time)); + imgui.same_line(); + imgui.text_colored(error_key, 0xFFAA66AA); + imgui.same_line(); + imgui.text(error.message); + end + + end + + if imgui.tree_node(language.current_language.customization_menu.error_history) then + + changed, cached_config.history_size = imgui.drag_int( + language.current_language.customization_menu.history_size, cached_config.history_size, 1, 0, 1024); + + config_changed = config_changed or changed; + + if changed then + error_handler.history = {}; + end + + for index, error in pairs(error_handler.history) do + imgui.text_colored(index, 0xFF66AA66); + imgui.same_line(); + imgui.button(string.format("%.3fs", error.time)); + imgui.same_line(); + imgui.text_colored(error.key, 0xFFAA66AA); + imgui.same_line(); + imgui.text(error.message); + end + + + imgui.tree_pop(); + end + + imgui.tree_pop(); + end + + return config_changed; +end + function this.init_dependencies() utils = require("MHR_Overlay.Misc.utils"); language = require("MHR_Overlay.Misc.language"); @@ -2279,6 +2337,8 @@ function this.init_dependencies() non_players = require("MHR_Overlay.Damage_Meter.non_players"); quest_status = require("MHR_Overlay.Game_Handler.quest_status"); buffs = require("MHR_Overlay.Buffs.buffs"); + error_handler = require("MHR_Overlay.Misc.error_handler"); + time = require("MHR_Overlay.Game_Handler.time"); label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization"); diff --git a/reframework/autorun/MHR_Overlay/UI/drawing.lua b/reframework/autorun/MHR_Overlay/UI/drawing.lua index 3658b48..82ce7da 100644 --- a/reframework/autorun/MHR_Overlay/UI/drawing.lua +++ b/reframework/autorun/MHR_Overlay/UI/drawing.lua @@ -2,6 +2,7 @@ local this = {}; local config; local utils; +local error_handler; local sdk = sdk; local tostring = tostring; @@ -82,7 +83,7 @@ function this.limit_text_size(text, size_limit) limited_text = utils.unicode.sub(limited_text, 1, -5) .. "..."; if limited_text == old_limited_text then - break + break; end end end @@ -379,6 +380,7 @@ end function this.init_dependencies() config = require("MHR_Overlay.Misc.config"); utils = require("MHR_Overlay.Misc.utils"); + error_handler = require("MHR_Overlay.Misc.error_handler"); end function this.init_module() diff --git a/reframework/data/MHR Overlay/languages/en-us.json b/reframework/data/MHR Overlay/languages/en-us.json index 75a02d1..c22edfc 100644 --- a/reframework/data/MHR Overlay/languages/en-us.json +++ b/reframework/data/MHR Overlay/languages/en-us.json @@ -112,6 +112,7 @@ "damage_meter_UI": "Damage Meter UI", "damage_percentage_label": "Damage Percentage Label", "damage_value_label": "Damage Value Label", + "debug": "Debug", "default_state": "Default State", "delete": "Delete", "distance": "Distance", @@ -126,6 +127,8 @@ "enabled": "Enabled", "endemic_life": "Endemic Life", "endemic_life_UI": "Endemic Life UI", + "error_history": "Error History", + "everything_seems_to_be_ok": "Everything seems to be OK!", "family": "Family", "farthest": "Farthest", "fight_time": "Fight Time", @@ -175,6 +178,7 @@ "highlighted_buildup_bar": "Highlighted Buildup Bar", "highlighted_damage_bar": "Highlighted Damage Bar", "highlighted_targeted": "Highlighted (targeted)", + "history_size": "History Size", "horizontal": "Horizontal", "hotkeys": "Hotkeys", "hunter_rank": "Hunter Rank", diff --git a/reframework/data/MHR Overlay/languages/ja-jp.json b/reframework/data/MHR Overlay/languages/ja-jp.json index 414a97b..833888b 100644 --- a/reframework/data/MHR Overlay/languages/ja-jp.json +++ b/reframework/data/MHR Overlay/languages/ja-jp.json @@ -112,6 +112,7 @@ "damage_meter_UI": "ダメージメーターUI", "damage_percentage_label": "ダメージ割合(%)ラベル", "damage_value_label": "ダメージラベル", + "debug": "Debug", "default_state": "Default State", "delete": "Delete", "distance": "距離", @@ -126,6 +127,8 @@ "enabled": "有効", "endemic_life": "Endemic Life", "endemic_life_UI": "環境生物UI", + "error_history": "Error History", + "everything_seems_to_be_ok": "Everything seems to be OK!", "family": "Family", "farthest": "Farthest", "fight_time": "戦闘時間", @@ -175,6 +178,7 @@ "highlighted_buildup_bar": "ハイライトされた蓄積値バー", "highlighted_damage_bar": "ハイライトされたダメージバー", "highlighted_targeted": "詳細表示 (ターゲット)", + "history_size": "History Size", "horizontal": "水平", "hotkeys": "ホットキー", "hunter_rank": "ハンターランク", diff --git a/reframework/data/MHR Overlay/languages/ko-kr.json b/reframework/data/MHR Overlay/languages/ko-kr.json index 3be98eb..3ee543f 100644 --- a/reframework/data/MHR Overlay/languages/ko-kr.json +++ b/reframework/data/MHR Overlay/languages/ko-kr.json @@ -112,6 +112,7 @@ "damage_meter_UI": "대미지 미터 UI", "damage_percentage_label": "대미지 비율 정보", "damage_value_label": "대미지 값 정보", + "debug_errors": "Debug Errors", "default_state": "기본 상태", "delete": "삭제하기", "distance": "간격", @@ -126,6 +127,8 @@ "enabled": "사용함", "endemic_life": "환경생물", "endemic_life_UI": "환경생물 UI", + "error_history": "Error History", + "everything_seems_to_be_ok": "Everything seems to be OK!", "family": "글꼴", "farthest": "가장 멀리있는", "fight_time": "전투 시간", @@ -175,6 +178,7 @@ "highlighted_buildup_bar": "주시대상 몬스터 누적치 막대", "highlighted_damage_bar": "주시대상 몬스터 대미지 막대", "highlighted_targeted": "주시대상 몬스터 표시", + "history_size": "History Size", "horizontal": "가로", "hotkeys": "단축키", "hunter_rank": "헌터 랭크", diff --git a/reframework/data/MHR Overlay/languages/ru-ru.json b/reframework/data/MHR Overlay/languages/ru-ru.json index 6eb071b..9845bba 100644 --- a/reframework/data/MHR Overlay/languages/ru-ru.json +++ b/reframework/data/MHR Overlay/languages/ru-ru.json @@ -112,6 +112,7 @@ "damage_meter_UI": "Интерфейс модуля урона", "damage_percentage_label": "Метка урона в процентах", "damage_value_label": "Метка значений урона", + "debug_errors": "Debug Errors", "default_state": "Состояние по умолчанию", "delete": "Удалить", "distance": "Расстояние", @@ -126,6 +127,8 @@ "enabled": "Включить", "endemic_life": "Местная живность", "endemic_life_UI": "Интерфейс местной живности", + "error_history": "Error History", + "everything_seems_to_be_ok": "Everything seems to be OK!", "family": "Семейство", "farthest": "Самый дальний", "fight_time": "Время в бою", @@ -175,6 +178,7 @@ "highlighted_buildup_bar": "Помеченная шкала накопления", "highlighted_damage_bar": "Помеченная шкала урона", "highlighted_targeted": "Помеченный", + "history_size": "History Size", "horizontal": "Горизонтально", "hotkeys": "Горячие клавиши", "hunter_rank": "Ранг охотника", diff --git a/reframework/data/MHR Overlay/languages/zh-cn.json b/reframework/data/MHR Overlay/languages/zh-cn.json index 2692607..06f1ad7 100644 --- a/reframework/data/MHR Overlay/languages/zh-cn.json +++ b/reframework/data/MHR Overlay/languages/zh-cn.json @@ -112,6 +112,7 @@ "damage_meter_UI": "伤害统计UI", "damage_percentage_label": "伤害百分比标签", "damage_value_label": "伤害量标签", + "debug_errors": "Debug Errors", "default_state": "默认阶段", "delete": "删除", "distance": "距离", @@ -126,6 +127,8 @@ "enabled": "开启", "endemic_life": "环境生物", "endemic_life_UI": "环境生物UI", + "error_history": "Error History", + "everything_seems_to_be_ok": "Everything seems to be OK!", "family": "字体", "farthest": "最远", "fight_time": "战斗时间", @@ -175,6 +178,7 @@ "highlighted_buildup_bar": "高亮积累值条", "highlighted_damage_bar": "高亮伤害条", "highlighted_targeted": "高亮目标[锁定目标的UI]", + "history_size": "History Size", "horizontal": "水平", "hotkeys": "热键", "hunter_rank": "猎人等级", diff --git a/reframework/data/MHR Overlay/languages/zh-tw.json b/reframework/data/MHR Overlay/languages/zh-tw.json index 999a419..b583240 100644 --- a/reframework/data/MHR Overlay/languages/zh-tw.json +++ b/reframework/data/MHR Overlay/languages/zh-tw.json @@ -112,6 +112,7 @@ "damage_meter_UI": "傷害量計算 UI", "damage_percentage_label": "傷害量百分比", "damage_value_label": "傷害量", + "debug_errors": "Debug Errors", "default_state": "Default State", "delete": "Delete", "distance": "距離", @@ -126,6 +127,8 @@ "enabled": "啟用", "endemic_life": "Endemic Life", "endemic_life_UI": "環境生物 UI", + "error_history": "Error History", + "everything_seems_to_be_ok": "Everything seems to be OK!", "family": "字體", "farthest": "最遠的", "fight_time": "戰鬥時間", @@ -175,6 +178,7 @@ "highlighted_buildup_bar": "重點累積條", "highlighted_damage_bar": "重點傷害條", "highlighted_targeted": "鎖定的魔物資訊(目標)", + "history_size": "History Size", "horizontal": "水平", "hotkeys": "快捷鍵", "hunter_rank": "獵人等級",