mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 21:26:23 +00:00
fix(Core/Spells): several improvements to cooldowns (#7559)
- Reworked spell category cooldowns. - Implemented category cooldowns for pets. - Properly shows pet spell cooldowns in player's UI. - Corrected pet spell cooldowns with infinity duration. - Do not add/remove infinity spell cooldown on aura apply/remove if casted by item. - Closes #5263
This commit is contained in:
@@ -2547,9 +2547,12 @@ bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time)
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, uint16 categoryId, uint32 end_time)
|
||||
{
|
||||
m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS() + end_time;
|
||||
CreatureSpellCooldown spellCooldown;
|
||||
spellCooldown.category = categoryId;
|
||||
spellCooldown.end = World::GetGameTimeMS() + end_time;
|
||||
m_CreatureSpellCooldowns[spell_id] = std::move(spellCooldown);
|
||||
}
|
||||
|
||||
void Creature::AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool /*needSendToClient*/, bool /*forceSendToSpectator*/)
|
||||
@@ -2561,33 +2564,31 @@ void Creature::AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_t
|
||||
// used in proc system, otherwise normal creature cooldown
|
||||
if (end_time)
|
||||
{
|
||||
_AddCreatureSpellCooldown(spellInfo->Id, end_time);
|
||||
_AddCreatureSpellCooldown(spellInfo->Id, 0, end_time);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 spellcooldown = spellInfo->RecoveryTime;
|
||||
uint32 categorycooldown = spellInfo->CategoryRecoveryTime;
|
||||
if(Player* modOwner = GetSpellModOwner())
|
||||
uint32 categoryId = spellInfo->GetCategory();
|
||||
uint32 categorycooldown = categoryId ? spellInfo->CategoryRecoveryTime : 0;
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, spellcooldown);
|
||||
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, categorycooldown);
|
||||
}
|
||||
|
||||
if (spellcooldown)
|
||||
_AddCreatureSpellCooldown(spellInfo->Id, spellcooldown);
|
||||
|
||||
if (categorycooldown)
|
||||
if (spellInfo->GetCategory())
|
||||
SpellCategoryStore::const_iterator i_scstore = sSpellsByCategoryStore.find(categoryId);
|
||||
if (categorycooldown && i_scstore != sSpellsByCategoryStore.end())
|
||||
{
|
||||
for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset)
|
||||
{
|
||||
SpellCategoryStore::const_iterator i_scstore = sSpellsByCategoryStore.find(spellInfo->GetCategory());
|
||||
if (i_scstore != sSpellsByCategoryStore.end())
|
||||
{
|
||||
uint32 cattime = categorycooldown;
|
||||
for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset)
|
||||
if (GetSpellCooldown(*i_scset) < cattime)
|
||||
_AddCreatureSpellCooldown(*i_scset, cattime);
|
||||
}
|
||||
_AddCreatureSpellCooldown(i_scset->second, categoryId, categorycooldown);
|
||||
}
|
||||
}
|
||||
else if (spellcooldown)
|
||||
{
|
||||
_AddCreatureSpellCooldown(spellInfo->Id, 0, spellcooldown);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Creature::GetSpellCooldown(uint32 spell_id) const
|
||||
@@ -2596,13 +2597,13 @@ uint32 Creature::GetSpellCooldown(uint32 spell_id) const
|
||||
if (itr == m_CreatureSpellCooldowns.end())
|
||||
return 0;
|
||||
|
||||
return itr->second > World::GetGameTimeMS() ? itr->second - World::GetGameTimeMS() : 0;
|
||||
return itr->second.end > World::GetGameTimeMS() ? itr->second.end - World::GetGameTimeMS() : 0;
|
||||
}
|
||||
|
||||
bool Creature::HasSpellCooldown(uint32 spell_id) const
|
||||
{
|
||||
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
|
||||
return (itr != m_CreatureSpellCooldowns.end() && itr->second > World::GetGameTimeMS());
|
||||
return (itr != m_CreatureSpellCooldowns.end() && itr->second.end > World::GetGameTimeMS());
|
||||
}
|
||||
|
||||
bool Creature::HasSpell(uint32 spellID) const
|
||||
|
||||
Reference in New Issue
Block a user