Fix Abnormal Statuses showing trash values when teleporting to Training Area

This commit is contained in:
GreenComfyTea
2023-08-16 13:53:34 +03:00
parent 2d669a6c4a
commit 1f0cd6e883
11 changed files with 92 additions and 63 deletions

View File

@@ -8,6 +8,7 @@ local players;
local utils;
local language;
local error_handler;
local time;
local sdk = sdk;
local tostring = tostring;
@@ -42,19 +43,34 @@ local ValueType = ValueType;
local package = package;
this.list = {
--poison = nil,
--stun = nil,
--sleep = nil,
--paralyze = nil,
--quake = nil,
--ear = nil,
--defense_down = nil,
--resistance_down = nil,
--stink = nil,
--onibomb = nil,
--bomb = nil,
--beto = nil,
--fire = nil,
fireblight = nil,
waterblight = nil,
iceblight = nil,
thunderblight = nil,
dragonblight = nil,
blastblight = nil,
bubbleblight = nil,
hellfireblight = nil,
bloodblight = nil,
poison = nil,
stun = nil,
paralysis = nil,
sleep = nil,
defense_down = nil,
resistance_down = nil,
tremor = nil,
roar = nil,
webbed = nil,
stench = nil,
leeched = nil,
whirlwind = nil,
bleeding = nil,
frenzy = nil,
frenzy_overcome = nil,
frenzy_infection = nil,
engulfed = nil,
frostblight = nil,
muck = nil
};
local frenzy_infected_duration = 121;
@@ -188,7 +204,7 @@ function this.update_generic_timer(debuff_key, timer_owner, timer_field, is_infi
return;
end
if timer == 0 then
if utils.number.is_equal(timer, 0) then
this.list[debuff_key] = nil;
return;
end
@@ -251,7 +267,7 @@ function this.update_frenzy_infection(player)
return;
end
if virus_accumulator_value == 0 and virus_timer == 0 then
if virus_accumulator_value == 0 and utils.number.is_equal(virus_timer, 0)then
this.list.frenzy_infection = nil;
return;
end
@@ -300,6 +316,7 @@ function this.init_dependencies()
players = require("MHR_Overlay.Damage_Meter.players");
language = require("MHR_Overlay.Misc.language");
error_handler = require("MHR_Overlay.Misc.error_handler");
time = require("MHR_Overlay.Game_Handler.time");
end
function this.init_module()

View File

@@ -62,11 +62,8 @@ local find_master_player_method = player_manager_type_def:get_method("findMaster
local player_base_type_def = find_master_player_method:get_return_type();
local get_player_data_method = player_base_type_def:get_method("get_PlayerData");
local music_data_field = player_base_type_def:get_field("_MusicData");
local system_array_type_def = sdk.find_type_definition("System.Array");
local length_method = system_array_type_def:get_method("get_Length");
local get_value_method = system_array_type_def:get_method("GetValue(System.Int32)");
local player_lobby_base_type_def = sdk.find_type_definition("snow.player.PlayerLobbyBase");
function this.new(type, key, name, level, duration)
local is_infinite = false;
@@ -79,7 +76,7 @@ function this.new(type, key, name, level, duration)
duration = 0;
end
if duration == 0 then
if utils.number.is_equal(duration, 0) then
is_infinite = true;
end
@@ -141,7 +138,6 @@ function this.update()
if quest_status.flow_state <= quest_status.flow_states.IN_LOBBY
or quest_status.flow_state == quest_status.flow_states.CUTSCENE
or quest_status.flow_state == quest_status.flow_states.LOADING_QUEST
or quest_status.flow_state >= quest_status.flow_states.QUEST_END_ANIMATION then
return;
end
@@ -153,6 +149,7 @@ function this.update()
end
local is_player_lobby_base = master_player:get_type_definition() == player_lobby_base_type_def;
local master_player_data = get_player_data_method:call(master_player);
if master_player_data ~= nil then
@@ -160,32 +157,15 @@ function this.update()
endemic_life_buffs.update(master_player_data);
skills.update(master_player, master_player_data);
dangos.update(master_player_data);
abnormal_statuses.update(master_player, master_player_data);
if not is_player_lobby_base then
abnormal_statuses.update(master_player, master_player_data);
end
else
error_handler.report("buffs.update", "Failed to access Data: master_player_data");
end
--xy = master_player_data._Attack;
local music_data_array = music_data_field:get_data(master_player);
if music_data_array ~= nil then
local music_data_table = {};
local length = length_method:call(music_data_array) - 1;
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
table.insert(music_data_table, music_data);
end
melody_effects.update(music_data_table);
else
error_handler.report("buffs.update", "Failed to access Data: music_data_array");
end
melody_effects.update(master_player);
end
function this.update_timer(buff, timer)

View File

@@ -153,7 +153,7 @@ function this.update_generic(consumable_key, player_data, item_parameter, value_
return;
end
if value_field == nil and timer == 0 then
if value_field == nil and utils.number.is_equal(timer, 0)then
this.list[consumable_key] = nil;
return;
end
@@ -279,7 +279,7 @@ function this.update_gourmet_fish(player_data, item_parameter)
return;
end
if gourmet_fish_timer == 0 then
if utils.number.is_equal(gourmet_fish_timer, 0) then
this.list.gourmet_fish = nil;
return;
end

View File

@@ -85,7 +85,7 @@ function this.update_cutterfly(player_data, item_parameter)
return;
end
if cutterfly_timer == 0 then
if utils.number.is_equal(cutterfly_timer, 0) then
this.list.cutterfly = nil;
return;
end
@@ -113,7 +113,7 @@ function this.update_clothfly(player_data, item_parameter)
return;
end
if clothfly_timer == 0 then
if utils.number.is_equal(clothfly_timer, 0) then
this.list.clothfly = nil;
return;
end

View File

@@ -105,15 +105,41 @@ local melody_effect_keys = {
this.list = {};
local player_manager_type_def = sdk.find_type_definition("snow.player.PlayerManager");
local find_master_player_method = player_manager_type_def:get_method("findMasterPlayer");
local player_base_type_def = find_master_player_method:get_return_type();
local music_data_field = player_base_type_def:get_field("_MusicData");
local music_data_type_def = sdk.find_type_definition("snow.player.Horn.MusicData");
local time_field = music_data_type_def:get_field("_Time");
function this.update(melody_data_table)
for lua_index, melody_data in ipairs(melody_data_table) do
if melody_data ~= "" then
this.update_melody_effect(lua_index, melody_data);
local system_array_type_def = sdk.find_type_definition("System.Array");
local length_method = system_array_type_def:get_method("get_Length");
local get_value_method = system_array_type_def:get_method("GetValue(System.Int32)");
function this.update(master_player)
local music_data_array = music_data_field:get_data(master_player);
if music_data_array == nil then
error_handler.report("melody_effects.update", "Failed to access Data: music_data_array");
return;
end
local length = length_method:call(music_data_array) - 1;
if length == nil then
error_handler.report("melody_effects.update", "Failed to access Data: music_data_array -> length");
return;
end
for i = 0, length do
local music_data = get_value_method:call(music_data_array, i);
if music_data == nil then
error_handler.report("melody_effects.update", "Failed to access Data: music_data No." .. tostring(i));
goto continue;
end
this.update_melody_effect(i+1, music_data);
::continue::
end
end
@@ -124,7 +150,7 @@ function this.update_melody_effect(lua_index, melody_data)
return;
end
if melody_timer == 0 then
if utils.number.is_equal(melody_timer, 0) then
this.list[lua_index] = nil;
return;
end

View File

@@ -233,7 +233,7 @@ function this.update_generic_timer(skill_key, timer_owner, timer_field, is_infin
return;
end
if timer == 0 then
if utils.number.is_equal(timer, 0) then
this.list[skill_key] = nil;
return;
end
@@ -286,7 +286,7 @@ function this.update_generic_number_value_field(skill_key, timer_owner, value_fi
return;
end
if value_field == nil and timer == 0 then
if value_field == nil and utils.number.is_equal(timer, 0) then
this.list[skill_key] = nil;
return;
end
@@ -332,7 +332,7 @@ function this.update_generic_boolean_value_field(skill_key, timer_owner, value_f
return;
end
if value_field == nil and timer == 0 then
if value_field == nil and utils.number.is_equal(timer, 0) then
this.list[skill_key] = nil;
return;
end
@@ -385,7 +385,7 @@ function this.update_generic_number_value_method(skill_key, timer_owner, value_m
return;
end
if value_method == nil and timer == 0 then
if value_method == nil and utils.number.is_equal(timer, 0) then
this.list[skill_key] = nil;
return;
end
@@ -431,7 +431,7 @@ function this.update_generic_boolean_value_method(skill_key, timer_owner, value_
return;
end
if value_method == nil and timer == 0 then
if value_method == nil and utils.number.is_equal(timer, 0) then
this.list[skill_key] = nil;
return;
end
@@ -500,7 +500,7 @@ function this.update_wind_mantle(player)
return;
end
if wind_mantle_timer == 0 then
if utils.number.is_equal(wind_mantle_timer, 0) then
this.list.wind_mantle = nil;
return;
end

View File

@@ -49,7 +49,7 @@ function this.report(error_key, error_message)
local error_time = time.total_elapsed_script_seconds;
if error_time == 0 then
if utils.number.is_equal(error_time, 0) then
return;
end

View File

@@ -12,6 +12,7 @@ local stamina_UI_entity;
local rage_UI_entity;
local env_creature;
local error_handler;
local utils;
local sdk = sdk;
local tostring = tostring;
@@ -52,7 +53,7 @@ function this.update()
local _displayed_creatures = {};
if cached_config.settings.max_distance == 0 then
if utils.number.is_equal(cached_config.settings.max_distance, 0) then
displayed_creatures = {};
return;
end
@@ -116,6 +117,7 @@ function this.init_dependencies()
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");
utils = require("MHR_Overlay.Misc.utils");
end
function this.init_module()

View File

@@ -11,6 +11,7 @@ local health_UI_entity;
local stamina_UI_entity;
local rage_UI_entity;
local error_handler;
local utils;
local sdk = sdk;
local tostring = tostring;
@@ -116,7 +117,7 @@ function this.update_dynamic_monsters(large_monster_list, cached_config)
local _displayed_dynamic_monsters = {};
if dynamic_cached_config.max_distance == 0 then
if utils.number.is_equal(dynamic_cached_config.max_distance, 0) then
displayed_dynamic_monsters = {};
return;
end
@@ -407,6 +408,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");
error_handler = require("MHR_Overlay.Misc.error_handler");
utils = require("MHR_Overlay.Misc.utils");
end
function this.init_module()

View File

@@ -10,6 +10,7 @@ local drawing;
local health_UI_entity;
local stamina_UI_entity;
local error_handler;
local utils;
local sdk = sdk;
local tostring = tostring;
@@ -52,7 +53,7 @@ local displayed_monsters = {};
function this.update()
local cached_config = config.current_config.small_monster_UI;
if cached_config.dynamic_positioning.enabled and cached_config.dynamic_positioning.max_distance == 0 then
if cached_config.dynamic_positioning.enabled and utils.number.is_equal(cached_config.dynamic_positioning.max_distance, 0) then
displayed_monsters = {};
return;
end
@@ -179,6 +180,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");
error_handler = require("MHR_Overlay.Misc.error_handler");
utils = require("MHR_Overlay.Misc.utils");
end
function this.init_module()

View File

@@ -200,7 +200,7 @@ function this.draw_bar(bar, position, opacity_scale, percentage)
local outline_offset = bar.outline.offset;
if outline_thickness == 0 then
if utils.number.is_equal(outline_thickness, 0) then
outline_offset = 0;
end
local half_outline_offset = outline_offset / 2;