Core/Auras: Allow some whitelisted spells to update effect values of non-passive auras when adding spell mods

Port From (https://github.com/TrinityCore/TrinityCore/commit/3a19b8160d8e2c8f2c2b10380fcd3fe7468810e2)
This commit is contained in:
Hondacrx
2025-06-02 14:03:36 -04:00
parent 2043ac37f9
commit 7b0433c028
2 changed files with 43 additions and 31 deletions
+21 -22
View File
@@ -461,56 +461,55 @@ namespace Game.Spells
return; return;
// reapply some passive spells after add/remove related spellmods // reapply some passive spells after add/remove related spellmods
// Warning: it is a dead loop if 2 auras each other amount-shouldn't happen // Warning: it is a dead loop if 2 auras each other amount-shouldn't happen
BitSet recalculateEffectMask = new(SpellConst.MaxEffects); uint? recalculateEffectIndex = null;
switch ((SpellModOp)GetMiscValue()) switch ((SpellModOp)GetMiscValue())
{ {
case SpellModOp.Points: case SpellModOp.Points:
recalculateEffectMask.SetAll(true);
break; break;
case SpellModOp.PointsIndex0: case SpellModOp.PointsIndex0:
recalculateEffectMask.Set(0, true); recalculateEffectIndex = 0;
break; break;
case SpellModOp.PointsIndex1: case SpellModOp.PointsIndex1:
recalculateEffectMask.Set(1, true); recalculateEffectIndex = 1;
break; break;
case SpellModOp.PointsIndex2: case SpellModOp.PointsIndex2:
recalculateEffectMask.Set(2, true); recalculateEffectIndex = 2;
break; break;
case SpellModOp.PointsIndex3: case SpellModOp.PointsIndex3:
recalculateEffectMask.Set(3, true); recalculateEffectIndex = 3;
break; break;
case SpellModOp.PointsIndex4: case SpellModOp.PointsIndex4:
recalculateEffectMask.Set(4, true); recalculateEffectIndex = 4;
break; break;
default: default:
break; return;
} }
if (recalculateEffectMask.Any())
{
if (triggeredBy == null) if (triggeredBy == null)
triggeredBy = this; triggeredBy = this;
ObjectGuid guid = target.GetGUID(); ObjectGuid guid = target.GetGUID();
var auras = target.GetAppliedAuras(); var auras = target.GetAppliedAuras();
foreach (var iter in auras) foreach (var (_, aurApp) in auras)
{ {
Aura aura = iter.Value.GetBase(); Aura aura = aurApp.GetBase();
// only passive and permament auras-active auras should have amount set on spellcast and not be affected // 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 is cast by others, it will not be affected
if ((aura.IsPassive() || aura.IsPermanent()) && aura.GetCasterGUID() == guid && aura.GetSpellInfo().IsAffectedBySpellMod(m_spellmod)) if ((!aura.IsPassive() && !aura.IsPermanent() && !GetSpellInfo().IsUpdatingTemporaryAuraValuesBySpellMod())
|| aura.GetCasterGUID() != guid || !aura.GetSpellInfo().IsAffectedBySpellMod(m_spellmod))
continue;
if (recalculateEffectIndex.HasValue)
{ {
for (uint i = 0; i < recalculateEffectMask.Count; ++i) AuraEffect aurEff = aura.GetEffect(recalculateEffectIndex.Value);
{ if (aurEff != null && aurEff != triggeredBy)
if (recalculateEffectMask[(int)i])
{
AuraEffect aurEff = aura.GetEffect(i);
if (aurEff != null)
if (aurEff != triggeredBy)
aurEff.RecalculateAmount(triggeredBy); aurEff.RecalculateAmount(triggeredBy);
} }
} else
} {
foreach (AuraEffect aurEff in aura.GetAuraEffects())
if (aurEff != triggeredBy)
aurEff.RecalculateAmount(triggeredBy);
} }
} }
} }
+13
View File
@@ -677,6 +677,19 @@ namespace Game.Spells
return false; return false;
} }
public bool IsUpdatingTemporaryAuraValuesBySpellMod()
{
switch (Id)
{
case 384669: // Overflowing Maelstrom
return true;
default:
break;
}
return false;
}
public bool CanPierceImmuneAura(SpellInfo auraSpellInfo) public bool CanPierceImmuneAura(SpellInfo auraSpellInfo)
{ {
// Dispels other auras on immunity, check if this spell makes the unit immune to aura // Dispels other auras on immunity, check if this spell makes the unit immune to aura