fix(Core/Spells): Periodic ticks number should not exceed the max one. (#10999)

Fixes #10876
This commit is contained in:
UltraNix
2022-03-15 21:33:44 +01:00
committed by GitHub
parent a24af63167
commit b025ec999e
2 changed files with 24 additions and 1 deletions

View File

@@ -892,9 +892,16 @@ void AuraEffect::Update(uint32 diff, Unit* caster)
{
if (m_isPeriodic && (GetBase()->GetDuration() >= 0 || GetBase()->IsPassive() || GetBase()->IsPermanent()))
{
uint32 totalTicks = GetTotalTicks();
m_periodicTimer -= int32(diff);
while (m_periodicTimer <= 0)
{
if (!GetBase()->IsPermanent() && (m_tickNumber + 1) > totalTicks)
{
break;
}
++m_tickNumber;
// update before tick (aura can be removed in TriggerSpell or PeriodicTick calls)
@@ -6993,3 +7000,19 @@ void AuraEffect::HandleRaidProcFromChargeWithValueAuraProc(AuraApplication* aurA
LOG_DEBUG("spells.aura", "AuraEffect::HandleRaidProcFromChargeWithValueAuraProc: Triggering spell {} from aura {} proc", triggerSpellId, GetId());
target->CastCustomSpell(target, triggerSpellId, &value, nullptr, nullptr, true, nullptr, this, GetCasterGUID());
}
int32 AuraEffect::GetTotalTicks() const
{
uint32 totalTicks = 1;
if (m_amplitude)
{
totalTicks = GetBase()->GetMaxDuration() / m_amplitude;
if (m_spellInfo->HasAttribute(SPELL_ATTR5_EXTRA_INITIAL_PERIOD))
{
++totalTicks;
}
}
return totalTicks;
}

View File

@@ -84,7 +84,7 @@ public:
void UpdatePeriodic(Unit* caster);
uint32 GetTickNumber() const { return m_tickNumber; }
int32 GetTotalTicks() const { return m_amplitude ? (GetBase()->GetMaxDuration() / m_amplitude) : 1;}
int32 GetTotalTicks() const;
void ResetPeriodic(bool resetPeriodicTimer = false) { if (resetPeriodicTimer) m_periodicTimer = m_amplitude; m_tickNumber = 0;}
void ResetTicks() { m_tickNumber = 0; }