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 {
456 owner->StopMoving();
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
543 init.SetVelocity(*velocity);
544 init.Launch();
545 }
546
547 return true;
548}
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
@ PATHFIND_NOPATH
Definition: PathGenerator.h:51
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:197
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
bool IsPlayer() const
Definition: Object.h:197
Creature * ToCreature()
Definition: Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:2858
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:674
Pet * ToPet()
Definition: Unit.h:1714
Movement::MoveSpline * movespline
Definition: Unit.h:1818
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1210
bool IsWalking() const
Definition: Unit.h:1695
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:396
void MovementInform(T *)
Definition: TargetedMovementGenerator.cpp:571
Optional< Position > _lastPredictedPosition
Definition: TargetedMovementGenerator.h:107
bool isWalking() const
Definition: MoveSpline.h:119
Definition: MoveSplineInit.h:71