Core/Spells: Ignore category cooldowns for triggered spells.

* This fixes weird issues where triggered spell fails because it has the same category as the spell triggering it

Closes #15794
Closes #15048
This commit is contained in:
Shauren
2016-01-22 22:11:11 +01:00
parent 2652d700e1
commit 044edced9a
5 changed files with 12 additions and 26 deletions
@@ -1342,18 +1342,11 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (apply)
{
// Remove cooldown of spells triggered on stance change - they may share cooldown with stance spell
if (spellId)
{
target->GetSpellHistory()->ResetCooldown(spellId);
target->CastSpell(target, spellId, true, NULL, this);
}
if (spellId2)
{
target->GetSpellHistory()->ResetCooldown(spellId2);
target->CastSpell(target, spellId2, true, NULL, this);
}
if (target->GetTypeId() == TYPEID_PLAYER)
{
+1 -1
View File
@@ -4708,7 +4708,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_READY;
}
if (!m_caster->GetSpellHistory()->IsReady(m_spellInfo, m_castItemEntry))
if (!m_caster->GetSpellHistory()->IsReady(m_spellInfo, m_castItemEntry, IsIgnoringCooldowns()))
{
if (m_triggeredByAuraSpell)
return SPELL_FAILED_DONT_REPORT;
-10
View File
@@ -780,11 +780,6 @@ void Spell::EffectTriggerSpell(SpellEffIndex /*effIndex*/)
values.AddSpellMod(SPELLVALUE_BASE_POINT2, damage);
}
// Remove spell cooldown (not category) if spell triggering spell with cooldown and same category
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->CategoryRecoveryTime && spellInfo->CategoryRecoveryTime
&& m_spellInfo->GetCategory() == spellInfo->GetCategory())
m_caster->GetSpellHistory()->ResetCooldown(spellInfo->Id);
// original caster guid only for GO cast
m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, NULL, NULL, m_originalCasterGUID);
}
@@ -833,11 +828,6 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex /*effIndex*/)
values.AddSpellMod(SPELLVALUE_BASE_POINT2, damage);
}
// Remove spell cooldown (not category) if spell triggering spell with cooldown and same category
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->CategoryRecoveryTime && spellInfo->CategoryRecoveryTime
&& m_spellInfo->GetCategory() == spellInfo->GetCategory())
m_caster->GetSpellHistory()->ResetCooldown(spellInfo->Id);
// original caster guid only for GO cast
m_caster->CastSpell(targets, spellInfo, &values, TRIGGERED_FULL_MASK, NULL, NULL, m_originalCasterGUID);
}
+8 -5
View File
@@ -258,13 +258,13 @@ void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Sp
StartCooldown(spellInfo, itemID, spell);
}
bool SpellHistory::IsReady(SpellInfo const* spellInfo, uint32 itemId /*= 0*/) const
bool SpellHistory::IsReady(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, bool ignoreCategoryCooldown /*= false*/) const
{
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
if (IsSchoolLocked(spellInfo->GetSchoolMask()))
return false;
if (HasCooldown(spellInfo->Id, itemId))
if (HasCooldown(spellInfo->Id, itemId, ignoreCategoryCooldown))
return false;
if (!HasCharge(spellInfo->ChargeCategoryEntry))
@@ -589,11 +589,14 @@ void SpellHistory::ResetAllCooldowns()
_spellCooldowns.clear();
}
bool SpellHistory::HasCooldown(SpellInfo const* spellInfo, uint32 itemId /*= 0*/) const
bool SpellHistory::HasCooldown(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, bool ignoreCategoryCooldown /*= false*/) const
{
if (_spellCooldowns.count(spellInfo->Id) != 0)
return true;
if (ignoreCategoryCooldown)
return false;
uint32 category = 0;
GetCooldownDurations(spellInfo, itemId, nullptr, &category, nullptr);
if (!category)
@@ -602,9 +605,9 @@ bool SpellHistory::HasCooldown(SpellInfo const* spellInfo, uint32 itemId /*= 0*/
return _categoryCooldowns.count(category) != 0;
}
bool SpellHistory::HasCooldown(uint32 spellId, uint32 itemId /*= 0*/) const
bool SpellHistory::HasCooldown(uint32 spellId, uint32 itemId /*= 0*/, bool ignoreCategoryCooldown /*= false*/) const
{
return HasCooldown(sSpellMgr->AssertSpellInfo(spellId), itemId);
return HasCooldown(sSpellMgr->AssertSpellInfo(spellId), itemId, ignoreCategoryCooldown);
}
uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo) const
+3 -3
View File
@@ -81,7 +81,7 @@ public:
void HandleCooldowns(SpellInfo const* spellInfo, Item const* item, Spell* spell = nullptr);
void HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell = nullptr);
bool IsReady(SpellInfo const* spellInfo, uint32 itemId = 0) const;
bool IsReady(SpellInfo const* spellInfo, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const;
template<class PacketType>
void WritePacket(PacketType* packet) const;
@@ -123,8 +123,8 @@ public:
}
void ResetAllCooldowns();
bool HasCooldown(SpellInfo const* spellInfo, uint32 itemId = 0) const;
bool HasCooldown(uint32 spellId, uint32 itemId = 0) const;
bool HasCooldown(SpellInfo const* spellInfo, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const;
bool HasCooldown(uint32 spellId, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const;
uint32 GetRemainingCooldown(SpellInfo const* spellInfo) const;
// School lockouts