442{
444 return false;
445
446 if (!owner || !owner->IsAlive())
447 return false;
448
451
452
453 if (owner->HasUnitState(
UNIT_STATE_NOT_MOVE) || (cOwner && owner->ToCreature()->IsMovementPreventedByCasting()))
454 {
458 return true;
459 }
460
461 bool followingMaster = false;
463 if (oPet)
464 {
466 followingMaster = true;
467 }
468
469 bool forceDest =
470 (followingMaster) ||
472 ;
473
474 bool targetIsMoving = false;
476 {
478 {
482
484 {
486 }
487
489 }
490 }
491 else
492 {
495
496
497 if (targetIsMoving)
498 {
501 return true;
502
504 targetPosition = predictedPosition;
506 }
507 else
508 {
511 }
512
514 i_path = std::make_unique<PathGenerator>(owner);
515 else
517
519
520 float x, y, z;
522
523 if (owner->IsHovering())
524 owner->UpdateAllowedPositionZ(x, y, z);
525
526 bool success =
i_path->CalculatePath(x, y, z, forceDest);
528 {
529 if (!owner->IsStopped())
530 owner->StopMoving();
531
532 return true;
533 }
534
536
538 init.MovebyPath(
i_path->GetPath());
541
544 init.SetVelocity(*velocity);
545 init.Launch();
546 }
547
548 return true;
549}
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
@ PATHFIND_NOPATH
Definition PathGenerator.h:50
static Optional< float > GetVelocity(Unit *owner, Unit *target, G3D::Vector3 const &dest, bool playerPet)
Definition TargetedMovementGenerator.cpp:334
static Position const PredictPosition(Unit *target)
Definition TargetedMovementGenerator.cpp:362
@ UNIT_STATE_NOT_MOVE
Definition UnitDefines.h:218
bool PositionOkay(Unit *target, bool isPlayerPet, bool &targetIsMoving, uint32 diff)
Definition TargetedMovementGenerator.cpp:396
void MovementInform(T *)
Definition TargetedMovementGenerator.cpp:572
Optional< Position > _lastPredictedPosition
Definition TargetedMovementGenerator.h:107
Definition MoveSplineInit.h:71
bool isWalking() const
Definition MoveSpline.h:119
bool IsPlayer() const
Definition Object.h:200
Creature * ToCreature()
Definition Object.h:205
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:112
TO * getTarget() const
Definition Reference.h:95
bool isValid() const
Definition Reference.h:79
FollowerReference i_target
Definition TargetedMovementGenerator.h:34
void ClearUnitState(uint32 f)
Definition Unit.h:708
Pet * ToPet()
Definition Unit.h:700
Movement::MoveSpline * movespline
Definition Unit.h:2029
void StopMoving()
Definition Unit.cpp:16702
ObjectGuid GetOwnerGUID() const
Definition Unit.h:684
bool IsWalking() const
Definition Unit.h:1627
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition Object.cpp:2871
float RelativeAngle
Definition MotionMaster.h:100
float ToAbsoluteAngle(float relAngle) const
Definition Position.h:207
float GetOrientation() const
Definition Position.h:124
void GetPosition(float &x, float &y) const
Definition Position.h:126
void Reset(int32 interval)
Definition Timer.h:249