From 73bf6f06066288eab40f0cc99100c39368e0d578 Mon Sep 17 00:00:00 2001 From: bash Date: Thu, 14 May 2026 22:07:14 +0200 Subject: [PATCH] fix(Core/RPG): LOS check on MoveRandomNear samples to avoid tree tunneling --- src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp b/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp index f1177ab5b..c66e8025a 100644 --- a/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp +++ b/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp @@ -554,6 +554,13 @@ bool NewRpgBaseAction::MoveRandomNear(float moveStep, MovementPriority priority, if (map->IsInWater(bot->GetPhaseMask(), dx, dy, dz, bot->GetCollisionHeight())) continue; + // Reject samples whose straight-line passes through visual + // obstacles (trees, models) that aren't in the navmesh. The + // smooth-path step can otherwise interpolate a waypoint inside + // a tree, making the bot visibly walk through it. + if (!bot->IsWithinLOS(dx, dy, dz)) + continue; + bool moved = MoveTo(bot->GetMapId(), dx, dy, dz, false, false, false, true, priority); if (moved) {