415{
417 return false;
418
419 if (!owner || !owner->IsAlive())
420 return false;
421
424
425
426 if (owner->HasUnitState(
UNIT_STATE_NOT_MOVE) || (cOwner && owner->ToCreature()->IsMovementPreventedByCasting()))
427 {
429 owner->StopMoving();
431 return true;
432 }
433
434 bool followingMaster = false;
436 if (oPet)
437 {
439 followingMaster = true;
440 }
441
442 bool forceDest =
443 (followingMaster) ||
445 ;
446
447 bool targetIsMoving = false;
449 {
451 {
455
457 {
459 }
460
462 }
463 }
464 else
465 {
468
469
470 if (targetIsMoving)
471 {
474 return true;
475
477 targetPosition = predictedPosition;
479 }
480 else
481 {
484 }
485
487 i_path = std::make_unique<PathGenerator>(owner);
488 else
490
492
493 float x, y, z;
495
496 if (owner->IsHovering())
497 owner->UpdateAllowedPositionZ(x, y, z);
498
499 bool success =
i_path->CalculatePath(x, y, z, forceDest);
501 {
502 if (!owner->IsStopped())
503 owner->StopMoving();
504
505 return true;
506 }
507
509
511 init.MovebyPath(
i_path->GetPath());
514 init.SetVelocity(*velocity);
515 init.Launch();
516 }
517
518 return true;
519}
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ UNIT_STATE_NOT_MOVE
Definition: Unit.h:371
@ PATHFIND_NOPATH
Definition: PathGenerator.h:51
static Optional< float > GetVelocity(Unit *owner, Unit *target, G3D::Vector3 const &dest, bool playerPet)
Definition: TargetedMovementGenerator.cpp:293
static Position const PredictPosition(Unit *target)
Definition: TargetedMovementGenerator.cpp:335
TO * getTarget() const
Definition: Reference.h:95
bool isValid() const
Definition: Reference.h:79
void Reset(int32 interval)
Definition: Timer.h:249
Definition: Creature.h:46
TypeID GetTypeId() const
Definition: Object.h:121
Creature * ToCreature()
Definition: Object.h:197
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:2846
Definition: Position.h:28
float ToAbsoluteAngle(float relAngle) const
Definition: Position.h:203
float GetOrientation() const
Definition: Position.h:120
void GetPosition(float &x, float &y) const
Definition: Position.h:122
void ClearUnitState(uint32 f)
Definition: Unit.h:1411
Pet * ToPet()
Definition: Unit.h:2410
Movement::MoveSpline * movespline
Definition: Unit.h:2452
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1826
bool IsWalking() const
Definition: Unit.h:2391
float RelativeAngle
Definition: MotionMaster.h:98
FollowerReference i_target
Definition: TargetedMovementGenerator.h:34
bool PositionOkay(Unit *target, bool isPlayerPet, bool &targetIsMoving, uint32 diff)
Definition: TargetedMovementGenerator.cpp:369
void MovementInform(T *)
Definition: TargetedMovementGenerator.cpp:542
Optional< Position > _lastPredictedPosition
Definition: TargetedMovementGenerator.h:106
bool isWalking() const
Definition: MoveSpline.h:119
Definition: MoveSplineInit.h:71