mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-30 07:18:03 -08:00
Compare commits
8 Commits
6528394876
...
475cd22610
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
475cd22610 | ||
|
|
a33b196521 | ||
|
|
d5b83eef2a | ||
|
|
2efdbd5f1a | ||
|
|
5125de6701 | ||
|
|
1c9eff6b06 | ||
|
|
6456e3bfaf | ||
|
|
f23cce3ba1 |
@@ -505,9 +505,7 @@ end
|
||||
-- #region
|
||||
re.on_draw_ui(function()
|
||||
if imgui.button(language.current_language.customization_menu.mod_name .. " v" .. config.current_config.version) then
|
||||
local cached_config = config.current_config.customization_menu;
|
||||
cached_config.visible = not cached_config.visible;
|
||||
config.save_current();
|
||||
customization_menu.is_opened = not customization_menu.is_opened;
|
||||
end
|
||||
end);
|
||||
|
||||
@@ -542,9 +540,9 @@ end);
|
||||
-- #endregion
|
||||
-----------------------Loop Callbacks------------------------
|
||||
|
||||
time.init_global_timers();
|
||||
time.new_timer(update_UI, 0.5);
|
||||
|
||||
if imgui.begin_table == nil then
|
||||
re.msg(language.current_language.customization_menu.reframework_outdated);
|
||||
end
|
||||
|
||||
time.init_global_timers();
|
||||
time.new_timer(update_UI, 0.5);
|
||||
@@ -264,13 +264,7 @@ function this.cart(dead_player_id, flag_cat_skill_insurance)
|
||||
-- flag_cat_skill_insurance = 0
|
||||
-- flag_cat_skill_insurance = 1
|
||||
|
||||
--local player = players.list[dead_player_id];
|
||||
--if player == nil then
|
||||
-- error_handler.report("damage_hook.cart", "No Dead Player Found");
|
||||
-- return;
|
||||
--end
|
||||
|
||||
quest_status.get_cart_count();
|
||||
quest_status.update_cart_count();
|
||||
end
|
||||
|
||||
function this.on_stock_direct_marionette_finish_shoot_hit_parts_damage(enemy, damage_rate, is_endure, is_ignore_multi_rate, category, no)
|
||||
|
||||
@@ -11,6 +11,7 @@ local language;
|
||||
local non_players;
|
||||
local utils;
|
||||
local error_handler;
|
||||
local large_monster;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -458,6 +459,7 @@ function this.update_players()
|
||||
non_players.update_otomo_list(is_on_quest, quest_status.is_online);
|
||||
|
||||
this.update_dps(false);
|
||||
quest_status.update_cart_count();
|
||||
end
|
||||
|
||||
function this.update_player_list(hunter_info_field_)
|
||||
@@ -473,8 +475,6 @@ function this.update_player_list(hunter_info_field_)
|
||||
return;
|
||||
end
|
||||
|
||||
local update_cart_count = false;
|
||||
|
||||
-- myself player
|
||||
local myself_player_info = my_hunter_info_field:get_data(singletons.lobby_manager);
|
||||
if myself_player_info == nil then
|
||||
@@ -502,7 +502,6 @@ function this.update_player_list(hunter_info_field_)
|
||||
this.list[this.myself.id] = nil;
|
||||
this.myself = this.new(myself_id, myself_player_name, myself_master_rank, myself_hunter_rank, this.types.myself);
|
||||
this.list[myself_id] = this.myself;
|
||||
update_cart_count = true;
|
||||
end
|
||||
|
||||
-- other players
|
||||
@@ -558,20 +557,14 @@ function this.update_player_list(hunter_info_field_)
|
||||
player = this.new(id, name, master_rank, hunter_rank, this.types.myself);
|
||||
this.myself = player;
|
||||
this.list[id] = player;
|
||||
update_cart_count = true;
|
||||
else
|
||||
player = this.new(id, name, master_rank, hunter_rank, this.types.other_player);
|
||||
this.list[id] = player;
|
||||
update_cart_count = true;
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
if update_cart_count then
|
||||
quest_status.get_cart_count();
|
||||
end
|
||||
end
|
||||
|
||||
function this.init_UI(player)
|
||||
@@ -608,6 +601,7 @@ function this.init_dependencies()
|
||||
non_players = require("MHR_Overlay.Damage_Meter.non_players");
|
||||
utils = require("MHR_Overlay.Misc.utils");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
@@ -158,54 +158,63 @@ function this.set_flow_state(new_flow_state)
|
||||
|
||||
damage_meter_UI.last_displayed_players = {};
|
||||
|
||||
elseif this.flow_state == this.flow_states.LOADING_QUEST then
|
||||
players.init();
|
||||
non_players.init();
|
||||
small_monster.init_list();
|
||||
large_monster.init_list();
|
||||
env_creature.init_list();
|
||||
|
||||
damage_meter_UI.last_displayed_players = {};
|
||||
|
||||
this.get_max_cart_count();
|
||||
elseif this.flow_state >= this.flow_states.LOADING_QUEST then
|
||||
this.get_cart_count();
|
||||
this.get_max_cart_count();
|
||||
end
|
||||
|
||||
players.update_players();
|
||||
end
|
||||
|
||||
function this.get_cart_count()
|
||||
function this.update_cart_count()
|
||||
if singletons.quest_manager == nil then
|
||||
error_handler.report("quest_status.get_cart_count", "Failed to access Data: quest_manager");
|
||||
error_handler.report("quest_status.update_cart_count", "Failed to access Data: quest_manager");
|
||||
return;
|
||||
end
|
||||
|
||||
local death_num = get_death_num_method:call(singletons.quest_manager);
|
||||
if death_num == nil then
|
||||
error_handler.report("quest_status.get_cart_count", "Failed to access Data: death_num");
|
||||
error_handler.report("quest_status.update_cart_count", "Failed to access Data: death_num");
|
||||
else
|
||||
this.cart_count = death_num;
|
||||
end
|
||||
|
||||
if singletons.player_manager == nil then
|
||||
error_handler.report("quest_status.get_cart_count", "Failed to access Data: player_manager");
|
||||
error_handler.report("quest_status.update_cart_count", "Failed to access Data: player_manager");
|
||||
return;
|
||||
end
|
||||
|
||||
local player_data_array = get_player_data_method:call(singletons.player_manager);
|
||||
if player_data_array == nil then
|
||||
error_handler.report("quest_status.get_cart_count", "Failed to access Data: player_data_array");
|
||||
error_handler.report("quest_status.update_cart_count", "Failed to access Data: player_data_array");
|
||||
return;
|
||||
end
|
||||
|
||||
local player_data_array_length = get_length_method:call(player_data_array);
|
||||
if player_data_array_length == nil then
|
||||
error_handler.report("quest_status.get_cart_count", "Failed to access Data: player_data_array_length");
|
||||
error_handler.report("quest_status.update_cart_count", "Failed to access Data: player_data_array_length");
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, player_data_array_length - 1 do
|
||||
local player_data = get_value_method:call(player_data_array, i);
|
||||
if player_data_array_length == nil then
|
||||
error_handler.report("quest_status.get_cart_count", string.format("Failed to access Data: player_data No. %d", i));
|
||||
error_handler.report("quest_status.update_cart_count", string.format("Failed to access Data: player_data No. %d", i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local die_count = die_count_field:get_data(player_data);
|
||||
if die_count == nil then
|
||||
error_handler.report("quest_status.get_cart_count", string.format("Failed to access Data: die_count No. %d", i));
|
||||
error_handler.report("quest_status.update_cart_count", string.format("Failed to access Data: die_count No. %d", i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ this.elapsed_seconds = 0;
|
||||
|
||||
this.total_elapsed_script_seconds = 0;
|
||||
|
||||
this.list = {};
|
||||
this.timer_list = {};
|
||||
this.delay_timer_list = {};
|
||||
|
||||
function this.new_timer(callback, cooldown_seconds, start_offset_seconds)
|
||||
start_offset_seconds = start_offset_seconds or utils.math.random();
|
||||
@@ -70,7 +71,22 @@ function this.new_timer(callback, cooldown_seconds, start_offset_seconds)
|
||||
|
||||
timer.last_trigger_time = os.clock() + start_offset_seconds;
|
||||
|
||||
this.list[callback] = timer;
|
||||
this.timer_list[callback] = timer;
|
||||
|
||||
end
|
||||
|
||||
function this.new_delay_timer(callback, delay)
|
||||
if callback == nil or delay == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local delay_timer = {};
|
||||
delay_timer.callback = callback;
|
||||
delay_timer.delay = delay;
|
||||
|
||||
delay_timer.init_time = os.clock();
|
||||
|
||||
this.delay_timer_list[callback] = delay_timer;
|
||||
|
||||
end
|
||||
|
||||
@@ -89,12 +105,25 @@ end
|
||||
function this.update_timers()
|
||||
this.update_script_time();
|
||||
|
||||
for callback, timer in pairs(this.list) do
|
||||
for callback, timer in pairs(this.timer_list) do
|
||||
if this.total_elapsed_script_seconds - timer.last_trigger_time > timer.cooldown then
|
||||
timer.last_trigger_time = this.total_elapsed_script_seconds;
|
||||
callback();
|
||||
end
|
||||
end
|
||||
|
||||
local remove_list = {};
|
||||
|
||||
for callback, delay_timer in pairs(this.delay_timer_list) do
|
||||
if this.total_elapsed_script_seconds - delay_timer.init_time > delay_timer.delay then
|
||||
callback();
|
||||
table.insert(remove_list, callback);
|
||||
end
|
||||
end
|
||||
|
||||
for i, callback in ipairs(remove_list) do
|
||||
this.delay_timer_list[callback] = nil;
|
||||
end
|
||||
end
|
||||
|
||||
function this.update_script_time()
|
||||
|
||||
@@ -7973,8 +7973,6 @@ function this.init_default()
|
||||
},
|
||||
|
||||
customization_menu = {
|
||||
visible = false,
|
||||
|
||||
position = {
|
||||
x = 360,
|
||||
y = 50
|
||||
|
||||
@@ -77,7 +77,7 @@ function this.new(enemy)
|
||||
monster.max_health = 0;
|
||||
monster.health_percentage = 0;
|
||||
monster.missing_health = 0;
|
||||
monster.is_health_initialized = false;
|
||||
monster.is_health_update_requested = true;
|
||||
|
||||
monster.is_capturable = true;
|
||||
monster.capture_health = 0;
|
||||
@@ -269,6 +269,9 @@ local get_tg_camera_method = gui_manager_type_def:get_method("get_refGuiHud_TgCa
|
||||
local tg_camera_type_def = get_tg_camera_method:get_return_type();
|
||||
local get_targeting_enemy_index_field = tg_camera_type_def:get_field("OldTargetingEmIndex");
|
||||
|
||||
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
||||
local receive_quest_hunter_info_method = lobby_manager_type_def:get_method("receiveQuestHunterInfo");
|
||||
|
||||
function this.init(monster, enemy)
|
||||
local monster_id = enemy_type_field:get_data(enemy);
|
||||
if monster_id == nil then
|
||||
@@ -461,6 +464,12 @@ function this.init_UI(monster, monster_UI, cached_config)
|
||||
body_part.init_part_names(monster.id, monster.parts);
|
||||
end
|
||||
|
||||
function this.request_health_update()
|
||||
for enemy, monster in pairs(this.list) do
|
||||
monster.is_health_update_requested = true;
|
||||
end
|
||||
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
|
||||
@@ -620,7 +629,7 @@ function this.update_health(enemy, monster)
|
||||
monster.capture_percentage = capture_health / max_health;
|
||||
end
|
||||
|
||||
monster.is_health_initialized = true;
|
||||
monster.is_health_update_requested = false;
|
||||
|
||||
return physical_param;
|
||||
end
|
||||
@@ -771,7 +780,6 @@ function this.update_rage(enemy, monster, anger_param)
|
||||
|
||||
local is_in_rage = is_anger_method:call(anger_param);
|
||||
if is_in_rage ~= nil then
|
||||
--xy = xy .. tostring(is_in_rage) .. "\n";
|
||||
monster.is_in_rage = is_in_rage;
|
||||
else
|
||||
error_handler.report("large_monster.update_rage", "Failed to access Data: is_in_rage");
|
||||
@@ -1299,6 +1307,11 @@ function this.init_dependencies()
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
sdk.hook(receive_quest_hunter_info_method, function(args)
|
||||
this.request_health_update();
|
||||
end, function(retval)
|
||||
return retval;
|
||||
end);
|
||||
end
|
||||
|
||||
return this;
|
||||
@@ -155,7 +155,7 @@ function this.update_large_monster(enemy)
|
||||
large_monster.update_rage_timer(enemy, monster, nil);
|
||||
|
||||
if (quest_status.is_online and players.myself.id ~= 0)
|
||||
or not monster.is_health_initialized then
|
||||
or monster.is_health_update_requested then
|
||||
local physical_param = large_monster.update_health(enemy, monster);
|
||||
pcall(large_monster.update_parts, enemy, monster, physical_param);
|
||||
pcall(large_monster.update_anomaly_parts, enemy, monster, nil);
|
||||
|
||||
@@ -64,6 +64,8 @@ local os = os;
|
||||
local ValueType = ValueType;
|
||||
local package = package;
|
||||
|
||||
this.is_opened = false;
|
||||
|
||||
this.font = nil;
|
||||
this.full_font_range = {0x1, 0xFFFF, 0};
|
||||
|
||||
@@ -326,7 +328,7 @@ function this.init()
|
||||
end
|
||||
|
||||
function this.draw()
|
||||
if not config.current_config.customization_menu.visible then
|
||||
if not this.is_opened then
|
||||
return;
|
||||
end
|
||||
|
||||
@@ -339,13 +341,13 @@ function this.draw()
|
||||
|
||||
imgui.push_font(this.font);
|
||||
|
||||
config.current_config.customization_menu.visible = imgui.begin_window(
|
||||
this.is_opened = imgui.begin_window(
|
||||
string.format("%s v%s", language.current_language.customization_menu.mod_name, config.current_config.version),
|
||||
config.current_config.customization_menu.visible,
|
||||
this.is_opened,
|
||||
this.window_flags);
|
||||
|
||||
|
||||
if not config.current_config.customization_menu.visible then
|
||||
if not this.is_opened then
|
||||
imgui.pop_font();
|
||||
imgui.end_window();
|
||||
config.save_current();
|
||||
|
||||
Reference in New Issue
Block a user