Bots and pets of players no longer glide when they chase or follow
A chasing bot was given a facing target for the whole walk, and a bot, or a pet or guardian of a player, re-pathed on every step of a moving target. Each new spline of a player unit starts with a stop packet, so the client showed it sliding without the run animation. - A player unit chasing is not given a facing target; it turns to the target on arrival. - A bot, or a pet or guardian of a player, re-paths a chase or follow spline in flight only after the target drifted 2.5 yards from where it stood at the last launch. Monsters and real players chase exactly as before.
This commit is contained in:
@@ -23,7 +23,11 @@
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "PathGenerator.h"
|
||||
#include "Player.h"
|
||||
#include "Unit.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
static constexpr float CHASE_BOT_REPATH_DIST = 2.5f;
|
||||
|
||||
static bool HasLostTarget(Unit* owner, Unit* target)
|
||||
{
|
||||
@@ -72,13 +76,19 @@ ChaseMovementGenerator::ChaseMovementGenerator(Unit *target, Optional<ChaseRange
|
||||
}
|
||||
ChaseMovementGenerator::~ChaseMovementGenerator() = default;
|
||||
|
||||
bool ChaseMovementGenerator::Initialize(Unit* /*owner*/)
|
||||
bool ChaseMovementGenerator::Initialize(Unit* owner)
|
||||
{
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INITIALIZED | MOVEMENTGENERATOR_FLAG_INFORM_ENABLED);
|
||||
|
||||
_path = nullptr;
|
||||
_lastTargetPosition.reset();
|
||||
// Pets and guardians of a player are throttled too: MoveSplineInit sends them the same stop packet before every new spline
|
||||
// (PlayerSideUnit), so a pet re-pathing on every step of a walking mob was shown sliding in its run pose, as if hovering
|
||||
// (Ironforge 2026-10-26: a bot hunter's wolf).
|
||||
Player const* playerOwner = owner->ToPlayer();
|
||||
_throttleRepath = (playerOwner && playerOwner->GetSession() && playerOwner->GetSession()->IsBot())
|
||||
|| (!owner->IsPlayer() && owner->GetCharmerOrOwnerGUID().IsPlayer());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -152,6 +162,15 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
DoMovementInform(owner, target);
|
||||
}
|
||||
|
||||
// Playerbot chasers: while a chase spline is in flight, re-path only once the target has drifted CHASE_BOT_REPATH_DIST from where it stood at
|
||||
// the last launch. The stock rule re-paths on ANY step of the target, i.e. every update while a mob walks about, and every launch of a player
|
||||
// unit is a stop packet and a new spline: the client got ten of them a second and showed the bot sliding without the run animation (PC 20 Oct,
|
||||
// mages and hunters ordered at a wandering mob). _lastTargetPosition is left untouched while holding, so the drift accumulates; a finished
|
||||
// spline, a speed change (reset) or a larger drift re-paths exactly as before.
|
||||
if (_throttleRepath && _lastTargetPosition && mutualChase == _mutualChase && owner->HasUnitState(UNIT_STATE_CHASE_MOVE) && !owner->movespline->Finalized()
|
||||
&& _lastTargetPosition->GetExactDistSq(target->GetPosition()) < CHASE_BOT_REPATH_DIST * CHASE_BOT_REPATH_DIST)
|
||||
return true;
|
||||
|
||||
// if the target moved, we have to consider whether to adjust
|
||||
if (!_lastTargetPosition || target->GetPosition() != _lastTargetPosition.value() || mutualChase != _mutualChase)
|
||||
{
|
||||
@@ -232,7 +251,11 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MovebyPath(_path->GetPath());
|
||||
init.SetWalk(walk);
|
||||
init.SetFacing(target);
|
||||
// A player unit (a bot driven by monster moves) is not given a facing target for the whole walk: the client shows it
|
||||
// gliding along the path without the run animation (Onyxia's Lair 2026-10-13, tank sent to the Warder). It turns to the
|
||||
// target on arrival (SetInFront above).
|
||||
if (!owner->IsPlayer())
|
||||
init.SetFacing(target);
|
||||
init.Launch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class ChaseMovementGenerator : public MovementGenerator, public AbstractFollower
|
||||
TimeTracker _rangeCheckTimer;
|
||||
bool _movingTowards = true;
|
||||
bool _mutualChase = true;
|
||||
bool _throttleRepath = false; // owner is a playerbot, or a pet / guardian of a player: see Update
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -69,8 +69,12 @@ bool FollowMovementGenerator::Initialize(Unit* owner)
|
||||
UpdatePetSpeed(owner);
|
||||
_path = nullptr;
|
||||
_lastTargetPosition.reset();
|
||||
// Pets and guardians of a player are throttled too: MoveSplineInit sends them the same stop packet before every new spline
|
||||
// (PlayerSideUnit), so a pet re-pathing on every step of its bot owner (a monster spline moves the owner every map update) was
|
||||
// shown sliding in its run pose, as if hovering (Ironforge 2026-10-26: a bot hunter's wolf).
|
||||
Player const* playerOwner = owner->ToPlayer();
|
||||
_throttleRepath = playerOwner && playerOwner->GetSession() && playerOwner->GetSession()->IsBot();
|
||||
_throttleRepath = (playerOwner && playerOwner->GetSession() && playerOwner->GetSession()->IsBot())
|
||||
|| (!owner->IsPlayer() && owner->GetCharmerOrOwnerGUID().IsPlayer());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class FollowMovementGenerator : public MovementGenerator, public AbstractFollowe
|
||||
Optional<TimeTracker> _duration;
|
||||
std::unique_ptr<PathGenerator> _path;
|
||||
Optional<Position> _lastTargetPosition;
|
||||
bool _throttleRepath = false; // owner is a playerbot: see Update
|
||||
bool _throttleRepath = false; // owner is a playerbot, or a pet / guardian of a player: see Update
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user