From 1c9eff6b0681078e17239d7490e258b0e352f233 Mon Sep 17 00:00:00 2001 From: GreenComfyTea Date: Thu, 17 Aug 2023 12:18:55 +0300 Subject: [PATCH] Update Large Monster Health when Host on Player Join? --- .../autorun/MHR_Overlay/Damage_Meter/players.lua | 14 +++++--------- .../autorun/MHR_Overlay/Monsters/large_monster.lua | 11 +++++++++-- .../autorun/MHR_Overlay/Monsters/monster_hook.lua | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua b/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua index 37fe037..5c13e68 100644 --- a/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua +++ b/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua @@ -11,6 +11,7 @@ local language; local non_players; local utils; local error_handler; +local large_monster; local sdk = sdk; local tostring = tostring; @@ -108,6 +109,8 @@ function this.new(id, name, master_rank, hunter_rank, type) this.init_highlighted_UI(); end + large_monster.request_health_update(); + return player; end @@ -458,6 +461,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 +477,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 +504,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 +559,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.update_cart_count(); - end end function this.init_UI(player) @@ -608,6 +603,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() diff --git a/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua b/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua index 0f7259b..e9a7929 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/large_monster.lua @@ -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; @@ -461,6 +461,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 +626,8 @@ function this.update_health(enemy, monster) monster.capture_percentage = capture_health / max_health; 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; end diff --git a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua index 9e6be56..2d22823 100644 --- a/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua +++ b/reframework/autorun/MHR_Overlay/Monsters/monster_hook.lua @@ -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);