[Battlegrounds] fixed bug I introduced in PR#422 where bots alternate mount/unmount near flag indefinately, also fixed other erroneous uses of sqrt on distances

This commit is contained in:
Fuzz
2024-08-08 21:18:52 +10:00
parent c0836c26e6
commit f1bfed190c
5 changed files with 56 additions and 59 deletions

View File

@@ -34,7 +34,7 @@ bool ReachAreaTriggerAction::Execute(Event event)
return true;
}
if (bot->GetMapId() != at->map || sqrt(bot->GetDistance(at->x, at->y, at->z)) > sPlayerbotAIConfig->sightDistance)
if (bot->GetMapId() != at->map)
{
botAI->TellError("I won't follow: too far away");
return true;
@@ -42,7 +42,7 @@ bool ReachAreaTriggerAction::Execute(Event event)
bot->GetMotionMaster()->MovePoint(at->map, at->x, at->y, at->z);
float distance = sqrt(bot->GetDistance(at->x, at->y, at->z));
float distance = bot->GetDistance(at->x, at->y, at->z);
float delay = 1000.0f * distance / bot->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay;
botAI->TellError("Wait for me");
botAI->SetNextCheckDelay(delay);