From 4754252eeb6cf02e556087eaf7c5a94ee8b49048 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 5 Aug 2024 14:14:43 +0800 Subject: [PATCH] Waypoint for move random --- src/strategy/actions/MovementActions.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 3bc458af..fc999005 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -2325,12 +2325,15 @@ bool MoveRandomAction::Execute(Event event) float angle = (float)rand_norm() * static_cast(M_PI); x += urand(0, distance) * cos(angle); y += urand(0, distance) * sin(angle); - bot->UpdateGroundPositionZ(x, y, z); - + if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), + bot->GetPositionZ(), x, y, z)) + { + continue; + } if (map->IsInWater(bot->GetPhaseMask(), x, y, z, bot->GetCollisionHeight())) continue; - bool moved = MoveTo(bot->GetMapId(), x, y, z); + bool moved = MoveTo(bot->GetMapId(), x, y, z, false, false, false, true); if (moved) return true; }