diff options
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 51 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 4 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 16 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_druid.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_mage.cpp | 1 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_paladin.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_priest.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_shaman.cpp | 6 |
8 files changed, 59 insertions, 25 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 8132912170a..797c0ce72bf 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -672,15 +672,28 @@ int32 AuraEffect::CalculateAmount(Unit* caster) return amount; } +uint32 AuraEffect::GetTotalTicks() const +{ + uint32 totalTicks = 0; + if (_period && !GetBase()->IsPermanent()) + { + totalTicks = static_cast<uint32>(GetBase()->GetMaxDuration() / _period); + if (m_spellInfo->HasAttribute(SPELL_ATTR5_START_PERIODIC_AT_APPLY)) + ++totalTicks; + } + + return totalTicks; +} + void AuraEffect::ResetPeriodic(bool resetPeriodicTimer /*= false*/) { _ticksDone = 0; if (resetPeriodicTimer) { - _periodicTimer = _period; + _periodicTimer = 0; // Start periodic on next tick or at aura apply - if (!m_spellInfo->HasAttribute(SPELL_ATTR5_START_PERIODIC_AT_APPLY)) - _periodicTimer = 0; + if (m_spellInfo->HasAttribute(SPELL_ATTR5_START_PERIODIC_AT_APPLY)) + _periodicTimer = _period; } } @@ -947,27 +960,29 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply) void AuraEffect::Update(uint32 diff, Unit* caster) { - if (m_isPeriodic && (GetBase()->GetDuration() >= 0 || GetBase()->IsPassive() || GetBase()->IsPermanent())) + if (!m_isPeriodic || (GetBase()->GetDuration() < 0 && !GetBase()->IsPassive() && !GetBase()->IsPermanent())) + return; + + uint32 totalTicks = GetTotalTicks(); + + _periodicTimer += diff; + while (_periodicTimer >= _period) { - _periodicTimer += diff; - while (_periodicTimer >= _period) - { - _periodicTimer -= _period; + _periodicTimer -= _period; - if (!GetBase()->IsPermanent() && (_ticksDone + 1) > GetTotalTicks()) - break; + if (!GetBase()->IsPermanent() && (_ticksDone + 1) > totalTicks) + break; - ++_ticksDone; + ++_ticksDone; - GetBase()->CallScriptEffectUpdatePeriodicHandlers(this); + GetBase()->CallScriptEffectUpdatePeriodicHandlers(this); - std::vector<AuraApplication*> effectApplications; - GetApplicationList(effectApplications); + std::vector<AuraApplication*> effectApplications; + GetApplicationList(effectApplications); - // tick on targets of effects - for (AuraApplication* aurApp : effectApplications) - PeriodicTick(aurApp, caster); - } + // tick on targets of effects + for (AuraApplication* aurApp : effectApplications) + PeriodicTick(aurApp, caster); } } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index c2e5ae24759..6503878de89 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -81,11 +81,11 @@ class TC_GAME_API AuraEffect void Update(uint32 diff, Unit* caster); - void ResetTicks() { _ticksDone = 0; } uint32 GetTickNumber() const { return _ticksDone; } uint32 GetRemainingTicks() const { return GetTotalTicks() - _ticksDone; } - uint32 GetTotalTicks() const { return (_period && !GetBase()->IsPermanent()) ? uint32(GetBase()->GetMaxDuration() / _period) : uint32(0); } + uint32 GetTotalTicks() const; void ResetPeriodic(bool resetPeriodicTimer = false); + void ResetTicks() { _ticksDone = 0; } bool IsPeriodic() const { return m_isPeriodic; } void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; } diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 53a732c1390..38ec721e822 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -3722,13 +3722,13 @@ uint32 SpellInfo::CalcCastTime(Spell* spell /*= nullptr*/) const uint32 SpellInfo::GetMaxTicks() const { + uint32 totalTicks = 0; int32 DotDuration = GetDuration(); - if (DotDuration == 0) - return 1; for (SpellEffectInfo const* effect : _effects) { if (effect && effect->Effect == SPELL_EFFECT_APPLY_AURA) + { switch (effect->ApplyAuraName) { case SPELL_AURA_PERIODIC_DAMAGE: @@ -3745,13 +3745,19 @@ uint32 SpellInfo::GetMaxTicks() const case SPELL_AURA_PERIODIC_TRIGGER_SPELL: case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE: case SPELL_AURA_PERIODIC_HEALTH_FUNNEL: - if (effect->ApplyAuraPeriod != 0) - return DotDuration / effect->ApplyAuraPeriod; + // skip infinite periodics + if (effect->ApplyAuraPeriod > 0 && DotDuration > 0) + { + totalTicks = static_cast<uint32>(DotDuration) / effect->ApplyAuraPeriod; + if (HasAttribute(SPELL_ATTR5_START_PERIODIC_AT_APPLY)) + ++totalTicks; + } break; } + } } - return 6; + return totalTicks; } uint32 SpellInfo::GetRecoveryTime() const diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 5719b684ccd..c46909bdf13 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -1383,6 +1383,8 @@ public: SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_DRUID_LANGUISH, GetCastDifficulty()); int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()); + + ASSERT(spellInfo->GetMaxTicks() > 0); amount /= spellInfo->GetMaxTicks(); // Add remaining ticks to damage done amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_DRUID_LANGUISH, SPELL_AURA_PERIODIC_DAMAGE); diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index 8dc3e31f781..c30f9b22643 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -452,6 +452,7 @@ class spell_mage_ignite : public AuraScript SpellInfo const* igniteDot = sSpellMgr->AssertSpellInfo(SPELL_MAGE_IGNITE, GetCastDifficulty()); int32 pct = aurEff->GetAmount(); + ASSERT(igniteDot->GetMaxTicks() > 0); int32 amount = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), pct) / igniteDot->GetMaxTicks()); amount += eventInfo.GetProcTarget()->GetRemainingPeriodicAmount(eventInfo.GetActor()->GetGUID(), SPELL_MAGE_IGNITE, SPELL_AURA_PERIODIC_DAMAGE); GetTarget()->CastCustomSpell(SPELL_MAGE_IGNITE, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, nullptr, aurEff); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 4cf7d5e5a2c..2b4b568fa57 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -1028,6 +1028,8 @@ class spell_pal_t8_2p_bonus : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_PALADIN_HOLY_MENDING, GetCastDifficulty()); int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount()); + + ASSERT(spellInfo->GetMaxTicks() > 0); amount /= spellInfo->GetMaxTicks(); // Add remaining ticks to damage done amount += target->GetRemainingPeriodicAmount(caster->GetGUID(), SPELL_PALADIN_HOLY_MENDING, SPELL_AURA_PERIODIC_HEAL); diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index d041d45032a..c4c63b35ee3 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -878,6 +878,8 @@ class spell_pri_t10_heal_2p_bonus : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_BLESSED_HEALING, GetCastDifficulty()); int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount()); + + ASSERT(spellInfo->GetMaxTicks() > 0); amount /= spellInfo->GetMaxTicks(); // Add remaining ticks to healing done diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 48fda95f406..e2052359cc0 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -1081,6 +1081,8 @@ class spell_sha_t8_elemental_4p_bonus : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_SHAMAN_ELECTRIFIED, GetCastDifficulty()); int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()); + + ASSERT(spellInfo->GetMaxTicks() > 0); amount /= spellInfo->GetMaxTicks(); // Add remaining ticks to damage done @@ -1128,6 +1130,8 @@ class spell_sha_t9_elemental_4p_bonus : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_SHAMAN_LAVA_BURST_BONUS_DAMAGE, GetCastDifficulty()); int32 amount = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()); + + ASSERT(spellInfo->GetMaxTicks() > 0); amount /= spellInfo->GetMaxTicks(); // Add remaining ticks to damage done @@ -1220,6 +1224,8 @@ class spell_sha_t10_restoration_4p_bonus : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(SPELL_SHAMAN_CHAINED_HEAL, GetCastDifficulty()); int32 amount = CalculatePct(static_cast<int32>(healInfo->GetHeal()), aurEff->GetAmount()); + + ASSERT(spellInfo->GetMaxTicks() > 0); amount /= spellInfo->GetMaxTicks(); // Add remaining ticks to healing done |