From 3dc2b71fa14ec386ea9e9f5cbb8d481629803c59 Mon Sep 17 00:00:00 2001 From: Xaver-DaRed Date: Sat, 31 May 2025 11:45:46 +0200 Subject: [PATCH 1/2] Change Drain 2/3 bonus to be a flat addition --- scripts/effects/max_hp_boost.lua | 4 ++-- scripts/globals/spells/absorb_spell.lua | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/effects/max_hp_boost.lua b/scripts/effects/max_hp_boost.lua index 007229d3af3..a1fc9f19969 100644 --- a/scripts/effects/max_hp_boost.lua +++ b/scripts/effects/max_hp_boost.lua @@ -5,14 +5,14 @@ local effectObject = {} effectObject.onEffectGain = function(target, effect) - target:addMod(xi.mod.HPP, effect:getPower()) + effect:addMod(xi.mod.HPP, effect:getPower()) -- % HP bonus to max HP + effect:addMod(xi.mod.HP, effect:getSubPower()) -- Flat HP bonus to max HP end effectObject.onEffectTick = function(target, effect) end effectObject.onEffectLose = function(target, effect) - target:delMod(xi.mod.HPP, effect:getPower()) end return effectObject diff --git a/scripts/globals/spells/absorb_spell.lua b/scripts/globals/spells/absorb_spell.lua index 3ec152d4bc5..9d30987f0c5 100644 --- a/scripts/globals/spells/absorb_spell.lua +++ b/scripts/globals/spells/absorb_spell.lua @@ -167,13 +167,30 @@ xi.spells.absorb.doDrainingSpell = function(caster, target, spell) target:updateEnmityFromDamage(caster, finalDamage) end - -- Drain II and Drain III increase max HP. + -- Drain II and Drain III increase max HP via effect. if absorbPointsData[spellId][5] then local overflow = finalDamage + caster:getHP() - caster:getMaxHP() if overflow > 0 then - local power = 100 * overflow / caster:getMaxHP() - local duration = 180 + 180 * caster:getMod(xi.mod.DARK_MAGIC_DURATION) / 100 - caster:addStatusEffect(xi.effect.MAX_HP_BOOST, power, 0, duration) + -- Check if effect should be applied. Only 1 "Max HP Effect" can be in place at a time. + -- Retail testing suggest that %power effect takes precedent over flat power. + local hasMaxHPEffect = caster:hasStatusEffect(xi.effect.MAX_HP_BOOST) + local maxHPEffectPower = 0 + local maxHPEffectSubpower = 0 + + if hasMaxHPEffect then + maxHPEffectPower = caster:getStatusEffect(xi.effect.MAX_HP_BOOST):getPower() + maxHPEffectSubpower = caster:getStatusEffect(xi.effect.MAX_HP_BOOST):getSubPower() + end + + if + not hasMaxHPEffect or -- No effect present, so apply. + (maxHPEffectPower == 0 and -- Effect present, but it isn't %. If subpower is higher, we can override the effect. + maxHPEffectSubpower < overflow) -- Subpower present is lower than new one, so we can override the effect. + then + local duration = 180 + 180 * caster:getMod(xi.mod.DARK_MAGIC_DURATION) / 100 + caster:delStatusEffect(xi.effect.MAX_HP_BOOST) + caster:addStatusEffect(xi.effect.MAX_HP_BOOST, 0, 0, duration, 0, overflow) + end end end From 21999eeab898515896d453e61e0f4a27f9f16d2f Mon Sep 17 00:00:00 2001 From: Xaver-DaRed Date: Sat, 31 May 2025 11:59:22 +0200 Subject: [PATCH 2/2] Fix Sublimation/Refresh interactions --- scripts/actions/abilities/sublimation.lua | 31 +++++++++------------- scripts/effects/refresh.lua | 8 ++++-- scripts/effects/sublimation_activated.lua | 1 + scripts/effects/sublimation_complete.lua | 1 + scripts/globals/monstrosity.lua | 4 +-- scripts/globals/regimes.lua | 4 +-- scripts/globals/spells/enhancing_spell.lua | 4 +-- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/scripts/actions/abilities/sublimation.lua b/scripts/actions/abilities/sublimation.lua index a6aea14b1ee..bad251a6f38 100644 --- a/scripts/actions/abilities/sublimation.lua +++ b/scripts/actions/abilities/sublimation.lua @@ -14,38 +14,33 @@ abilityObject.onAbilityCheck = function(player, target, ability) end abilityObject.onUseAbility = function(player, target, ability) - local sublimationComplete = player:getStatusEffect(xi.effect.SUBLIMATION_COMPLETE) - local sublimationCharging = player:getStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) - local mp = 0 + local mp = 0 + local maxMP = player:getMaxMP() + local currentMP = player:getMP() - if sublimationComplete ~= nil then - mp = sublimationComplete:getPower() - local maxmp = player:getMaxMP() - local currmp = player:getMP() + if player:hasStatusEffect(xi.effect.SUBLIMATION_COMPLETE) then + mp = player:getStatusEffect(xi.effect.SUBLIMATION_COMPLETE):getPower() - if mp + currmp > maxmp then - mp = maxmp - currmp + if mp + currentMP > maxMP then + mp = maxMP - currentMP end player:addMP(mp) player:delStatusEffectSilent(xi.effect.SUBLIMATION_COMPLETE) ability:setMsg(xi.msg.basic.JA_RECOVERS_MP) - elseif sublimationCharging ~= nil then - mp = sublimationCharging:getPower() - local maxmp = player:getMaxMP() - local currmp = player:getMP() + elseif player:hasStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) then + mp = player:getStatusEffect(xi.effect.SUBLIMATION_ACTIVATED):getPower() - if mp + currmp > maxmp then - mp = maxmp - currmp + if mp + currentMP > maxMP then + mp = maxMP - currentMP end player:addMP(mp) player:delStatusEffectSilent(xi.effect.SUBLIMATION_ACTIVATED) ability:setMsg(xi.msg.basic.JA_RECOVERS_MP) else - local refresh = player:getStatusEffect(xi.effect.REFRESH) - - if refresh == nil or refresh:getSubPower() < 3 then + local refreshTier = player:hasStatusEffect(xi.effect.REFRESH) and player:getStatusEffect(xi.effect.REFRESH):getTier() or 0 + if refreshTier < 3 then player:delStatusEffect(xi.effect.REFRESH) player:addStatusEffect(xi.effect.SUBLIMATION_ACTIVATED, 0, 3, 7200) else diff --git a/scripts/effects/refresh.lua b/scripts/effects/refresh.lua index b04b6df1404..9772fc42b64 100644 --- a/scripts/effects/refresh.lua +++ b/scripts/effects/refresh.lua @@ -5,14 +5,18 @@ local effectObject = {} effectObject.onEffectGain = function(target, effect) - target:addMod(xi.mod.REFRESH, effect:getPower()) + if effect:getTier() >= 3 then + target:delStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) + target:delStatusEffect(xi.effect.SUBLIMATION_COMPLETE) + end + + effect:addMod(xi.mod.REFRESH, effect:getPower()) end effectObject.onEffectTick = function(target, effect) end effectObject.onEffectLose = function(target, effect) - target:delMod(xi.mod.REFRESH, effect:getPower()) end return effectObject diff --git a/scripts/effects/sublimation_activated.lua b/scripts/effects/sublimation_activated.lua index dd9f481c14c..69a00d1c679 100644 --- a/scripts/effects/sublimation_activated.lua +++ b/scripts/effects/sublimation_activated.lua @@ -5,6 +5,7 @@ local effectObject = {} effectObject.onEffectGain = function(target, effect) + target:delStatusEffect(xi.effect.REFRESH) end effectObject.onEffectTick = function(target, effect) diff --git a/scripts/effects/sublimation_complete.lua b/scripts/effects/sublimation_complete.lua index b9a766ee5aa..85c2cf576d6 100644 --- a/scripts/effects/sublimation_complete.lua +++ b/scripts/effects/sublimation_complete.lua @@ -5,6 +5,7 @@ local effectObject = {} effectObject.onEffectGain = function(target, effect) + target:delStatusEffect(xi.effect.REFRESH) end effectObject.onEffectTick = function(target, effect) diff --git a/scripts/globals/monstrosity.lua b/scripts/globals/monstrosity.lua index b8ab297c378..aee276ee783 100644 --- a/scripts/globals/monstrosity.lua +++ b/scripts/globals/monstrosity.lua @@ -1505,9 +1505,7 @@ xi.monstrosity.teyrnonOnEventFinish = function(player, csid, option, npc) end player:delStatusEffectSilent(xi.effect.REFRESH) - player:delStatusEffect(xi.effect.SUBLIMATION_COMPLETE) - player:delStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) - player:addStatusEffect(xi.effect.REFRESH, 1, 3, 3600, 0, 3) + player:addStatusEffect(xi.effect.REFRESH, 1, 3, 3600) -- Does indeed get overwriten by regular refresh. end, -- 4: Protect diff --git a/scripts/globals/regimes.lua b/scripts/globals/regimes.lua index 5a4fee556ef..83069111569 100644 --- a/scripts/globals/regimes.lua +++ b/scripts/globals/regimes.lua @@ -1225,9 +1225,7 @@ xi.regime.bookOnEventFinish = function(player, option, regimeType) ['REFRESH'] = function() player:delStatusEffectSilent(xi.effect.REFRESH) - player:delStatusEffect(xi.effect.SUBLIMATION_COMPLETE) - player:delStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) - player:addStatusEffect(xi.effect.REFRESH, 1, 3, 3600, 0, 3) + player:addStatusEffect(xi.effect.REFRESH, 1, 3, 3600) -- Does indeed get overwriten by regular refresh. end, ['PROTECT'] = function() diff --git a/scripts/globals/spells/enhancing_spell.lua b/scripts/globals/spells/enhancing_spell.lua index a01478c21de..7ed69450a74 100644 --- a/scripts/globals/spells/enhancing_spell.lua +++ b/scripts/globals/spells/enhancing_spell.lua @@ -497,8 +497,8 @@ xi.spells.enhancing.useEnhancingSpell = function(caster, target, spell) -- Refresh elseif spellEffect == xi.effect.REFRESH then if - target:hasStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) or - target:hasStatusEffect(xi.effect.SUBLIMATION_COMPLETE) + tier < 3 and + (target:hasStatusEffect(xi.effect.SUBLIMATION_ACTIVATED) or target:hasStatusEffect(xi.effect.SUBLIMATION_COMPLETE)) then spell:setMsg(xi.msg.basic.MAGIC_NO_EFFECT) return 0