411{
413 return false;
414
415 if (!owner || !owner->IsAlive())
416 return false;
417
420
421
422 if (owner->HasUnitState(
UNIT_STATE_NOT_MOVE) || (cOwner && owner->ToCreature()->IsMovementPreventedByCasting()))
423 {
425 owner->StopMoving();
427 return true;
428 }
429
430 bool followingMaster = false;
432 if (oPet)
433 {
435 followingMaster = true;
436 }
437
438 bool forceDest =
439 (followingMaster) ||
441 ;
442
443 bool targetIsMoving = false;
445 {
447 {
451
453 {
455 }
456
458 }
459 }
460 else
461 {
464
465
466 if (targetIsMoving)
467 {
470 return true;
471
473 targetPosition = predictedPosition;
475 }
476 else
477 {
480 }
481
483 i_path = std::make_unique<PathGenerator>(owner);
484 else
486
488
489 float x, y, z;
491
492 if (owner->IsHovering())
493 owner->UpdateAllowedPositionZ(x, y, z);
494
495 bool success =
i_path->CalculatePath(x, y, z, forceDest);
497 {
498 if (!owner->IsStopped())
499 owner->StopMoving();
500
501 return true;
502 }
503
505
507 init.MovebyPath(
i_path->GetPath());
510 init.SetVelocity(*velocity);
511 init.Launch();
512 }
513
514 return true;
515}
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:303
static Position const PredictPosition(Unit *target)
Definition: TargetedMovementGenerator.cpp:331
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:2412
Movement::MoveSpline * movespline
Definition: Unit.h:2454
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1828
bool IsWalking() const
Definition: Unit.h:2393
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:365
void MovementInform(T *)
Definition: TargetedMovementGenerator.cpp:538
Optional< Position > _lastPredictedPosition
Definition: TargetedMovementGenerator.h:106
bool isWalking() const
Definition: MoveSpline.h:119
Definition: MoveSplineInit.h:71