From e8c76f51d2c83db1e827ba51adbb90eafefe1b5f Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Thu, 26 Oct 2023 21:14:28 +0800 Subject: [PATCH] move random angle --- src/strategy/actions/MovementActions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index de1446ad..12639509 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -1473,8 +1473,9 @@ bool MoveRandomAction::Execute(Event event) float x = bot->GetPositionX(); float y = bot->GetPositionY(); float z = bot->GetPositionZ(); - x += urand(0, distance) - distance / 2; - y += urand(0, distance) - distance / 2; + 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 (map->IsInWater(bot->GetPhaseMask(), x, y, z, bot->GetCollisionHeight()))