AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
HomeMovementGenerator< Creature > Class Reference

#include "HomeMovementGenerator.h"

Inheritance diagram for HomeMovementGenerator< Creature >:
MovementGeneratorMedium< Creature, HomeMovementGenerator< Creature > > MovementGenerator

Public Member Functions

 HomeMovementGenerator (bool walk)
 
 ~HomeMovementGenerator ()
 
void DoInitialize (Creature *)
 
void DoFinalize (Creature *)
 
void DoReset (Creature *)
 
bool DoUpdate (Creature *, const uint32)
 
MovementGeneratorType GetMovementGeneratorType ()
 
void unitSpeedChanged ()
 
- Public Member Functions inherited from MovementGeneratorMedium< Creature, HomeMovementGenerator< Creature > >
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 Member Functions

void _setTargetLocation (Creature *)
 

Private Attributes

bool arrived: 1
 
bool i_recalculateTravel: 1
 
bool _walk
 

Detailed Description

Constructor & Destructor Documentation

◆ HomeMovementGenerator()

32: arrived(false), i_recalculateTravel(false), _walk(walk) {}
bool i_recalculateTravel
Definition: HomeMovementGenerator.h:45
bool _walk
Definition: HomeMovementGenerator.h:46
bool arrived
Definition: HomeMovementGenerator.h:44

◆ ~HomeMovementGenerator()

Member Function Documentation

◆ _setTargetLocation()

void HomeMovementGenerator< Creature >::_setTargetLocation ( Creature owner)
private
49{
50 // Xinef: dont interrupt in any cast!
51 //if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
52 // return;
53 Movement::MoveSplineInit init(owner);
54 float x, y, z, o;
55
56 // Xinef: if there is motion generator on controlled slot, this one is not updated
57 // Xinef: always get reset pos from idle slot
59 if (owner->GetMotionMaster()->empty() || !gen || !gen->GetResetPosition(x, y, z))
60 {
61 owner->GetHomePosition(x, y, z, o);
62 init.SetFacing(o);
63 }
64
65 owner->UpdateAllowedPositionZ(x, y, z);
66 init.MoveTo(x, y, z, DisableMgr::IsPathfindingEnabled(owner->FindMap()), true);
67 init.SetWalk(_walk);
68 init.Launch();
69
70 arrived = false;
71
73}
std::uint32_t uint32
Definition: Define.h:107
@ MOTION_SLOT_IDLE
Definition: MotionMaster.h:61
@ UNIT_STATE_EVADE
Definition: UnitDefines.h:170
@ UNIT_STATE_POSSESSED
Definition: UnitDefines.h:165
@ UNIT_STATE_ALL_STATE
Definition: UnitDefines.h:199
@ UNIT_STATE_IGNORE_PATHFINDING
Definition: UnitDefines.h:176
@ UNIT_STATE_NO_ENVIRONMENT_UPD
Definition: UnitDefines.h:177
bool IsPathfindingEnabled(const Map *map)
Definition: DisableMgr.cpp:411
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:339
void UpdateAllowedPositionZ(float x, float y, float &z, float *groundZ=nullptr) const
Definition: Object.cpp:1554
Map * FindMap() const
Definition: Object.h:532
void ClearUnitState(uint32 f)
Definition: Unit.h:674
MotionMaster * GetMotionMaster()
Definition: Unit.h:1601
_Ty GetMotionSlot(int slot) const
Definition: MotionMaster.h:153
bool empty() const
Definition: MotionMaster.h:146
Definition: MovementGenerator.h:30
virtual bool GetResetPosition(float &, float &, float &)
Definition: MovementGenerator.h:53
Definition: MoveSplineInit.h:71

References Unit::ClearUnitState(), MotionMaster::empty(), WorldObject::FindMap(), Creature::GetHomePosition(), Unit::GetMotionMaster(), MotionMaster::GetMotionSlot(), MovementGenerator::GetResetPosition(), DisableMgr::IsPathfindingEnabled(), Movement::MoveSplineInit::Launch(), MOTION_SLOT_IDLE, Movement::MoveSplineInit::MoveTo(), Movement::MoveSplineInit::SetFacing(), Movement::MoveSplineInit::SetWalk(), UNIT_STATE_ALL_STATE, UNIT_STATE_EVADE, UNIT_STATE_IGNORE_PATHFINDING, UNIT_STATE_NO_ENVIRONMENT_UPD, UNIT_STATE_POSSESSED, and WorldObject::UpdateAllowedPositionZ().

◆ DoFinalize()

void HomeMovementGenerator< Creature >::DoFinalize ( Creature owner)
30{
32 if (arrived)
33 {
34 // Xinef: npc run by default
35 //owner->SetWalk(true);
36 owner->LoadCreaturesAddon(true);
37 owner->AI()->JustReachedHome();
38 }
39
40 if (!owner->HasSwimmingFlagOutOfCombat())
42}
@ UNIT_FLAG_SWIMMING
Definition: UnitDefines.h:244
virtual void JustReachedHome()
Definition: CreatureAI.h:164
bool LoadCreaturesAddon(bool reload=false)
Definition: Creature.cpp:2705
bool HasSwimmingFlagOutOfCombat() const
Definition: Creature.h:396
CreatureAI * AI() const
Definition: Creature.h:143
void RemoveUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition: Unit.h:684

References Creature::AI(), Unit::ClearUnitState(), Creature::HasSwimmingFlagOutOfCombat(), CreatureAI::JustReachedHome(), Creature::LoadCreaturesAddon(), Unit::RemoveUnitFlag(), UNIT_FLAG_SWIMMING, and UNIT_STATE_EVADE.

◆ DoInitialize()

void HomeMovementGenerator< Creature >::DoInitialize ( Creature owner)
25{
26 _setTargetLocation(owner);
27}
void _setTargetLocation(Creature *)
Definition: HomeMovementGenerator.cpp:48

◆ DoReset()

void HomeMovementGenerator< Creature >::DoReset ( Creature )
45{
46}

◆ DoUpdate()

bool HomeMovementGenerator< Creature >::DoUpdate ( Creature owner,
const  uint32 
)
76{
77 arrived = owner->movespline->Finalized();
78 if (arrived)
79 return false;
80
82 {
83 _setTargetLocation(owner);
84 i_recalculateTravel = false;
85 }
86
87 return true;
88}
Movement::MoveSpline * movespline
Definition: Unit.h:1818
bool Finalized() const
Definition: MoveSpline.h:116

References Movement::MoveSpline::Finalized(), and Unit::movespline.

◆ GetMovementGeneratorType()

MovementGeneratorType HomeMovementGenerator< Creature >::GetMovementGeneratorType ( )
inlinevirtual

Implements MovementGenerator.

39{ return HOME_MOTION_TYPE; }
@ HOME_MOTION_TYPE
Definition: MotionMaster.h:44

References HOME_MOTION_TYPE.

◆ unitSpeedChanged()

void HomeMovementGenerator< Creature >::unitSpeedChanged ( )
inlinevirtual

Reimplemented from MovementGenerator.

40{ i_recalculateTravel = true; }

Member Data Documentation

◆ _walk

bool HomeMovementGenerator< Creature >::_walk
private

◆ arrived

bool HomeMovementGenerator< Creature >::arrived
private

◆ i_recalculateTravel

bool HomeMovementGenerator< Creature >::i_recalculateTravel
private