fix(Core/Movement): Updated creature pet's follow movement. (#15360)

This commit is contained in:
UltraNix
2023-03-13 12:14:40 +01:00
committed by GitHub
parent 3fa4117195
commit 3d5ec682c0

View File

@@ -296,7 +296,13 @@ static Optional<float> GetVelocity(Unit* owner, Unit* target, G3D::Vector3 const
if (!owner->IsInCombat() && !owner->IsVehicle() && !owner->HasUnitFlag(UNIT_FLAG_POSSESSED) &&
(owner->IsPet() || owner->IsGuardian() || owner->GetGUID() == target->GetCritterGUID() || owner->GetCharmerOrOwnerGUID() == target->GetGUID()))
{
UnitMoveType moveType = Movement::SelectSpeedType(target->GetUnitMovementFlags());
uint32 moveFlags = target->GetUnitMovementFlags();
if (target->movespline->isWalking())
{
moveFlags |= MOVEMENTFLAG_WALKING;
}
UnitMoveType moveType = Movement::SelectSpeedType(moveFlags);
speed = std::max(target->GetSpeed(moveType), owner->GetSpeed(moveType));
if (playerPet)
@@ -503,8 +509,8 @@ bool FollowMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
Movement::MoveSplineInit init(owner);
init.MovebyPath(i_path->GetPath());
init.SetWalk(target->IsWalking());
if (Optional<float> velocity = GetVelocity(owner, target, i_path->GetActualEndPosition(), owner->IsGuardian() && target->GetTypeId() == TYPEID_PLAYER))
init.SetWalk(target->IsWalking() || target->movespline->isWalking());
if (Optional<float> velocity = GetVelocity(owner, target, i_path->GetActualEndPosition(), owner->IsGuardian()))
init.SetVelocity(*velocity);
init.Launch();
}