Abnormal Statuses: Implemented

This commit is contained in:
GreenComfyTea
2023-08-10 16:52:47 +03:00
parent c509876712
commit 084dd9667e
13 changed files with 496 additions and 12 deletions

View File

@@ -0,0 +1,308 @@
local this = {};
local buffs;
local buff_UI_entity;
local config;
local singletons;
local players;
local utils;
local language;
local error_handler;
local sdk = sdk;
local tostring = tostring;
local pairs = pairs;
local ipairs = ipairs;
local tonumber = tonumber;
local require = require;
local pcall = pcall;
local table = table;
local string = string;
local Vector3f = Vector3f;
local d2d = d2d;
local math = math;
local json = json;
local log = log;
local fs = fs;
local next = next;
local type = type;
local setmetatable = setmetatable;
local getmetatable = getmetatable;
local assert = assert;
local select = select;
local coroutine = coroutine;
local utf8 = utf8;
local re = re;
local imgui = imgui;
local draw = draw;
local Vector2f = Vector2f;
local reframework = reframework;
local os = os;
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,
};
local frenzy_infected_duration = 121;
local player_quest_base_type_def = sdk.find_type_definition("snow.player.PlayerQuestBase");
-- Fireblight
local fire_duration_timer = player_quest_base_type_def:get_field("_FireLDurationTimer");
-- Waterblight
local water_duration_timer = player_quest_base_type_def:get_field("_WaterLDurationTimer");
-- Iceblight
local ice_duration_timer = player_quest_base_type_def:get_field("_IceLDurationTimer");
-- Thunderblight
local thunder_duration_timer = player_quest_base_type_def:get_field("_ThunderLDurationTimer");
-- Dragonblight
local dragon_duration_timer = player_quest_base_type_def:get_field("_DragonLDurationTimer");
-- blastblight
local bomb_duration_timer = player_quest_base_type_def:get_field("_BombDurationTimer");
-- Bubbleblight
local bubble_damage_timer = player_quest_base_type_def:get_field("_BubbleDamageTimer");
-- Hellfireblight
local oni_bomb_duration_timer = player_quest_base_type_def:get_field("_OniBombDurationTimer");
-- Bloodblight
local mystery_debuff_timer = player_quest_base_type_def:get_field("_MysteryDebuffTimer");
-- Frostblight
local get_is_frozen_damage_method = player_quest_base_type_def:get_method("get_IsFrozenDamage");
-- Poison
local poison_duration_timer = player_quest_base_type_def:get_field("_PoisonDurationTimer");
-- Stun
local stun_duration_timer = player_quest_base_type_def:get_field("_StunDurationTimer");
-- Sleep
local sleep_duration_timer = player_quest_base_type_def:get_field("_SleepDurationTimer");
-- Paralysis
local paralyze_duration_timer = player_quest_base_type_def:get_field("_ParalyzeDurationTimer");
-- Defense Down
local defense_down_duration_timer = player_quest_base_type_def:get_field("_DefenceDownDurationTimer");
-- Resistance Down
local resistance_down_duration_timer = player_quest_base_type_def:get_field("_ResistanceDownDurationTimer");
-- Tremor
local quake_duration_timer = player_quest_base_type_def:get_field("_QuakeDurationTimer");
-- Roar
local ear_duration_timer = player_quest_base_type_def:get_field("_EarDurationTimer");
-- Webbed
local beto_duration_timer = player_quest_base_type_def:get_field("_BetoDurationTimer");
-- Stench
local stink_duration_timer = player_quest_base_type_def:get_field("_StinkDurationTimer");
-- Leeched
local blooding_enemy_timer = player_quest_base_type_def:get_field("_BloodingEnemyTimer");
-- Bleeding
local bleeding_debuff_timer = player_quest_base_type_def:get_field("_BleedingDebuffTimer");
-- Engulfed
local get_is_vacuum_damage_method = player_quest_base_type_def:get_method("get__IsVacuumDamage");
-- Muck
local get_is_mud_damage_method = player_quest_base_type_def:get_method("get__IsMudDamage");
local get_is_gold_mud_damage_method = player_quest_base_type_def:get_method("get__IsGoldMudDamage");
-- Frenzy Infected
local virus_accumulator_field = player_quest_base_type_def:get_field("_VirusAccumulator");
local virus_timer_field = player_quest_base_type_def:get_field("_VirusTimer");
-- Frenzy
local virus_onset_timer_field = player_quest_base_type_def:get_field("_VirusOnsetTimer");
local player_data_type_def = sdk.find_type_definition("snow.player.PlayerData");
-- Frenzy Overcome
local virus_overcome_buff_timer_field = player_data_type_def:get_field("_VirusOvercomeBuffTimer");
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(player, player_data)
--local item_parameter = get_ref_item_parameter_method:call(singletons.player_manager);
--if item_parameter == nil then
-- error_handler.report("consumables.update", "Failed to access Data: item_parameter");
-- return;
--end
-- Missing:
-- Whirlwind
this.update_muck(player);
this.update_frenzy_infection(player);
this.update_generic_timer("fireblight", player, fire_duration_timer);
this.update_generic_timer("waterblight", player, water_duration_timer);
this.update_generic_timer("iceblight", player, ice_duration_timer);
this.update_generic_timer("thunderblight", player, thunder_duration_timer);
this.update_generic_timer("dragonblight", player, dragon_duration_timer);
this.update_generic_timer("blastblight", player, bomb_duration_timer);
this.update_generic_timer("bubbleblight", player, bubble_damage_timer);
this.update_generic_timer("hellfireblight", player, oni_bomb_duration_timer);
this.update_generic_timer("bloodblight", player, mystery_debuff_timer);
this.update_generic_timer("poison", player, poison_duration_timer);
this.update_generic_timer("stun", player, stun_duration_timer);
this.update_generic_timer("paralysis", player, paralyze_duration_timer);
this.update_generic_timer("sleep", player, sleep_duration_timer);
this.update_generic_timer("defense_down", player, defense_down_duration_timer);
this.update_generic_timer("resistance_down", player, resistance_down_duration_timer);
this.update_generic_timer("tremor", player, quake_duration_timer);
this.update_generic_timer("roar", player, ear_duration_timer);
this.update_generic_timer("webbed", player, beto_duration_timer);
this.update_generic_timer("stench", player, stink_duration_timer);
this.update_generic_timer("leeched", player, blooding_enemy_timer, true);
-- whirlwind?
this.update_generic_timer("bleeding", player, bleeding_debuff_timer);
this.update_generic_timer("frenzy", player, virus_onset_timer_field);
this.update_generic_timer("frenzy_overcome", player_data, virus_overcome_buff_timer_field);
this.update_generic_boolean_value_method("engulfed", player, get_is_vacuum_damage_method);
this.update_generic_boolean_value_method("frostblight", player, get_is_frozen_damage_method);
end
function this.update_generic_timer(debuff_key, timer_owner, timer_field, is_infinite)
if is_infinite == nil then is_infinite = false; end
local timer = timer_field:get_data(timer_owner);
if timer == nil then
error_handler.report("abnormal_statuses.update_generic_timer", string.format("Failed to access Data: %s_timer", debuff_key));
return;
end
if timer == 0 then
this.list[debuff_key] = nil;
return;
end
if is_infinite then
timer = nil;
else
timer = timer / 60;
end
this.update_generic(debuff_key, timer);
end
function this.update_generic_boolean_value_method(debuff_key, value_owner, value_method)
local value = value_method:call(value_owner);
if value == nil then
error_handler.report("abnormal_statuses.update_generic_boolean_value_method", string.format("Failed to access Data: %s_value", debuff_key));
return;
end
if not value then
this.list[debuff_key] = nil;
return;
end
this.update_generic(debuff_key, nil);
end
function this.update_muck(player)
local is_mud_damage = get_is_mud_damage_method:call(player);
if is_mud_damage == nil then
error_handler.report("abnormal_statuses.update_generic_boolean_value_method", "Failed to access Data: is_mud_damage");
return;
end
local is_gold_mud_damage = get_is_gold_mud_damage_method:call(player);
if is_gold_mud_damage == nil then
error_handler.report("abnormal_statuses.update_generic_boolean_value_method", "Failed to access Data: is_gold_mud_damage");
return;
end
if not is_mud_damage and not is_gold_mud_damage then
this.list.muck = nil;
return;
end
this.update_generic("muck", nil);
end
function this.update_frenzy_infection(player)
local virus_accumulator_value = virus_accumulator_field:get_data(player);
if virus_accumulator_value == nil then
error_handler.report("abnormal_statuses.update_frenzy_infection", "Failed to access Data: virus_accumulator_value");
return;
end
local virus_timer = virus_timer_field:get_data(player);
if virus_timer == nil then
error_handler.report("abnormal_statuses.update_frenzy_infection", "Failed to access Data: virus_timer");
return;
end
if virus_accumulator_value == 0 and virus_timer == 0 then
this.list.frenzy_infection = nil;
return;
end
local timer = frenzy_infected_duration - (virus_accumulator_value + virus_timer / 60);
this.update_generic("frenzy_infection", timer, frenzy_infected_duration);
end
function this.update_generic(debuff_key, timer, duration)
duration = duration or timer;
local debuff = this.list[debuff_key];
if debuff == nil then
local name = language.current_language.ailments[debuff_key];
if name == nil then
name = debuff_key;
end
debuff = buffs.new(buffs.types.debuff, debuff_key, name, 1, duration);
this.list[debuff_key] = debuff;
elseif timer ~= nil then
buffs.update_timer(debuff, timer);
end
end
function this.init_names()
for debuff_key, debuff in pairs(this.list) do
local name = language.current_language.ailments[debuff_key];
if name == nil then
name = debuff_key;
end
debuff.name = name;
end
end
function this.init_dependencies()
buffs = require("MHR_Overlay.Buffs.buffs");
config = require("MHR_Overlay.Misc.config");
utils = require("MHR_Overlay.Misc.utils");
buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity");
singletons = require("MHR_Overlay.Game_Handler.singletons");
players = require("MHR_Overlay.Damage_Meter.players");
language = require("MHR_Overlay.Misc.language");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()
end
return this;

View File

@@ -14,6 +14,7 @@ local error_handler;
local endemic_life_buffs;
local skills;
local dangos;
local abnormal_statuses;
local sdk = sdk;
local tostring = tostring;
@@ -52,6 +53,7 @@ this.types = {
melody_effect = 1,
dango = 2,
skill = 4,
debuff = 8
};
local player_manager_type_def = sdk.find_type_definition("snow.player.PlayerManager");
@@ -124,6 +126,7 @@ function this.init_names()
endemic_life_buffs.init_names();
skills.init_names();
dangos.init_names();
abnormal_statuses.init_names();
end
function this.update()
@@ -148,6 +151,8 @@ function this.update()
return;
end
abnormal_statuses.update(master_player);
local master_player_data = get_player_data_method:call(master_player);
if master_player_data ~= nil then
consumables.update(master_player_data);
@@ -186,6 +191,10 @@ function this.update_timer(buff, timer)
timer = 0;
end
if timer > buff.duration then
buff.duration = timer;
end
local minutes_left = math.floor(timer / 60);
buff.timer = timer;
@@ -217,10 +226,11 @@ function this.init_dependencies()
endemic_life_buffs = require("MHR_Overlay.Buffs.endemic_life_buffs");
skills = require("MHR_Overlay.Buffs.skills");
dangos = require("MHR_Overlay.Buffs.dangos");
abnormal_statuses = require("MHR_Overlay.Buffs.abnormal_statuses");
end
function this.init_module()
time.new_timer(this.update, 0.5);
time.new_timer(this.update, 1/60);
end
return this;

View File

@@ -332,7 +332,7 @@ function this.on_stock_direct_marionette_finish_shoot_hit_parts_damage(enemy, da
end
wall_hit_damage_queue = {};
players.update_damage(players.total, damage_source_type, false, small_monster_damage_object);
players.update_damage(player, damage_source_type, false, small_monster_damage_object);

View File

@@ -175,8 +175,9 @@ this.default_language = {
blast = "Blast",
exhaust = "Exhaust",
ride = "Wyvern Riding",
waterblight = "Waterblight",
fireblight = "Fireblight",
waterblight = "Waterblight",
iceblight = "Iceblight",
thunderblight = "Thunderblight",
@@ -187,7 +188,29 @@ this.default_language = {
steel_fang = "Steel Fang",
quick_sand = "Quick Sand",
fall_otomo_trap = "Fall Buddy Trap",
shock_otomo_trap = "Shock Buddy Trap"
shock_otomo_trap = "Shock Buddy Trap",
dragonblight = "Dragonblight",
blastblight = "Blastblight",
bubbleblight = "Bubbleblight",
hellfireblight = "Hellfireblight",
bloodblight = "Bloodblight",
frostblight = "Frostblight",
defense_down = "Defense Down",
resistance_down = "Resistance Down",
tremor = "Tremor",
roar = "Roar",
webbed = "Webbed",
stench = "Stench",
leeched = "Leeched",
bleeding = "Bleeding",
engulfed = "Engulfed",
muck = "Muck",
frenzy = "Frenzy",
frenzy_infection = "Frenzy Infection",
frenzy_overcome = "Frenzy Overcome"
},
consumables = {
@@ -253,7 +276,9 @@ this.default_language = {
offensive_guard = "Offensive Guard",
hellfire_cloak = "Hellfire Cloak",
agitator = "Agitator",
furious = "Furious"
furious = "Furious",
heroics = "Heroics",
resuscitate = "Resuscitate"
},
dangos = {

View File

@@ -120,7 +120,6 @@ function this.blast_proc(blast_param)
local blast_damage = blast_damage_method:call(blast_param);
local blast_adjust_rate = blast_adjust_rate_method:call(blast_param);
ailments.apply_ailment_damage(monster, ailments.blast_id, blast_damage * blast_adjust_rate);
ailments.clear_ailment_contribution(monster, ailments.blast_id);
end

View File

@@ -11,6 +11,7 @@ local utils;
local error_handler;
local skills;
local dangos;
local abnormal_statuses;
local sdk = sdk;
local tostring = tostring;
@@ -102,6 +103,17 @@ function this.draw()
::continue5::
end
for key, abnormal_status in pairs(abnormal_statuses.list) do
if not abnormal_status.is_active then
goto continue5;
end
table.insert(displayed_buffs, abnormal_status);
::continue5::
end
-- sort
if cached_config.sorting.type == "Name" then
if cached_config.sorting.reversed_order then
@@ -175,6 +187,7 @@ function this.init_dependencies()
endemic_life_buff = require("MHR_Overlay.Buffs.endemic_life_buffs");
skills = require("MHR_Overlay.Buffs.skills");
dangos = require("MHR_Overlay.Buffs.dangos");
abnormal_statuses = require("MHR_Overlay.Buffs.abnormal_statuses");
end
function this.init_module()