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
551: BasicEvent(), m_owner(owner), m_threatVictimGUID(threatVictimGUID), m_threatValue(threatValue) { }
BasicEvent()=default
float m_threatValue
Definition: Creature.h:557
Creature & m_owner
Definition: Creature.h:555
ObjectGuid m_threatVictimGUID
Definition: Creature.h:556

Member Function Documentation

◆ Execute()

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

Reimplemented from BasicEvent.

258{
260 {
261 if (m_owner.IsInCombatWith(victim))
262 {
263 m_owner.GetThreatMgr().ModifyThreatByPercent(victim, -100); // Reset threat to zero.
264 m_owner.GetThreatMgr().AddThreat(victim, m_threatValue); // Set to the previous value it had, first before modification.
265 }
266 }
267
268 return true;
269}
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:199
void ModifyThreatByPercent(Unit *victim, int32 percent)
Definition: ThreatMgr.cpp:508
void AddThreat(Unit *victim, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition: ThreatMgr.cpp:436
Definition: Unit.h:630
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:21038
ThreatMgr & GetThreatMgr()
Definition: Unit.h:903

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().