diff --git a/scripts/globals/job_utils/rune_fencer.lua b/scripts/globals/job_utils/rune_fencer.lua index 89e08b030ed..3462ee836cf 100644 --- a/scripts/globals/job_utils/rune_fencer.lua +++ b/scripts/globals/job_utils/rune_fencer.lua @@ -296,8 +296,7 @@ local function applyVallationValianceSDTMods(target, SDTTypes, power, effect, du local newEffect = target:getStatusEffect(effect) for _, SDT in ipairs(SDTTypes) do - target:addMod(SDT, power) - newEffect:addMod(SDT, power) -- due to order of events, this only adds mods to the container, not to the owner of the effect. + newEffect:addMod(SDT, power) end end end @@ -309,8 +308,7 @@ local function applyGambitSDTMods(target, SDTTypes, power, effect, duration) -- local newEffect = target:getStatusEffect(effect) for _, SDT in ipairs(SDTTypes) do - target:addMod(SDT, power) - newEffect:addMod(SDT, power) -- due to order of events, this only adds mods to the container, not to the owner of the effect. + newEffect:addMod(SDT, power) end end end @@ -695,7 +693,7 @@ local function addPflugResistType(type, effect, power) local resistTypes = pflugResistTypes[type] - for _, resistMod in pairs(resistTypes) do -- store mod in effect, this function is triggered from event onEffectGain so it adds to the player automatically. + for _, resistMod in pairs(resistTypes) do effect:addMod(resistMod, power) end end @@ -782,7 +780,6 @@ xi.job_utils.rune_fencer.useRayke = function(player, target, ability, action) local element = getRaykeElement(rune) raykeElements = raykeElements + bit.lshift(element, 4 * i) -- pack 4 bit damage type into 16 bit int - target:addMod(resRankMod, -1) effect:addMod(resRankMod, -1) -- Status effect handles removing the mods i = i + 1 diff --git a/src/map/lua/lua_statuseffect.cpp b/src/map/lua/lua_statuseffect.cpp index ad49105e321..19859ed57e5 100644 --- a/src/map/lua/lua_statuseffect.cpp +++ b/src/map/lua/lua_statuseffect.cpp @@ -23,8 +23,8 @@ #include "common/timer.h" #include "lua_statuseffect.h" -#include "status_effect_container.h" #include "status_effect.h" +#include "status_effect_container.h" #include "entities/battleentity.h" @@ -207,6 +207,14 @@ void CLuaStatusEffect::setStartTime(uint32 time) void CLuaStatusEffect::addMod(uint16 mod, int16 amount) { m_PLuaStatusEffect->addMod(static_cast(mod), amount); + + // Since an effect's mod list is only applied to entity when adding the effect + // we need to add the mod to the entity manually if the effect is already applied + auto* PBattleEntity = dynamic_cast(m_PBaseEntity); + if (PBattleEntity) + { + PBattleEntity->addModifier(static_cast(mod), amount); + } } //======================================================// diff --git a/src/map/status_effect_container.h b/src/map/status_effect_container.h index c9d6e34536c..7d9d8d5eb71 100644 --- a/src/map/status_effect_container.h +++ b/src/map/status_effect_container.h @@ -133,7 +133,7 @@ class CStatusEffectContainer CBattleEntity* m_POwner = nullptr; // void ReplaceStatusEffect(EFFECT effect); //this needs to be implemented - void RemoveStatusEffect(uint32 id, bool silent = false); // We remove the effect by its number in the container + void RemoveStatusEffect(uint32 id, bool silent = false); // We remove the effect by its number in the container void DeleteStatusEffects(); void SetEffectParams(CStatusEffect* StatusEffect); // We set the effect of the effect void HandleAura(CStatusEffect* PStatusEffect);