Core/Spells: Add function for modify cooldown

Thx shauren for helping
This commit is contained in:
Vincent-Michael committed 2013-06-16 22:55:14 +02:00
1 parent 8c42b4ce8a
commit d2e1b7421a
2 files changed
+22

No files matched your search

@@ -22238,6 +22238,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(LOG_FILTER_GENERAL, "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
+1
View File
@@ -1836,6 +1836,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);