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
2f00af0352
commit
13b10e5d20
@ -3146,9 +3146,8 @@ bool MovementAction::LaunchWalkSpline(TravelPlan& state)
|
|||||||
|
|
||||||
G3D::Vector3 const& last = state.walkPoints.back();
|
G3D::Vector3 const& last = state.walkPoints.back();
|
||||||
|
|
||||||
// Update LastMovement so MoveFarTo's spline-active early-out
|
// Mirror what MoveTo does after dispatching a spline so the
|
||||||
// knows about this in-flight walk and won't recompute the path
|
// lastPath cache below picks up the in-flight waypoint chain.
|
||||||
// mid-spline. Mirror what MoveTo does after dispatching a spline.
|
|
||||||
{
|
{
|
||||||
float delay = static_cast<float>(state.expectedDuration);
|
float delay = static_cast<float>(state.expectedDuration);
|
||||||
delay = std::min(delay, static_cast<float>(sPlayerbotAIConfig.maxWaitForMove));
|
delay = std::min(delay, static_cast<float>(sPlayerbotAIConfig.maxWaitForMove));
|
||||||
|
|||||||
@ -48,7 +48,19 @@
|
|||||||
bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
||||||
{
|
{
|
||||||
if (dest == WorldPosition())
|
if (dest == WorldPosition())
|
||||||
|
{
|
||||||
|
EmitDebugMove("MoveFar", "empty-dest", 0.0f, 0.0f, 0.0f);
|
||||||
return false;
|
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
|
// Already-at-dest short-stop. Below targetPosRecalcDistance the
|
||||||
// move is effectively done — stop any active spline and clear
|
// move is effectively done — stop any active spline and clear
|
||||||
@ -64,26 +76,12 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
|||||||
lastMove.clear();
|
lastMove.clear();
|
||||||
}
|
}
|
||||||
bot->StopMoving();
|
bot->StopMoving();
|
||||||
|
EmitDebugMove("MoveFar", "arrived",
|
||||||
|
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
||||||
return false;
|
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
|
// 10% lastPath reuse — if the cached path's endpoint is still
|
||||||
// close (within 10%) to the new dest, trim the cached path to
|
// close (within 10%) to the new dest, trim the cached path to
|
||||||
// the bot's current position via makeShortCut and re-dispatch.
|
// 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
|
// the bot's STEEP/water filter is honored via CreateFilter. If even
|
||||||
// that fails, the engine falls back to a direct spline.
|
// that fails, the engine falls back to a direct spline.
|
||||||
if (bot->GetMapId() != dest.GetMapId())
|
if (bot->GetMapId() != dest.GetMapId())
|
||||||
|
{
|
||||||
|
EmitDebugMove("MoveFar", "cross-map",
|
||||||
|
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char const* reason = (probe.empty() || probe.size() < 2) ? "mmap-empty" : "mmap-noprogress";
|
char const* reason = (probe.empty() || probe.size() < 2) ? "mmap-empty" : "mmap-noprogress";
|
||||||
EmitDebugMove("MoveFar", reason,
|
EmitDebugMove("MoveFar", reason,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user