mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Refactoring
This commit is contained in:
@@ -29,7 +29,7 @@ local json = json;
|
||||
local log = log;
|
||||
local fs = fs;
|
||||
local next = next;
|
||||
local type = type;
|
||||
local skills_type_name = type;
|
||||
local setmetatable = setmetatable;
|
||||
local getmetatable = getmetatable;
|
||||
local assert = assert;
|
||||
@@ -73,6 +73,8 @@ this.list = {
|
||||
resentment = nil
|
||||
};
|
||||
|
||||
local skills_type_name = "skills";
|
||||
|
||||
local skill_data_list = {
|
||||
-- 1 Pl_EquipSkill_000 Attack Boost
|
||||
-- 2 Pl_EquipSkill_001 Agitator
|
||||
@@ -231,7 +233,7 @@ local skill_data_list = {
|
||||
-- 147 Pl_EquipSkill_235 Inspiration
|
||||
}
|
||||
|
||||
local burst_breakpoint = 5;
|
||||
local burst_breakpoints = {5};
|
||||
local kushara_daora_soul_breakpoint = 5;
|
||||
local intrepid_heart_minimal_value = 400;
|
||||
local dereliction_breakpoints = {100, 50};
|
||||
@@ -336,7 +338,7 @@ local get_hunter_wire_skill_231_num_method = player_quest_base_type_def:get_meth
|
||||
|
||||
local qeree = {};
|
||||
|
||||
function this.update(player, player_data)
|
||||
function this.update(player, player_data, weapon_type)
|
||||
--local item_parameter = get_ref_item_parameter_method:call(singletons.player_manager);
|
||||
--if item_parameter == nil then
|
||||
-- error_handler.report("skills.update", "Failed to access Data: item_parameter");
|
||||
@@ -385,8 +387,7 @@ function this.update(player, player_data)
|
||||
|
||||
this.update_equipped_skill_data(player);
|
||||
|
||||
this.update_dereliction(player_data);
|
||||
this.update_wind_mantle(player);
|
||||
this.update_wind_mantle(player, weapon_type);
|
||||
this.update_maximum_might(player_data);
|
||||
this.update_bloodlust();
|
||||
this.update_frenzied_bloodlust(player, player_data);
|
||||
@@ -394,30 +395,49 @@ function this.update(player, player_data)
|
||||
this.update_dragonheart();
|
||||
this.update_resentment(player_data);
|
||||
|
||||
this.update_generic_number_value_field("burst", player_data,
|
||||
rengeki_power_up_count_field, rengeki_power_up_timer_field, false, nil, burst_breakpoint);
|
||||
this.update_generic_skill("dereliction", player_data, symbiosis_skill_lost_vital_field,
|
||||
nil, nil, nil, nil, true, nil, dereliction_breakpoints);
|
||||
|
||||
this.update_generic_number_value_field("kushala_daora_soul", player_data,
|
||||
hyakuryu_dragon_power_up_count_field, hyakuryu_dragon_power_up_timer_field, false, nil, kushara_daora_soul_breakpoint);
|
||||
this.update_generic_skill("burst", player_data, rengeki_power_up_count_field,
|
||||
player_data, rengeki_power_up_timer_field, nil, nil, false, nil, burst_breakpoints);
|
||||
|
||||
this.update_generic_number_value_field("intrepid_heart", player_data, equip_skill_223_accumulator_field, nil, true, intrepid_heart_minimal_value);
|
||||
this.update_generic_timer("latent_power", player, power_freedom_timer_field);
|
||||
this.update_generic_timer("protective_polish", player, sharpness_gauge_boost_timer_field);
|
||||
this.update_generic_timer("grinder_s", player_data, brand_new_sharpness_adjust_up_timer_field);
|
||||
this.update_generic_timer("counterstrike", player_data, counterattack_powerup_timer_field);
|
||||
this.update_generic_timer("affinity_sliding", player_data, sliding_powerup_timer_field);
|
||||
this.update_generic_timer("coalescence", player_data, disaster_turn_powerup_timer_field);
|
||||
this.update_generic_timer("adrenaline_rush", player_data, equip_skill_208_atk_up_field);
|
||||
this.update_generic_timer("wall_runner", player_data, wall_run_powerup_timer_field);
|
||||
this.update_generic_timer("offensive_guard", player_data, equip_skill_036_timer_field);
|
||||
this.update_generic_timer("hellfire_cloak", player_data, onibi_powerup_timer_field);
|
||||
this.update_generic_timer("agitator", player_data, challenge_timer_field, true);
|
||||
this.update_generic_timer("furious", player_data, furious_skill_stamina_buff_second_timer_field);
|
||||
this.update_generic_timer("status_trigger", player_data, equip_skill_222_timer_field);
|
||||
this.update_generic_skill("kushala_daora_soul", player_data, hyakuryu_dragon_power_up_count_field,
|
||||
player_data, hyakuryu_dragon_power_up_timer_field, nil, nil, false, nil, {kushara_daora_soul_breakpoint});
|
||||
|
||||
this.update_generic_boolean_value_method("heaven_sent", player, is_active_equip_skill_230_method);
|
||||
this.update_generic_boolean_value_method("heroics", player, is_predicament_power_up_method);
|
||||
this.update_generic_boolean_value_method("resuscitate", player, is_debuff_state_method);
|
||||
this.update_generic_skill("intrepid_heart", player_data, equip_skill_223_accumulator_field,
|
||||
nil, nil, nil, nil, true, intrepid_heart_minimal_value);
|
||||
|
||||
this.update_generic_skill("latent_power", nil, nil, player, power_freedom_timer_field);
|
||||
this.update_generic_skill("protective_polish", nil, nil, player, sharpness_gauge_boost_timer_field);
|
||||
this.update_generic_skill("grinder_s", nil, nil, player_data, brand_new_sharpness_adjust_up_timer_field);
|
||||
this.update_generic_skill("counterstrike", nil, nil, player_data, counterattack_powerup_timer_field);
|
||||
this.update_generic_skill("affinity_sliding", nil, nil, player_data, sliding_powerup_timer_field);
|
||||
this.update_generic_skill("coalescence", nil, nil, player_data, disaster_turn_powerup_timer_field);
|
||||
this.update_generic_skill("adrenaline_rush", nil, nil, player_data, equip_skill_208_atk_up_field);
|
||||
this.update_generic_skill("wall_runner", nil, nil, player_data, wall_run_powerup_timer_field);
|
||||
this.update_generic_skill("offensive_guard", nil, nil, player_data, equip_skill_036_timer_field);
|
||||
this.update_generic_skill("hellfire_cloak", nil, nil, player_data, onibi_powerup_timer_field);
|
||||
this.update_generic_skill("agitator", nil, nil, player_data, challenge_timer_field, true);
|
||||
this.update_generic_skill("furious", nil, nil, player_data, furious_skill_stamina_buff_second_timer_field);
|
||||
this.update_generic_skill("status_trigger", nil, nil, player_data, equip_skill_222_timer_field);
|
||||
|
||||
this.update_generic_skill("heaven_sent", player, is_active_equip_skill_230_method);
|
||||
this.update_generic_skill("heroics", player, is_predicament_power_up_method);
|
||||
this.update_generic_skill("resuscitate", player, is_debuff_state_method);
|
||||
end
|
||||
|
||||
function this.update_generic_skill(skill_key, value_owner, value_holder, timer_owner, timer_holder, duration_owner, duration_holder,
|
||||
is_infinite, minimal_value, level_breakpoints)
|
||||
|
||||
local skill_data = skill_data_list[skill_key];
|
||||
if skill_data ~= nil and not skill_data.is_equipped then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
buffs.update_generic_buff(this.list, skills_type_name, skill_key,
|
||||
value_owner, value_holder, timer_owner, timer_holder, duration_owner, duration_holder,
|
||||
is_infinite, minimal_value, level_breakpoints);
|
||||
end
|
||||
|
||||
function this.update_equipped_skill_data(player)
|
||||
@@ -461,295 +481,7 @@ function this.update_equipped_skill_data(player)
|
||||
end
|
||||
end
|
||||
|
||||
function this.update_generic_timer(skill_key, timer_owner, timer_field, is_infinite)
|
||||
if is_infinite == nil then is_infinite = false; end
|
||||
|
||||
local skill_data = skill_data_list[skill_key];
|
||||
if skill_data ~= nil and not skill_data.is_equipped then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
local timer = nil;
|
||||
if timer_field ~= nil then
|
||||
timer = timer_field:get_data(timer_owner);
|
||||
if timer == nil then
|
||||
error_handler.report("skills.update_generic_timer", string.format("Failed to access Data: %s_timer", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if utils.number.is_equal(timer, 0) then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if is_infinite then
|
||||
timer = nil;
|
||||
else
|
||||
timer = timer / 60;
|
||||
end
|
||||
end
|
||||
|
||||
this.update_generic(skill_key, 1, timer);
|
||||
end
|
||||
|
||||
function this.update_generic_number_value_field(skill_key, timer_owner, value_field, timer_field, is_infinite, minimal_value, level_breakpoint)
|
||||
if minimal_value == nil then minimal_value = 1; end
|
||||
level_breakpoint = level_breakpoint or 1000000;
|
||||
if is_infinite == nil then is_infinite = false; end
|
||||
|
||||
local skill_data = skill_data_list[skill_key];
|
||||
if skill_data ~= nil and not skill_data.is_equipped then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
local level = 1;
|
||||
|
||||
if value_field ~= nil then
|
||||
local value = value_field:get_data(timer_owner);
|
||||
|
||||
if value == nil then
|
||||
error_handler.report("skills.update_generic_number_value_field", string.format("Failed to access Data: %s_value", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value < minimal_value then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if value >= level_breakpoint then
|
||||
level = 2;
|
||||
end
|
||||
end
|
||||
|
||||
local timer = nil;
|
||||
if timer_field ~= nil then
|
||||
timer = timer_field:get_data(timer_owner);
|
||||
if timer == nil then
|
||||
error_handler.report("skills.update_generic_number_value_field", string.format("Failed to access Data: %s_timer", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value_field == nil and utils.number.is_equal(timer, 0) then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if is_infinite then
|
||||
timer = nil;
|
||||
else
|
||||
timer = timer / 60;
|
||||
end
|
||||
end
|
||||
|
||||
this.update_generic(skill_key, level, timer);
|
||||
end
|
||||
|
||||
function this.update_generic_boolean_value_field(skill_key, timer_owner, value_field, timer_field, is_infinite, minimal_value)
|
||||
if minimal_value == nil then minimal_value = true; end
|
||||
if is_infinite == nil then is_infinite = false; end
|
||||
|
||||
local skill_data = skill_data_list[skill_key];
|
||||
if skill_data ~= nil and not skill_data.is_equipped then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if value_field ~= nil then
|
||||
local value = value_field:get_data(timer_owner);
|
||||
|
||||
if value == nil then
|
||||
error_handler.report("skills.update_generic_boolean_value_field", string.format("Failed to access Data: %s_value", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value < minimal_value then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
local timer = nil;
|
||||
if timer_field ~= nil then
|
||||
timer = timer_field:get_data(timer_owner);
|
||||
if timer == nil then
|
||||
error_handler.report("skills.update_generic_boolean_value_field", string.format("Failed to access Data: %s_timer", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value_field == nil and utils.number.is_equal(timer, 0) then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if is_infinite then
|
||||
timer = nil;
|
||||
else
|
||||
timer = timer / 60;
|
||||
end
|
||||
end
|
||||
|
||||
this.update_generic(skill_key, 1, timer);
|
||||
end
|
||||
|
||||
function this.update_generic_number_value_method(skill_key, timer_owner, value_method, timer_field, is_infinite, minimal_value, level_breakpoint)
|
||||
if minimal_value == nil then minimal_value = 1; end
|
||||
level_breakpoint = level_breakpoint or 1000000;
|
||||
if is_infinite == nil then is_infinite = false; end
|
||||
|
||||
local skill_data = skill_data_list[skill_key];
|
||||
if skill_data ~= nil and not skill_data.is_equipped then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
local level = 1;
|
||||
|
||||
if value_method ~= nil then
|
||||
local value = value_method:call(timer_owner);
|
||||
|
||||
if value == nil then
|
||||
error_handler.report("skills.update_generic_number_value_method", string.format("Failed to access Data: %s_value", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value < minimal_value then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if value >= level_breakpoint then
|
||||
level = 2;
|
||||
end
|
||||
end
|
||||
|
||||
local timer = nil;
|
||||
if timer_field ~= nil then
|
||||
timer = timer_field:get_data(timer_owner);
|
||||
if timer == nil then
|
||||
error_handler.report("skills.update_generic_number_value_method", string.format("Failed to access Data: %s_timer", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value_method == nil and utils.number.is_equal(timer, 0) then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if is_infinite then
|
||||
timer = nil;
|
||||
else
|
||||
timer = timer / 60;
|
||||
end
|
||||
end
|
||||
|
||||
this.update_generic(skill_key, level, timer);
|
||||
end
|
||||
|
||||
function this.update_generic_boolean_value_method(skill_key, timer_owner, value_method, timer_field, is_infinite, minimal_value)
|
||||
if minimal_value == nil then minimal_value = true; end
|
||||
if is_infinite == nil then is_infinite = false; end
|
||||
|
||||
local skill_data = skill_data_list[skill_key];
|
||||
if skill_data ~= nil and not skill_data.is_equipped then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if value_method ~= nil then
|
||||
local value = value_method:call(timer_owner);
|
||||
|
||||
if value == nil then
|
||||
error_handler.report("skills.update_generic_boolean_value_method", string.format("Failed to access Data: %s_value", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value ~= minimal_value then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
local timer = nil;
|
||||
if timer_field ~= nil then
|
||||
timer = timer_field:get_data(timer_owner);
|
||||
if timer == nil then
|
||||
error_handler.report("skills.update_generic_boolean_value_method", string.format("Failed to access Data: %s_timer", skill_key));
|
||||
return;
|
||||
end
|
||||
|
||||
if value_method == nil and utils.number.is_equal(timer, 0) then
|
||||
this.list[skill_key] = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
if is_infinite then
|
||||
timer = nil;
|
||||
else
|
||||
timer = timer / 60;
|
||||
end
|
||||
end
|
||||
|
||||
this.update_generic(skill_key, 1, timer);
|
||||
end
|
||||
|
||||
function this.update_generic(skill_key, level, timer, duration)
|
||||
duration = duration or timer;
|
||||
|
||||
local skill = this.list[skill_key];
|
||||
if skill == nil then
|
||||
local name = language.current_language.skills[skill_key];
|
||||
|
||||
skill = buffs.new(buffs.types.skill, skill_key, name, level, duration);
|
||||
this.list[skill_key] = skill;
|
||||
else
|
||||
skill.level = level;
|
||||
|
||||
if timer ~= nil then
|
||||
buffs.update_timer(skill, timer);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function this.update_dereliction(player_data)
|
||||
if not skill_data_list.dereliction.is_equipped then
|
||||
this.list.dereliction = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
local dereliction_value = symbiosis_skill_lost_vital_field:get_data(player_data);
|
||||
if dereliction_value == nil then
|
||||
error_handler.report("skills.update_derelection", "Failed to access Data: dereliction_value");
|
||||
return;
|
||||
end
|
||||
|
||||
if dereliction_value == 0 then
|
||||
this.list.dereliction = nil;
|
||||
return;
|
||||
end
|
||||
|
||||
local level = 1;
|
||||
for index, breakpoint in ipairs(dereliction_breakpoints) do
|
||||
if dereliction_value >= breakpoint then
|
||||
level = 4 - index;
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
local skill = this.list.dereliction;
|
||||
if skill == nil then
|
||||
local name = language.current_language.skills.dereliction;
|
||||
|
||||
skill = buffs.new(buffs.types.skill, "dereliction", name, level);
|
||||
this.list.dereliction = skill;
|
||||
else
|
||||
skill.level = level;
|
||||
end
|
||||
end
|
||||
|
||||
function this.update_wind_mantle(player)
|
||||
function this.update_wind_mantle(player, weapon_type)
|
||||
local wind_mantle_timer = equip_skill_226_attack_off_timer_field:get_data(player);
|
||||
if wind_mantle_timer == nil then
|
||||
error_handler.report("skills.update_wind_mantle", "Failed to access Data: wind_mantle_timer");
|
||||
@@ -767,38 +499,19 @@ function this.update_wind_mantle(player)
|
||||
return;
|
||||
end
|
||||
|
||||
local weapon_type = player_weapon_type_field:get_data(player);
|
||||
if player == nil then
|
||||
error_handler.report("skills.update_wind_mantle", "Failed to access Data: weapon_type");
|
||||
return;
|
||||
end
|
||||
|
||||
local breakpoints = wind_mantle_breakpoints;
|
||||
for weapon_type_index, special_breakpoints in pairs(wind_mantle_special_breakpoints) do
|
||||
if weapon_type == weapon_type_index then
|
||||
breakpoints = special_breakpoints;
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
local level = 1;
|
||||
|
||||
local breakpoints = wind_mantle_special_breakpoints[weapon_type] or wind_mantle_breakpoints;
|
||||
local breakpoint_count = #breakpoints;
|
||||
|
||||
for index, breakpoint in ipairs(breakpoints) do
|
||||
if wind_mantle_value >= breakpoint then
|
||||
level = 4 - index;
|
||||
level = 2 + breakpoint_count - index;
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
local skill = this.list.wind_mantle;
|
||||
if skill == nil then
|
||||
local name = language.current_language.skills.wind_mantle;
|
||||
|
||||
skill = buffs.new(buffs.types.skill, "wind_mantle", name, level, wind_mantle_duration);
|
||||
this.list.wind_mantle = skill;
|
||||
else
|
||||
skill.level = level;
|
||||
buffs.update_timer(skill, wind_mantle_duration - (wind_mantle_timer / 60));
|
||||
end
|
||||
buffs.update_generic(this.list, skills_type_name, "wind_mantle", level, wind_mantle_duration - (wind_mantle_timer / 60), wind_mantle_duration);
|
||||
end
|
||||
|
||||
function this.update_maximum_might(player_data)
|
||||
@@ -829,16 +542,14 @@ function this.update_maximum_might(player_data)
|
||||
local name = language.current_language.skills.maximum_might;
|
||||
|
||||
if whole_body_timer < maximum_might_previous_timer_value then
|
||||
skill = buffs.new(type, "maximum_might", name, 1);
|
||||
this.list.maximum_might = skill;
|
||||
this.list.maximum_might = buffs.new(skills_type_name, "maximum_might", name, 1);
|
||||
|
||||
elseif is_timer_zero then
|
||||
if maximum_might_delay_timer == nil then
|
||||
maximum_might_delay_timer = time.new_delay_timer(function()
|
||||
maximum_might_delay_timer = nil;
|
||||
|
||||
skill = buffs.new(type, "maximum_might", name, 1);
|
||||
this.list.maximum_might = skill;
|
||||
this.list.maximum_might = buffs.new(skills_type_name, "maximum_might", name, 1);
|
||||
end, 3.5);
|
||||
end
|
||||
|
||||
@@ -864,7 +575,7 @@ function this.update_bloodlust()
|
||||
|
||||
if this.list.bloodlust == nil then
|
||||
local name = language.current_language.skills.bloodlust;
|
||||
this.list.bloodlust = buffs.new(buffs.types.skill, "bloodlust", name, 0);
|
||||
this.list.bloodlust = buffs.new(skills_type_name, "bloodlust", name);
|
||||
end
|
||||
end
|
||||
|
||||
@@ -915,9 +626,8 @@ function this.update_frenzied_bloodlust(player, player_data)
|
||||
timer = equip_skill_231_wp_off_timer;
|
||||
end
|
||||
|
||||
this.update_generic("frenzied_bloodlust", 1, timer / 60);
|
||||
|
||||
local skill = this.list.frenzied_bloodlust;
|
||||
local skill = buffs.update_generic(this.list, skills_type_name, "frenzied_bloodlust", 1, timer / 60);
|
||||
|
||||
if is_wp_off_timer_max then
|
||||
skill.duration = frenzied_bloodlust_duration / 60;
|
||||
else
|
||||
@@ -936,7 +646,7 @@ function this.update_peak_performance()
|
||||
return;
|
||||
end
|
||||
|
||||
this.update_generic("peak_performance", 1);
|
||||
buffs.update_generic(this.list, skills_type_name, "peak_performance");
|
||||
end
|
||||
|
||||
function this.update_dragonheart()
|
||||
@@ -959,7 +669,7 @@ function this.update_dragonheart()
|
||||
return;
|
||||
end
|
||||
|
||||
this.update_generic("dragonheart", 1);
|
||||
buffs.update_generic(this.list, skills_type_name, "dragonheart");
|
||||
end
|
||||
|
||||
function this.update_resentment(player_data)
|
||||
@@ -979,7 +689,7 @@ function this.update_resentment(player_data)
|
||||
return;
|
||||
end
|
||||
|
||||
this.update_generic("resentment", 1);
|
||||
buffs.update_generic(this.list, skills_type_name, "resentment");
|
||||
end
|
||||
|
||||
function this.init_names()
|
||||
|
||||
Reference in New Issue
Block a user