mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
refactor(Core/Travel): Remove dead spline-progress tracking and unused NODE_TELEPORT path
This commit is contained in:
parent
a0e21d9f38
commit
f4d308b684
@ -3084,51 +3084,6 @@ bool MoveAwayFromPlayerWithDebuffAction::isPossible()
|
|||||||
return bot->CanFreeMove();
|
return bot->CanFreeMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MovementAction::CheckSplineProgress(TravelPlan& state)
|
|
||||||
{
|
|
||||||
if (!state.splineActive)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// walkPoints may have been cleared by a map transfer or external reset
|
|
||||||
// while the spline was still flagged active; bail out safely.
|
|
||||||
if (state.walkPoints.empty())
|
|
||||||
{
|
|
||||||
state.splineActive = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bot->movespline->Finalized())
|
|
||||||
{
|
|
||||||
G3D::Vector3 const& endPt = state.walkPoints.back();
|
|
||||||
float distToEnd = bot->GetExactDist(endPt.x, endPt.y, endPt.z);
|
|
||||||
|
|
||||||
if (distToEnd < 10.0f)
|
|
||||||
{
|
|
||||||
state.splineActive = false;
|
|
||||||
state.walkPoints.clear();
|
|
||||||
return true; // Arrived
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spline finalized short of target — interrupted (combat/knockback/etc).
|
|
||||||
// Caller will re-launch.
|
|
||||||
state.splineActive = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stuck detection
|
|
||||||
if (state.splineStartTime &&
|
|
||||||
GetMSTimeDiffToNow(state.splineStartTime) > state.expectedDuration * 2 + (30 * IN_MILLISECONDS))
|
|
||||||
{
|
|
||||||
G3D::Vector3 const& endPt = state.walkPoints.back();
|
|
||||||
botAI->TeleportTo(WorldLocation(bot->GetMapId(), endPt.x, endPt.y, endPt.z));
|
|
||||||
state.splineActive = false;
|
|
||||||
state.walkPoints.clear();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false; // Still moving
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MovementAction::LaunchWalkSpline(TravelPlan& state)
|
bool MovementAction::LaunchWalkSpline(TravelPlan& state)
|
||||||
{
|
{
|
||||||
if (state.walkPoints.size() < 2)
|
if (state.walkPoints.size() < 2)
|
||||||
@ -3210,9 +3165,6 @@ bool MovementAction::LaunchWalkSpline(TravelPlan& state)
|
|||||||
|
|
||||||
bot->GetMotionMaster()->MoveSplinePath(&state.walkPoints, FORCED_MOVEMENT_RUN);
|
bot->GetMotionMaster()->MoveSplinePath(&state.walkPoints, FORCED_MOVEMENT_RUN);
|
||||||
|
|
||||||
state.splineStartTime = getMSTime();
|
|
||||||
state.splineActive = true;
|
|
||||||
|
|
||||||
G3D::Vector3 const& last = state.walkPoints.back();
|
G3D::Vector3 const& last = state.walkPoints.back();
|
||||||
|
|
||||||
// Update LastMovement so MoveFarTo's spline-active early-out
|
// Update LastMovement so MoveFarTo's spline-active early-out
|
||||||
@ -3343,19 +3295,6 @@ bool MovementAction::ExecuteTravelPlan(TravelPlan& state)
|
|||||||
// an executor-ran-this-tick label here would whisper every tick
|
// an executor-ran-this-tick label here would whisper every tick
|
||||||
// while the plan is active.
|
// while the plan is active.
|
||||||
|
|
||||||
// Handle active spline
|
|
||||||
if (state.splineActive)
|
|
||||||
{
|
|
||||||
if (!CheckSplineProgress(state))
|
|
||||||
{
|
|
||||||
if (state.splineActive)
|
|
||||||
return true; // Still moving
|
|
||||||
else
|
|
||||||
LaunchWalkSpline(state); // Interrupted, re-launch
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.stepIdx >= state.steps.size())
|
if (state.stepIdx >= state.steps.size())
|
||||||
{
|
{
|
||||||
state.Reset();
|
state.Reset();
|
||||||
@ -3608,41 +3547,6 @@ bool MovementAction::ExecuteTravelPlan(TravelPlan& state)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PathNodeType::NODE_TELEPORT:
|
|
||||||
{
|
|
||||||
// Teleport-spell node: hearthstone (spell 8690) or class
|
|
||||||
// teleport spells (mage/druid). `entry` holds the spell ID.
|
|
||||||
uint32 spellId = pt.entry;
|
|
||||||
if (!spellId)
|
|
||||||
{
|
|
||||||
state.Reset();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bot->IsInFlight() || bot->IsNonMeleeSpellCast(false))
|
|
||||||
return true; // wait
|
|
||||||
|
|
||||||
if (bot->IsMounted())
|
|
||||||
bot->Dismount();
|
|
||||||
botAI->RemoveShapeshift();
|
|
||||||
|
|
||||||
bool cast = false;
|
|
||||||
if (spellId == 8690)
|
|
||||||
cast = botAI->DoSpecificAction("hearthstone", Event(), true);
|
|
||||||
else if (bot->HasSpell(spellId) && !bot->HasSpellCooldown(spellId))
|
|
||||||
cast = botAI->CastSpell(spellId, bot);
|
|
||||||
|
|
||||||
if (!cast)
|
|
||||||
{
|
|
||||||
state.Reset();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cast started — advance past the teleport step.
|
|
||||||
state.stepIdx++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PathNodeType::NODE_TRANSPORT:
|
case PathNodeType::NODE_TRANSPORT:
|
||||||
{
|
{
|
||||||
if (state.stepIdx + 1 >= state.steps.size())
|
if (state.stepIdx + 1 >= state.steps.size())
|
||||||
|
|||||||
@ -104,7 +104,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool LaunchWalkSpline(TravelPlan& state);
|
bool LaunchWalkSpline(TravelPlan& state);
|
||||||
bool CheckSplineProgress(TravelPlan& state);
|
|
||||||
bool MoveToSpline(TravelPlan& state, WorldPosition target);
|
bool MoveToSpline(TravelPlan& state, WorldPosition target);
|
||||||
// Per-segment mmap refinement of a travel-node-graph walk batch.
|
// Per-segment mmap refinement of a travel-node-graph walk batch.
|
||||||
// The graph stores offline-baked coords whose straight-line
|
// The graph stores offline-baked coords whose straight-line
|
||||||
|
|||||||
@ -898,11 +898,6 @@ TravelPath TravelNodeRoute::BuildPath(std::vector<WorldPosition> pathToStart, st
|
|||||||
// Full taxi waypoint route; same reasoning as transport.
|
// Full taxi waypoint route; same reasoning as transport.
|
||||||
travelPath.addPath(nodePath->GetPath(), PathNodeType::NODE_FLIGHTPATH, nodePath->getPathObject());
|
travelPath.addPath(nodePath->GetPath(), PathNodeType::NODE_FLIGHTPATH, nodePath->getPathObject());
|
||||||
}
|
}
|
||||||
else if (nodePath->getPathType() == TravelNodePathType::teleportSpell)
|
|
||||||
{
|
|
||||||
travelPath.addPoint(*prevNode->getPosition(), PathNodeType::NODE_TELEPORT, nodePath->getPathObject());
|
|
||||||
travelPath.addPoint(*node->getPosition(), PathNodeType::NODE_TELEPORT, nodePath->getPathObject());
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<WorldPosition> path = nodePath->GetPath();
|
std::vector<WorldPosition> path = nodePath->GetPath();
|
||||||
|
|||||||
@ -93,7 +93,9 @@ enum class TravelNodePathType : uint8
|
|||||||
areaTrigger = 2,
|
areaTrigger = 2,
|
||||||
transport = 3,
|
transport = 3,
|
||||||
flightPath = 4,
|
flightPath = 4,
|
||||||
teleportSpell = 5,
|
// value 5 (teleportSpell) reserved — no generator emits it and no
|
||||||
|
// consumer handles it. Re-add when a teleport-spell edge generator
|
||||||
|
// / executor handler returns.
|
||||||
staticPortal = 6
|
staticPortal = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -414,7 +416,8 @@ enum class PathNodeType : uint8
|
|||||||
NODE_AREA_TRIGGER = 3,
|
NODE_AREA_TRIGGER = 3,
|
||||||
NODE_TRANSPORT = 4,
|
NODE_TRANSPORT = 4,
|
||||||
NODE_FLIGHTPATH = 5,
|
NODE_FLIGHTPATH = 5,
|
||||||
NODE_TELEPORT = 6,
|
// value 6 (NODE_TELEPORT) reserved — no consumer; re-add when a
|
||||||
|
// teleport-spell handler / generator returns.
|
||||||
NODE_STATIC_PORTAL = 7
|
NODE_STATIC_PORTAL = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -561,9 +564,7 @@ struct TravelPlan
|
|||||||
|
|
||||||
// Spline scratch (used by executor):
|
// Spline scratch (used by executor):
|
||||||
std::vector<G3D::Vector3> walkPoints;
|
std::vector<G3D::Vector3> walkPoints;
|
||||||
bool splineActive{false};
|
uint32 expectedDuration{0}; // used to derive the lastMove delay
|
||||||
uint32 splineStartTime{0};
|
|
||||||
uint32 expectedDuration{0};
|
|
||||||
|
|
||||||
// Taxi scratch:
|
// Taxi scratch:
|
||||||
std::vector<uint32> route;
|
std::vector<uint32> route;
|
||||||
@ -576,8 +577,6 @@ struct TravelPlan
|
|||||||
steps.clear();
|
steps.clear();
|
||||||
stepIdx = 0;
|
stepIdx = 0;
|
||||||
walkPoints.clear();
|
walkPoints.clear();
|
||||||
splineActive = false;
|
|
||||||
splineStartTime = 0;
|
|
||||||
expectedDuration = 0;
|
expectedDuration = 0;
|
||||||
route.clear();
|
route.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user