AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ThreatMgr Class Reference

#include "ThreatMgr.h"

Public Member Functions

 ThreatMgr (Unit *owner)
 
 ~ThreatMgr ()
 
UnitSelectVictim ()
 
UnitGetCurrentVictim () const
 
UnitGetAnyTarget () const
 
void clearReferences ()
 
void AddThreat (Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
 
void DoAddThreat (Unit *victim, float threat)
 
void ModifyThreatByPercent (Unit *victim, int32 percent)
 
float GetThreat (Unit *victim, bool alsoSearchOfflineList=false)
 
float GetThreatListSize () const
 
float getThreatWithoutTemp (Unit *victim, bool alsoSearchOfflineList=false)
 
bool isThreatListEmpty () const
 
bool areThreatListsEmpty () const
 
Acore::IteratorPair< std::list< ThreatReference * >::const_iterator > GetSortedThreatList () const
 
Acore::IteratorPair< std::list< ThreatReference * >::const_iterator > GetUnsortedThreatList () const
 
void processThreatEvent (ThreatRefStatusChangeEvent *threatRefStatusChangeEvent)
 
bool isNeedUpdateToClient (uint32 time)
 
HostileReferencegetCurrentVictim () const
 
UnitGetOwner () const
 
UnitgetHostileTarget ()
 
void tauntApply (Unit *taunter)
 
void tauntFadeOut (Unit *taunter)
 
void setCurrentVictim (HostileReference *hostileRef)
 
void setDirty (bool isDirty)
 
void ResetThreat (Unit const *who)
 
void ResetAllThreat ()
 
void ClearThreat (Unit const *who)
 
void ClearAllThreat ()
 
template<class PREDICATE >
void resetAggro (PREDICATE predicate)
 
ThreatContainer::StorageType const & GetThreatList () const
 
ThreatContainer::StorageType const & GetOfflineThreatList () const
 
ThreatContainerGetOnlineContainer ()
 
ThreatContainerGetOfflineContainer ()
 

Private Member Functions

HostileReferenceFindReference (Unit const *who, bool includeOffline) const
 
void _addThreat (Unit *victim, float threat)
 

Private Attributes

HostileReferenceiCurrentVictim
 
UnitiOwner
 
uint32 iUpdateTimer
 
ThreatContainer iThreatContainer
 
ThreatContainer iThreatOfflineContainer
 

Friends

class HostileReference
 

Detailed Description

Constructor & Destructor Documentation

◆ ThreatMgr()

ThreatMgr::ThreatMgr ( Unit owner)
explicit
415{
416}
#define THREAT_UPDATE_INTERVAL
Definition: ThreatMgr.h:36
HostileReference * iCurrentVictim
Definition: ThreatMgr.h:284
Unit * iOwner
Definition: ThreatMgr.h:285
uint32 iUpdateTimer
Definition: ThreatMgr.h:286

◆ ~ThreatMgr()

ThreatMgr::~ThreatMgr ( )
inline
210{ clearReferences(); }
void clearReferences()
Definition: ThreatMgr.cpp:427

References clearReferences().

Member Function Documentation

◆ _addThreat()

void ThreatMgr::_addThreat ( Unit victim,
float  threat 
)
private
490{
491 HostileReference* ref = iThreatContainer.AddThreat(victim, threat);
492 // Ref is not in the online refs, search the offline refs next
493 if (!ref)
494 ref = iThreatOfflineContainer.AddThreat(victim, threat);
495
496 if (!ref) // there was no ref => create a new one
497 {
498 // threat has to be 0 here
499 HostileReference* hostileRef = new HostileReference(victim, this, 0);
500 iThreatContainer.addReference(hostileRef);
501 hostileRef->AddThreat(threat); // now we add the real threat
502 if (victim->GetTypeId() == TYPEID_PLAYER && victim->ToPlayer()->IsGameMaster())
503 hostileRef->setOnlineOfflineState(false); // GM is always offline
504 }
505}
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
Definition: ThreatMgr.h:49
void AddThreat(float modThreat)
Definition: ThreatMgr.cpp:139
void setOnlineOfflineState(bool isOnline)
Definition: ThreatMgr.cpp:215
HostileReference * AddThreat(Unit *victim, float threat)
Definition: ThreatMgr.cpp:287
void addReference(HostileReference *hostileRef)
Definition: ThreatMgr.h:185
ThreatContainer iThreatOfflineContainer
Definition: ThreatMgr.h:288
ThreatContainer iThreatContainer
Definition: ThreatMgr.h:287
friend class HostileReference
Definition: ThreatMgr.h:206
Player * ToPlayer()
Definition: Object.h:195
TypeID GetTypeId() const
Definition: Object.h:121
bool IsGameMaster() const
Definition: Player.h:1136

References ThreatContainer::addReference(), HostileReference::AddThreat(), ThreatContainer::AddThreat(), Object::GetTypeId(), HostileReference, Player::IsGameMaster(), iThreatContainer, iThreatOfflineContainer, HostileReference::setOnlineOfflineState(), Object::ToPlayer(), and TYPEID_PLAYER.

Referenced by DoAddThreat().

◆ AddThreat()

void ThreatMgr::AddThreat ( Unit victim,
float  threat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL,
SpellInfo const *  threatSpell = nullptr 
)
438{
439 if (!ThreatCalcHelper::isValidProcess(victim, iOwner, threatSpell))
440 return;
441
442 threat = ThreatCalcHelper::calcThreat(victim, threat, schoolMask, threatSpell);
443 if (Creature* hatingCreature = iOwner->ToCreature())
444 {
445 if (hatingCreature->IsAIEnabled)
446 {
447 hatingCreature->AI()->CalculateThreat(victim, threat, threatSpell);
448 }
449 }
450
451 DoAddThreat(victim, threat);
452}
static float calcThreat(Unit *hatedUnit, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition: ThreatMgr.cpp:35
static bool isValidProcess(Unit *hatedUnit, Unit *hatingUnit, SpellInfo const *threatSpell=nullptr)
Definition: ThreatMgr.cpp:55
void DoAddThreat(Unit *victim, float threat)
Definition: ThreatMgr.cpp:454
Definition: Creature.h:46
Creature * ToCreature()
Definition: Object.h:197

References ThreatCalcHelper::calcThreat(), DoAddThreat(), iOwner, ThreatCalcHelper::isValidProcess(), and Object::ToCreature().

Referenced by HostileReference::AddThreat(), Unit::AddThreat(), ScriptedAI::DoAddThreat(), TemporaryThreatModifierEvent::Execute(), npc_frostwing_vrykul::npc_frostwing_vrykulAI::SpellHitTarget(), boss_drakkisath::boss_drakkisathAI::UpdateAI(), boss_grilek::boss_grilekAI::UpdateAI(), boss_gothik::boss_gothikAI::UpdateAI(), and boss_netherspite::boss_netherspiteAI::UpdatePortals().

◆ areThreatListsEmpty()

bool ThreatMgr::areThreatListsEmpty ( ) const
inline
bool empty() const
Definition: ThreatMgr.h:164

References ThreatContainer::empty(), iThreatContainer, and iThreatOfflineContainer.

◆ ClearAllThreat()

void ThreatMgr::ClearAllThreat ( )
419{
423}
bool isThreatListEmpty() const
Definition: ThreatMgr.h:225
bool CanHaveThreatList() const
Definition: Unit.cpp:14509
void SendClearThreatListOpcode()
Definition: Unit.cpp:20288

References Unit::CanHaveThreatList(), clearReferences(), iOwner, isThreatListEmpty(), and Unit::SendClearThreatListOpcode().

Referenced by CreatureAI::_EnterEvadeMode(), Unit::CleanupBeforeRemoveFromMap(), boss_kiljaeden::boss_kiljaedenAI::DamageTaken(), boss_grand_champion::boss_grand_championAI::DamageTaken(), npc_crystalline_frayer::npc_crystalline_frayerAI::DamageTaken(), npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI::DamageTaken(), npc_dark_nucleus::npc_dark_nucleusAI::DamageTaken(), npc_crok_scourgebane::npc_crok_scourgebaneAI::DoAction(), npc_spark_of_ionar::npc_spark_of_ionarAI::DoAction(), npc_taskmaster_fizzule::npc_taskmaster_fizzuleAI::DoFriend(), npc_unkor_the_ruthless::npc_unkor_the_ruthlessAI::DoNice(), npc_tirion_fordring_tft::npc_tirion_fordringAI::EnterEvadeMode(), GuardAI::EnterEvadeMode(), boss_doomrel::boss_doomrelAI::EnterEvadeMode(), npc_koltira_deathweaver::npc_koltira_deathweaverAI::EnterEvadeMode(), npc_varian_wrynn::npc_varian_wrynnAI::EnterEvadeMode(), npc_thrall_bfu::npc_thrall_bfuAI::EnterEvadeMode(), npc_pos_freed_slave::npc_pos_freed_slaveAI::EnterEvadeMode(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::EnterEvadeMode(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::EnterEvadeMode(), gunship_npc_AI::EnterEvadeMode(), npc_gunship_boarding_addAI::EnterEvadeMode(), npc_terenas_menethil::npc_terenas_menethilAI::EnterEvadeMode(), violet_hold_trashAI::EnterEvadeMode(), npc_pet_hunter_snake_trap::EnterEvadeMode(), npc_escortAI::EnterEvadeMode(), FollowerAI::EnterEvadeMode(), hyjalAI::EnterEvadeMode(), spell_q11919_q11940_drake_hunt::spell_q11919_q11940_drake_hunt_AuraScript::HandleEffectRemove(), PetAI::HandleReturnMovement(), Unit::Kill(), boss_urom::boss_uromAI::LeaveCombat(), Unit::setDeathState(), npc_yenniku::npc_yennikuAI::SpellHit(), spell_putricide_ooze_channel::spell_putricide_ooze_channel_SpellScript::StartAttack(), npc_highlord_darion_mograine::npc_highlord_darion_mograineAI::UpdateAI(), npc_yenniku::npc_yennikuAI::UpdateAI(), npc_snobold_vassal::npc_snobold_vassalAI::UpdateAI(), boss_malygos::boss_malygosAI::UpdateAI(), and npc_aeranas::npc_aeranasAI::UpdateAI().

◆ clearReferences()

◆ ClearThreat()

void ThreatMgr::ClearThreat ( Unit const *  who)
inline
252{ if (auto* ref = FindReference(who, true)) ref->removeReference(); }
HostileReference * FindReference(Unit const *who, bool includeOffline) const
Definition: ThreatMgr.h:280

References FindReference().

◆ DoAddThreat()

void ThreatMgr::DoAddThreat ( Unit victim,
float  threat 
)
455{
456 uint32 redirectThreadPct = victim->GetRedirectThreatPercent();
457 Unit* redirectTarget = victim->GetRedirectThreatTarget();
458
459 // Personal Spawns from same summoner can aggro each other
460 if (TempSummon* tempSummonVictim = victim->ToTempSummon())
461 {
462 if (tempSummonVictim->IsVisibleBySummonerOnly())
463 {
464 if (!GetOwner()->ToTempSummon() ||
465 !GetOwner()->ToTempSummon()->IsVisibleBySummonerOnly() ||
466 tempSummonVictim->GetSummonerGUID() != GetOwner()->ToTempSummon()->GetSummonerGUID())
467 {
468 redirectThreadPct = 100;
469 redirectTarget = tempSummonVictim->GetSummonerUnit();
470 }
471 }
472 }
473
474 // must check > 0.0f, otherwise dead loop
475 if (threat > 0.0f && redirectThreadPct)
476 {
477 if (redirectTarget)
478 {
479 float redirectThreat = CalculatePct(threat, redirectThreadPct);
480 threat -= redirectThreat;
481 if (ThreatCalcHelper::isValidProcess(redirectTarget, GetOwner()))
482 _addThreat(redirectTarget, redirectThreat);
483 }
484 }
485
486 _addThreat(victim, threat);
487}
std::uint32_t uint32
Definition: Define.h:108
T CalculatePct(T base, U pct)
Definition: Util.h:61
void _addThreat(Unit *victim, float threat)
Definition: ThreatMgr.cpp:489
Unit * GetOwner() const
Definition: ThreatMgr.h:237
Definition: TemporarySummon.h:40
Definition: Unit.h:1290
Unit * GetRedirectThreatTarget() const
Definition: Unit.cpp:19678
TempSummon * ToTempSummon()
Definition: Unit.h:2400
uint32 GetRedirectThreatPercent()
Definition: Unit.h:2347

References _addThreat(), CalculatePct(), GetOwner(), Unit::GetRedirectThreatPercent(), Unit::GetRedirectThreatTarget(), ThreatCalcHelper::isValidProcess(), and Unit::ToTempSummon().

Referenced by AddThreat(), Spell::EffectTaunt(), and HostileRefMgr::threatAssist().

◆ FindReference()

HostileReference * ThreatMgr::FindReference ( Unit const *  who,
bool  includeOffline 
) const
inlineprivate
280{ if (auto* ref = iThreatContainer.getReferenceByTarget(who)) return ref; if (includeOffline) if (auto* ref = iThreatOfflineContainer.getReferenceByTarget(who)) return ref; return nullptr; }
HostileReference * getReferenceByTarget(Unit const *victim) const
Definition: ThreatMgr.cpp:262

References ThreatContainer::getReferenceByTarget(), iThreatContainer, and iThreatOfflineContainer.

Referenced by ClearThreat(), and ResetThreat().

◆ GetAnyTarget()

Unit * ThreatMgr::GetAnyTarget ( ) const
inline
214{ auto const& list = GetThreatList(); if (!list.empty()) return list.front()->getTarget(); return nullptr; }
ThreatContainer::StorageType const & GetThreatList() const
Definition: ThreatMgr.h:274

References GetThreatList().

◆ GetCurrentVictim()

Unit * ThreatMgr::GetCurrentVictim ( ) const
inline
213{ if (ThreatReference* ref = getCurrentVictim()) return ref->GetVictim(); else return nullptr; }
HostileReference * getCurrentVictim() const
Definition: ThreatMgr.h:235

References getCurrentVictim(), and Unit::GetVictim().

Referenced by NonTankTargetSelector::operator()(), and UnitAI::SelectTargetList().

◆ getCurrentVictim()

HostileReference * ThreatMgr::getCurrentVictim ( ) const
inline

◆ getHostileTarget()

Unit * ThreatMgr::getHostileTarget ( )
517{
520 setCurrentVictim(nextVictim);
521 return getCurrentVictim() != nullptr ? getCurrentVictim()->getTarget() : nullptr;
522}
TO * getTarget() const
Definition: Reference.h:95
void update()
Definition: ThreatMgr.cpp:306
HostileReference * SelectNextVictim(Creature *attacker, HostileReference *currentVictim) const
Definition: ThreatMgr.cpp:318
void setCurrentVictim(HostileReference *hostileRef)
Definition: ThreatMgr.cpp:573

References getCurrentVictim(), GetOwner(), Reference< TO, FROM >::getTarget(), iThreatContainer, ThreatContainer::SelectNextVictim(), setCurrentVictim(), and ThreatContainer::update().

Referenced by SelectVictim(), and Creature::SelectVictim().

◆ GetOfflineContainer()

ThreatContainer & ThreatMgr::GetOfflineContainer ( )
inline

◆ GetOfflineThreatList()

ThreatContainer::StorageType const & ThreatMgr::GetOfflineThreatList ( ) const
inline
StorageType const & GetThreatList() const
Definition: ThreatMgr.h:177

References ThreatContainer::GetThreatList(), and iThreatOfflineContainer.

Referenced by debug_commandscript::HandleDebugThreatListCommand(), and Unit::SetPhaseMask().

◆ GetOnlineContainer()

◆ GetOwner()

◆ GetSortedThreatList()

Acore::IteratorPair< std::list< ThreatReference * >::const_iterator > ThreatMgr::GetSortedThreatList ( ) const
inline
228{ auto& list = iThreatContainer.GetThreatList(); return { list.cbegin(), list.cend() }; }

References ThreatContainer::GetThreatList(), and iThreatContainer.

Referenced by GetUnsortedThreatList(), and UnitAI::SelectTargetList().

◆ GetThreat()

◆ GetThreatList()

ThreatContainer::StorageType const & ThreatMgr::GetThreatList ( ) const
inline

References ThreatContainer::GetThreatList(), and iThreatContainer.

Referenced by boss_archimonde::boss_archimondeAI::CanUseFingerOfDeath(), boss_lady_deathwhisper::boss_lady_deathwhisperAI::DamageTaken(), boss_ysondre::boss_ysondreAI::DamageTaken(), UnitAI::DoAddAuraToAllHostilePlayers(), boss_archimonde::boss_archimondeAI::DoCastProtection(), UnitAI::DoCastToAllHostilePlayers(), boss_faction_championsAI::EnemiesInRange(), boss_ragnaros::boss_ragnarosAI::EnterEvadeMode(), boss_ouro::EnterEvadeMode(), boss_supremus::boss_supremusAI::FindHatefulStrikeTarget(), boss_shade_of_aran::boss_aranAI::FlameWreathEffect(), GetAnyTarget(), SmartScript::GetTargets(), GetThreatListSize(), debug_commandscript::HandleDebugThreatListCommand(), Unit::IsInCombatWith(), SmartScript::ProcessAction(), boss_priestess_lackey_commonAI::RecalculateThreat(), boss_faction_championsAI::RecalculateThreat(), boss_faction_championsAI::SelectEnemyCaster(), npc_scholomance_occultist::npc_scholomance_occultistAI::SelectUnitCasting(), Unit::SendChangeCurrentVictimOpcode(), Unit::SendThreatListUpdate(), Unit::SetPhaseMask(), npc_frostwing_vrykul::npc_frostwing_vrykulAI::SpellHitTarget(), BossAI::TeleportCheaters(), boss_nefarian::UpdateAI(), boss_yazzai::boss_yazzaiAI::UpdateAI(), boss_mandokir::boss_mandokirAI::UpdateAI(), boss_renataki::boss_renatakiAI::UpdateAI(), boss_taldaram::UpdateAI(), npc_green_dragon_combat_trigger::npc_green_dragon_combat_triggerAI::UpdateAI(), boss_kelthuzad::boss_kelthuzadAI::UpdateAI(), boss_patchwerk::boss_patchwerkAI::UpdateAI(), boss_sapphiron::boss_sapphironAI::UpdateAI(), boss_blackheart_the_inciter::boss_blackheart_the_inciterAI::UpdateAI(), boss_murmur::boss_murmurAI::UpdateAI(), boss_the_lurker_below::boss_the_lurker_belowAI::UpdateAI(), boss_alar::boss_alarAI::UpdateAI(), and npc_phase_hunter::npc_phase_hunterAI::UpdateAI().

◆ GetThreatListSize()

◆ getThreatWithoutTemp()

float ThreatMgr::getThreatWithoutTemp ( Unit victim,
bool  alsoSearchOfflineList = false 
)
540{
541 float threat = 0.0f;
543 if (!ref && alsoSearchOfflineList)
545 if (ref)
546 threat = ref->GetThreat() - ref->getTempThreatModifier();
547 return threat;
548}
float getTempThreatModifier()
Definition: ThreatMgr.h:94

References ThreatContainer::getReferenceByTarget(), HostileReference::getTempThreatModifier(), HostileReference::GetThreat(), iThreatContainer, and iThreatOfflineContainer.

Referenced by boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::UpdateAI().

◆ GetUnsortedThreatList()

Acore::IteratorPair< std::list< ThreatReference * >::const_iterator > ThreatMgr::GetUnsortedThreatList ( ) const
inline
229{ return GetSortedThreatList(); }
Acore::IteratorPair< std::list< ThreatReference * >::const_iterator > GetSortedThreatList() const
Definition: ThreatMgr.h:228

References GetSortedThreatList().

Referenced by boss_attumen::boss_attumenAI::IsSummonedBy(), and UnitAI::SelectTargetList().

◆ isNeedUpdateToClient()

bool ThreatMgr::isNeedUpdateToClient ( uint32  time)
638{
639 if (isThreatListEmpty())
640 return false;
641
642 if (time >= iUpdateTimer)
643 {
645 return true;
646 }
647 iUpdateTimer -= time;
648 return false;
649}

References isThreatListEmpty(), iUpdateTimer, and THREAT_UPDATE_INTERVAL.

◆ isThreatListEmpty()

◆ ModifyThreatByPercent()

◆ processThreatEvent()

void ThreatMgr::processThreatEvent ( ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
587{
588 threatRefStatusChangeEvent->setThreatMgr(this); // now we can set the threat manager
589
590 HostileReference* hostileRef = threatRefStatusChangeEvent->getReference();
591
592 switch (threatRefStatusChangeEvent->getType())
593 {
595 if ((getCurrentVictim() == hostileRef && threatRefStatusChangeEvent->getFValue() < 0.0f) ||
596 (getCurrentVictim() != hostileRef && threatRefStatusChangeEvent->getFValue() > 0.0f))
597 setDirty(true); // the order in the threat list might have changed
598 break;
600 if (!hostileRef->IsOnline())
601 {
602 if (hostileRef == getCurrentVictim())
603 {
604 setCurrentVictim(nullptr);
605 setDirty(true);
606 }
607 if (GetOwner() && GetOwner()->IsInWorld())
608 if (Unit* target = ObjectAccessor::GetUnit(*GetOwner(), hostileRef->getUnitGuid()))
609 if (GetOwner()->IsInMap(target))
611 iThreatContainer.remove(hostileRef);
613 }
614 else
615 {
616 if (getCurrentVictim() && hostileRef->GetThreat() > (1.1f * getCurrentVictim()->GetThreat()))
617 setDirty(true);
618 iThreatContainer.addReference(hostileRef);
620 }
621 break;
623 if (hostileRef == getCurrentVictim())
624 {
625 setCurrentVictim(nullptr);
626 setDirty(true);
627 }
629 if (hostileRef->IsOnline())
630 iThreatContainer.remove(hostileRef);
631 else
633 break;
634 }
635}
@ UEV_THREAT_REF_THREAT_CHANGE
Definition: UnitEvents.h:36
@ UEV_THREAT_REF_ONLINE_STATUS
Definition: UnitEvents.h:33
@ UEV_THREAT_REF_REMOVE_FROM_LIST
Definition: UnitEvents.h:39
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:204
ObjectGuid getUnitGuid() const
Definition: ThreatMgr.h:107
bool IsOnline() const
Definition: ThreatMgr.h:67
void remove(HostileReference *hostileRef)
Definition: ThreatMgr.h:180
void setDirty(bool isDirty)
Definition: ThreatMgr.h:246
float GetThreat(Unit *victim, bool alsoSearchOfflineList=false)
Definition: ThreatMgr.cpp:526
uint32 getType() const
Definition: UnitEvents.h:75
float getFValue() const
Definition: UnitEvents.h:105
void setThreatMgr(ThreatMgr *pThreatMgr)
Definition: UnitEvents.h:113
HostileReference * getReference() const
Definition: UnitEvents.h:111
void SendRemoveFromThreatListOpcode(HostileReference *pHostileReference)
Definition: Unit.cpp:20296

References ThreatContainer::addReference(), getCurrentVictim(), ThreatRefStatusChangeEvent::getFValue(), GetOwner(), ThreatRefStatusChangeEvent::getReference(), HostileReference::GetThreat(), GetThreat(), UnitBaseEvent::getType(), ObjectAccessor::GetUnit(), HostileReference::getUnitGuid(), iOwner, HostileReference::IsOnline(), iThreatContainer, iThreatOfflineContainer, ThreatContainer::remove(), Unit::SendRemoveFromThreatListOpcode(), setCurrentVictim(), setDirty(), ThreatRefStatusChangeEvent::setThreatMgr(), UEV_THREAT_REF_ONLINE_STATUS, UEV_THREAT_REF_REMOVE_FROM_LIST, and UEV_THREAT_REF_THREAT_CHANGE.

Referenced by HostileReference::fireStatusChanged().

◆ resetAggro()

template<class PREDICATE >
void ThreatMgr::resetAggro ( PREDICATE  predicate)
inline
257 {
259 if (threatList.empty())
260 return;
261
262 for (auto ref : threatList)
263 {
264 if (predicate(ref->getTarget()))
265 {
266 ref->SetThreat(0);
267 setDirty(true);
268 }
269 }
270 }
StorageType iThreatList
Definition: ThreatMgr.h:195
std::list< HostileReference * > StorageType
Definition: ThreatMgr.h:148

References iThreatContainer, ThreatContainer::iThreatList, and setDirty().

Referenced by boss_gothik::boss_gothikAI::UpdateAI().

◆ ResetAllThreat()

◆ ResetThreat()

void ThreatMgr::ResetThreat ( Unit const *  who)
inline
249{ if (auto* ref = FindReference(who, true)) ref->SetThreat(0.0f); }

References FindReference().

Referenced by ScriptedAI::DoResetThreat().

◆ SelectVictim()

Unit * ThreatMgr::SelectVictim ( )
inline
212{ return getHostileTarget(); }
Unit * getHostileTarget()
Definition: ThreatMgr.cpp:516

References getHostileTarget().

◆ setCurrentVictim()

void ThreatMgr::setCurrentVictim ( HostileReference hostileRef)
574{
575 if (pHostileReference && pHostileReference != iCurrentVictim)
576 {
577 iOwner->SendChangeCurrentVictimOpcode(pHostileReference);
578 }
579 iCurrentVictim = pHostileReference;
580}
void SendChangeCurrentVictimOpcode(HostileReference *pHostileReference)
Definition: Unit.cpp:20267

References iCurrentVictim, iOwner, and Unit::SendChangeCurrentVictimOpcode().

Referenced by Spell::EffectTaunt(), getHostileTarget(), and processThreatEvent().

◆ setDirty()

void ThreatMgr::setDirty ( bool  isDirty)
inline
246{ iThreatContainer.setDirty(isDirty); }
void setDirty(bool isDirty)
Definition: ThreatMgr.h:160

References iThreatContainer, and ThreatContainer::setDirty().

Referenced by processThreatEvent(), resetAggro(), and ResetAllThreat().

◆ tauntApply()

void ThreatMgr::tauntApply ( Unit taunter)

◆ tauntFadeOut()

void ThreatMgr::tauntFadeOut ( Unit taunter)
565{
567 if (ref)
568 ref->resetTempThreat();
569}
void resetTempThreat()
Definition: ThreatMgr.h:85

References ThreatContainer::getReferenceByTarget(), iThreatContainer, and HostileReference::resetTempThreat().

Friends And Related Function Documentation

◆ HostileReference

friend class HostileReference
friend

Referenced by _addThreat().

Member Data Documentation

◆ iCurrentVictim

HostileReference* ThreatMgr::iCurrentVictim
private

◆ iOwner

Unit* ThreatMgr::iOwner
private

◆ iThreatContainer

◆ iThreatOfflineContainer

◆ iUpdateTimer

uint32 ThreatMgr::iUpdateTimer
private