TrinityCore
ThreatManager Class Reference

#include <ThreatManager.h>

Classes

class  Heap
 
class  ThreatListIterator
 

Public Member Functions

 ThreatManager (Unit *owner)
 
 ~ThreatManager ()
 
void Initialize ()
 
void Update (uint32 tdiff)
 
UnitGetOwner () const
 
bool CanHaveThreatList () const
 
UnitGetCurrentVictim ()
 
UnitGetLastVictim () const
 
UnitGetAnyTarget () const
 
bool IsThreatListEmpty (bool includeOffline=false) const
 
bool IsThreatenedBy (ObjectGuid const &who, bool includeOffline=false) const
 
bool IsThreatenedBy (Unit const *who, bool includeOffline=false) const
 
float GetThreat (Unit const *who, bool includeOffline=false) const
 
size_t GetThreatListSize () const
 
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetUnsortedThreatList () const
 
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetSortedThreatList () const
 
std::vector< ThreatReference * > GetModifiableThreatList ()
 
bool IsThreateningAnyone (bool includeOffline=false) const
 
bool IsThreateningTo (ObjectGuid const &who, bool includeOffline=false) const
 
bool IsThreateningTo (Unit const *who, bool includeOffline=false) const
 
auto const & GetThreatenedByMeList () const
 
void EvaluateSuppressed (bool canExpire=false)
 
void AddThreat (Unit *target, float amount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false, bool ignoreRedirects=false)
 == AFFECT MY THREAT LIST == More...
 
void ScaleThreat (Unit *target, float factor)
 
void ModifyThreatByPercent (Unit *target, int32 percent)
 
void ResetThreat (Unit *target)
 
void MatchUnitThreatToHighestThreat (Unit *target)
 
void TauntUpdate ()
 
void ResetAllThreat ()
 
void ClearThreat (Unit *target)
 
void ClearThreat (ThreatReference *ref)
 
void ClearAllThreat ()
 
void FixateTarget (Unit *target)
 
void ClearFixate ()
 
UnitGetFixateTarget () const
 
void ForwardThreatForAssistingMe (Unit *assistant, float baseAmount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false)
 == AFFECT OTHERS' THREAT LISTS == More...
 
void RemoveMeFromThreatLists (bool(*unitFilter)(Unit const *otherUnit))
 
void UpdateMyTempModifiers ()
 
void UpdateMySpellSchoolModifiers ()
 
void RegisterRedirectThreat (uint32 spellId, ObjectGuid const &victim, uint32 pct)
 == REDIRECT SYSTEM == More...
 
void UnregisterRedirectThreat (uint32 spellId)
 
void UnregisterRedirectThreat (uint32 spellId, ObjectGuid const &victim)
 
 ThreatManager (ThreatManager const &)=delete
 
ThreatManageroperator= (ThreatManager const &)=delete
 

Static Public Member Functions

static bool CanHaveThreatList (Unit const *who)
 

Static Public Attributes

static const uint32 THREAT_UPDATE_INTERVAL = 1000u
 

Private Member Functions

void SendClearAllThreatToClients () const
 
void SendRemoveToClients (Unit const *victim) const
 
void SendThreatListToClients (bool newHighest) const
 
void PutThreatListRef (ObjectGuid const &guid, ThreatReference *ref)
 == MY THREAT LIST == More...
 
void PurgeThreatListRef (ObjectGuid const &guid)
 
void ProcessAIUpdates ()
 
void RegisterForAIUpdate (ObjectGuid const &guid)
 
void UpdateVictim ()
 
ThreatReference const * ReselectVictim ()
 
void PutThreatenedByMeRef (ObjectGuid const &guid, ThreatReference *ref)
 == OTHERS' THREAT LISTS == More...
 
void PurgeThreatenedByMeRef (ObjectGuid const &guid)
 
void UpdateRedirectInfo ()
 

Static Private Member Functions

static bool CompareReferencesLT (ThreatReference const *a, ThreatReference const *b, float aWeight)
 
static float CalculateModifiedThreat (float threat, Unit const *victim, SpellInfo const *spell)
 

Private Attributes

Unit *const _owner
 
bool _ownerCanHaveThreatList
 
bool _needClientUpdate
 
uint32 _updateTimer
 
std::unique_ptr< Heap_sortedThreatList
 
std::unordered_map< ObjectGuid, ThreatReference * > _myThreatListEntries
 
std::vector< ObjectGuid_needsAIUpdate
 
ThreatReference const * _currentVictimRef
 
ThreatReference const * _fixateRef
 
std::unordered_map< ObjectGuid, ThreatReference * > _threatenedByMe
 
std::array< float, MAX_SPELL_SCHOOL_singleSchoolModifiers
 
std::unordered_map< std::underlying_type< SpellSchoolMask >::type, float > _multiSchoolModifiers
 
std::vector< std::pair< ObjectGuid, uint32 > > _redirectInfo
 
std::unordered_map< uint32, std::unordered_map< ObjectGuid, uint32 > > _redirectRegistry
 

Static Private Attributes

static const CompareThreatLessThan CompareThreat
 

Friends

class ThreatReference
 
class ThreatReferenceImpl
 
struct CompareThreatLessThan
 
class debug_commandscript
 

Detailed Description

Definition at line 81 of file ThreatManager.h.

Constructor & Destructor Documentation

◆ ThreatManager() [1/2]

ThreatManager::ThreatManager ( Unit owner)

Definition at line 192 of file ThreatManager.cpp.

◆ ~ThreatManager()

ThreatManager::~ThreatManager ( )

Definition at line 199 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ ThreatManager() [2/2]

ThreatManager::ThreatManager ( ThreatManager const &  )
delete

Member Function Documentation

◆ AddThreat()

void ThreatManager::AddThreat ( Unit target,
float  amount,
SpellInfo const *  spell = nullptr,
bool  ignoreModifiers = false,
bool  ignoreRedirects = false 
)

== AFFECT MY THREAT LIST ==

Definition at line 353 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateModifiedThreat()

float ThreatManager::CalculateModifiedThreat ( float  threat,
Unit const *  victim,
SpellInfo const *  spell 
)
staticprivate

Definition at line 662 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanHaveThreatList() [1/2]

bool ThreatManager::CanHaveThreatList ( ) const
inline

Definition at line 103 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ CanHaveThreatList() [2/2]

bool ThreatManager::CanHaveThreatList ( Unit const *  who)
static

Definition at line 172 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClearAllThreat()

void ThreatManager::ClearAllThreat ( )

Definition at line 538 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClearFixate()

void ThreatManager::ClearFixate ( )
inline

Definition at line 161 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ ClearThreat() [1/2]

void ThreatManager::ClearThreat ( ThreatReference ref)

Definition at line 530 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ ClearThreat() [2/2]

void ThreatManager::ClearThreat ( Unit target)

Definition at line 523 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CompareReferencesLT()

bool ThreatManager::CompareReferencesLT ( ThreatReference const *  a,
ThreatReference const *  b,
float  aWeight 
)
staticprivate

Definition at line 653 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EvaluateSuppressed()

void ThreatManager::EvaluateSuppressed ( bool  canExpire = false)

Definition at line 335 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ FixateTarget()

void ThreatManager::FixateTarget ( Unit target)

Definition at line 549 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ForwardThreatForAssistingMe()

void ThreatManager::ForwardThreatForAssistingMe ( Unit assistant,
float  baseAmount,
SpellInfo const *  spell = nullptr,
bool  ignoreModifiers = false 
)

== AFFECT OTHERS' THREAT LISTS ==

Definition at line 718 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAnyTarget()

Unit * ThreatManager::GetAnyTarget ( ) const

Definition at line 239 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCurrentVictim()

Unit * ThreatManager::GetCurrentVictim ( )

Definition at line 224 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFixateTarget()

Unit * ThreatManager::GetFixateTarget ( ) const

Definition at line 563 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetLastVictim()

Unit * ThreatManager::GetLastVictim ( ) const

Definition at line 232 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetModifiableThreatList()

std::vector< ThreatReference * > ThreatManager::GetModifiableThreatList ( )

Definition at line 307 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ GetOwner()

Unit * ThreatManager::GetOwner ( ) const
inline

Definition at line 100 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ GetSortedThreatList()

Trinity::IteratorPair< ThreatManager::ThreatListIterator, std::nullptr_t > ThreatManager::GetSortedThreatList ( ) const

Definition at line 293 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ GetThreat()

float ThreatManager::GetThreat ( Unit const *  who,
bool  includeOffline = false 
) const

Definition at line 266 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetThreatenedByMeList()

auto const & ThreatManager::GetThreatenedByMeList ( ) const
inline

Definition at line 135 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ GetThreatListSize()

size_t ThreatManager::GetThreatListSize ( ) const

Definition at line 274 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ GetUnsortedThreatList()

Trinity::IteratorPair< ThreatManager::ThreatListIterator, std::nullptr_t > ThreatManager::GetUnsortedThreatList ( ) const

Definition at line 279 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ Initialize()

void ThreatManager::Initialize ( )

Definition at line 206 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsThreatenedBy() [1/2]

bool ThreatManager::IsThreatenedBy ( ObjectGuid const &  who,
bool  includeOffline = false 
) const

Definition at line 257 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ IsThreatenedBy() [2/2]

bool ThreatManager::IsThreatenedBy ( Unit const *  who,
bool  includeOffline = false 
) const

Definition at line 264 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ IsThreateningAnyone()

bool ThreatManager::IsThreateningAnyone ( bool  includeOffline = false) const

Definition at line 316 of file ThreatManager.cpp.

◆ IsThreateningTo() [1/2]

bool ThreatManager::IsThreateningTo ( ObjectGuid const &  who,
bool  includeOffline = false 
) const

Definition at line 326 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ IsThreateningTo() [2/2]

bool ThreatManager::IsThreateningTo ( Unit const *  who,
bool  includeOffline = false 
) const

Definition at line 333 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ IsThreatListEmpty()

bool ThreatManager::IsThreatListEmpty ( bool  includeOffline = false) const

Definition at line 247 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ MatchUnitThreatToHighestThreat()

void ThreatManager::MatchUnitThreatToHighestThreat ( Unit target)

Definition at line 474 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ModifyThreatByPercent()

void ThreatManager::ModifyThreatByPercent ( Unit target,
int32  percent 
)
inline

Definition at line 143 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ operator=()

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

◆ ProcessAIUpdates()

void ThreatManager::ProcessAIUpdates ( )
private

Definition at line 641 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PurgeThreatenedByMeRef()

void ThreatManager::PurgeThreatenedByMeRef ( ObjectGuid const &  guid)
private

Definition at line 901 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ PurgeThreatListRef()

void ThreatManager::PurgeThreatListRef ( ObjectGuid const &  guid)
private

Definition at line 879 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ PutThreatenedByMeRef()

void ThreatManager::PutThreatenedByMeRef ( ObjectGuid const &  guid,
ThreatReference ref 
)
private

== OTHERS' THREAT LISTS ==

Definition at line 894 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PutThreatListRef()

void ThreatManager::PutThreatListRef ( ObjectGuid const &  guid,
ThreatReference ref 
)
private

== MY THREAT LIST ==

Definition at line 870 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterForAIUpdate()

void ThreatManager::RegisterForAIUpdate ( ObjectGuid const &  guid)
inlineprivate

Definition at line 207 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ RegisterRedirectThreat()

void ThreatManager::RegisterRedirectThreat ( uint32  spellId,
ObjectGuid const &  victim,
uint32  pct 
)

== REDIRECT SYSTEM ==

Definition at line 786 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveMeFromThreatLists()

void ThreatManager::RemoveMeFromThreatLists ( bool(*)(Unit const *otherUnit)  unitFilter)

Definition at line 746 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ ReselectVictim()

ThreatReference const * ThreatManager::ReselectVictim ( )
private

Definition at line 586 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResetAllThreat()

void ThreatManager::ResetAllThreat ( )

Definition at line 517 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ ResetThreat()

void ThreatManager::ResetThreat ( Unit target)
inline

Definition at line 145 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ ScaleThreat()

void ThreatManager::ScaleThreat ( Unit target,
float  factor 
)

Definition at line 467 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ SendClearAllThreatToClients()

void ThreatManager::SendClearAllThreatToClients ( ) const
private

Definition at line 814 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendRemoveToClients()

void ThreatManager::SendRemoveToClients ( Unit const *  victim) const
private

Definition at line 824 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendThreatListToClients()

void ThreatManager::SendThreatListToClients ( bool  newHighest) const
private

Definition at line 835 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TauntUpdate()

void ThreatManager::TauntUpdate ( )

Definition at line 494 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnregisterRedirectThreat() [1/2]

void ThreatManager::UnregisterRedirectThreat ( uint32  spellId)

Definition at line 792 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnregisterRedirectThreat() [2/2]

void ThreatManager::UnregisterRedirectThreat ( uint32  spellId,
ObjectGuid const &  victim 
)

Definition at line 801 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ Update()

void ThreatManager::Update ( uint32  tdiff)

Definition at line 211 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateMySpellSchoolModifiers()

void ThreatManager::UpdateMySpellSchoolModifiers ( )

Definition at line 779 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateMyTempModifiers()

void ThreatManager::UpdateMyTempModifiers ( )

Definition at line 758 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateRedirectInfo()

void ThreatManager::UpdateRedirectInfo ( )
private

Definition at line 908 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ UpdateVictim()

void ThreatManager::UpdateVictim ( )
private

Definition at line 571 of file ThreatManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ CompareThreatLessThan

friend struct CompareThreatLessThan
friend

Definition at line 254 of file ThreatManager.h.

◆ debug_commandscript

friend class debug_commandscript
friend

Definition at line 255 of file ThreatManager.h.

◆ ThreatReference

friend class ThreatReference
friend

Definition at line 252 of file ThreatManager.h.

◆ ThreatReferenceImpl

friend class ThreatReferenceImpl
friend

Definition at line 253 of file ThreatManager.h.

Member Data Documentation

◆ _currentVictimRef

ThreatReference const* ThreatManager::_currentVictimRef
private

Definition at line 213 of file ThreatManager.h.

◆ _fixateRef

ThreatReference const* ThreatManager::_fixateRef
private

Definition at line 214 of file ThreatManager.h.

◆ _multiSchoolModifiers

std::unordered_map<std::underlying_type<SpellSchoolMask>::type, float> ThreatManager::_multiSchoolModifiers
mutableprivate

Definition at line 221 of file ThreatManager.h.

◆ _myThreatListEntries

std::unordered_map<ObjectGuid, ThreatReference*> ThreatManager::_myThreatListEntries
private

Definition at line 202 of file ThreatManager.h.

◆ _needClientUpdate

bool ThreatManager::_needClientUpdate
private

Definition at line 199 of file ThreatManager.h.

◆ _needsAIUpdate

std::vector<ObjectGuid> ThreatManager::_needsAIUpdate
private

Definition at line 208 of file ThreatManager.h.

◆ _owner

Unit* const ThreatManager::_owner
private

Definition at line 183 of file ThreatManager.h.

◆ _ownerCanHaveThreatList

bool ThreatManager::_ownerCanHaveThreatList
private

Definition at line 184 of file ThreatManager.h.

◆ _redirectInfo

std::vector<std::pair<ObjectGuid, uint32> > ThreatManager::_redirectInfo
private

Definition at line 225 of file ThreatManager.h.

◆ _redirectRegistry

std::unordered_map<uint32, std::unordered_map<ObjectGuid, uint32> > ThreatManager::_redirectRegistry
private

Definition at line 226 of file ThreatManager.h.

◆ _singleSchoolModifiers

std::array<float, MAX_SPELL_SCHOOL> ThreatManager::_singleSchoolModifiers
private

Definition at line 220 of file ThreatManager.h.

◆ _sortedThreatList

std::unique_ptr<Heap> ThreatManager::_sortedThreatList
private

Definition at line 201 of file ThreatManager.h.

◆ _threatenedByMe

std::unordered_map<ObjectGuid, ThreatReference*> ThreatManager::_threatenedByMe
private

Definition at line 219 of file ThreatManager.h.

◆ _updateTimer

uint32 ThreatManager::_updateTimer
private

Definition at line 200 of file ThreatManager.h.

◆ CompareThreat

const CompareThreatLessThan ThreatManager::CompareThreat
staticprivate

Definition at line 186 of file ThreatManager.h.

◆ THREAT_UPDATE_INTERVAL

const uint32 ThreatManager::THREAT_UPDATE_INTERVAL = 1000u
static

Definition at line 86 of file ThreatManager.h.


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