fix(Core/RPG): Use GetNearPoint and followAngle in MoveWorldObjectTo, bump travel-node threshold to sightDistance

This commit is contained in:
bash 2026-05-30 18:11:06 +02:00
parent 65bf6a0dff
commit f656c3d9ef

View File

@ -138,13 +138,13 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
float disToDest = bot->GetDistance(dest); float disToDest = bot->GetDistance(dest);
float dis = bot->GetExactDist(dest); float dis = bot->GetExactDist(dest);
// Try the travel-node graph first for cross-map or > 50y moves; // Try the travel-node graph for cross-map or moves longer than the
// fall back to chained mmap probe otherwise. BGs skip the graph. // bot's sight distance; otherwise the chained mmap probe handles it.
constexpr float TRAVELNODE_THRESHOLD = 50.0f; // BGs skip the graph.
bool tryNodes = sPlayerbotAIConfig.enableTravelNodes && bool tryNodes = sPlayerbotAIConfig.enableTravelNodes &&
!bot->InBattleground() && !bot->InBattleground() &&
((bot->GetMapId() != dest.GetMapId()) || ((bot->GetMapId() != dest.GetMapId()) ||
(dis > TRAVELNODE_THRESHOLD)); (dis > sPlayerbotAIConfig.sightDistance));
// Ride the active node plan only if its dest still matches. // Ride the active node plan only if its dest still matches.
// A stale plan would steer the bot past a new target. // A stale plan would steer the bot past a new target.
@ -444,19 +444,23 @@ bool NewRpgBaseAction::MoveWorldObjectTo(ObjectGuid guid, float distance)
if (!map) if (!map)
return false; return false;
// 8 angles around the target, first one reachable wins. LOS check // 8 angles around the target starting at the bot's preferred follow
// ignores M2 models (trees, decorative props) so long-distance NPCs // angle (group-aware spread). For each angle, ask the engine for a
// through forested terrain still pass — the mmap probe in MoveFarTo // valid nearby ground point at the requested distance — that snaps
// is the authoritative reachability check. // to terrain/collision. LOS check ignores M2 models so long-distance
float const baseAngle = object->GetAngle(bot); // NPCs through forested terrain still pass; the mmap probe in
// MoveFarTo is the authoritative reachability check.
float const followAngle = GetFollowAngle();
float const searchSize = bot->GetObjectSize();
for (float step = 0.0f; step < 2.0f * static_cast<float>(M_PI); for (float step = 0.0f; step < 2.0f * static_cast<float>(M_PI);
step += static_cast<float>(M_PI) / 4.0f) step += static_cast<float>(M_PI) / 4.0f)
{ {
float const angle = baseAngle + step; float const angle = followAngle + step;
float const x = object->GetPositionX() + std::cos(angle) * distance; float x = object->GetPositionX();
float const y = object->GetPositionY() + std::sin(angle) * distance; float y = object->GetPositionY();
float const z = object->GetPositionZ(); float z = object->GetPositionZ();
object->GetNearPoint(bot, x, y, z, searchSize, distance, angle);
if (!bot->IsWithinLOS(x, y, z + bot->GetCollisionHeight(), if (!bot->IsWithinLOS(x, y, z + bot->GetCollisionHeight(),
VMAP::ModelIgnoreFlags::M2)) VMAP::ModelIgnoreFlags::M2))