Implement Global Cooldown (originaly written for TC2 v2.4.3).

Thanks eugen.rivniy for the port.
Fixes issue #67.

--HG--
branch : trunk
This commit is contained in:
Trazom62
2010-04-09 20:10:55 +02:00
parent 0c22e5ac99
commit bca335f9bd
3 changed files with 59 additions and 1 deletions

View File

@@ -2756,6 +2756,9 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const * triggere
m_caster->SetCurrentCastedSpell(this);
SendSpellStart();
if (m_caster->GetTypeId() == TYPEID_PLAYER)
m_caster->ToPlayer()->AddGlobalCooldown(m_spellInfo,this);
if (!m_casttime && !m_spellInfo->StartRecoveryTime
&& !m_castItemGUID //item: first cast may destroy item and second cast causes crash
&& GetCurrentContainer() == CURRENT_GENERIC_SPELL)
@@ -2798,7 +2801,10 @@ void Spell::cancel()
// spell is canceled-take mods and clear list
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_caster->ToPlayer()->RemoveGlobalCooldown(m_spellInfo);
m_caster->ToPlayer()->RemoveSpellMods(this);
}
m_appliedMods.clear();
} break;
@@ -4415,7 +4421,8 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!m_IsTriggeredSpell && m_caster->ToPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_ALLOW_ONLY_ABILITY))
return SPELL_FAILED_SPELL_IN_PROGRESS;
if (m_caster->ToPlayer()->HasSpellCooldown(m_spellInfo->Id))
if (m_caster->ToPlayer()->HasSpellCooldown(m_spellInfo->Id) ||
(strict && !m_IsTriggeredSpell && m_caster->ToPlayer()->HasGlobalCooldown(m_spellInfo)))
{
if (m_triggeredByAuraSpell)
return SPELL_FAILED_DONT_REPORT;