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 ()
 
Unit * GetOwner () const
 
bool CanHaveThreatList () const
 
Unit * GetCurrentVictim ()
 
Unit * GetLastVictim () const
 
Unit * GetAnyTarget () 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
 
uint32 GetThreatListPlayerCount (bool includeOffline=false) 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 ()
 
Unit * GetFixateTarget () 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
 
ThreatManager & operator= (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.

References _singleSchoolModifiers, and MAX_SPELL_SCHOOL.

◆ ~ThreatManager()

ThreatManager::~ThreatManager ( )

◆ 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 382 of file ThreatManager.cpp.

References _currentVictimRef, _myThreatListEntries, ThreatReference::_online, _owner, _redirectInfo, ThreatReference::AddThreat(), AddThreat(), CalculateModifiedThreat(), CalculatePct(), CanHaveThreatList(), Unit::GetCombatManager(), BaseEntity::GetGUID(), ThreatReference::GetOnlineState(), Unit::GetThreatManager(), ObjectAccessor::GetUnit(), SpellInfo::HasAttribute(), ThreatReference::HeapNotifyIncreased(), Unit::IsEngaged(), CombatManager::IsInCombatWith(), ThreatReference::IsOnline(), ThreatReference::ONLINE_STATE_ONLINE, ThreatReference::ONLINE_STATE_SUPPRESSED, ProcessAIUpdates(), PutThreatenedByMeRef(), PutThreatListRef(), CombatManager::SetInCombatWith(), ThreatReference::ShouldBeSuppressed(), SPELL_ATTR1_NO_THREAT, SPELL_ATTR2_NO_INITIAL_THREAT, ThreatReferenceImpl, ThreatReference::UpdateOffline(), and UpdateVictim().

Referenced by AddThreat(), ScriptedAI::AddThreat(), spell_opera_picnic_basket_smell::AfterRemove(), Spell::EffectThreat(), Unit::EngageWithTarget(), ForwardThreatForAssistingMe(), spell_leotheras_the_blind_whirlwind_init::HandleAfterCast(), AuraEffect::HandleAuraDummy(), spell_thaddius_magnetic_pull::HandleCast(), spell_auriaya_agro_creator::HandleDummyEffect(), spell_alysrazor_aggro_closest::spell_alysrazor_aggro_closest_SpellScript::HandleEffect(), spell_ulduar_random_aggro_periodic::HandleEffectPeriodic(), AuraEffect::HandlePeriodicManaLeechAuraTick(), spell_frostwarden_handler_focus_fire::HandleScript(), spell_the_lich_king_vile_spirit_move_target_search::HandleScript(), spell_sartura_whirlwind::HandleScript(), spell_toravon_random_aggro::HandleScript(), spell_leotheras_the_blind_whirlwind_effect::HandleScript(), Spell::HandleThreatSpells(), boss_blackheart_the_inciter_mc_dummy::IsSummonedBy(), MatchUnitThreatToHighestThreat(), SmartScript::ProcessAction(), and spell_putricide_ooze_channel::StartAttack().

◆ CalculateModifiedThreat()

◆ CanHaveThreatList() [1/2]

bool ThreatManager::CanHaveThreatList ( ) const
inline

Definition at line 106 of file ThreatManager.h.

Referenced by AddThreat(), Initialize(), and Update().

◆ CanHaveThreatList() [2/2]

◆ ClearAllThreat()

void ThreatManager::ClearAllThreat ( )

Definition at line 548 of file ThreatManager.cpp.

References _myThreatListEntries, and _needThreatClearUpdate.

Referenced by CombatManager::EndAllPvECombat().

◆ ClearFixate()

void ThreatManager::ClearFixate ( )
inline

◆ ClearThreat() [1/2]

void ThreatManager::ClearThreat ( ThreatReference *  ref)

◆ ClearThreat() [2/2]

◆ CompareReferencesLT()

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

◆ EvaluateSuppressed()

◆ FixateTarget()

◆ ForwardThreatForAssistingMe()

◆ GetAnyTarget()

Unit * ThreatManager::GetAnyTarget ( ) const

Definition at line 257 of file ThreatManager.cpp.

References _sortedThreatList, and Unit::GetVictim().

Referenced by Creature::CallForHelp().

◆ GetCurrentVictim()

◆ GetFixateTarget()

Unit * ThreatManager::GetFixateTarget ( ) const

◆ GetLastVictim()

Unit * ThreatManager::GetLastVictim ( ) const

◆ GetModifiableThreatList()

◆ GetOwner()

Unit * ThreatManager::GetOwner ( ) const
inline

Definition at line 103 of file ThreatManager.h.

◆ GetSortedThreatList()

◆ GetThreat()

◆ GetThreatenedByMeList()

auto const & ThreatManager::GetThreatenedByMeList ( ) const
inline

◆ GetThreatListPlayerCount()

uint32 ThreatManager::GetThreatListPlayerCount ( bool  includeOffline = false) const

◆ GetThreatListSize()

size_t ThreatManager::GetThreatListSize ( ) const

◆ GetUnsortedThreatList()

◆ Initialize()

void ThreatManager::Initialize ( )

◆ IsThreatenedBy() [1/2]

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

Definition at line 275 of file ThreatManager.cpp.

References _myThreatListEntries.

Referenced by IsThreatenedBy().

◆ IsThreatenedBy() [2/2]

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

Definition at line 282 of file ThreatManager.cpp.

References BaseEntity::GetGUID(), and IsThreatenedBy().

◆ IsThreateningAnyone()

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

Definition at line 345 of file ThreatManager.cpp.

References _threatenedByMe.

◆ IsThreateningTo() [1/2]

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

Definition at line 355 of file ThreatManager.cpp.

References _threatenedByMe.

Referenced by IsThreateningTo().

◆ IsThreateningTo() [2/2]

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

Definition at line 362 of file ThreatManager.cpp.

References BaseEntity::GetGUID(), and IsThreateningTo().

◆ IsThreatListEmpty()

◆ MatchUnitThreatToHighestThreat()

void ThreatManager::MatchUnitThreatToHighestThreat ( Unit *  target)

◆ ModifyThreatByPercent()

◆ operator=()

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

◆ ProcessAIUpdates()

void ThreatManager::ProcessAIUpdates ( )
private

◆ PurgeThreatenedByMeRef()

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

Definition at line 916 of file ThreatManager.cpp.

References _threatenedByMe.

Referenced by ThreatReference::UnregisterAndFree().

◆ PurgeThreatListRef()

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

◆ PutThreatenedByMeRef()

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

== OTHERS' THREAT LISTS ==

Definition at line 909 of file ThreatManager.cpp.

References _owner, _threatenedByMe, ASSERT, BaseEntity::GetGUID(), and ObjectGuid::ToString().

Referenced by AddThreat().

◆ PutThreatListRef()

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

== MY THREAT LIST ==

Definition at line 885 of file ThreatManager.cpp.

References _myThreatListEntries, _needClientUpdate, _owner, _sortedThreatList, ASSERT, BaseEntity::GetGUID(), and ObjectGuid::ToString().

Referenced by AddThreat().

◆ RegisterForAIUpdate()

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

Definition at line 662 of file ThreatManager.cpp.

References _needsAIUpdate.

Referenced by ThreatReference::UpdateOffline().

◆ RegisterRedirectThreat()

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

== REDIRECT SYSTEM ==

Definition at line 801 of file ThreatManager.cpp.

References _redirectRegistry, and UpdateRedirectInfo().

Referenced by Spell::EffectRedirectThreat().

◆ RemoveMeFromThreatLists()

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

Definition at line 761 of file ThreatManager.cpp.

References _owner, and _threatenedByMe.

Referenced by CombatManager::EndAllPvECombat().

◆ ReselectVictim()

◆ ResetAllThreat()

◆ ResetThreat()

void ThreatManager::ResetThreat ( Unit *  target)
inline

Definition at line 149 of file ThreatManager.h.

Referenced by ScriptedAI::ResetThreat(), and boss_murmur::UpdateAI().

◆ ResetUpdateTimer()

void ThreatManager::ResetUpdateTimer ( )

Definition at line 237 of file ThreatManager.cpp.

References _updateTimer, and THREAT_UPDATE_INTERVAL.

Referenced by Creature::AtEngage().

◆ ScaleThreat()

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

Definition at line 477 of file ThreatManager.cpp.

References _myThreatListEntries, and BaseEntity::GetGUID().

◆ SendClearAllThreatToClients()

void ThreatManager::SendClearAllThreatToClients ( ) const
private

◆ SendRemoveToClients()

◆ SendThreatListToClients()

◆ TauntUpdate()

◆ UnregisterRedirectThreat() [1/2]

◆ UnregisterRedirectThreat() [2/2]

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

Definition at line 816 of file ThreatManager.cpp.

References _redirectRegistry, and UpdateRedirectInfo().

◆ Update()

◆ UpdateMySpellSchoolModifiers()

void ThreatManager::UpdateMySpellSchoolModifiers ( )

◆ UpdateMyTempModifiers()

void ThreatManager::UpdateMyTempModifiers ( )

◆ UpdateRedirectInfo()

void ThreatManager::UpdateRedirectInfo ( )
private

◆ UpdateVictim()

void ThreatManager::UpdateVictim ( )
private

Friends And Related Symbol Documentation

◆ CompareThreatLessThan

friend struct CompareThreatLessThan
friend

Definition at line 259 of file ThreatManager.h.

◆ debug_commandscript

friend class debug_commandscript
friend

Definition at line 260 of file ThreatManager.h.

◆ ThreatReference

friend class ThreatReference
friend

Definition at line 257 of file ThreatManager.h.

◆ ThreatReferenceImpl

friend class ThreatReferenceImpl
friend

Definition at line 258 of file ThreatManager.h.

Referenced by AddThreat().

Member Data Documentation

◆ _currentVictimRef

ThreatReference const* ThreatManager::_currentVictimRef
private

◆ _fixateRef

ThreatReference const* ThreatManager::_fixateRef
private

Definition at line 219 of file ThreatManager.h.

Referenced by FixateTarget(), GetFixateTarget(), PurgeThreatListRef(), and ReselectVictim().

◆ _multiSchoolModifiers

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

◆ _myThreatListEntries

◆ _needClientUpdate

bool ThreatManager::_needClientUpdate
private

◆ _needsAIUpdate

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

Definition at line 213 of file ThreatManager.h.

Referenced by ProcessAIUpdates(), and RegisterForAIUpdate().

◆ _needThreatClearUpdate

bool ThreatManager::_needThreatClearUpdate
private

Definition at line 204 of file ThreatManager.h.

Referenced by ClearAllThreat(), and Update().

◆ _owner

◆ _ownerCanHaveThreatList

bool ThreatManager::_ownerCanHaveThreatList
private

Definition at line 188 of file ThreatManager.h.

Referenced by Initialize().

◆ _redirectInfo

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

◆ _redirectRegistry

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

◆ _singleSchoolModifiers

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

◆ _sortedThreatList

◆ _threatenedByMe

◆ _updateTimer

uint32 ThreatManager::_updateTimer
private

Definition at line 205 of file ThreatManager.h.

Referenced by ResetUpdateTimer(), and Update().

◆ CompareThreat

const CompareThreatLessThan ThreatManager::CompareThreat
staticprivate

Definition at line 190 of file ThreatManager.h.

◆ THREAT_UPDATE_INTERVAL

const uint32 ThreatManager::THREAT_UPDATE_INTERVAL = 1000u
static

Definition at line 86 of file ThreatManager.h.

Referenced by ResetUpdateTimer(), and Update().


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