diff options
author | Trazom62 <none@none> | 2010-04-09 20:10:55 +0200 |
---|---|---|
committer | Trazom62 <none@none> | 2010-04-09 20:10:55 +0200 |
commit | bca335f9bd4e11e42d13613d4e8a98695a990c8a (patch) | |
tree | 6041dbeeda0b147101f3d33326273a6c8e5fbfbd /src/game/Player.cpp | |
parent | 0c22e5ac994ae5b039a4d011493428e1e88c6404 (diff) |
Implement Global Cooldown (originaly written for TC2 v2.4.3).
Thanks eugen.rivniy for the port.
Fixes issue #67.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 34b5bde73b0..762af7b0a48 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -498,6 +498,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa for (int i = 0; i < MAX_POWERS; ++i) m_powerFraction[i] = 0; + + m_globalCooldowns.clear(); } Player::~Player () @@ -1144,6 +1146,17 @@ void Player::Update(uint32 p_time) m_nextMailDelivereTime = 0; } + for (std::map<uint32, uint32>::iterator itr = m_globalCooldowns.begin(); itr != m_globalCooldowns.end(); ++itr) + { + if (itr->second) + { + if (itr->second > p_time) + itr->second -= p_time; + else + itr->second = 0; + } + } + // If this is set during update SetSpellModTakingSpell call is missing somewhere in the code // Having this would prevent more aura charges to be dropped, so let's crash //assert (!m_spellModTakingSpell); @@ -22034,6 +22047,38 @@ void Player::UpdateCharmedAI() } } +void Player::AddGlobalCooldown(SpellEntry const *spellInfo, Spell const *spell) +{ + if (!spellInfo || !spellInfo->StartRecoveryTime) + return; + + uint32 cdTime = spellInfo->StartRecoveryTime; + + if (!(spellInfo->Attributes & (SPELL_ATTR_UNK4|SPELL_ATTR_PASSIVE))) + cdTime *= GetFloatValue(UNIT_MOD_CAST_SPEED); + else if (IsRangedWeaponSpell(spellInfo) && !spell->IsAutoRepeat()) + cdTime *= m_modAttackSpeedPct[RANGED_ATTACK]; + + m_globalCooldowns[spellInfo->StartRecoveryCategory] = ((cdTime < 1000 || cdTime > 2000) ? 1000 : cdTime); +} + +bool Player::HasGlobalCooldown(SpellEntry const *spellInfo) const +{ + if (!spellInfo) + return false; + + std::map<uint32, uint32>::const_iterator itr = m_globalCooldowns.find(spellInfo->StartRecoveryCategory); + return itr != m_globalCooldowns.end() && (itr->second > sWorld.GetUpdateTime()); +} + +void Player::RemoveGlobalCooldown(SpellEntry const *spellInfo) +{ + if (!spellInfo) + return; + + m_globalCooldowns[spellInfo->StartRecoveryCategory] = 0; +} + uint32 Player::GetRuneBaseCooldown(uint8 index) { uint8 rune = GetBaseRune(index); |