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:
UltraNix
2021-09-13 20:57:48 +02:00
committed by GitHub
parent 7e2e6f8ee8
commit 7406a01ac3
19 changed files with 178 additions and 111 deletions

View File

@@ -182,6 +182,7 @@ typedef GuidList WhisperListContainer;
struct SpellCooldown
{
uint32 end;
uint16 category;
uint32 itemid;
uint32 maxduration;
bool sendToSpectator: 1;
@@ -1655,8 +1656,6 @@ public:
void DropModCharge(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
static uint32 const infinityCooldownDelay = 0x9A7EC800; // used for set "infinity cooldowns" for spells and check, MONTH*IN_MILLISECONDS
static uint32 const infinityCooldownDelayCheck = 0x4D3F6400; //MONTH*IN_MILLISECONDS/2;
[[nodiscard]] bool HasSpellCooldown(uint32 spell_id) const override
{
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
@@ -1674,6 +1673,7 @@ public:
}
void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = nullptr, bool infinityCooldown = false);
void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override;
void _AddSpellCooldown(uint32 spell_id, uint16 categoryId, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false);
void ModifySpellCooldown(uint32 spellId, int32 cooldown);
void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = nullptr, bool setCooldown = true);
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) override;