Improve Bot Repositioning Based on Line of Sight and Vertical Distance

This update enhances bot behavior by adding a check for both line of sight (LoS) and significant vertical height differences between the bot and its target. If the bot cannot see its target or if the height difference exceeds 5.0f, it calculates a valid path and moves closer to regain visibility and combat effectiveness. This resolves cases where bots would previously stand still when enemies jumped from elevated terrain or were behind obstacles.
This commit is contained in:
EricksOliveira
2025-07-28 08:36:28 -03:00
committed by GitHub
parent 8a9a833c98
commit 21bcbece7a

View File

@@ -4164,12 +4164,18 @@ bool ArenaTactics::Execute(Event event)
// Repositioning if the target is out of line of sight
Unit* target = bot->GetVictim();
if (target && !bot->IsWithinLOSInMap(target))
if (target && (!bot->IsWithinLOSInMap(target) || fabs(bot->GetPositionZ() - target->GetPositionZ()) > 5.0f))
{
float x, y, z;
target->GetPosition(x, y, z);
botAI->TellMasterNoFacing("Repositioning to exit LoS");
return MoveTo(target->GetMapId(), x + frand(-1, +1), y + frand(-1, +1), z, false, true);
PathFinder path(bot);
path.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false);
if (path.IsValid() && path.GetPathType() != PATHFIND_NOPATH)
{
float x, y, z;
target->GetPosition(x, y, z);
botAI->TellMasterNoFacing("Repositioning to exit LoS or Height");
return MoveTo(target->GetMapId(), x + frand(-1, +1), y + frand(-1, +1), z, false, true);
}
}
if (!bot->IsInCombat())