AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Movement::MoveSplineInit Class Reference

#include "MoveSplineInit.h"

Public Member Functions

 MoveSplineInit (Unit *m)
 
int32 Launch ()
 
void Stop ()
 
void SetParabolic (float amplitude, float start_time)
 
void SetAnimation (AnimType anim)
 
void SetFacing (float angle)
 
void SetFacing (Vector3 const &point)
 
void SetFacing (Unit const *target)
 
void MovebyPath (const PointsArray &path, int32 pointId=0)
 
void MoveTo (const Vector3 &destination, bool generatePath=false, bool forceDestination=false)
 
void MoveTo (float x, float y, float z, bool generatePath=false, bool forceDestination=false)
 
void SetFirstPointId (int32 pointId)
 
void SetSmooth ()
 
void SetFly ()
 
void SetWalk (bool enable)
 
void SetCyclic ()
 
void SetFall ()
 
void SetTransportEnter ()
 
void SetTransportExit ()
 
void SetOrientationInversed ()
 
void SetOrientationFixed (bool enable)
 
void SetVelocity (float velocity)
 
PointsArrayPath ()
 
void DisableTransportPathTransformations ()
 

Protected Attributes

MoveSplineInitArgs args
 
Unitunit
 

Detailed Description

Constructor & Destructor Documentation

◆ MoveSplineInit()

Movement::MoveSplineInit::MoveSplineInit ( Unit m)
explicit
188 : unit(m)
189 {
192 // mix existing state into new
195 }
MovementFlags
Definition: Unit.h:550
@ MOVEMENTFLAG_ONTRANSPORT
Definition: Unit.h:561
@ MOVEMENTFLAG_DISABLE_GRAVITY
Definition: Unit.h:562
@ MOVEMENTFLAG_CAN_FLY
Definition: Unit.h:576
@ MOVEMENTFLAG_WALKING
Definition: Unit.h:560
UInt32Counter splineIdGen
Definition: MovementUtil.cpp:25
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:322
MovementInfo m_movementInfo
Definition: Object.h:595
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2274
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:18924
T NewId()
Definition: MovementTypedefs.h:63
bool flying
Definition: MoveSplineFlag.h:121
bool walkmode
Definition: MoveSplineFlag.h:120
MoveSplineInitArgs args
Definition: MoveSplineInit.h:160
Unit * unit
Definition: MoveSplineInit.h:161
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:53
uint32 splineId
Definition: MoveSplineInitArgs.h:58
bool TransformForTransport
Definition: MoveSplineInitArgs.h:61

References args, Movement::MoveSplineInitArgs::flags, Movement::MoveSplineFlag::flying, Unit::GetTransGUID(), MovementInfo::HasMovementFlag(), Unit::HasUnitMovementFlag(), WorldObject::m_movementInfo, MOVEMENTFLAG_CAN_FLY, MOVEMENTFLAG_DISABLE_GRAVITY, MOVEMENTFLAG_ONTRANSPORT, MOVEMENTFLAG_WALKING, Movement::counter< T, limit >::NewId(), Movement::MoveSplineInitArgs::splineId, Movement::splineIdGen, Movement::MoveSplineInitArgs::TransformForTransport, unit, and Movement::MoveSplineFlag::walkmode.

Member Function Documentation

◆ DisableTransportPathTransformations()

◆ Launch()

int32 Movement::MoveSplineInit::Launch ( )
59 {
60 MoveSpline& move_spline = *unit->movespline;
61
63 Location real_position;
64 // there is a big chance that current position is unknown if current state is not finalized, need compute it
65 // this also allows CalculatePath spline position and update map position in much greater intervals
66 // Don't compute for transport movement if the unit is in a motion between two transports
67 if (!move_spline.Finalized() && move_spline.onTransport == transport)
68 real_position = move_spline.ComputePosition();
69 else
70 {
71 Position const* pos;
72 if (!transport)
73 pos = unit;
74 else
76
77 real_position.x = pos->GetPositionX();
78 real_position.y = pos->GetPositionY();
79 real_position.z = pos->GetPositionZ();
80 real_position.orientation = unit->GetOrientation();
81 }
82
83 // should i do the things that user should do? - no.
84 if (args.path.empty())
85 return 0;
86
87 // corrent first vertex
88 args.path[0] = real_position;
89 args.initialOrientation = real_position.orientation;
90 move_spline.onTransport = transport;
91
93 moveFlags |= MOVEMENTFLAG_SPLINE_ENABLED;
94
96 {
97 moveFlags = (moveFlags & ~(MOVEMENTFLAG_BACKWARD)) | MOVEMENTFLAG_FORWARD;
98 }
99 else
100 {
101 moveFlags = (moveFlags & ~(MOVEMENTFLAG_FORWARD)) | MOVEMENTFLAG_BACKWARD;
102 }
103
104 if (moveFlags & MOVEMENTFLAG_ROOT)
105 moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;
106
107 if (!args.HasVelocity)
108 {
109 // If spline is initialized with SetWalk method it only means we need to select
110 // walk move speed for it but not add walk flag to unit
111 uint32 moveFlagsForSpeed = moveFlags;
112 if (args.flags.walkmode)
113 moveFlagsForSpeed |= MOVEMENTFLAG_WALKING;
114 else
115 moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;
116
117 args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
118 }
119
120 // limit the speed in the same way the client does
121 args.velocity = std::min(args.velocity, args.flags.catmullrom || args.flags.flying ? 50.0f : std::max(28.0f, unit->GetSpeed(MOVE_RUN) * 4.0f));
122
123 if (!args.Validate(unit))
124 return 0;
125
127 move_spline.Initialize(args);
128
130 data << unit->GetPackGUID();
131 if (transport)
132 {
133 data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
134 data << unit->GetTransGUID().WriteAsPacked();
135 data << int8(unit->GetTransSeat());
136 }
137
138 PacketBuilder::WriteMonsterMove(move_spline, data);
139 unit->SendMessageToSet(&data, true);
140
141 return move_spline.Duration();
142 }
std::uint32_t uint32
Definition: Define.h:108
std::int8_t int8
Definition: Define.h:106
@ MOVEMENTFLAG_SPLINE_ENABLED
Definition: Unit.h:579
@ MOVEMENTFLAG_FORWARD
Definition: Unit.h:552
@ MOVEMENTFLAG_BACKWARD
Definition: Unit.h:553
@ MOVEMENTFLAG_ROOT
Definition: Unit.h:563
@ MOVE_RUN
Definition: Unit.h:379
@ SMSG_MONSTER_MOVE
Definition: Opcodes.h:251
@ SMSG_MONSTER_MOVE_TRANSPORT
Definition: Opcodes.h:716
UnitMoveType SelectSpeedType(uint32 moveFlags)
Definition: MoveSplineInit.cpp:29
PackedGuid const & GetPackGUID() const
Definition: Object.h:108
struct MovementInfo::TransportInfo transport
void SetMovementFlags(uint32 flag)
Definition: Object.h:319
uint32 GetMovementFlags() const
Definition: Object.h:318
Position pos
Definition: Object.h:285
int8 GetTransSeat() const
Definition: Object.h:591
virtual void SendMessageToSet(WorldPacket const *data, bool self) const
Definition: Object.h:482
PackedGuid WriteAsPacked() const
Definition: ObjectGuid.h:318
Definition: Position.h:28
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Movement::MoveSpline * movespline
Definition: Unit.h:2440
float GetSpeed(UnitMoveType mtype) const
Definition: Unit.cpp:14318
static void WriteMonsterMove(const MoveSpline &mov, ByteBuffer &data)
Definition: MovementPacketBuilder.cpp:142
bool catmullrom
Definition: MoveSplineFlag.h:126
bool orientationInversed
Definition: MoveSplineFlag.h:135
bool Validate(Unit *unit) const
============================================================================================
Definition: MoveSpline.cpp:201
PointsArray path
Definition: MoveSplineInitArgs.h:51
float initialOrientation
Definition: MoveSplineInitArgs.h:59
bool HasVelocity
Definition: MoveSplineInitArgs.h:60
float velocity
Definition: MoveSplineInitArgs.h:55
Definition: WorldPacket.h:27
Definition: zone_shadowmoon_valley.cpp:847
float y
Definition: zone_shadowmoon_valley.cpp:848
float z
Definition: zone_shadowmoon_valley.cpp:848
float x
Definition: zone_shadowmoon_valley.cpp:848

References args, Movement::MoveSplineFlag::catmullrom, Movement::MoveSpline::ComputePosition(), Movement::MoveSpline::Duration(), Movement::MoveSpline::Finalized(), Movement::MoveSplineInitArgs::flags, Movement::MoveSplineFlag::flying, MovementInfo::GetMovementFlags(), Position::GetOrientation(), Object::GetPackGUID(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetSpeed(), Unit::GetTransGUID(), WorldObject::GetTransSeat(), Unit::HasUnitMovementFlag(), Movement::MoveSplineInitArgs::HasVelocity, Movement::MoveSpline::Initialize(), Movement::MoveSplineInitArgs::initialOrientation, WorldObject::m_movementInfo, MOVE_RUN, MOVEMENTFLAG_BACKWARD, MOVEMENTFLAG_FORWARD, MOVEMENTFLAG_ONTRANSPORT, MOVEMENTFLAG_ROOT, MOVEMENTFLAG_SPLINE_ENABLED, MOVEMENTFLAG_WALKING, Unit::movespline, Movement::MoveSpline::onTransport, Movement::Location::orientation, Movement::MoveSplineFlag::orientationInversed, Movement::MoveSplineInitArgs::path, MovementInfo::TransportInfo::pos, Movement::SelectSpeedType(), WorldObject::SendMessageToSet(), MovementInfo::SetMovementFlags(), WorldPacket::SetOpcode(), SMSG_MONSTER_MOVE, SMSG_MONSTER_MOVE_TRANSPORT, MovementInfo::transport, unit, Movement::MoveSplineInitArgs::Validate(), Movement::MoveSplineInitArgs::velocity, Movement::MoveSplineFlag::walkmode, ObjectGuid::WriteAsPacked(), and Movement::PacketBuilder::WriteMonsterMove().

Referenced by Unit::_ExitVehicle(), RandomMovementGenerator< T >::_setRandomLocation(), HomeMovementGenerator< Creature >::_setTargetLocation(), Vehicle::AddPassenger(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::DoAction(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::DoAction(), boss_algalon_the_observer::boss_algalon_the_observerAI::DoAction(), EscortMovementGenerator< T >::DoInitialize(), FlightPathMovementGenerator::DoReset(), ConfusedMovementGenerator< T >::DoUpdate(), EscortMovementGenerator< T >::DoUpdate(), PointMovementGenerator< T >::DoUpdate(), ChaseMovementGenerator< T >::DoUpdate(), FollowMovementGenerator< T >::DoUpdate(), MoveDelayed::Execute(), npc_kalecgos_kj::npc_kalecgos_kjAI::JustSummoned(), npc_medivh_bm::JustSummoned(), Unit::MonsterMoveWithSpeed(), MotionMaster::MoveBackwards(), MotionMaster::MoveCharge(), MotionMaster::MoveCircleTarget(), MotionMaster::MoveFall(), MotionMaster::MoveJump(), MotionMaster::MoveKnockbackFrom(), MotionMaster::MoveLand(), MotionMaster::MoveTakeoff(), Unit::SetFacingTo(), Unit::SetFacingToObject(), FleeingMovementGenerator< T >::SetTargetLocation(), WaypointMovementGenerator< Creature >::StartMove(), Unit::StopMovingOnCurrentPos(), boss_kiljaeden::boss_kiljaedenAI::UpdateAI(), boss_malygos::boss_malygosAI::UpdateAI(), and npc_lord_arete::npc_lord_areteAI::UpdateAI().

◆ MovebyPath()

◆ MoveTo() [1/2]

void Movement::MoveSplineInit::MoveTo ( const Vector3 &  destination,
bool  generatePath = false,
bool  forceDestination = false 
)
218 {
219 if (generatePath)
220 {
221 PathGenerator path(unit);
222 bool result = path.CalculatePath(dest.x, dest.y, dest.z, forceDestination);
223 if (result && !(path.GetPathType() & PATHFIND_NOPATH))
224 {
225 MovebyPath(path.GetPath());
226 return;
227 }
228 }
229
231 args.path.resize(2);
232 TransportPathTransform transform(unit, args.TransformForTransport);
233 args.path[1] = transform(dest);
234 }
@ PATHFIND_NOPATH
Definition: PathGenerator.h:51
Definition: PathGenerator.h:60
void MovebyPath(const PointsArray &path, int32 pointId=0)
Definition: MoveSplineInit.h:175

References args, PathGenerator::CalculatePath(), PathGenerator::GetPath(), PathGenerator::GetPathType(), MovebyPath(), Movement::MoveSplineInitArgs::path, Movement::MoveSplineInitArgs::path_Idx_offset, PATHFIND_NOPATH, Movement::MoveSplineInitArgs::TransformForTransport, and unit.

Referenced by Unit::_ExitVehicle(), RandomMovementGenerator< T >::_setRandomLocation(), HomeMovementGenerator< Creature >::_setTargetLocation(), Vehicle::AddPassenger(), boss_algalon_the_observer::boss_algalon_the_observerAI::DoAction(), EscortMovementGenerator< T >::DoInitialize(), ConfusedMovementGenerator< T >::DoUpdate(), EscortMovementGenerator< T >::DoUpdate(), PointMovementGenerator< T >::DoUpdate(), MoveDelayed::Execute(), npc_kalecgos_kj::npc_kalecgos_kjAI::JustSummoned(), Unit::MonsterMoveWithSpeed(), MotionMaster::MoveBackwards(), MotionMaster::MoveCircleTarget(), MotionMaster::MoveFall(), MotionMaster::MoveJump(), MotionMaster::MoveKnockbackFrom(), MotionMaster::MoveLand(), MotionMaster::MoveTakeoff(), MoveTo(), Unit::SetFacingTo(), Unit::SetFacingToObject(), WaypointMovementGenerator< Creature >::StartMove(), Unit::StopMovingOnCurrentPos(), boss_malygos::boss_malygosAI::UpdateAI(), and npc_lord_arete::npc_lord_areteAI::UpdateAI().

◆ MoveTo() [2/2]

void Movement::MoveSplineInit::MoveTo ( float  x,
float  y,
float  z,
bool  generatePath = false,
bool  forceDestination = false 
)
inline
183 {
184 MoveTo(G3D::Vector3(x, y, z), generatePath, forceDestination);
185 }
void MoveTo(const Vector3 &destination, bool generatePath=false, bool forceDestination=false)
Definition: MoveSplineInit.cpp:217

References MoveTo().

◆ Path()

PointsArray & Movement::MoveSplineInit::Path ( )
inline

◆ SetAnimation()

void Movement::MoveSplineInit::SetAnimation ( AnimType  anim)
inline
195 {
196 args.time_perc = 0.f;
198 }
std::uint8_t uint8
Definition: Define.h:110
void EnableAnimation(uint8 anim)
Definition: MoveSplineFlag.h:104
float time_perc
Definition: MoveSplineInitArgs.h:57

References args, Movement::MoveSplineFlag::EnableAnimation(), Movement::MoveSplineInitArgs::flags, and Movement::MoveSplineInitArgs::time_perc.

Referenced by MotionMaster::MoveLand(), MotionMaster::MoveTakeoff(), and WaypointMovementGenerator< Creature >::StartMove().

◆ SetCyclic()

void Movement::MoveSplineInit::SetCyclic ( )
inline

◆ SetFacing() [1/3]

void Movement::MoveSplineInit::SetFacing ( float  angle)
204 {
206 {
207 if (Unit* vehicle = unit->GetVehicleBase())
208 angle -= vehicle->GetOrientation();
209 else if (Transport* transport = unit->GetTransport())
210 angle -= transport->GetOrientation();
211 }
212
213 args.facing.angle = G3D::wrap(angle, 0.f, (float)G3D::twoPi());
215 }
Transport * GetTransport() const
Definition: Object.h:585
Definition: Transport.h:29
Definition: Unit.h:1290
Unit * GetVehicleBase() const
Definition: Unit.cpp:18910
void EnableFacingAngle()
Definition: MoveSplineFlag.h:110
float angle
Definition: MoveSplineInitArgs.h:37
FacingInfo facing
Definition: MoveSplineInitArgs.h:52

References Movement::FacingInfo::angle, args, Movement::MoveSplineFlag::EnableFacingAngle(), Movement::MoveSplineInitArgs::facing, Movement::MoveSplineInitArgs::flags, WorldObject::GetTransport(), Unit::GetVehicleBase(), Movement::MoveSplineInitArgs::TransformForTransport, and unit.

Referenced by Unit::_ExitVehicle(), HomeMovementGenerator< Creature >::_setTargetLocation(), Vehicle::AddPassenger(), PointMovementGenerator< T >::DoUpdate(), ChaseMovementGenerator< T >::DoUpdate(), MoveDelayed::Execute(), npc_kalecgos_kj::npc_kalecgos_kjAI::JustSummoned(), MotionMaster::MoveBackwards(), MotionMaster::MoveCircleTarget(), MotionMaster::MoveJump(), Unit::SetFacingTo(), Unit::SetFacingToObject(), WaypointMovementGenerator< Creature >::StartMove(), Unit::StopMovingOnCurrentPos(), and boss_malygos::boss_malygosAI::UpdateAI().

◆ SetFacing() [2/3]

void Movement::MoveSplineInit::SetFacing ( Unit const *  target)

◆ SetFacing() [3/3]

void Movement::MoveSplineInit::SetFacing ( Vector3 const &  point)
inline
201 {
202 TransportPathTransform transform(unit, args.TransformForTransport);
203 Vector3 finalSpot = transform(spot);
204 args.facing.f.x = finalSpot.x;
205 args.facing.f.y = finalSpot.y;
206 args.facing.f.z = finalSpot.z;
208 }
void EnableFacingPoint()
Definition: MoveSplineFlag.h:109
struct Movement::FacingInfo::@284 f
float z
Definition: MoveSplineInitArgs.h:34
float x
Definition: MoveSplineInitArgs.h:34
float y
Definition: MoveSplineInitArgs.h:34

References args, Movement::MoveSplineFlag::EnableFacingPoint(), Movement::FacingInfo::f, Movement::MoveSplineInitArgs::facing, Movement::MoveSplineInitArgs::flags, Movement::MoveSplineInitArgs::TransformForTransport, unit, Movement::FacingInfo::x, Movement::FacingInfo::y, and Movement::FacingInfo::z.

◆ SetFall()

void Movement::MoveSplineInit::SetFall ( )
inline

◆ SetFirstPointId()

void Movement::MoveSplineInit::SetFirstPointId ( int32  pointId)
inline

◆ SetFly()

void Movement::MoveSplineInit::SetFly ( )
inline

◆ SetOrientationFixed()

void Movement::MoveSplineInit::SetOrientationFixed ( bool  enable)
inline

◆ SetOrientationInversed()

void Movement::MoveSplineInit::SetOrientationInversed ( )
inline

◆ SetParabolic()

void Movement::MoveSplineInit::SetParabolic ( float  amplitude,
float  start_time 
)
inline

◆ SetSmooth()

void Movement::MoveSplineInit::SetSmooth ( )
inline

◆ SetTransportEnter()

void Movement::MoveSplineInit::SetTransportEnter ( )
inline

◆ SetTransportExit()

void Movement::MoveSplineInit::SetTransportExit ( )
inline

◆ SetVelocity()

◆ SetWalk()

◆ Stop()

void Movement::MoveSplineInit::Stop ( )
145 {
146 MoveSpline& move_spline = *unit->movespline;
147
148 // No need to stop if we are not moving
149 if (move_spline.Finalized())
150 return;
151
153 Location loc;
154 if (move_spline.onTransport == transport)
155 loc = move_spline.ComputePosition();
156 else
157 {
158 Position const* pos;
159 if (!transport)
160 pos = unit;
161 else
163
164 loc.x = pos->GetPositionX();
165 loc.y = pos->GetPositionY();
166 loc.z = pos->GetPositionZ();
167 loc.orientation = unit->GetOrientation();
168 }
169
172 move_spline.onTransport = transport;
173 move_spline.Initialize(args);
174
176 data << unit->GetPackGUID();
177 if (transport)
178 {
179 data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
180 data << unit->GetTransGUID().WriteAsPacked();
181 data << int8(unit->GetTransSeat());
182 }
183
185 unit->SendMessageToSet(&data, true);
186 }
void RemoveMovementFlag(uint32 flag)
Definition: Object.h:321
static void WriteStopMovement(Vector3 const &loc, uint32 splineId, ByteBuffer &data)
Definition: MovementPacketBuilder.cpp:91
@ Done
Definition: MoveSplineFlag.h:39

References args, Movement::MoveSpline::ComputePosition(), Movement::MoveSplineFlag::Done, Movement::MoveSpline::Finalized(), Movement::MoveSplineInitArgs::flags, Position::GetOrientation(), Object::GetPackGUID(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Unit::GetTransGUID(), WorldObject::GetTransSeat(), Unit::HasUnitMovementFlag(), Movement::MoveSpline::Initialize(), WorldObject::m_movementInfo, MOVEMENTFLAG_BACKWARD, MOVEMENTFLAG_FORWARD, MOVEMENTFLAG_ONTRANSPORT, MOVEMENTFLAG_SPLINE_ENABLED, Unit::movespline, Movement::MoveSpline::onTransport, Movement::Location::orientation, MovementInfo::TransportInfo::pos, MovementInfo::RemoveMovementFlag(), WorldObject::SendMessageToSet(), WorldPacket::SetOpcode(), SMSG_MONSTER_MOVE, SMSG_MONSTER_MOVE_TRANSPORT, Movement::MoveSplineInitArgs::splineId, MovementInfo::transport, unit, ObjectGuid::WriteAsPacked(), and Movement::PacketBuilder::WriteStopMovement().

Referenced by Unit::StopMoving().

Member Data Documentation

◆ args

◆ unit

Unit* Movement::MoveSplineInit::unit
protected