Skip to content

Commit b7003bf

Browse files
JildorXenphis
authored andcommitted
Core/Spells: Send the appropriate SpellCastResult error when a spell with a cooldown event is on cooldown, depending on whether it has OnHold enabled. (#31887)
1 parent 6860f50 commit b7003bf

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/server/game/Spells/Spell.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5177,10 +5177,10 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
51775177

51785178
if (m_caster->ToUnit() && !m_caster->ToUnit()->GetSpellHistory()->IsReady(m_spellInfo, m_castItemEntry, IsIgnoringCooldowns()))
51795179
{
5180-
if (m_triggeredByAuraSpell || m_spellInfo->IsCooldownStartedOnEvent())
5180+
if (m_triggeredByAuraSpell || (m_spellInfo->IsCooldownStartedOnEvent() && !m_caster->ToUnit()->GetSpellHistory()->HasCooldownOnHold(m_spellInfo->Id)))
51815181
return SPELL_FAILED_DONT_REPORT;
5182-
else
5183-
return SPELL_FAILED_NOT_READY;
5182+
5183+
return SPELL_FAILED_NOT_READY;
51845184
}
51855185
}
51865186

src/server/game/Spells/SpellHistory.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,13 @@ bool SpellHistory::HasCooldown(uint32 spellId, uint32 itemId /*= 0*/, bool ignor
479479
return HasCooldown(sSpellMgr->AssertSpellInfo(spellId), itemId, ignoreCategoryCooldown);
480480
}
481481

482+
bool SpellHistory::HasCooldownOnHold(uint32 spellId) const
483+
{
484+
// TODO: Delete this function and make SpellHistory::IsReady return enum with reason instead of bool
485+
auto itr = _spellCooldowns.find(spellId);
486+
return itr != _spellCooldowns.end() && itr->second.OnHold;
487+
}
488+
482489
uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo) const
483490
{
484491
Clock::time_point end;

src/server/game/Spells/SpellHistory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class TC_GAME_API SpellHistory
122122
void ResetAllCooldowns();
123123
bool HasCooldown(SpellInfo const* spellInfo, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const;
124124
bool HasCooldown(uint32 spellId, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const;
125+
bool HasCooldownOnHold(uint32 spellId) const;
125126
uint32 GetRemainingCooldown(SpellInfo const* spellInfo) const;
126127

127128
// School lockouts

0 commit comments

Comments
 (0)