![]() |
TrinityCore
|
#include <SpellHistory.h>
Classes | |
| struct | CooldownEntry |
| struct | PersistenceHelper |
| struct | PersistenceHelper< Pet > |
| struct | PersistenceHelper< Player > |
Public Types | |
| typedef std::chrono::system_clock | Clock |
| typedef std::unordered_map< uint32, CooldownEntry > | CooldownStorageType |
| typedef std::unordered_map< uint32, CooldownEntry * > | CategoryCooldownStorageType |
| typedef std::unordered_map< uint32, Clock::time_point > | GlobalCooldownStorageType |
Public Member Functions | |
| SpellHistory (Unit *owner) | |
| template<class OwnerType > | |
| void | LoadFromDB (PreparedQueryResult cooldownsResult) |
| template<class OwnerType > | |
| void | SaveToDB (CharacterDatabaseTransaction trans) |
| void | Update () |
| void | HandleCooldowns (SpellInfo const *spellInfo, Item const *item, Spell *spell=nullptr) |
| void | HandleCooldowns (SpellInfo const *spellInfo, uint32 itemID, Spell *spell=nullptr) |
| bool | IsReady (SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const |
| template<class OwnerType > | |
| void | WritePacket (WorldPacket &packet) const |
| void | WritePacket (WorldPackets::Spells::InitialSpells *initialSpells) const |
| void | StartCooldown (SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false) |
| void | SendCooldownEvent (SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true) |
| template<class Type , class Period > | |
| void | AddCooldown (uint32 spellId, uint32 itemId, std::chrono::duration< Type, Period > cooldownDuration) |
| void | AddCooldown (uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, uint32 categoryId, Clock::time_point categoryEnd, bool onHold=false) |
| void | ModifyCooldown (uint32 spellId, int32 cooldownModMs) |
| void | ResetCooldown (uint32 spellId, bool update=false) |
| void | ResetCooldown (CooldownStorageType::iterator &itr, bool update=false) |
| template<typename Predicate > | |
| void | ResetCooldowns (Predicate predicate, bool update=false) |
| void | ResetAllCooldowns () |
| bool | HasCooldown (SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const |
| bool | HasCooldown (uint32 spellId, uint32 itemId=0, bool ignoreCategoryCooldown=false) const |
| bool | HasCooldownOnHold (uint32 spellId) const |
| uint32 | GetRemainingCooldown (SpellInfo const *spellInfo) const |
| void | LockSpellSchool (SpellSchoolMask schoolMask, uint32 lockoutTime) |
| bool | IsSchoolLocked (SpellSchoolMask schoolMask) const |
| bool | HasGlobalCooldown (SpellInfo const *spellInfo) const |
| void | AddGlobalCooldown (SpellInfo const *spellInfo, uint32 duration) |
| void | CancelGlobalCooldown (SpellInfo const *spellInfo) |
| void | BuildCooldownPacket (WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown) const |
| CooldownStorageType::size_type | GetCooldownsSizeForPacket () const |
| void | SaveCooldownStateBeforeDuel () |
| void | RestoreCooldownStateAfterDuel () |
| template<> | |
| void | WritePacket (WorldPacket &packet) const |
Static Public Member Functions | |
| static void | GetCooldownDurations (SpellInfo const *spellInfo, uint32 itemId, int32 *cooldown, uint32 *categoryId, int32 *categoryCooldown) |
Static Public Attributes | |
| static Clock::duration const | InfinityCooldownDelay = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH)) |
| static Clock::duration const | InfinityCooldownDelayCheck = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH / 2)) |
Private Types | |
| typedef std::unordered_map< uint32, uint32 > | PacketCooldowns |
Private Member Functions | |
| Player * | GetPlayerOwner () const |
| void | SendClearCooldowns (std::vector< int32 > const &cooldowns) const |
| CooldownStorageType::iterator | EraseCooldown (CooldownStorageType::iterator itr) |
| void | BuildCooldownPacket (WorldPacket &data, uint8 flags, PacketCooldowns const &cooldowns) const |
Private Attributes | |
| Unit * | _owner |
| CooldownStorageType | _spellCooldowns |
| CooldownStorageType | _spellCooldownsBeforeDuel |
| CategoryCooldownStorageType | _categoryCooldowns |
| Clock::time_point | _schoolLockouts [MAX_SPELL_SCHOOL] |
| GlobalCooldownStorageType | _globalCooldowns |
Definition at line 48 of file SpellHistory.h.
| typedef std::unordered_map<uint32 , CooldownEntry*> SpellHistory::CategoryCooldownStorageType |
Definition at line 64 of file SpellHistory.h.
| typedef std::chrono::system_clock SpellHistory::Clock |
Definition at line 51 of file SpellHistory.h.
| typedef std::unordered_map<uint32 , CooldownEntry> SpellHistory::CooldownStorageType |
Definition at line 63 of file SpellHistory.h.
| typedef std::unordered_map<uint32 , Clock::time_point> SpellHistory::GlobalCooldownStorageType |
Definition at line 65 of file SpellHistory.h.
|
private |
Definition at line 154 of file SpellHistory.h.
|
inlineexplicit |
Definition at line 67 of file SpellHistory.h.
| void SpellHistory::AddCooldown | ( | uint32 | spellId, |
| uint32 | itemId, | ||
| Clock::time_point | cooldownEnd, | ||
| uint32 | categoryId, | ||
| Clock::time_point | categoryEnd, | ||
| bool | onHold = false |
||
| ) |
Definition at line 383 of file SpellHistory.cpp.
References _categoryCooldowns, _spellCooldowns, SpellHistory::CooldownEntry::CategoryEnd, SpellHistory::CooldownEntry::CategoryId, SpellHistory::CooldownEntry::CooldownEnd, SpellHistory::CooldownEntry::ItemId, SpellHistory::CooldownEntry::OnHold, and SpellHistory::CooldownEntry::SpellId.
|
inline |
Definition at line 92 of file SpellHistory.h.
References GameTime::GetSystemTime().
Referenced by spell_rog_cheat_death::Absorb(), spell_pal_ardent_defender::Absorb(), Player::ApplyEquipCooldown(), Aura::HandleAuraSpecificMods(), spell_dru_leader_of_the_pack::HandleProc(), LockSpellSchool(), npc_gunship_boarding_addAI::MovementInform(), StartCooldown(), gunship_npc_AI::TriggerBurningPitch(), and npc_gunship_rocketeer::UpdateAI().
Definition at line 586 of file SpellHistory.cpp.
References _globalCooldowns, GameTime::GetSystemTime(), and SpellInfo::StartRecoveryCategory.
Referenced by Player::EquipItem(), and Spell::TriggerGlobalCooldown().
|
private |
Definition at line 624 of file SpellHistory.cpp.
References _owner, flags, Object::GetGUID(), WorldPacket::Initialize(), and SMSG_SPELL_COOLDOWN.
| void SpellHistory::BuildCooldownPacket | ( | WorldPacket & | data, |
| uint8 | flags, | ||
| uint32 | spellId, | ||
| uint32 | cooldown | ||
| ) | const |
Definition at line 615 of file SpellHistory.cpp.
References _owner, flags, Object::GetGUID(), WorldPacket::Initialize(), and SMSG_SPELL_COOLDOWN.
Referenced by Player::EquipItem(), Aura::HandleAuraSpecificMods(), spell_gen_charmed_unit_spell_cooldown::HandleCast(), LockSpellSchool(), RestoreCooldownStateAfterDuel(), and StartCooldown().
| void SpellHistory::CancelGlobalCooldown | ( | SpellInfo const * | spellInfo | ) |
Definition at line 591 of file SpellHistory.cpp.
References _globalCooldowns, and SpellInfo::StartRecoveryCategory.
Referenced by Spell::CancelGlobalCooldown().
|
inlineprivate |
Definition at line 148 of file SpellHistory.h.
Referenced by ModifyCooldown(), ResetCooldown(), and Update().
|
static |
Definition at line 636 of file SpellHistory.cpp.
References ASSERT, SpellInfo::CategoryRecoveryTime, SpellInfo::GetCategory(), SpellInfo::Id, SpellInfo::RecoveryTime, and sObjectMgr.
Referenced by HasCooldown(), Player::RemoveArenaSpellCooldowns(), SendCooldownEvent(), and StartCooldown().
|
inline |
Definition at line 141 of file SpellHistory.h.
Referenced by Player::VehicleSpellInitialize().
|
private |
Definition at line 596 of file SpellHistory.cpp.
References _owner, and WorldObject::GetCharmerOrOwnerPlayerOrPlayerItself().
Referenced by LockSpellSchool(), ModifyCooldown(), ResetAllCooldowns(), ResetCooldown(), SendClearCooldowns(), SendCooldownEvent(), and StartCooldown().
Definition at line 489 of file SpellHistory.cpp.
References _categoryCooldowns, _spellCooldowns, SpellInfo::GetCategory(), GameTime::GetSystemTime(), and SpellInfo::Id.
Referenced by Player::ApplyEquipCooldown(), Aura::HandleAuraSpecificMods(), LockSpellSchool(), DuelResetScript::ResetSpellCooldowns(), and boss_general_bjarngrim::UpdateAI().
| void SpellHistory::HandleCooldowns | ( | SpellInfo const * | spellInfo, |
| Item const * | item, | ||
| Spell * | spell = nullptr |
||
| ) |
Definition at line 162 of file SpellHistory.cpp.
References Object::GetEntry(), and HandleCooldowns().
Referenced by HandleCooldowns(), and Spell::SendSpellCooldown().
| void SpellHistory::HandleCooldowns | ( | SpellInfo const * | spellInfo, |
| uint32 | itemID, | ||
| Spell * | spell = nullptr |
||
| ) |
Definition at line 167 of file SpellHistory.cpp.
References _owner, SpellInfo::IsCooldownStartedOnEvent(), Spell::IsIgnoringCooldowns(), SpellInfo::IsPassive(), sObjectMgr, StartCooldown(), and Object::ToPlayer().
| bool SpellHistory::HasCooldown | ( | SpellInfo const * | spellInfo, |
| uint32 | itemId = 0, |
||
| bool | ignoreCategoryCooldown = false |
||
| ) | const |
Definition at line 461 of file SpellHistory.cpp.
References _categoryCooldowns, _spellCooldowns, GetCooldownDurations(), and SpellInfo::Id.
Referenced by spell_rog_cheat_death::Absorb(), spell_rog_vanish::ApplyStealth(), Spell::EffectCastButtons(), Spell::EffectStuck(), Aura::HandleAuraSpecificMods(), spell_item_refocus::HandleDummy(), WorldSession::HandlePetActionHelper(), WorldSession::HandlePetCastSpellOpcode(), spell_dru_leader_of_the_pack::HandleProc(), spell_gen_divine_storm_cd_reset::HandleScript(), HasCooldown(), IsReady(), gunship_npc_AI::TriggerBurningPitch(), and npc_gunship_rocketeer::UpdateAI().
| bool SpellHistory::HasCooldown | ( | uint32 | spellId, |
| uint32 | itemId = 0, |
||
| bool | ignoreCategoryCooldown = false |
||
| ) | const |
Definition at line 477 of file SpellHistory.cpp.
References HasCooldown(), and sSpellMgr.
| bool SpellHistory::HasCooldownOnHold | ( | uint32 | spellId | ) | const |
Definition at line 482 of file SpellHistory.cpp.
References _spellCooldowns.
Referenced by Spell::CheckCast().
| bool SpellHistory::HasGlobalCooldown | ( | SpellInfo const * | spellInfo | ) | const |
Definition at line 580 of file SpellHistory.cpp.
References _globalCooldowns, GameTime::GetSystemTime(), and SpellInfo::StartRecoveryCategory.
Referenced by Spell::CheckPetCast(), Spell::HasGlobalCooldown(), PetAI::UpdateAI(), and PlayerAI::VerifySpellCast().
| bool SpellHistory::IsReady | ( | SpellInfo const * | spellInfo, |
| uint32 | itemId = 0, |
||
| bool | ignoreCategoryCooldown = false |
||
| ) | const |
Definition at line 191 of file SpellHistory.cpp.
References SpellInfo::GetSchoolMask(), HasCooldown(), SpellInfo::Id, IsSchoolLocked(), SpellInfo::PreventionType, and SPELL_PREVENTION_TYPE_SILENCE.
Referenced by Spell::CheckCast(), and PetAI::UpdateAI().
| bool SpellHistory::IsSchoolLocked | ( | SpellSchoolMask | schoolMask | ) | const |
Definition at line 569 of file SpellHistory.cpp.
References _schoolLockouts, GameTime::GetSystemTime(), and MAX_SPELL_SCHOOL.
Referenced by IsReady().
| template void SpellHistory::LoadFromDB< Pet > | ( | PreparedQueryResult | cooldownsResult | ) |
Definition at line 98 of file SpellHistory.cpp.
References _categoryCooldowns, _spellCooldowns, and SpellHistory::CooldownEntry::CategoryId.
Referenced by Player::LoadFromDB().
| void SpellHistory::LockSpellSchool | ( | SpellSchoolMask | schoolMask, |
| uint32 | lockoutTime | ||
| ) |
Definition at line 512 of file SpellHistory.cpp.
References _owner, _schoolLockouts, AddCooldown(), BuildCooldownPacket(), GetPlayerOwner(), GetRemainingCooldown(), SpellInfo::GetSchoolMask(), GameTime::GetSystemTime(), SpellInfo::IsCooldownStartedOnEvent(), Creature::m_spells, MAX_CREATURE_SPELLS, MAX_SPELL_SCHOOL, PETSPELL_REMOVED, PLAYERSPELL_REMOVED, SpellInfo::PreventionType, SPELL_COOLDOWN_FLAG_NONE, SPELL_PREVENTION_TYPE_SILENCE, sSpellMgr, Object::ToCreature(), Unit::ToPet(), and Object::ToPlayer().
Referenced by Spell::EffectInterruptCast().
Definition at line 397 of file SpellHistory.cpp.
References _owner, _spellCooldowns, EraseCooldown(), Object::GetGUID(), GetPlayerOwner(), GameTime::GetSystemTime(), and SMSG_MODIFY_COOLDOWN.
| void SpellHistory::ResetAllCooldowns | ( | ) |
Definition at line 445 of file SpellHistory.cpp.
References _categoryCooldowns, _spellCooldowns, GetPlayerOwner(), and SendClearCooldowns().
Referenced by CreatureAI::_EnterEvadeMode(), Spell::EffectSummonPet(), and misc_commandscript::HandleCooldownCommand().
| void SpellHistory::ResetCooldown | ( | CooldownStorageType::iterator & | itr, |
| bool | update = false |
||
| ) |
Definition at line 429 of file SpellHistory.cpp.
References _owner, EraseCooldown(), Object::GetGUID(), GetPlayerOwner(), and SMSG_CLEAR_COOLDOWN.
| void SpellHistory::ResetCooldown | ( | uint32 | spellId, |
| bool | update = false |
||
| ) |
Definition at line 420 of file SpellHistory.cpp.
References _spellCooldowns, and ResetCooldown().
Referenced by Spell::_cast(), spell_rog_vanish::ApplyStealth(), Spell::cancel(), Aura::HandleAuraSpecificMods(), misc_commandscript::HandleCooldownCommand(), spell_item_rocket_boots::HandleDummy(), spell_item_refocus::HandleDummy(), WorldSession::HandlePetActionHelper(), WorldSession::HandlePetCastSpellOpcode(), spell_dk_glyph_of_death_grip::HandleProc(), spell_gen_divine_storm_cd_reset::HandleScript(), and ResetCooldown().
|
inline |
Definition at line 103 of file SpellHistory.h.
Referenced by spell_hun_readiness::HandleDummy(), spell_mage_cold_snap::HandleDummy(), spell_rog_preparation::HandleDummy(), spell_dru_berserk::HandleEffectApply(), spell_dk_rime::HandleProc(), spell_warr_sword_and_board::HandleProc(), spell_mage_glyph_of_ice_block::HandleProc(), Player::RemoveArenaSpellCooldowns(), and DuelResetScript::ResetSpellCooldowns().
| void SpellHistory::RestoreCooldownStateAfterDuel | ( | ) |
Definition at line 683 of file SpellHistory.cpp.
References _owner, _spellCooldowns, _spellCooldownsBeforeDuel, BuildCooldownPacket(), SpellInfo::CategoryRecoveryTime, GameTime::GetSystemTime(), IN_MILLISECONDS, MINUTE, SpellInfo::RecoveryTime, SPELL_COOLDOWN_FLAG_INCLUDE_EVENT_COOLDOWNS, sSpellMgr, and Object::ToPlayer().
Referenced by DuelResetScript::OnDuelEnd().
| void SpellHistory::SaveCooldownStateBeforeDuel | ( | ) |
Definition at line 678 of file SpellHistory.cpp.
References _spellCooldowns, and _spellCooldownsBeforeDuel.
Referenced by DuelResetScript::OnDuelStart().
| template void SpellHistory::SaveToDB< Pet > | ( | CharacterDatabaseTransaction | trans | ) |
Definition at line 120 of file SpellHistory.cpp.
References _owner, _spellCooldowns, and CharacterDatabase.
Referenced by Pet::SavePetToDB(), and Player::SaveToDB().
|
private |
Definition at line 601 of file SpellHistory.cpp.
References _owner, Object::GetGUID(), GetPlayerOwner(), and SMSG_CLEAR_COOLDOWN.
Referenced by ResetAllCooldowns().
| void SpellHistory::SendCooldownEvent | ( | SpellInfo const * | spellInfo, |
| uint32 | itemId = 0, |
||
| Spell * | spell = nullptr, |
||
| bool | startCooldown = true |
||
| ) |
Definition at line 352 of file SpellHistory.cpp.
References _categoryCooldowns, _owner, SpellInfo::GetCategory(), GetCooldownDurations(), Object::GetGUID(), GetPlayerOwner(), SpellInfo::Id, SMSG_COOLDOWN_EVENT, sSpellMgr, and StartCooldown().
Referenced by Aura::_UnapplyForTarget(), Unit::RemoveGameObjectImpl(), Unit::SetMinion(), Totem::UnSummon(), and Player::UpdatePotionCooldown().
| void SpellHistory::StartCooldown | ( | SpellInfo const * | spellInfo, |
| uint32 | itemId, | ||
| Spell * | spell = nullptr, |
||
| bool | onHold = false |
||
| ) |
Definition at line 271 of file SpellHistory.cpp.
References _owner, AddCooldown(), BuildCooldownPacket(), Unit::GetAttackTime(), GetCooldownDurations(), GetPlayerOwner(), WorldObject::GetSpellModOwner(), GameTime::GetSystemTime(), Unit::GetTotalAuraModifier(), SpellInfo::HasAttribute(), Player::HasSpell(), SpellInfo::Id, IN_MILLISECONDS, InfinityCooldownDelay, SpellInfo::IsAutoRepeatRangedSpell(), RANGED_ATTACK, SPELL_ATTR6_IGNORE_CATEGORY_COOLDOWN_MODS, SPELL_AURA_MOD_COOLDOWN, SPELL_COOLDOWN_FLAG_NONE, and SPELLMOD_COOLDOWN.
Referenced by Aura::_ApplyForTarget(), Unit::AddGameObject(), HandleCooldowns(), spell_dk_raise_dead::OverrideCooldown(), SendCooldownEvent(), and Unit::SetMinion().
| void SpellHistory::Update | ( | ) |
Definition at line 142 of file SpellHistory.cpp.
References _categoryCooldowns, _spellCooldowns, EraseCooldown(), and GameTime::GetSystemTime().
Referenced by Unit::_UpdateSpells().
| void SpellHistory::WritePacket | ( | WorldPacket & | packet | ) | const |
Definition at line 204 of file SpellHistory.cpp.
References _spellCooldowns, and GameTime::GetSystemTime().
| void SpellHistory::WritePacket | ( | WorldPacket & | packet | ) | const |
Referenced by Player::PetSpellInitialize(), Player::SendInitialSpells(), and Player::VehicleSpellInitialize().
| void SpellHistory::WritePacket | ( | WorldPackets::Spells::InitialSpells * | initialSpells | ) | const |
Definition at line 240 of file SpellHistory.cpp.
References _spellCooldowns, WorldPackets::Spells::SpellHistoryEntry::Category, WorldPackets::Spells::SpellHistoryEntry::CategoryRecoveryTime, GameTime::GetSystemTime(), WorldPackets::Spells::SpellHistoryEntry::ItemID, WorldPackets::Spells::SpellHistoryEntry::OnHold, WorldPackets::Spells::SpellHistoryEntry::RecoveryTime, WorldPackets::Spells::InitialSpells::SpellHistory, and WorldPackets::Spells::SpellHistoryEntry::SpellID.
|
private |
Definition at line 160 of file SpellHistory.h.
Referenced by AddCooldown(), GetRemainingCooldown(), HasCooldown(), LoadFromDB(), ResetAllCooldowns(), SendCooldownEvent(), and Update().
|
private |
Definition at line 162 of file SpellHistory.h.
Referenced by AddGlobalCooldown(), CancelGlobalCooldown(), and HasGlobalCooldown().
|
private |
Definition at line 157 of file SpellHistory.h.
Referenced by BuildCooldownPacket(), BuildCooldownPacket(), GetPlayerOwner(), HandleCooldowns(), LockSpellSchool(), ModifyCooldown(), ResetCooldown(), RestoreCooldownStateAfterDuel(), SaveToDB(), SendClearCooldowns(), SendCooldownEvent(), and StartCooldown().
|
private |
Definition at line 161 of file SpellHistory.h.
Referenced by IsSchoolLocked(), and LockSpellSchool().
|
private |
Definition at line 158 of file SpellHistory.h.
Referenced by AddCooldown(), GetRemainingCooldown(), HasCooldown(), HasCooldownOnHold(), LoadFromDB(), ModifyCooldown(), ResetAllCooldowns(), ResetCooldown(), RestoreCooldownStateAfterDuel(), SaveCooldownStateBeforeDuel(), SaveToDB(), Update(), WritePacket(), and WritePacket().
|
private |
Definition at line 159 of file SpellHistory.h.
Referenced by RestoreCooldownStateAfterDuel(), and SaveCooldownStateBeforeDuel().
|
static |
Definition at line 85 of file SpellHistory.h.
Referenced by StartCooldown().
|
static |
Definition at line 86 of file SpellHistory.h.