From 90190f5af7e98692f1a1d4a8d60197afe210f03d Mon Sep 17 00:00:00 2001 From: GreenComfyTea Date: Fri, 30 Jun 2023 18:57:14 +0300 Subject: [PATCH] Implement Consumable Buffs --- reframework/autorun/MHR_Overlay.lua | 23 +- .../autorun/MHR_Overlay/Buffs/buffs.lua | 251 ++++++++++- .../autorun/MHR_Overlay/Buffs/consumables.lua | 406 ++++++++++++++++++ .../autorun/MHR_Overlay/Misc/config.lua | 26 +- .../MHR_Overlay/UI/Modules/buff_UI.lua | 13 + 5 files changed, 690 insertions(+), 29 deletions(-) create mode 100644 reframework/autorun/MHR_Overlay/Buffs/consumables.lua diff --git a/reframework/autorun/MHR_Overlay.lua b/reframework/autorun/MHR_Overlay.lua index 5e0f23a..61408dc 100644 --- a/reframework/autorun/MHR_Overlay.lua +++ b/reframework/autorun/MHR_Overlay.lua @@ -41,7 +41,8 @@ local language = require("MHR_Overlay.Misc.language"); local part_names = require("MHR_Overlay.Misc.part_names"); local utils = require("MHR_Overlay.Misc.utils"); ---local buffs = require("MHR_Overlay.Buffs.buffs"); +local buffs = require("MHR_Overlay.Buffs.buffs"); +local consumables = require("MHR_Overlay.Buffs.consumables"); local players = require("MHR_Overlay.Damage_Meter.players"); local non_players = require("MHR_Overlay.Damage_Meter.non_players"); @@ -63,7 +64,7 @@ local large_monster_UI = require("MHR_Overlay.UI.Modules.large_monster_UI"); local small_monster_UI = require("MHR_Overlay.UI.Modules.small_monster_UI"); local time_UI = require("MHR_Overlay.UI.Modules.time_UI"); local env_creature_UI = require("MHR_Overlay.UI.Modules.env_creature_UI"); ---local buff_UI = require("MHR_Overlay.UI.Modules.buff_UI"); +local buff_UI = require("MHR_Overlay.UI.Modules.buff_UI"); local body_part_UI_entity = require("MHR_Overlay.UI.UI_Entities.body_part_UI_entity"); local damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.damage_UI_entity"); @@ -72,7 +73,7 @@ local stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity" local rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity"); local ailment_UI_entity = require("MHR_Overlay.UI.UI_Entities.ailment_UI_entity"); local ailment_buildup_UI_entity = require("MHR_Overlay.UI.UI_Entities.ailment_buildup_UI_entity"); ---local buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity"); +local buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity"); local customization_menu = require("MHR_Overlay.UI.customization_menu"); local label_customization = require("MHR_Overlay.UI.Customizations.label_customization"); @@ -108,9 +109,10 @@ rage_UI_entity.init_module(); ailment_UI_entity.init_module(); ailment_buildup_UI_entity.init_module(); body_part_UI_entity.init_module(); ---buff_UI_entity.init_module(); +buff_UI_entity.init_module(); ---buffs.init_module(); +buffs.init_module(); +consumables.init_module(); damage_hook.init_module(); players.init_module(); @@ -151,7 +153,7 @@ large_monster_UI.init_module(); small_monster_UI.init_module(); time_UI.init_module(); env_creature_UI.init_module(); ---buff_UI.init_module(); +buff_UI.init_module(); keyboard.init_module(); @@ -207,12 +209,12 @@ local function draw_modules(module_visibility_config, flow_state_name) end end - --[[if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then - local success = truepcall(buff_UI.draw); + if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then + local success = pcall(buff_UI.draw); if not success then customization_menu.status = string.format("[%s] Buff UI Drawing Function threw an Exception", flow_state_name); end - end]] + end end local function main_loop() @@ -223,6 +225,9 @@ local function main_loop() quest_status.update_is_online(); --quest_status.update_is_quest_host(); time.tick(); + consumables.update(); + + --buffs.debug(); if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then diff --git a/reframework/autorun/MHR_Overlay/Buffs/buffs.lua b/reframework/autorun/MHR_Overlay/Buffs/buffs.lua index d8820ec..f26a02f 100644 --- a/reframework/autorun/MHR_Overlay/Buffs/buffs.lua +++ b/reframework/autorun/MHR_Overlay/Buffs/buffs.lua @@ -2,6 +2,7 @@ local this = {}; local buff_UI_entity; local config; +local singletons; local sdk = sdk; local tostring = tostring; @@ -37,12 +38,23 @@ local package = package; this.list = {}; -function this.new(name) +function this.new(name, value, duration) + local is_infinite = false; + + value = value or 0; + + if duration == nil then + duration = 0; + is_infinite = true; + end + local buff = {}; buff.name = name; - buff.timer = 0; - buff.duration = 0; + buff.value = value; + + buff.timer = duration; + buff.duration = duration; buff.is_active = true; @@ -51,7 +63,9 @@ function this.new(name) buff.minutes_left = 0; buff.seconds_left = 0; - buff.is_infinite = false; + buff.is_infinite = is_infinite; + + this.update_timer(buff, buff.timer); this.init_UI(buff); @@ -71,12 +85,28 @@ function this.draw(buff, buff_UI, position_on_screen, opacity_scale) buff_UI_entity.draw(buff, buff_UI, position_on_screen, opacity_scale); end +function this.update_timer(buff, timer) + if timer < 0 then + timer = 0; + end + + local minutes_left = math.floor(timer / 60); + + buff.timer = timer; + buff.minutes_left = minutes_left; + buff.seconds_left = timer - 60 * minutes_left; + + if buff.duration ~= 0 then + buff.timer_percentage = timer / buff.duration; + end +end + function this.init_module() config = require("MHR_Overlay.Misc.config"); buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity"); + singletons = require("MHR_Overlay.Game_Handler.singletons"); - - local buff = this.new("Enviroment Damage Negated"); + --[[local buff = this.new("Enviroment Damage Negated"); buff.duration = 90; buff.timer = 65; buff.timer_percentage = 0.66; @@ -102,7 +132,214 @@ function this.init_module() buff.seconds_left = 10 buff.is_infinite = true; - this.list["Sharpness Loss Reduced 2"] = buff; + this.list["Sharpness Loss Reduced 2"] = buff;]] +end + +function this.debug() + --Buffs location: + --snow.player.PlayerManager -> k_BackingField -> [0] + + -- snow.player.PlayerManager -> + -- k_BackingField -> [0] + + -- Attack Up + -- Defense Up + -- Affinity Up _AtkUpEcSecond and _AtkUpEcSecondTimer + -- Sharpness Loss Reduced + -- Elemental Attack Boost + -- Divine Protection + -- Health Regeneration + -- Natural Healing Up + -- Blight Negated + -- Immunity + -- Stamina Recovery Up + -- Stamina Use Reduced + -- Knockbacks Negated _DefUpEcSecond and _DefUpEcSecondTimer + -- Sonic Barrier + -- Earplugs (S) + -- Earplugs (L) + -- Tremor Negated + -- Enviroment Damage Negated + -- Stun Negated + -- Wind Pressure Negated + -- Gourmet Fish Effect + -- Self Improvement + -- Infernal Melody + + local player_data_array = singletons.player_manager:get_field("k__BackingField"); + local player_data = player_data_array:get_element(0); + + local _AtkUpAlive = player_data:get_field("_AtkUpAlive"); + local _DefUpAlive = player_data:get_field("_DefUpAlive"); + + xy = "AtkUpAlive: " .. tostring(_AtkUpAlive); + xy = xy .. "\n_DefUpAlive: " .. tostring(_DefUpAlive); + + local _AtkUpBuffSecond = player_data:get_field("_AtkUpBuffSecond"); + local _DefUpBuffSecond = player_data:get_field("_DefUpBuffSecond"); + local _DefUpBuffSecondRate = player_data:get_field("_DefUpBuffSecondRate"); + + xy = xy .. "\n_AtkUpBuffSecond: " .. tostring(_AtkUpBuffSecond); + xy = xy .. "\n_DefUpBuffSecond: " .. tostring(_DefUpBuffSecond); + xy = xy .. "\n_DefUpBuffSecondRate: " .. tostring(_DefUpBuffSecondRate); + + local _AtkUpBuffSecondTimer = player_data:get_field("_AtkUpBuffSecondTimer"); + local _DefUpBuffSecondTimer = player_data:get_field("_DefUpBuffSecondTimer"); + local _DefUpBuffSecondRateTimer = player_data:get_field("_DefUpBuffSecondRateTimer"); + + xy = xy .. "\n_AtkUpBuffSecondTimer: " .. tostring(_AtkUpBuffSecondTimer); + xy = xy .. "\n_DefUpBuffSecondTimer: " .. tostring(_DefUpBuffSecondTimer); + xy = xy .. "\n_DefUpBuffSecondRateTimer: " .. tostring(_DefUpBuffSecondRateTimer); + + local _StaminaUpBuffSecondTimer = player_data:get_field("_StaminaUpBuffSecondTimer"); + + xy = xy .. "\n_StaminaUpBuffSecondTimer: " .. tostring(_StaminaUpBuffSecondTimer); + + local _AtkUpItemSecond = player_data:get_field("_AtkUpItemSecond"); + local _DefUpItemSecond = player_data:get_field("_DefUpItemSecond"); + + xy = xy .. "\n_AtkUpItemSecond: " .. tostring(_AtkUpItemSecond); + xy = xy .. "\n_DefUpItemSecond: " .. tostring(_DefUpItemSecond); + + local _AtkUpItemSecondTimer = player_data:get_field("_AtkUpItemSecondTimer"); + local _DefUpItemSecondTimer = player_data:get_field("_DefUpItemSecondTimer"); + + xy = xy .. "\n_AtkUpItemSecondTimer: " .. tostring(_AtkUpItemSecondTimer); + xy = xy .. "\n_DefUpItemSecondTimer: " .. tostring(_DefUpItemSecondTimer); + + local _SuperArmorItemTimer = player_data:get_field("_SuperArmorItemTimer"); + + xy = xy .. "\n_SuperArmorItemTimer: " .. tostring(_SuperArmorItemTimer); + + local _AtkUpEcSecondTimer = player_data:get_field("_AtkUpEcSecondTimer"); + local _AtkUpEcSecond = player_data:get_field("_AtkUpEcSecond"); + + xy = xy .. "\n_AtkUpEcSecondTimer: " .. tostring(_AtkUpEcSecondTimer); + xy = xy .. "\n_AtkUpEcSecond: " .. tostring(_AtkUpEcSecond); + + local _DefUpEcSecondTimer = player_data:get_field("_DefUpEcSecondTimer"); + local _DefUpEcSecond = player_data:get_field("_DefUpEcSecond"); + + xy = xy .. "\n_DefUpEcSecondTimer: " .. tostring(_DefUpEcSecondTimer); + xy = xy .. "\n_DefUpEcSecond: " .. tostring(_DefUpEcSecond); + + local _CritUpEcSecondTimer = player_data:get_field("_CritUpEcSecondTimer"); + local _CritChanceUpBowTimer = player_data:get_field("_CritChanceUpBowTimer"); + local _CritChanceUpBow = player_data:get_field("_CritChanceUpBow"); + + xy = xy .. "\n_CritUpEcSecondTimer: " .. tostring(_CritUpEcSecondTimer); + xy = xy .. "\n_CritChanceUpBowTimer: " .. tostring(_CritChanceUpBowTimer); + xy = xy .. "\n_CritChanceUpBow: " .. tostring(_CritChanceUpBow); + + local _MusicRegeneTimer = player_data:get_field("_MusicRegeneTimer"); + + xy = xy .. "\n_MusicRegeneTimer: " .. tostring(_MusicRegeneTimer); + + local _LeadEnemyTimer = player_data:get_field("_LeadEnemyTimer"); + local _IsLeadEnemy = player_data:get_field("_IsLeadEnemy"); + + xy = xy .. "\n_LeadEnemyTimer: " .. tostring(_LeadEnemyTimer); + xy = xy .. "\n_IsLeadEnemy: " .. tostring(_IsLeadEnemy); + + local _DebuffPreventionTimer = player_data:get_field("_DebuffPreventionTimer"); + + xy = xy .. "\n_DebuffPreventionTimer: " .. tostring(_DebuffPreventionTimer); + + local _FishRegeneTimer = player_data:get_field("_FishRegeneTimer"); + local _FishRegeneEnableTimer = player_data:get_field("_FishRegeneEnableTimer"); + + xy = xy .. "\n_FishRegeneTimer: " .. tostring(_FishRegeneTimer); + xy = xy .. "\n_FishRegeneEnableTimer: " .. tostring(_FishRegeneEnableTimer); + + local _VitalizerTimer = player_data:get_field("_VitalizerTimer"); + + xy = xy .. "\n_VitalizerTimer: " .. tostring(_VitalizerTimer); + + local _RunhighOtomoTimer = player_data:get_field("_RunhighOtomoTimer"); + local _KijinBulletTimer = player_data:get_field("_KijinBulletTimer"); + local _KoukaBulletTimer = player_data:get_field("_KoukaBulletTimer"); + local _EquipSkill_036_Timer = player_data:get_field("_EquipSkill_036_Timer"); + + xy = xy .. "\n_RunhighOtomoTimer: " .. tostring(_RunhighOtomoTimer); + xy = xy .. "\n_KijinBulletTimer: " .. tostring(_KijinBulletTimer); + xy = xy .. "\n_KoukaBulletTimer: " .. tostring(_KoukaBulletTimer); + xy = xy .. "\n_EquipSkill_036_Timer: " .. tostring(_EquipSkill_036_Timer); + + local _HyperArmorItemTimer = player_data:get_field("_HyperArmorItemTimer"); + + xy = xy .. "\n_HyperArmorItemTimer: " .. tostring(_HyperArmorItemTimer); + + local _KijinOtomoTimer = player_data:get_field("_KijinOtomoTimer"); + local _BeastRoarOtomoTimer = player_data:get_field("_BeastRoarOtomoTimer"); + local _ChallengeTimer = player_data:get_field("_ChallengeTimer"); + local _WholeBodyTimer = player_data:get_field("_WholeBodyTimer"); + + xy = xy .. "\n_KijinOtomoTimer: " .. tostring(_KijinOtomoTimer); + xy = xy .. "\n_BeastRoarOtomoTimer: " .. tostring(_BeastRoarOtomoTimer); + xy = xy .. "\n_ChallengeTimer: " .. tostring(_ChallengeTimer); + xy = xy .. "\n_WholeBodyTimer: " .. tostring(_WholeBodyTimer); + + local _SlidingTimer = player_data:get_field("_SlidingTimer"); + local _SlidingPowerupTimer = player_data:get_field("_SlidingPowerupTimer"); + + xy = xy .. "\n_SlidingTimer: " .. tostring(_SlidingTimer); + xy = xy .. "\n_SlidingPowerupTimer: " .. tostring(_SlidingPowerupTimer); + + local _WallRunTimer = player_data:get_field("_WallRunTimer"); + local _WallRunPowerupTimer = player_data:get_field("_WallRunPowerupTimer"); + + xy = xy .. "\n_WallRunTimer: " .. tostring(_WallRunTimer); + xy = xy .. "\n_WallRunPowerupTimer: " .. tostring(_WallRunPowerupTimer); + + local _CounterattackPowerupTimer = player_data:get_field("_CounterattackPowerupTimer"); + + xy = xy .. "\n_CounterattackPowerupTimer: " .. tostring(_CounterattackPowerupTimer); + + -- sic! + local _OnibiPowerUpTiemr = player_data:get_field("_OnibiPowerUpTiemr"); + local _OnibiPowerUpInterval = player_data:get_field("_OnibiPowerUpInterval"); + + xy = xy .. "\n_OnibiPowerUpTiemr: " .. tostring(_OnibiPowerUpTiemr); + xy = xy .. "\n_OnibiPowerUpInterval: " .. tostring(_OnibiPowerUpInterval); + + local _HyakuryuDragonPowerUpTimer = player_data:get_field("_HyakuryuDragonPowerUpTimer"); + local _HyakuryuDragonPowerUpCnt = player_data:get_field("_HyakuryuDragonPowerUpCnt"); + local _HyakuryuHyakuryuOnazutiPowerUpInterval = player_data:get_field("_HyakuryuHyakuryuOnazutiPowerUpInterval"); + + xy = xy .. "\n_HyakuryuDragonPowerUpTimer: " .. tostring(_HyakuryuDragonPowerUpTimer); + xy = xy .. "\n_HyakuryuDragonPowerUpCnt: " .. tostring(_HyakuryuDragonPowerUpCnt); + xy = xy .. "\n_HyakuryuHyakuryuOnazutiPowerUpInterval: " .. tostring(_HyakuryuHyakuryuOnazutiPowerUpInterval); + + local _KitchenSkill027Timer = player_data:get_field("_KitchenSkill027Timer"); + local _KitchenSkill045Timer = player_data:get_field("_KitchenSkill045Timer"); + + xy = xy .. "\n_KitchenSkill027Timer: " .. tostring(_KitchenSkill027Timer); + xy = xy .. "\n_KitchenSkill045Timer: " .. tostring(_KitchenSkill045Timer); + + -- sic! + local _ReduseUseStaminaKichenSkillActive = player_data:get_field("_ReduseUseStaminaKichenSkillActive"); + + xy = xy .. "\n_ReduseUseStaminaKichenSkillActive: " .. tostring(_ReduseUseStaminaKichenSkillActive); + + local _HeavyBowgunWyvernSnipeTimer = player_data:get_field("_HeavyBowgunWyvernSnipeTimer"); + local _HeavyBowgunWyvernMachineGunTimer = player_data:get_field("_HeavyBowgunWyvernMachineGunTimer"); + local _HeavyBowgunWyvernSnipeBullet = player_data:get_field("_HeavyBowgunWyvernSnipeBullet"); + local _HeavyBowgunWyvernMachineGunBullet = player_data:get_field("_HeavyBowgunWyvernMachineGunBullet"); + + xy = xy .. "\n_HeavyBowgunWyvernSnipeTimer: " .. tostring(_HeavyBowgunWyvernSnipeTimer); + xy = xy .. "\n_HeavyBowgunWyvernMachineGunTimer: " .. tostring(_HeavyBowgunWyvernMachineGunTimer); + xy = xy .. "\n_HeavyBowgunWyvernSnipeBullet: " .. tostring(_HeavyBowgunWyvernSnipeBullet); + xy = xy .. "\n_HeavyBowgunWyvernMachineGunBullet: " .. tostring(_HeavyBowgunWyvernMachineGunBullet); + + local _ChargeDragonSlayCannonTime = player_data:get_field("_ChargeDragonSlayCannonTime"); + + xy = xy .. "\n_ChargeDragonSlayCannonTime: " .. tostring(_ChargeDragonSlayCannonTime); + + local _WyvernBlastGauge = player_data:get_field("_WyvernBlastGauge"); + local _WyvernBlastReloadTimer = player_data:get_field("_WyvernBlastReloadTimer"); + + xy = xy .. "\n_WyvernBlastGauge: " .. tostring(_WyvernBlastGauge); + xy = xy .. "\n_WyvernBlastReloadTimer: " .. tostring(_WyvernBlastReloadTimer); end return this; \ No newline at end of file diff --git a/reframework/autorun/MHR_Overlay/Buffs/consumables.lua b/reframework/autorun/MHR_Overlay/Buffs/consumables.lua new file mode 100644 index 0000000..92111e5 --- /dev/null +++ b/reframework/autorun/MHR_Overlay/Buffs/consumables.lua @@ -0,0 +1,406 @@ +local this = {}; + +local buff_UI_entity; +local config; +local singletons; + +local buffs; +local buff_UI_entity; +local config; +local singletons; + +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; + + +local ids = { + demondrug = 0, + mega_demondrug = 1, + armorskin = 2, + mega_armorskin = 4, + might_seed = 8, + adamant_seed = 16, + demon_powder = 32, + hardshell_powder = 64, + immunizer = 128, + dash_juice = 256 +}; + +this.list = { + demondrug = nil, + mega_demondrug = nil, + armorskin = nil, + mega_armorskin = nil, + might_seed = nil, + adamant_seed = nil, + hardshell_powder = nil, + hardshell_powder = nil, + immunizer = nil, + dash_juice = nil +}; + +local player_manager_type_def = sdk.find_type_definition("snow.player.PlayerManager"); +local get_player_data_method = player_manager_type_def:get_method("get_PlayerData"); +local get_ref_item_parameter_method = player_manager_type_def:get_method("get_RefItemParameter"); + +local player_user_data_item_parameter_type_def = get_ref_item_parameter_method:get_return_type(); + +local demondrug_atk_up_field = player_user_data_item_parameter_type_def:get_field("_DemondrugAtkUp"); +local great_demondrug_atk_up_field = player_user_data_item_parameter_type_def:get_field("_GreatDemondrugAtkUp"); +local armorskin_def_up_field = player_user_data_item_parameter_type_def:get_field("_ArmorSkinDefUp"); +local great_armorskin_def_up_field = player_user_data_item_parameter_type_def:get_field("_GreatArmorSkinDefUp"); + +local might_seed_timer_field = player_user_data_item_parameter_type_def:get_field("_MightSeedTimer"); +local adamant_seed_timer_field = player_user_data_item_parameter_type_def:get_field("_AdamantSeedTimer"); +local demondrug_powder_timer_field = player_user_data_item_parameter_type_def:get_field("_DemondrugPowderTimer"); +local armorskin_powder_timer_field = player_user_data_item_parameter_type_def:get_field("_ArmorSkinPowderTimer"); +local vitalizer_timer_const_field = player_user_data_item_parameter_type_def:get_field("_VitalizerTimer"); +local stamina_up_buff_second_field = player_user_data_item_parameter_type_def:get_field("_StaminaUpBuffSecond"); + +local player_data_type_def = sdk.find_type_definition("snow.player.PlayerData"); +-- Demondrug/Mega Demondrug +local atk_up_alive_field = player_data_type_def:get_field("_AtkUpAlive"); +-- Armorskin/Mega Armorskin +local def_up_alive_field = player_data_type_def:get_field("_DefUpAlive"); +-- Might Seed +local atk_up_buff_second_field = player_data_type_def:get_field("_AtkUpBuffSecond"); +local atk_up_buff_second_timer_field = player_data_type_def:get_field("_AtkUpBuffSecondTimer"); +-- Adamant Seed +local def_up_buff_second_field = player_data_type_def:get_field("_DefUpBuffSecond"); +local def_up_buff_second_timer_field = player_data_type_def:get_field("_DefUpBuffSecondTimer"); +-- Demon Powder +local atk_up_item_second_field = player_data_type_def:get_field("_AtkUpItemSecond"); +local atk_up_item_second_timer_field = player_data_type_def:get_field("_AtkUpItemSecondTimer"); +-- Hardshell Powder +local def_up_item_second_field = player_data_type_def:get_field("_DefUpItemSecond"); +local def_up_item_second_timer_field = player_data_type_def:get_field("_DefUpItemSecondTimer"); +-- Immunizer +local vitalizer_timer_field = player_data_type_def:get_field("_VitalizerTimer"); +-- Dash Juice +local stamina_up_buff_second_timer_field = player_data_type_def:get_field("_StaminaUpBuffSecondTimer"); + +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() + local player_data_array = get_player_data_method:call(singletons.player_manager); + if player_data_array == nil then + return; + end + + local player_data = get_value_method:call(player_data_array, 0); + if player_data == nil then + return; + end + + local item_parameter = get_ref_item_parameter_method:call(singletons.player_manager); + if item_parameter == nil then + return; + end + + this.update_demondrug(player_data, item_parameter); + this.update_armorskin(player_data, item_parameter); + this.update_might_seed(player_data, item_parameter); + this.update_adamant_seed(player_data, item_parameter); + this.update_demon_powder(player_data, item_parameter); + this.update_hardshell_powder(player_data, item_parameter); + this.update_immunizer(player_data, item_parameter); + this.update_dash_juice(player_data, item_parameter); +end + +function this.update_demondrug(player_data, item_parameter) + local demondrug = atk_up_alive_field:get_data(player_data); + if demondrug == nil then + return; + end + + if demondrug == 0 then + this.list.demondrug = nil; + this.list.mega_demondrug = nil; + return; + end + + local demondrug_const_value = demondrug_atk_up_field:get_data(item_parameter); + if demondrug_const_value == nil then + return; + end + + local mega_demondrug_const_value = great_demondrug_atk_up_field:get_data(item_parameter); + if mega_demondrug_const_value == nil then + return; + end + + if demondrug == demondrug_const_value then + local buff = this.list.demondrug; + if buff ~= nil and buff.value == demondrug then + return; + end + + this.list.demondrug = buffs.new("Demondrug", demondrug); + this.list.mega_demondrug = nil; + + elseif demondrug == mega_demondrug_const_value then + local buff = this.list.mega_demondrug; + if buff ~= nil and buff.value == demondrug then + return; + end + + this.list.demondrug = nil; + this.list.mega_demondrug = buffs.new("Mega Demondrug", demondrug); + end +end + +function this.update_armorskin(player_data, item_parameter) + local armorskin = def_up_alive_field:get_data(player_data); + if armorskin == nil then + return; + end + + if armorskin == 0 then + this.list.armorskin = nil; + this.list.mega_armorskin = nil; + return; + end + + local armorskin_const_value = armorskin_def_up_field:get_data(item_parameter); + if armorskin_const_value == nil then + return; + end + + local mega_armorskin_const_value = great_armorskin_def_up_field:get_data(item_parameter); + if mega_armorskin_const_value == nil then + return; + end + + if armorskin == armorskin_const_value then + local buff = this.list.armorskin; + if buff ~= nil and buff.value == armorskin then + return; + end + + this.list.armorskin = buffs.new("Armorskin", armorskin); + this.list.mega_armorskin = nil; + + elseif armorskin == mega_armorskin_const_value then + local buff = this.list.mega_armorskin; + if buff ~= nil and buff.value == armorskin then + return; + end + + this.list.armorskin = nil; + this.list.mega_armorskin = buffs.new("Mega Armorskin", armorskin); + end +end + +function this.update_might_seed(player_data, item_parameter) + local might_seed = atk_up_buff_second_field:get_data(player_data); + if might_seed == nil then + return; + end + + if might_seed == 0 then + this.list.might_seed = nil; + return; + end + + local might_seed_timer = atk_up_buff_second_timer_field:get_data(player_data); + if might_seed_timer == nil then + return; + end + + local buff = this.list.might_seed; + if buff == nil then + local might_seed_timer_const_value = might_seed_timer_field:get_data(item_parameter); + if might_seed_timer_const_value == nil then + return; + end + + buff = buffs.new("Might Seed", might_seed, might_seed_timer_const_value); + this.list.might_seed = buff; + else + buff.value = might_seed; + buffs.update_timer(buff, might_seed_timer / 60); + end +end + +function this.update_adamant_seed(player_data, item_parameter) + local adamant_seed = def_up_buff_second_field:get_data(player_data); + if adamant_seed == nil then + return; + end + + if adamant_seed == 0 then + this.list.adamant_seed = nil; + return; + end + + local adamant_seed_timer = def_up_buff_second_timer_field:get_data(player_data); + if adamant_seed_timer == nil then + return; + end + + local buff = this.list.adamant_seed; + if buff == nil then + local adamant_seed_timer_const_value = adamant_seed_timer_field:get_data(item_parameter); + if adamant_seed_timer_const_value == nil then + return; + end + + buff = buffs.new("Adamant Seed", adamant_seed, adamant_seed_timer_const_value); + this.list.adamant_seed = buff; + else + buff.value = adamant_seed; + buffs.update_timer(buff, adamant_seed_timer / 60); + end +end + +function this.update_demon_powder(player_data, item_parameter) + local demon_powder = atk_up_item_second_field:get_data(player_data); + if demon_powder == nil then + return; + end + + if demon_powder == 0 then + this.list.demon_powder = nil; + return; + end + + local demon_powder_timer = atk_up_item_second_timer_field:get_data(player_data); + if demon_powder_timer == nil then + return; + end + + local buff = this.list.demon_powder; + if buff == nil then + local demon_powder_timer_const_value = demondrug_powder_timer_field:get_data(item_parameter); + if demon_powder_timer_const_value == nil then + return; + end + + buff = buffs.new("Demon Powder", demon_powder, demon_powder_timer_const_value); + this.list.demon_powder = buff; + else + buff.value = demon_powder; + buffs.update_timer(buff, demon_powder_timer / 60); + end +end + +function this.update_hardshell_powder(player_data, item_parameter) + local hardshell_powder = def_up_item_second_field:get_data(player_data); + if hardshell_powder == nil then + return; + end + + if hardshell_powder == 0 then + this.list.hardshell_powder = nil; + return; + end + + local hardshell_powder_timer = def_up_item_second_timer_field:get_data(player_data); + if hardshell_powder_timer == nil then + return; + end + + local buff = this.list.hardshell_powder; + if buff == nil then + local demon_powder_timer_const_value = armorskin_powder_timer_field:get_data(item_parameter); + if demon_powder_timer_const_value == nil then + return; + end + + buff = buffs.new("Hardshell Powder", hardshell_powder, demon_powder_timer_const_value); + this.list.hardshell_powder = buff; + else + buff.value = hardshell_powder; + buffs.update_timer(buff, hardshell_powder_timer / 60); + end +end + +function this.update_immunizer(player_data, item_parameter) + local immunizer_timer = vitalizer_timer_field:get_data(player_data); + if immunizer_timer == nil then + return; + end + + if immunizer_timer == 0 then + this.list.immunizer = nil; + return; + end + + local buff = this.list.immunizer; + if buff == nil then + local immunizer_timer_const_value = vitalizer_timer_const_field:get_data(item_parameter); + if immunizer_timer_const_value == nil then + return; + end + + buff = buffs.new("Immunizer", 0, immunizer_timer_const_value); + this.list.immunizer = buff; + else + buffs.update_timer(buff, immunizer_timer / 60); + end +end + +function this.update_dash_juice(player_data, item_parameter) + local dash_juice_timer = stamina_up_buff_second_timer_field:get_data(player_data); + if dash_juice_timer == nil then + return; + end + + if dash_juice_timer == 0 then + this.list.dash_juice = nil; + return; + end + + local buff = this.list.dash_juice; + if buff == nil then + local dash_juice_timer_const_value = stamina_up_buff_second_field:get_data(item_parameter); + if dash_juice_timer_const_value == nil then + return; + end + + buff = buffs.new("Dash Juice", 0, dash_juice_timer_const_value); + this.list.dash_juice = buff; + else + buffs.update_timer(buff, dash_juice_timer / 60); + end +end + +function this.init_module() + buffs = require("MHR_Overlay.Buffs.buffs"); + config = require("MHR_Overlay.Misc.config"); + buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity"); + singletons = require("MHR_Overlay.Game_Handler.singletons"); +end + +return this; \ No newline at end of file diff --git a/reframework/autorun/MHR_Overlay/Misc/config.lua b/reframework/autorun/MHR_Overlay/Misc/config.lua index ff65037..cd66a85 100644 --- a/reframework/autorun/MHR_Overlay/Misc/config.lua +++ b/reframework/autorun/MHR_Overlay/Misc/config.lua @@ -89,7 +89,7 @@ function this.init_default() large_monster_highlighted_UI = true, damage_meter_UI = true, endemic_life_UI = true, - --buff_UI = true + buff_UI = true }, cutscene = { @@ -100,7 +100,7 @@ function this.init_default() time_UI = false, damage_meter_UI = false, endemic_life_UI = false, - --buff_UI = false + buff_UI = false }, loading_quest = { @@ -111,7 +111,7 @@ function this.init_default() time_UI = false, damage_meter_UI = false, endemic_life_UI = false, - --buff_UI = false + buff_UI = false }, quest_start_animation = { @@ -122,7 +122,7 @@ function this.init_default() time_UI = true, damage_meter_UI = true, endemic_life_UI = true, - --buff_UI = true + buff_UI = true }, playing_quest = { @@ -133,7 +133,7 @@ function this.init_default() time_UI = true, damage_meter_UI = true, endemic_life_UI = true, - --buff_UI = true + buff_UI = true }, killcam = { @@ -144,7 +144,7 @@ function this.init_default() time_UI = true, damage_meter_UI = true, endemic_life_UI = true, - --buff_UI = true + buff_UI = true }, quest_end_timer = { @@ -155,7 +155,7 @@ function this.init_default() time_UI = true, damage_meter_UI = true, endemic_life_UI = true, - --buff_UI = true + buff_UI = true }, quest_end_animation = { @@ -166,7 +166,7 @@ function this.init_default() time_UI = false, damage_meter_UI = false, endemic_life_UI = false, - --buff_UI = false + buff_UI = false }, quest_end_screen = { @@ -177,7 +177,7 @@ function this.init_default() time_UI = false, damage_meter_UI = false, endemic_life_UI = false, - --buff_UI = false + buff_UI = false }, reward_screen = { @@ -188,7 +188,7 @@ function this.init_default() time_UI = true, damage_meter_UI = true, endemic_life_UI = false, - --buff_UI = false + buff_UI = false }, summary_screen = { @@ -199,7 +199,7 @@ function this.init_default() time_UI = true, damage_meter_UI = true, endemic_life_UI = false, - --buff_UI = false + buff_UI = false }, }, @@ -7452,7 +7452,7 @@ function this.init_default() } }, - --[[buff_UI = { + buff_UI = { enabled = true, settings = { @@ -7564,7 +7564,7 @@ function this.init_default() outline = 0xC0000000 } } - }]] + } }; end diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua index 6002f0b..093fe9b 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/buff_UI.lua @@ -3,6 +3,7 @@ local this = {}; local buff_UI_entity; local config; local buffs; +local consumables; local screen; local sdk = sdk; @@ -54,6 +55,17 @@ function this.draw() ::continue:: end + for _, consumable in pairs(consumables.list) do + + if not consumable.is_active then + goto continue + end + + table.insert(displayed_buffs, consumable); + + ::continue:: + end + -- sort if cached_config.sorting.type == "Name" then if cached_config.sorting.reversed_order then @@ -113,6 +125,7 @@ end function this.init_module() config = require("MHR_Overlay.Misc.config"); buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity"); + consumables = require("MHR_Overlay.Buffs.consumables"); buffs = require("MHR_Overlay.Buffs.buffs"); --singletons = require("MHR_Overlay.Game_Handler.singletons"); config = require("MHR_Overlay.Misc.config");