mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
refactor(Core/Movement): Align MoveFarTo preamble + drop spline-plan throttle
This commit is contained in:
parent
1601d6a514
commit
0c9131692c
@ -3146,9 +3146,8 @@ bool MovementAction::LaunchWalkSpline(TravelPlan& state)
|
||||
|
||||
G3D::Vector3 const& last = state.walkPoints.back();
|
||||
|
||||
// Update LastMovement so MoveFarTo's spline-active early-out
|
||||
// knows about this in-flight walk and won't recompute the path
|
||||
// mid-spline. Mirror what MoveTo does after dispatching a spline.
|
||||
// Mirror what MoveTo does after dispatching a spline so the
|
||||
// lastPath cache below picks up the in-flight waypoint chain.
|
||||
{
|
||||
float delay = static_cast<float>(state.expectedDuration);
|
||||
delay = std::min(delay, static_cast<float>(sPlayerbotAIConfig.maxWaitForMove));
|
||||
|
||||
@ -48,7 +48,19 @@
|
||||
bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
||||
{
|
||||
if (dest == WorldPosition())
|
||||
{
|
||||
EmitDebugMove("MoveFar", "empty-dest", 0.0f, 0.0f, 0.0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateMovementState();
|
||||
|
||||
if (!IsMovingAllowed())
|
||||
{
|
||||
EmitDebugMove("MoveFar", "cant-move",
|
||||
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Already-at-dest short-stop. Below targetPosRecalcDistance the
|
||||
// move is effectively done — stop any active spline and clear
|
||||
@ -64,26 +76,12 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
||||
lastMove.clear();
|
||||
}
|
||||
bot->StopMoving();
|
||||
EmitDebugMove("MoveFar", "arrived",
|
||||
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Let an in-flight spline finish before recomputing — prevents
|
||||
// oscillation when re-resolve produces a slightly different endpoint.
|
||||
{
|
||||
LastMovement& lastMove = AI_VALUE(LastMovement&, "last movement");
|
||||
if (bot->isMoving() && lastMove.lastMoveToMapId == bot->GetMapId())
|
||||
{
|
||||
float remaining = bot->GetExactDist(lastMove.lastMoveToX, lastMove.lastMoveToY, lastMove.lastMoveToZ);
|
||||
if (remaining > 10.0f)
|
||||
{
|
||||
EmitDebugMove("MoveFar", "spline-plan",
|
||||
lastMove.lastMoveToX, lastMove.lastMoveToY, lastMove.lastMoveToZ);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 10% lastPath reuse — if the cached path's endpoint is still
|
||||
// close (within 10%) to the new dest, trim the cached path to
|
||||
// the bot's current position via makeShortCut and re-dispatch.
|
||||
@ -240,7 +238,11 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
||||
// the bot's STEEP/water filter is honored via CreateFilter. If even
|
||||
// that fails, the engine falls back to a direct spline.
|
||||
if (bot->GetMapId() != dest.GetMapId())
|
||||
{
|
||||
EmitDebugMove("MoveFar", "cross-map",
|
||||
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
||||
return false;
|
||||
}
|
||||
|
||||
char const* reason = (probe.empty() || probe.size() < 2) ? "mmap-empty" : "mmap-noprogress";
|
||||
EmitDebugMove("MoveFar", reason,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user