mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Auras: Allow some whitelisted spells to update effect values of non-passive auras when adding spell mods
This commit is contained in:
@@ -1168,50 +1168,53 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply, AuraEffect const* trigg
|
||||
|
||||
// reapply some passive spells after add/remove related spellmods
|
||||
// Warning: it is a dead loop if 2 auras each other amount-shouldn't happen
|
||||
std::bitset<MAX_SPELL_EFFECTS> recalculateEffectMask;
|
||||
Optional<SpellEffIndex> recalculateEffectIndex;
|
||||
switch (SpellModOp(GetMiscValue()))
|
||||
{
|
||||
case SpellModOp::Points:
|
||||
recalculateEffectMask.set();
|
||||
break;
|
||||
case SpellModOp::PointsIndex0:
|
||||
recalculateEffectMask.set(EFFECT_0);
|
||||
recalculateEffectIndex = EFFECT_0;
|
||||
break;
|
||||
case SpellModOp::PointsIndex1:
|
||||
recalculateEffectMask.set(EFFECT_1);
|
||||
recalculateEffectIndex = EFFECT_1;
|
||||
break;
|
||||
case SpellModOp::PointsIndex2:
|
||||
recalculateEffectMask.set(EFFECT_2);
|
||||
recalculateEffectIndex = EFFECT_2;
|
||||
break;
|
||||
case SpellModOp::PointsIndex3:
|
||||
recalculateEffectMask.set(EFFECT_3);
|
||||
recalculateEffectIndex = EFFECT_3;
|
||||
break;
|
||||
case SpellModOp::PointsIndex4:
|
||||
recalculateEffectMask.set(EFFECT_4);
|
||||
recalculateEffectIndex = EFFECT_4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
if (recalculateEffectMask.any())
|
||||
{
|
||||
if (!triggeredBy)
|
||||
triggeredBy = this;
|
||||
if (!triggeredBy)
|
||||
triggeredBy = this;
|
||||
|
||||
ObjectGuid guid = target->GetGUID();
|
||||
Unit::AuraApplicationMap& auras = target->GetAppliedAuras();
|
||||
for (auto iter = auras.begin(); iter != auras.end(); ++iter)
|
||||
ObjectGuid guid = target->GetGUID();
|
||||
for (auto& [_, aurApp] : target->GetAppliedAuras())
|
||||
{
|
||||
Aura* aura = aurApp->GetBase();
|
||||
// only passive and permament auras-active auras should have amount set on spellcast and not be affected
|
||||
// if aura is cast by others, it will not be affected
|
||||
if ((!aura->IsPassive() && !aura->IsPermanent() && !GetSpellInfo()->IsUpdatingTemporaryAuraValuesBySpellMod())
|
||||
|| aura->GetCasterGUID() != guid || !aura->GetSpellInfo()->IsAffectedBySpellMod(m_spellmod))
|
||||
continue;
|
||||
|
||||
if (recalculateEffectIndex)
|
||||
{
|
||||
Aura* aura = iter->second->GetBase();
|
||||
// only passive and permament auras-active auras should have amount set on spellcast and not be affected
|
||||
// if aura is cast by others, it will not be affected
|
||||
if ((aura->IsPassive() || aura->IsPermanent()) && aura->GetCasterGUID() == guid && aura->GetSpellInfo()->IsAffectedBySpellMod(m_spellmod))
|
||||
for (size_t i = 0; i < recalculateEffectMask.size(); ++i)
|
||||
if (recalculateEffectMask[i])
|
||||
if (AuraEffect* aurEff = aura->GetEffect(i))
|
||||
if (aurEff != triggeredBy)
|
||||
aurEff->RecalculateAmount(triggeredBy);
|
||||
if (AuraEffect* aurEff = aura->GetEffect(*recalculateEffectIndex))
|
||||
if (aurEff != triggeredBy)
|
||||
aurEff->RecalculateAmount(triggeredBy);
|
||||
}
|
||||
else
|
||||
for (AuraEffect* aurEff : aura->GetAuraEffects())
|
||||
if (aurEff != triggeredBy)
|
||||
aurEff->RecalculateAmount(triggeredBy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1881,6 +1881,19 @@ bool SpellInfo::IsAffectedBySpellMod(SpellModifier const* mod) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpellInfo::IsUpdatingTemporaryAuraValuesBySpellMod() const
|
||||
{
|
||||
switch (Id)
|
||||
{
|
||||
case 384669: // Overflowing Maelstrom
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpellInfo::CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const
|
||||
{
|
||||
// Dispels other auras on immunity, check if this spell makes the unit immune to aura
|
||||
|
||||
@@ -516,6 +516,7 @@ class TC_GAME_API SpellInfo
|
||||
|
||||
bool IsAffectedBySpellMods() const;
|
||||
bool IsAffectedBySpellMod(SpellModifier const* mod) const;
|
||||
bool IsUpdatingTemporaryAuraValuesBySpellMod() const;
|
||||
|
||||
bool CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const;
|
||||
bool CanDispelAura(SpellInfo const* auraSpellInfo) const;
|
||||
|
||||
Reference in New Issue
Block a user