TrinityCore
Loading...
Searching...
No Matches
SpellHistory Class Reference

#include <SpellHistory.h>

Classes

struct  ChargeEntry
 
struct  CooldownEntry
 
struct  PersistenceHelper
 
struct  PersistenceHelper< Pet >
 
struct  PersistenceHelper< Player >
 

Public Types

using Clock = std::chrono::system_clock
 
using Duration = Milliseconds
 
using TimePoint = std::chrono::time_point< Clock, Duration >
 
using ChargeEntryCollection = std::deque< ChargeEntry >
 
using CooldownStorageType = std::unordered_map< uint32, CooldownEntry >
 
using CategoryCooldownStorageType = std::unordered_map< uint32, CooldownEntry * >
 
using ChargeStorageType = std::unordered_map< uint32, ChargeEntryCollection >
 
using GlobalCooldownStorageType = std::unordered_map< uint32, TimePoint >
 

Public Member Functions

 SpellHistory (Unit *owner)
 
 ~SpellHistory ()
 
 SpellHistory (SpellHistory const &)=delete
 
 SpellHistory (SpellHistory &&)=delete
 
SpellHistory & operator= (SpellHistory const &)=delete
 
SpellHistory & operator= (SpellHistory &&)=delete
 
template<class OwnerType >
void LoadFromDB (PreparedQueryResult cooldownsResult, PreparedQueryResult chargesResult)
 
template<class OwnerType >
void SaveToDB (CharacterDatabaseTransaction trans)
 
void Update ()
 
void HandleCooldowns (SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr)
 
bool IsReady (SpellInfo const *spellInfo, uint32 itemId=0) const
 
void WritePacket (WorldPackets::Spells::SendSpellHistory *sendSpellHistory) const
 
void WritePacket (WorldPackets::Spells::SendSpellCharges *sendSpellCharges) const
 
void WritePacket (WorldPackets::Pet::PetSpells *petSpells) const
 
void StartCooldown (SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false, Optional< Duration > forcedCooldown={})
 
void SendCooldownEvent (SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true)
 
void AddCooldown (uint32 spellId, uint32 itemId, Duration cooldownDuration)
 
void AddCooldown (uint32 spellId, uint32 itemId, TimePoint cooldownEnd, uint32 categoryId, TimePoint categoryEnd, bool onHold=false)
 
void ModifyCooldown (uint32 spellId, Duration cooldownMod, bool withoutCategoryCooldown=false)
 
void ModifyCooldown (SpellInfo const *spellInfo, Duration cooldownMod, bool withoutCategoryCooldown=false)
 
template<Trinity::invocable_r< bool, CooldownEntry const & > Predicate>
void ModifyCoooldowns (Predicate &&predicate, Duration cooldownMod, bool withoutCategoryCooldown=false)
 
template<Trinity::invocable_r< bool, CooldownEntry const & > Predicate>
void UpdateCooldownRecoveryRate (Predicate &&predicate, float modChange, bool apply)
 
void ResetCooldown (uint32 spellId, bool update=false)
 
template<Trinity::invocable_r< bool, CooldownEntry const & > Predicate>
void ResetCooldowns (Predicate &&predicate, bool update=false)
 
void ResetAllCooldowns ()
 
bool HasCooldown (SpellInfo const *spellInfo, uint32 itemId=0) const
 
bool HasCooldown (uint32 spellId, uint32 itemId=0) const
 
bool HasCooldownOnHold (uint32 spellId) const
 
Duration GetRemainingCooldown (SpellInfo const *spellInfo) const
 
Duration GetRemainingCategoryCooldown (uint32 categoryId) const
 
Duration GetRemainingCategoryCooldown (SpellInfo const *spellInfo) const
 
void LockSpellSchool (SpellSchoolMask schoolMask, Duration lockoutTime)
 
bool IsSchoolLocked (SpellSchoolMask schoolMask) const
 
void ConsumeCharge (uint32 chargeCategoryId)
 
void ModifyChargeRecoveryTime (uint32 chargeCategoryId, Duration cooldownMod)
 
void UpdateChargeRecoveryRate (uint32 chargeCategoryId, float modChange, bool apply)
 
void RestoreCharge (uint32 chargeCategoryId)
 
void ResetCharges (uint32 chargeCategoryId)
 
void ResetAllCharges ()
 
bool HasCharge (uint32 chargeCategoryId) const
 
int32 GetMaxCharges (uint32 chargeCategoryId) const
 
int32 GetChargeRecoveryTime (uint32 chargeCategoryId) const
 
bool HasGlobalCooldown (SpellInfo const *spellInfo) const
 
void AddGlobalCooldown (SpellInfo const *spellInfo, Duration duration)
 
void CancelGlobalCooldown (SpellInfo const *spellInfo)
 
Duration GetRemainingGlobalCooldown (SpellInfo const *spellInfo) const
 
bool IsPaused () const
 
void PauseCooldowns ()
 
void ResumeCooldowns ()
 
void AtExitCombat ()
 
void SaveCooldownStateBeforeDuel ()
 
void RestoreCooldownStateAfterDuel ()
 

Static Public Member Functions

static void GetCooldownDurations (SpellInfo const *spellInfo, uint32 itemId, Duration *cooldown, uint32 *categoryId, Duration *categoryCooldown)
 

Private Member Functions

Player * GetPlayerOwner () const
 
void ModifySpellCooldown (uint32 spellId, Duration cooldownMod, bool withoutCategoryCooldown)
 
void ModifySpellCooldown (CooldownStorageType::iterator &itr, Duration cooldownMod, bool withoutCategoryCooldown)
 
void UpdateCooldownRecoveryRate (CooldownStorageType::iterator &itr, float modChange, bool apply)
 
void ResetCooldown (CooldownStorageType::iterator &itr, bool update=false)
 
void SendClearCooldowns (std::vector< int32 > &&cooldowns) const
 
CooldownStorageType::iterator EraseCooldown (CooldownStorageType::iterator itr)
 
void SendSetSpellCharges (uint32 chargeCategoryId, ChargeEntryCollection const &chargeCollection) const
 

Private Attributes

Unit * _owner
 
CooldownStorageType _spellCooldowns
 
CooldownStorageType _spellCooldownsBeforeDuel
 
CategoryCooldownStorageType _categoryCooldowns
 
TimePoint _schoolLockouts [MAX_SPELL_SCHOOL]
 
ChargeStorageType _categoryCharges
 
GlobalCooldownStorageType _globalCooldowns
 
Optional< TimePoint > _pauseTime
 

Detailed Description

Definition at line 58 of file SpellHistory.h.

Member Typedef Documentation

◆ CategoryCooldownStorageType

Definition at line 87 of file SpellHistory.h.

◆ ChargeEntryCollection

Definition at line 85 of file SpellHistory.h.

◆ ChargeStorageType

Definition at line 88 of file SpellHistory.h.

◆ Clock

using SpellHistory::Clock = std::chrono::system_clock

Definition at line 61 of file SpellHistory.h.

◆ CooldownStorageType

Definition at line 86 of file SpellHistory.h.

◆ Duration

Definition at line 62 of file SpellHistory.h.

◆ GlobalCooldownStorageType

Definition at line 89 of file SpellHistory.h.

◆ TimePoint

using SpellHistory::TimePoint = std::chrono::time_point<Clock, Duration>

Definition at line 63 of file SpellHistory.h.

Constructor & Destructor Documentation

◆ SpellHistory() [1/3]

SpellHistory::SpellHistory ( Unit *  owner)
explicit

Definition at line 140 of file SpellHistory.cpp.

◆ ~SpellHistory()

SpellHistory::~SpellHistory ( )
default

◆ SpellHistory() [2/3]

SpellHistory::SpellHistory ( SpellHistory const &  )
delete

◆ SpellHistory() [3/3]

SpellHistory::SpellHistory ( SpellHistory &&  )
delete

Member Function Documentation

◆ AddCooldown() [1/2]

◆ AddCooldown() [2/2]

◆ AddGlobalCooldown()

void SpellHistory::AddGlobalCooldown ( SpellInfo const *  spellInfo,
Duration  duration 
)

◆ AtExitCombat()

void SpellHistory::AtExitCombat ( )

◆ CancelGlobalCooldown()

void SpellHistory::CancelGlobalCooldown ( SpellInfo const *  spellInfo)

Definition at line 1030 of file SpellHistory.cpp.

References _globalCooldowns, and SpellInfo::StartRecoveryCategory.

Referenced by Spell::CancelGlobalCooldown().

◆ ConsumeCharge()

void SpellHistory::ConsumeCharge ( uint32  chargeCategoryId)

◆ EraseCooldown()

SpellHistory::CooldownStorageType::iterator SpellHistory::EraseCooldown ( CooldownStorageType::iterator  itr)
private

Definition at line 1091 of file SpellHistory.cpp.

References _categoryCooldowns, and _spellCooldowns.

Referenced by ModifySpellCooldown(), ResetCooldown(), and Update().

◆ GetChargeRecoveryTime()

◆ GetCooldownDurations()

void SpellHistory::GetCooldownDurations ( SpellInfo const *  spellInfo,
uint32  itemId,
Duration *  cooldown,
uint32 *  categoryId,
Duration *  categoryCooldown 
)
static

◆ GetMaxCharges()

int32 SpellHistory::GetMaxCharges ( uint32  chargeCategoryId) const

◆ GetPlayerOwner()

◆ GetRemainingCategoryCooldown() [1/2]

SpellHistory::Duration SpellHistory::GetRemainingCategoryCooldown ( SpellInfo const *  spellInfo) const

Definition at line 759 of file SpellHistory.cpp.

References SpellInfo::GetCategory(), and GetRemainingCategoryCooldown().

◆ GetRemainingCategoryCooldown() [2/2]

SpellHistory::Duration SpellHistory::GetRemainingCategoryCooldown ( uint32  categoryId) const

◆ GetRemainingCooldown()

◆ GetRemainingGlobalCooldown()

SpellHistory::Duration SpellHistory::GetRemainingGlobalCooldown ( SpellInfo const *  spellInfo) const

◆ HandleCooldowns()

◆ HasCharge()

bool SpellHistory::HasCharge ( uint32  chargeCategoryId) const

◆ HasCooldown() [1/2]

◆ HasCooldown() [2/2]

bool SpellHistory::HasCooldown ( uint32  spellId,
uint32  itemId = 0 
) const

◆ HasCooldownOnHold()

bool SpellHistory::HasCooldownOnHold ( uint32  spellId) const

Definition at line 702 of file SpellHistory.cpp.

References _spellCooldowns.

Referenced by Spell::CheckCast().

◆ HasGlobalCooldown()

bool SpellHistory::HasGlobalCooldown ( SpellInfo const *  spellInfo) const

◆ IsPaused()

bool SpellHistory::IsPaused ( ) const
inline

Definition at line 199 of file SpellHistory.h.

◆ IsReady()

◆ IsSchoolLocked()

bool SpellHistory::IsSchoolLocked ( SpellSchoolMask  schoolMask) const

Definition at line 823 of file SpellHistory.cpp.

References _schoolLockouts, and MAX_SPELL_SCHOOL.

Referenced by IsReady().

◆ LoadFromDB()

template<class OwnerType >
template void SpellHistory::LoadFromDB< Pet > ( PreparedQueryResult  cooldownsResult,
PreparedQueryResult  chargesResult 
)

◆ LockSpellSchool()

◆ ModifyChargeRecoveryTime()

void SpellHistory::ModifyChargeRecoveryTime ( uint32  chargeCategoryId,
Duration  cooldownMod 
)

◆ ModifyCooldown() [1/2]

void SpellHistory::ModifyCooldown ( SpellInfo const *  spellInfo,
Duration  cooldownMod,
bool  withoutCategoryCooldown = false 
)

◆ ModifyCooldown() [2/2]

void SpellHistory::ModifyCooldown ( uint32  spellId,
Duration  cooldownMod,
bool  withoutCategoryCooldown = false 
)

Definition at line 632 of file SpellHistory.cpp.

References _owner, Map::GetDifficultyID(), WorldObject::GetMap(), ModifyCooldown(), and sSpellMgr.

Referenced by Spell::EffectModifyCooldown(), spell_mage_ethereal_blink_triggered::FilterTargets(), spell_evo_causality_pyre::HandleCooldown(), spell_sha_chain_lightning_crash_lightning::HandleCooldownReduction(), spell_warr_rumbling_earth::HandleCooldownReduction(), spell_dh_cycle_of_hatred::HandleCycleOfHatred(), spell_pri_protector_of_the_frail::HandleEffectHit(), spell_pal_crusader_might::HandleEffectProc(), spell_pal_fist_of_justice::HandleEffectProc(), spell_pal_righteous_protector::HandleEffectProc(), spell_dh_cycle_of_binding::HandleEffectProc(), spell_hun_scrappy::HandleEffectProc(), spell_warl_cull_the_weak::HandleEffectProc(), spell_pri_heavens_wrath::HandleEffectProc(), spell_dh_darkglare_boon::HandleEffectRemove(), spell_hun_steady_shot::HandleOnHit(), spell_hun_take_aim::HandleOnHit(), spell_hun_hunting_party::HandleProc(), spell_rog_restless_blades::HandleProc(), spell_warr_anger_management_proc::HandleProc(), spell_hun_focused_aim::HandleProc(), ModifyCooldown(), spell_pri_holy_words_base::ModifyCooldown(), spell_evo_causality_disintegrate::OnTick(), spell_pri_holy_word_salvation_cooldown_reduction::ReduceCooldown(), spell_sha_ashen_catalyst::ReduceLavaLashCooldown(), spell_pri_train_of_thought::ReducePenanceCooldown(), spell_pri_train_of_thought::ReducePowerWordShieldCooldown(), and spell_gen_trainer_heal_cooldown::UpdateReviveBattlePetCooldown().

◆ ModifyCoooldowns()

template<Trinity::invocable_r< bool, CooldownEntry const & > Predicate>
void SpellHistory::ModifyCoooldowns ( Predicate &&  predicate,
Duration  cooldownMod,
bool  withoutCategoryCooldown = false 
)
inline

◆ ModifySpellCooldown() [1/2]

void SpellHistory::ModifySpellCooldown ( CooldownStorageType::iterator &  itr,
Duration  cooldownMod,
bool  withoutCategoryCooldown 
)
private

◆ ModifySpellCooldown() [2/2]

void SpellHistory::ModifySpellCooldown ( uint32  spellId,
Duration  cooldownMod,
bool  withoutCategoryCooldown 
)
private

Definition at line 569 of file SpellHistory.cpp.

References _spellCooldowns, and ModifySpellCooldown().

Referenced by ModifyCooldown(), and ModifySpellCooldown().

◆ operator=() [1/2]

SpellHistory & SpellHistory::operator= ( SpellHistory &&  )
delete

◆ operator=() [2/2]

SpellHistory & SpellHistory::operator= ( SpellHistory const &  )
delete

◆ PauseCooldowns()

void SpellHistory::PauseCooldowns ( )

Definition at line 1050 of file SpellHistory.cpp.

References _pauseTime.

◆ ResetAllCharges()

◆ ResetAllCooldowns()

void SpellHistory::ResetAllCooldowns ( )

◆ ResetCharges()

◆ ResetCooldown() [1/2]

void SpellHistory::ResetCooldown ( CooldownStorageType::iterator &  itr,
bool  update = false 
)
private

◆ ResetCooldown() [2/2]

◆ ResetCooldowns()

template<Trinity::invocable_r< bool, CooldownEntry const & > Predicate>
void SpellHistory::ResetCooldowns ( Predicate &&  predicate,
bool  update = false 
)
inline

◆ RestoreCharge()

◆ RestoreCooldownStateAfterDuel()

◆ ResumeCooldowns()

void SpellHistory::ResumeCooldowns ( )

Definition at line 1055 of file SpellHistory.cpp.

References _categoryCharges, _pauseTime, _spellCooldowns, and Update().

◆ SaveCooldownStateBeforeDuel()

void SpellHistory::SaveCooldownStateBeforeDuel ( )

Definition at line 1164 of file SpellHistory.cpp.

References _spellCooldowns, and _spellCooldownsBeforeDuel.

Referenced by DuelResetScript::OnDuelStart().

◆ SaveToDB()

template<class OwnerType >
template void SpellHistory::SaveToDB< Pet > ( CharacterDatabaseTransaction  trans)

Definition at line 182 of file SpellHistory.cpp.

References _categoryCharges, _owner, _spellCooldowns, and CharacterDatabase.

Referenced by Pet::SavePetToDB(), and Player::SaveToDB().

◆ SendClearCooldowns()

void SpellHistory::SendClearCooldowns ( std::vector< int32 > &&  cooldowns) const
private

◆ SendCooldownEvent()

◆ SendSetSpellCharges()

◆ StartCooldown()

◆ Update()

void SpellHistory::Update ( )

Definition at line 220 of file SpellHistory.cpp.

References _categoryCharges, _categoryCooldowns, _spellCooldowns, and EraseCooldown().

Referenced by ResumeCooldowns().

◆ UpdateChargeRecoveryRate()

◆ UpdateCooldownRecoveryRate() [1/2]

void SpellHistory::UpdateCooldownRecoveryRate ( CooldownStorageType::iterator &  itr,
float  modChange,
bool  apply 
)
private

◆ UpdateCooldownRecoveryRate() [2/2]

template<Trinity::invocable_r< bool, CooldownEntry const & > Predicate>
void SpellHistory::UpdateCooldownRecoveryRate ( Predicate &&  predicate,
float  modChange,
bool  apply 
)
inline

◆ WritePacket() [1/3]

◆ WritePacket() [2/3]

◆ WritePacket() [3/3]

Member Data Documentation

◆ _categoryCharges

◆ _categoryCooldowns

◆ _globalCooldowns

GlobalCooldownStorageType SpellHistory::_globalCooldowns
private

◆ _owner

◆ _pauseTime

Optional<TimePoint> SpellHistory::_pauseTime
private

Definition at line 228 of file SpellHistory.h.

Referenced by PauseCooldowns(), and ResumeCooldowns().

◆ _schoolLockouts

TimePoint SpellHistory::_schoolLockouts[MAX_SPELL_SCHOOL]
private

Definition at line 225 of file SpellHistory.h.

Referenced by IsSchoolLocked(), and LockSpellSchool().

◆ _spellCooldowns

◆ _spellCooldownsBeforeDuel

CooldownStorageType SpellHistory::_spellCooldownsBeforeDuel
private

Definition at line 223 of file SpellHistory.h.

Referenced by RestoreCooldownStateAfterDuel(), and SaveCooldownStateBeforeDuel().


The documentation for this class was generated from the following files: