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

#include "FleeingMovementGenerator.h"

Inheritance diagram for TimedFleeingMovementGenerator:
FleeingMovementGenerator< Creature > MovementGeneratorMedium< T, D > MovementGenerator

Public Member Functions

 TimedFleeingMovementGenerator (ObjectGuid fright, uint32 time)
 
MovementGeneratorType GetMovementGeneratorType ()
 
bool Update (Unit *, uint32)
 
void Finalize (Unit *)
 
- Public Member Functions inherited from FleeingMovementGenerator< Creature >
 FleeingMovementGenerator (ObjectGuid fleeTargetGUID)
 
MovementGeneratorType GetMovementGeneratorType () override
 
void DoInitialize (Creature *)
 
void DoFinalize (Creature *)
 
void DoFinalize (Player *owner)
 
void DoReset (Creature *)
 
bool DoUpdate (Creature *, uint32)
 
- Public Member Functions inherited from MovementGeneratorMedium< T, D >
void Initialize (Unit *u) override
 
void Finalize (Unit *u) override
 
void Reset (Unit *u) override
 
bool Update (Unit *u, uint32 time_diff) override
 
- Public Member Functions inherited from MovementGenerator
virtual ~MovementGenerator ()
 
virtual void Initialize (Unit *)=0
 
virtual void Finalize (Unit *)=0
 
virtual void Reset (Unit *)=0
 
virtual bool Update (Unit *, uint32 time_diff)=0
 
virtual MovementGeneratorType GetMovementGeneratorType ()=0
 
virtual uint32 GetSplineId () const
 
virtual void unitSpeedChanged ()
 
virtual void Pause (uint32)
 
virtual void Resume (uint32)
 
virtual bool GetResetPosition (float &, float &, float &)
 

Private Attributes

TimeTracker i_totalFleeTime
 

Detailed Description

Constructor & Destructor Documentation

◆ TimedFleeingMovementGenerator()

TimedFleeingMovementGenerator::TimedFleeingMovementGenerator ( ObjectGuid  fright,
uint32  time 
)
inline
50 :
52 i_totalFleeTime(time) {}
Definition: FleeingMovementGenerator.h:25
TimeTracker i_totalFleeTime
Definition: FleeingMovementGenerator.h:59

Member Function Documentation

◆ Finalize()

void TimedFleeingMovementGenerator::Finalize ( Unit owner)
virtual

Reimplemented from MovementGeneratorMedium< T, D >.

234{
237
238 if (Unit* victim = owner->GetVictim())
239 {
240 owner->SetTarget(victim->GetGUID());
241 }
242
243 if (Creature* ownerCreature = owner->ToCreature())
244 {
245 if (CreatureAI* AI = ownerCreature->AI())
246 {
247 AI->MovementInform(TIMED_FLEEING_MOTION_TYPE, 0);
248 }
249 }
250}
@ TIMED_FLEEING_MOTION_TYPE
Definition: MotionMaster.h:51
@ UNIT_STATE_FLEEING_MOVE
Definition: UnitDefines.h:173
@ UNIT_STATE_FLEEING
Definition: UnitDefines.h:156
@ UNIT_FLAG_FLEEING
Definition: UnitDefines.h:252
Definition: CreatureAI.h:71
Definition: Creature.h:46
Creature * ToCreature()
Definition: Object.h:202
Definition: Unit.h:630
void ClearUnitState(uint32 f)
Definition: Unit.h:674
Unit * GetVictim() const
Definition: Unit.h:789
virtual void SetTarget(ObjectGuid=ObjectGuid::Empty)=0
void RemoveUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition: Unit.h:684

References Unit::ClearUnitState(), Unit::GetVictim(), Unit::RemoveUnitFlag(), Unit::SetTarget(), TIMED_FLEEING_MOTION_TYPE, Object::ToCreature(), UNIT_FLAG_FLEEING, UNIT_STATE_FLEEING, and UNIT_STATE_FLEEING_MOVE.

◆ GetMovementGeneratorType()

MovementGeneratorType TimedFleeingMovementGenerator::GetMovementGeneratorType ( )
inlinevirtual

◆ Update()

bool TimedFleeingMovementGenerator::Update ( Unit owner,
uint32  time_diff 
)
virtual

Reimplemented from MovementGeneratorMedium< T, D >.

253{
254 if (!owner->IsAlive())
255 return false;
256
258 {
259 owner->StopMoving();
260 return true;
261 }
262
263 i_totalFleeTime.Update(time_diff);
265 return false;
266
267 // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, uint32) version
268 // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly
270}
@ UNIT_STATE_NOT_MOVE
Definition: UnitDefines.h:197
void Update(time_t diff)
Definition: Timer.h:207
bool Passed() const
Definition: Timer.h:212
virtual bool IsMovementPreventedByCasting() const
Definition: Unit.cpp:4141
bool IsAlive() const
Definition: Unit.h:1204
void StopMoving()
Definition: Unit.cpp:16606
bool HasUnitState(const uint32 f) const
Definition: Unit.h:673
Definition: MovementGenerator.h:58
bool Update(Unit *, uint32)
Definition: FleeingMovementGenerator.cpp:252

References Unit::HasUnitState(), i_totalFleeTime, Unit::IsAlive(), Unit::IsMovementPreventedByCasting(), TimeTracker::Passed(), Unit::StopMoving(), UNIT_STATE_NOT_MOVE, TimeTracker::Update(), and Update().

Referenced by Update().

Member Data Documentation

◆ i_totalFleeTime

TimeTracker TimedFleeingMovementGenerator::i_totalFleeTime
private

Referenced by Update().