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

#include "Creature.h"

Inheritance diagram for TemporaryThreatModifierEvent:
BasicEvent

Public Member Functions

 TemporaryThreatModifierEvent (Creature &owner, ObjectGuid threatVictimGUID, float threatValue)
 
bool Execute (uint64 e_time, uint32 p_time) override
 
- Public Member Functions inherited from BasicEvent
 BasicEvent ()=default
 
virtual ~BasicEvent ()=default
 
virtual bool Execute (uint64, uint32)
 
virtual bool IsDeletable () const
 
virtual void Abort (uint64)
 
void ScheduleAbort ()
 

Private Attributes

Creaturem_owner
 
ObjectGuid m_threatVictimGUID
 
float m_threatValue
 

Detailed Description

Constructor & Destructor Documentation

◆ TemporaryThreatModifierEvent()

TemporaryThreatModifierEvent::TemporaryThreatModifierEvent ( Creature owner,
ObjectGuid  threatVictimGUID,
float  threatValue 
)
inline
521: BasicEvent(), m_owner(owner), m_threatVictimGUID(threatVictimGUID), m_threatValue(threatValue) { }
BasicEvent()=default
float m_threatValue
Definition: Creature.h:527
Creature & m_owner
Definition: Creature.h:525
ObjectGuid m_threatVictimGUID
Definition: Creature.h:526

Member Function Documentation

◆ Execute()

bool TemporaryThreatModifierEvent::Execute ( uint64  e_time,
uint32  p_time 
)
overridevirtual

Reimplemented from BasicEvent.

205{
207 {
208 if (m_owner.IsInCombatWith(victim))
209 {
210 m_owner.GetThreatMgr().ModifyThreatByPercent(victim, -100); // Reset threat to zero.
211 m_owner.GetThreatMgr().AddThreat(victim, m_threatValue); // Set to the previous value it had, first before modification.
212 }
213 }
214
215 return true;
216}
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:204
void ModifyThreatByPercent(Unit *victim, int32 percent)
Definition: ThreatMgr.cpp:509
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition: ThreatMgr.cpp:437
Definition: Unit.h:1290
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:21205
ThreatMgr & GetThreatMgr()
Definition: Unit.h:2145

References ThreatMgr::AddThreat(), Unit::GetThreatMgr(), ObjectAccessor::GetUnit(), Unit::IsInCombatWith(), m_owner, m_threatValue, m_threatVictimGUID, and ThreatMgr::ModifyThreatByPercent().

Member Data Documentation

◆ m_owner

Creature& TemporaryThreatModifierEvent::m_owner
private

Referenced by Execute().

◆ m_threatValue

float TemporaryThreatModifierEvent::m_threatValue
private

Referenced by Execute().

◆ m_threatVictimGUID

ObjectGuid TemporaryThreatModifierEvent::m_threatVictimGUID
private

Referenced by Execute().