diff options
author | Vincent-Michael <Vincent_Michael@gmx.de> | 2013-06-16 22:55:14 +0200 |
---|---|---|
committer | Vincent-Michael <Vincent_Michael@gmx.de> | 2014-07-07 11:47:29 +0200 |
commit | cb22fe570d602953e5902278a88c959c490e3868 (patch) | |
tree | 13fbddb527f6e61ee9c111a042557e88986dad25 | |
parent | a6494375f9839b8c428c8daa508b9ca93caa0575 (diff) |
Core/Spells: Add function for modify cooldown
Thx shauren for helping
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 21 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9fac78bc5a0..5c96e607355 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -22061,6 +22061,27 @@ void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) m_spellCooldowns[spellid] = sc; } +void Player::ModifySpellCooldown(uint32 spellId, int32 cooldown) +{ + SpellCooldowns::iterator itr = m_spellCooldowns.find(spellId); + if (itr == m_spellCooldowns.end()) + return; + + time_t now = time(NULL); + if (itr->second.end + (cooldown / IN_MILLISECONDS) > now) + itr->second.end += (cooldown / IN_MILLISECONDS); + else + m_spellCooldowns.erase(itr); + + WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4); + data << uint32(spellId); // Spell ID + data << uint64(GetGUID()); // Player GUID + data << int32(cooldown); // Cooldown mod in milliseconds + GetSession()->SendPacket(&data); + + TC_LOG_DEBUG("misc", "ModifySpellCooldown:: Player: %s (GUID: %u) Spell: %u cooldown: %u", GetName().c_str(), GetGUIDLow(), spellId, GetSpellCooldownDelay(spellId)); +} + void Player::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, Spell* spell /*= NULL*/, bool setCooldown /*= true*/) { // start cooldowns at server side, if any diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 5f500b7f1d8..a146b5d672a 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1647,6 +1647,7 @@ class Player : public Unit, public GridObject<Player> uint32 GetSpellCooldownDelay(uint32 spell_id) const; void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false); void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); + void ModifySpellCooldown(uint32 spellId, int32 cooldown); void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true); void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs); void RemoveSpellCooldown(uint32 spell_id, bool update = false); |