Core/Auras: fixed off by one error in counting SPELL_ATTR5_START_PERIODIC_AT_APPLY ticks
Port From (https://github.com/TrinityCore/TrinityCore/commit/794a3e43887d3fea4bb9b1ec77a98ab596eea0be)
This commit is contained in:
@@ -125,15 +125,29 @@ namespace Game.Spells
|
|||||||
amount *= GetBase().GetStackAmount();
|
amount *= GetBase().GetStackAmount();
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint GetTotalTicks()
|
||||||
|
{
|
||||||
|
uint totalTicks = 0;
|
||||||
|
if (_period != 0 && !GetBase().IsPermanent())
|
||||||
|
{
|
||||||
|
totalTicks = (uint)(GetBase().GetMaxDuration() / _period);
|
||||||
|
if (m_spellInfo.HasAttribute(SpellAttr5.StartPeriodicAtApply))
|
||||||
|
++totalTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalTicks;
|
||||||
|
}
|
||||||
|
|
||||||
void ResetPeriodic(bool resetPeriodicTimer = false)
|
void ResetPeriodic(bool resetPeriodicTimer = false)
|
||||||
{
|
{
|
||||||
_ticksDone = 0;
|
_ticksDone = 0;
|
||||||
if (resetPeriodicTimer)
|
if (resetPeriodicTimer)
|
||||||
{
|
{
|
||||||
_periodicTimer = _period;
|
_periodicTimer = 0;
|
||||||
// Start periodic on next tick or at aura apply
|
// Start periodic on next tick or at aura apply
|
||||||
if (!m_spellInfo.HasAttribute(SpellAttr5.StartPeriodicAtApply))
|
if (m_spellInfo.HasAttribute(SpellAttr5.StartPeriodicAtApply))
|
||||||
_periodicTimer = 0;
|
_periodicTimer = _period;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void CalculatePeriodic(Unit caster, bool resetPeriodicTimer = true, bool load = false)
|
public void CalculatePeriodic(Unit caster, bool resetPeriodicTimer = true, bool load = false)
|
||||||
@@ -401,26 +415,27 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public void Update(uint diff, Unit caster)
|
public void Update(uint diff, Unit caster)
|
||||||
{
|
{
|
||||||
if (m_isPeriodic && (GetBase().GetDuration() >= 0 || GetBase().IsPassive() || GetBase().IsPermanent()))
|
if (!m_isPeriodic || (GetBase().GetDuration() < 0 && !GetBase().IsPassive() && !GetBase().IsPermanent()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint totalTicks = GetTotalTicks();
|
||||||
|
|
||||||
|
_periodicTimer += (int)diff;
|
||||||
|
while (_periodicTimer >= _period)
|
||||||
{
|
{
|
||||||
_periodicTimer += (int)diff;
|
_periodicTimer -= _period;
|
||||||
while (_periodicTimer >= _period)
|
|
||||||
{
|
|
||||||
_periodicTimer -= _period;
|
|
||||||
|
|
||||||
if (!GetBase().IsPermanent() && (_ticksDone + 1) > GetTotalTicks())
|
if (!GetBase().IsPermanent() && (_ticksDone + 1) > totalTicks)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
++_ticksDone;
|
++_ticksDone;
|
||||||
|
|
||||||
GetBase().CallScriptEffectUpdatePeriodicHandlers(this);
|
GetBase().CallScriptEffectUpdatePeriodicHandlers(this);
|
||||||
|
|
||||||
GetApplicationList(out List<AuraApplication> effectApplications);
|
GetApplicationList(out List<AuraApplication> effectApplications);
|
||||||
// tick on targets of effects
|
// tick on targets of effects
|
||||||
foreach (var appt in effectApplications)
|
foreach (var appt in effectApplications)
|
||||||
if (appt.HasEffect(GetEffIndex()))
|
PeriodicTick(appt, caster);
|
||||||
PeriodicTick(appt, caster);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -796,7 +811,6 @@ namespace Game.Spells
|
|||||||
public void ResetTicks() { _ticksDone = 0; }
|
public void ResetTicks() { _ticksDone = 0; }
|
||||||
public uint GetTickNumber() { return _ticksDone; }
|
public uint GetTickNumber() { return _ticksDone; }
|
||||||
public uint GetRemainingTicks() { return GetTotalTicks() - _ticksDone; }
|
public uint GetRemainingTicks() { return GetTotalTicks() - _ticksDone; }
|
||||||
public uint GetTotalTicks() { return (_period != 0 && !GetBase().IsPermanent()) ? (uint)(GetBase().GetMaxDuration() / _period) : 0u; }
|
|
||||||
|
|
||||||
public bool IsPeriodic() { return m_isPeriodic; }
|
public bool IsPeriodic() { return m_isPeriodic; }
|
||||||
public void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; }
|
public void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; }
|
||||||
|
|||||||
@@ -2652,9 +2652,8 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public uint GetMaxTicks()
|
public uint GetMaxTicks()
|
||||||
{
|
{
|
||||||
|
uint totalTicks = 0;
|
||||||
int DotDuration = GetDuration();
|
int DotDuration = GetDuration();
|
||||||
if (DotDuration == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
foreach (SpellEffectInfo effect in _effects)
|
foreach (SpellEffectInfo effect in _effects)
|
||||||
{
|
{
|
||||||
@@ -2676,14 +2675,19 @@ namespace Game.Spells
|
|||||||
case AuraType.PeriodicTriggerSpell:
|
case AuraType.PeriodicTriggerSpell:
|
||||||
case AuraType.PeriodicTriggerSpellWithValue:
|
case AuraType.PeriodicTriggerSpellWithValue:
|
||||||
case AuraType.PeriodicHealthFunnel:
|
case AuraType.PeriodicHealthFunnel:
|
||||||
if (effect.ApplyAuraPeriod != 0)
|
// skip infinite periodics
|
||||||
return (uint)(DotDuration / effect.ApplyAuraPeriod);
|
if (effect.ApplyAuraPeriod > 0 && DotDuration > 0)
|
||||||
|
{
|
||||||
|
totalTicks = (uint)DotDuration / effect.ApplyAuraPeriod;
|
||||||
|
if (HasAttribute(SpellAttr5.StartPeriodicAtApply))
|
||||||
|
++totalTicks;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 6;
|
return totalTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GetRecoveryTime()
|
public uint GetRecoveryTime()
|
||||||
|
|||||||
Reference in New Issue
Block a user