Update Large Monster Health when Host on Player Join?

This commit is contained in:
GreenComfyTea
2023-08-17 12:18:55 +03:00
parent 6456e3bfaf
commit 1c9eff6b06
3 changed files with 15 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ local language;
local non_players; local non_players;
local utils; local utils;
local error_handler; local error_handler;
local large_monster;
local sdk = sdk; local sdk = sdk;
local tostring = tostring; local tostring = tostring;
@@ -108,6 +109,8 @@ function this.new(id, name, master_rank, hunter_rank, type)
this.init_highlighted_UI(); this.init_highlighted_UI();
end end
large_monster.request_health_update();
return player; return player;
end end
@@ -458,6 +461,7 @@ function this.update_players()
non_players.update_otomo_list(is_on_quest, quest_status.is_online); non_players.update_otomo_list(is_on_quest, quest_status.is_online);
this.update_dps(false); this.update_dps(false);
quest_status.update_cart_count();
end end
function this.update_player_list(hunter_info_field_) function this.update_player_list(hunter_info_field_)
@@ -473,8 +477,6 @@ function this.update_player_list(hunter_info_field_)
return; return;
end end
local update_cart_count = false;
-- myself player -- myself player
local myself_player_info = my_hunter_info_field:get_data(singletons.lobby_manager); local myself_player_info = my_hunter_info_field:get_data(singletons.lobby_manager);
if myself_player_info == nil then if myself_player_info == nil then
@@ -502,7 +504,6 @@ function this.update_player_list(hunter_info_field_)
this.list[this.myself.id] = nil; 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.myself = this.new(myself_id, myself_player_name, myself_master_rank, myself_hunter_rank, this.types.myself);
this.list[myself_id] = this.myself; this.list[myself_id] = this.myself;
update_cart_count = true;
end end
-- other players -- other players
@@ -558,20 +559,14 @@ function this.update_player_list(hunter_info_field_)
player = this.new(id, name, master_rank, hunter_rank, this.types.myself); player = this.new(id, name, master_rank, hunter_rank, this.types.myself);
this.myself = player; this.myself = player;
this.list[id] = player; this.list[id] = player;
update_cart_count = true;
else else
player = this.new(id, name, master_rank, hunter_rank, this.types.other_player); player = this.new(id, name, master_rank, hunter_rank, this.types.other_player);
this.list[id] = player; this.list[id] = player;
update_cart_count = true;
end end
end end
::continue:: ::continue::
end end
if update_cart_count then
quest_status.update_cart_count();
end
end end
function this.init_UI(player) function this.init_UI(player)
@@ -608,6 +603,7 @@ function this.init_dependencies()
non_players = require("MHR_Overlay.Damage_Meter.non_players"); non_players = require("MHR_Overlay.Damage_Meter.non_players");
utils = require("MHR_Overlay.Misc.utils"); utils = require("MHR_Overlay.Misc.utils");
error_handler = require("MHR_Overlay.Misc.error_handler"); error_handler = require("MHR_Overlay.Misc.error_handler");
large_monster = require("MHR_Overlay.Monsters.large_monster");
end end
function this.init_module() function this.init_module()

View File

@@ -77,7 +77,7 @@ function this.new(enemy)
monster.max_health = 0; monster.max_health = 0;
monster.health_percentage = 0; monster.health_percentage = 0;
monster.missing_health = 0; monster.missing_health = 0;
monster.is_health_initialized = false; monster.is_health_update_requested = true;
monster.is_capturable = true; monster.is_capturable = true;
monster.capture_health = 0; monster.capture_health = 0;
@@ -461,6 +461,12 @@ function this.init_UI(monster, monster_UI, cached_config)
body_part.init_part_names(monster.id, monster.parts); body_part.init_part_names(monster.id, monster.parts);
end 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) function this.update_position(enemy, monster)
if not config.current_config.large_monster_UI.dynamic.enabled if not config.current_config.large_monster_UI.dynamic.enabled
and config.current_config.large_monster_UI.static.sorting.type ~= "Distance" then and config.current_config.large_monster_UI.static.sorting.type ~= "Distance" then
@@ -620,7 +626,8 @@ function this.update_health(enemy, monster)
monster.capture_percentage = capture_health / max_health; monster.capture_percentage = capture_health / max_health;
end end
monster.is_health_initialized = true; xy = string.format("%s %s: %d\n", xy, monster.name, monster.health);
monster.is_health_update_requested = false;
return physical_param; return physical_param;
end end

View File

@@ -155,7 +155,7 @@ function this.update_large_monster(enemy)
large_monster.update_rage_timer(enemy, monster, nil); large_monster.update_rage_timer(enemy, monster, nil);
if (quest_status.is_online and players.myself.id ~= 0) 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); local physical_param = large_monster.update_health(enemy, monster);
pcall(large_monster.update_parts, enemy, monster, physical_param); pcall(large_monster.update_parts, enemy, monster, physical_param);
pcall(large_monster.update_anomaly_parts, enemy, monster, nil); pcall(large_monster.update_anomaly_parts, enemy, monster, nil);