From 21bcbece7ad4784a71ad7190e9a4e5dfa8a0385d Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 08:36:28 -0300 Subject: [PATCH] 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. --- src/strategy/actions/BattleGroundTactics.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index 1fa182ca..a14831fa 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -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())