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

#include <ThreatManager.h>

Classes

class  Heap
 
class  ThreatListIterator
 

Public Member Functions

 ThreatManager (Unit *owner)
 
 ~ThreatManager ()
 
void Initialize ()
 
void Update (uint32 tdiff)
 
void ResetUpdateTimer ()
 
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 ==
 
void ScaleThreat (Unit *target, float factor)
 
void ModifyThreatByPercent (Unit *target, float 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 ==
 
void RemoveMeFromThreatLists (bool(*unitFilter)(Unit const *otherUnit))
 
void UpdateMyTempModifiers ()
 
void UpdateMySpellSchoolModifiers ()
 
void RegisterRedirectThreat (uint32 spellId, ObjectGuid const &victim, float pct)
 == REDIRECT SYSTEM ==
 
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 ==
 
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 ==
 
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
 
bool _needThreatClearUpdate
 
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, float > > _redirectInfo
 
std::unordered_map< uint32, std::unordered_map< ObjectGuid, float > > _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 196 of file ThreatManager.cpp.

◆ ~ThreatManager()

ThreatManager::~ThreatManager ( )

Definition at line 203 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 371 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 666 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 106 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 537 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ ClearFixate()

void ThreatManager::ClearFixate ( )
inline

Definition at line 164 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ ClearThreat() [1/2]

void ThreatManager::ClearThreat ( ThreatReference ref)

Definition at line 529 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ ClearThreat() [2/2]

void ThreatManager::ClearThreat ( Unit target)

Definition at line 522 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 657 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 353 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ FixateTarget()

void ThreatManager::FixateTarget ( Unit target)

Definition at line 548 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 722 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 257 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 242 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 562 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 250 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 325 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ GetOwner()

Unit * ThreatManager::GetOwner ( ) const
inline

Definition at line 103 of file ThreatManager.h.

◆ GetSortedThreatList()

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

Definition at line 311 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 284 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 138 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ GetThreatListSize()

size_t ThreatManager::GetThreatListSize ( ) const

Definition at line 292 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 297 of file ThreatManager.cpp.

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

◆ Initialize()

void ThreatManager::Initialize ( )

Definition at line 210 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 275 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 282 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ IsThreateningAnyone()

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

Definition at line 334 of file ThreatManager.cpp.

◆ IsThreateningTo() [1/2]

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

Definition at line 344 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 351 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ IsThreatListEmpty()

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

Definition at line 265 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ MatchUnitThreatToHighestThreat()

void ThreatManager::MatchUnitThreatToHighestThreat ( Unit target)

Definition at line 473 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,
float  percent 
)
inline

Definition at line 146 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 640 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 905 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ PurgeThreatListRef()

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

Definition at line 883 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 898 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 874 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)
private

Definition at line 651 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ RegisterRedirectThreat()

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

== REDIRECT SYSTEM ==

Definition at line 790 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 750 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ ReselectVictim()

ThreatReference const * ThreatManager::ReselectVictim ( )
private

Definition at line 585 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 516 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ ResetThreat()

void ThreatManager::ResetThreat ( Unit target)
inline

Definition at line 148 of file ThreatManager.h.

+ Here is the caller graph for this function:

◆ ResetUpdateTimer()

void ThreatManager::ResetUpdateTimer ( )

Definition at line 237 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ ScaleThreat()

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

Definition at line 466 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ SendClearAllThreatToClients()

void ThreatManager::SendClearAllThreatToClients ( ) const
private

Definition at line 818 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 828 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 839 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 493 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 796 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 805 of file ThreatManager.cpp.

+ Here is the call graph for this function:

◆ Update()

void ThreatManager::Update ( uint32  tdiff)

Definition at line 215 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 783 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 762 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 912 of file ThreatManager.cpp.

+ Here is the caller graph for this function:

◆ UpdateVictim()

void ThreatManager::UpdateVictim ( )
private

Definition at line 570 of file ThreatManager.cpp.

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

Friends And Related Symbol Documentation

◆ CompareThreatLessThan

friend struct CompareThreatLessThan
friend

Definition at line 258 of file ThreatManager.h.

◆ debug_commandscript

friend class debug_commandscript
friend

Definition at line 259 of file ThreatManager.h.

◆ ThreatReference

friend class ThreatReference
friend

Definition at line 256 of file ThreatManager.h.

◆ ThreatReferenceImpl

friend class ThreatReferenceImpl
friend

Definition at line 257 of file ThreatManager.h.

Member Data Documentation

◆ _currentVictimRef

ThreatReference const* ThreatManager::_currentVictimRef
private

Definition at line 217 of file ThreatManager.h.

◆ _fixateRef

ThreatReference const* ThreatManager::_fixateRef
private

Definition at line 218 of file ThreatManager.h.

◆ _multiSchoolModifiers

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

Definition at line 225 of file ThreatManager.h.

◆ _myThreatListEntries

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

Definition at line 206 of file ThreatManager.h.

◆ _needClientUpdate

bool ThreatManager::_needClientUpdate
private

Definition at line 202 of file ThreatManager.h.

◆ _needsAIUpdate

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

Definition at line 212 of file ThreatManager.h.

◆ _needThreatClearUpdate

bool ThreatManager::_needThreatClearUpdate
private

Definition at line 203 of file ThreatManager.h.

◆ _owner

Unit* const ThreatManager::_owner
private

Definition at line 186 of file ThreatManager.h.

◆ _ownerCanHaveThreatList

bool ThreatManager::_ownerCanHaveThreatList
private

Definition at line 187 of file ThreatManager.h.

◆ _redirectInfo

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

Definition at line 229 of file ThreatManager.h.

◆ _redirectRegistry

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

Definition at line 230 of file ThreatManager.h.

◆ _singleSchoolModifiers

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

Definition at line 224 of file ThreatManager.h.

◆ _sortedThreatList

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

Definition at line 205 of file ThreatManager.h.

◆ _threatenedByMe

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

Definition at line 223 of file ThreatManager.h.

◆ _updateTimer

uint32 ThreatManager::_updateTimer
private

Definition at line 204 of file ThreatManager.h.

◆ CompareThreat

const CompareThreatLessThan ThreatManager::CompareThreat
staticprivate

Definition at line 189 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: