Core/Spells: Fix periodic rolling adding bonuses twice

Port From (https://github.com/TrinityCore/TrinityCore/commit/9fa95b4b57c1d843392d0c321cdabbc3a21e1d69)
This commit is contained in:
hondacrx
2021-09-08 22:52:23 -04:00
parent d3530ddf1c
commit f9779537a8
9 changed files with 16 additions and 34 deletions
-16
View File
@@ -2370,22 +2370,6 @@ namespace Game.Entities
m_Diminishing[i].Clear();
}
public uint GetRemainingPeriodicAmount(ObjectGuid caster, uint spellId, AuraType auraType, int effectIndex = 0)
{
uint amount = 0;
var periodicAuras = GetAuraEffectsByType(auraType);
foreach (var aurEff in periodicAuras)
{
if (aurEff.GetCasterGUID() != caster || aurEff.GetId() != spellId || aurEff.GetEffIndex() != effectIndex || aurEff.GetTotalTicks() == 0)
continue;
amount += (uint)((aurEff.GetAmount() * aurEff.GetRemainingTicks()) / aurEff.GetTotalTicks());
break;
}
return amount;
}
// Interrupts
public void InterruptNonMeleeSpells(bool withDelayed, uint spell_id = 0, bool withInstant = true)
{
+12
View File
@@ -58,6 +58,7 @@ namespace Game.Spells
targetList.Add(app.GetTarget());
}
}
void GetApplicationList(out List<AuraApplication> applicationList)
{
applicationList = new List<AuraApplication>();
@@ -120,6 +121,17 @@ namespace Game.Spells
break;
}
if (GetSpellInfo().HasAttribute(SpellAttr10.RollingPeriodic))
{
var periodicAuras = GetBase().GetUnitOwner().GetAuraEffectsByType(GetAuraType());
amount = periodicAuras.Aggregate(0, (val, aurEff) =>
{
if (aurEff.GetCasterGUID() == GetCasterGUID() && aurEff.GetId() == GetId() && aurEff.GetEffIndex() == GetEffIndex() && aurEff.GetTotalTicks() > 0)
val += aurEff.GetAmount() * (int)aurEff.GetRemainingTicks() / (int)aurEff.GetTotalTicks();
return val;
});
}
GetBase().CallScriptEffectCalcAmountHandlers(this, ref amount, ref m_canBeRecalculated);
if (!GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes.NoScaleWithStack))
amount *= GetBase().GetStackAmount();