From d8d94f33ee92cd5c83cdb477a60354d7af1b8bcd Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Sun, 27 Jul 2025 18:35:43 -0300 Subject: [PATCH 01/10] Improve Arena Bot Behavior When Target is Behind Obstacles This update enhances bot behavior in arena scenarios by addressing the issue where bots remain idle if their target moves behind line-of-sight (LoS obstacles). The bot now attempts to reposition near the target to regain LoS instead of standing still, preventing situations where enemies can recover without pressure. Could someone test it? --- src/strategy/actions/BattleGroundTactics.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index d43c1d22..63e1512f 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4152,7 +4152,6 @@ bool ArenaTactics::Execute(Event event) if (bot->isMoving()) return false; - // startup phase if (bg->GetStartDelayTime() > 0) return false; @@ -4163,12 +4162,15 @@ bool ArenaTactics::Execute(Event event) if (botAI->HasStrategy("buff", BOT_STATE_NON_COMBAT)) botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT); - // this causes bot to reset constantly in arena - // if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID())) - // { - // botAI->ResetStrategies(false); - // botAI->SetMaster(nullptr); - // } + // Repositioning if the target is out of line of sight + Unit* target = botAI->GetCombatTarget(); + if (target && !bot->IsWithinLOSInMap(target)) + { + 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); + } if (!bot->IsInCombat()) return moveToCenter(bg); From 101c7f3046346c05e8a0928d0034c48f39ee221b Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Sun, 27 Jul 2025 18:45:04 -0300 Subject: [PATCH 02/10] . --- src/strategy/actions/BattleGroundTactics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index 63e1512f..bebc2ed2 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4163,7 +4163,7 @@ bool ArenaTactics::Execute(Event event) botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT); // Repositioning if the target is out of line of sight - Unit* target = botAI->GetCombatTarget(); + Unit* target = botAI->GetAiObject("current target"); if (target && !bot->IsWithinLOSInMap(target)) { float x, y, z; From 8a9a833c985e9e4ec10a13e72ceeb8194cb00ba3 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Sun, 27 Jul 2025 19:31:54 -0300 Subject: [PATCH 03/10] fix --- src/strategy/actions/BattleGroundTactics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index bebc2ed2..1fa182ca 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4163,7 +4163,7 @@ bool ArenaTactics::Execute(Event event) botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT); // Repositioning if the target is out of line of sight - Unit* target = botAI->GetAiObject("current target"); + Unit* target = bot->GetVictim(); if (target && !bot->IsWithinLOSInMap(target)) { float x, y, z; From 21bcbece7ad4784a71ad7190e9a4e5dfa8a0385d Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 08:36:28 -0300 Subject: [PATCH 04/10] 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()) From 8a8571c54fea975213d1188c1c92c4fca2adff99 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 08:45:20 -0300 Subject: [PATCH 05/10] . --- src/strategy/actions/BattleGroundTactics.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index a14831fa..856b43c6 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -26,6 +26,7 @@ #include "Playerbots.h" #include "PositionValue.h" #include "PvpTriggers.h" +#include "PathFinder.h" #include "ServerFacade.h" #include "Vehicle.h" From 18d1821dab63ade97da0dd0bf8b12bd7e00b89f2 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 08:57:19 -0300 Subject: [PATCH 06/10] Fix --- src/strategy/actions/BattleGroundTactics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index 856b43c6..ab7cc3ac 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -26,7 +26,7 @@ #include "Playerbots.h" #include "PositionValue.h" #include "PvpTriggers.h" -#include "PathFinder.h" +#include "PathGenerator.h" #include "ServerFacade.h" #include "Vehicle.h" @@ -4167,7 +4167,7 @@ bool ArenaTactics::Execute(Event event) Unit* target = bot->GetVictim(); if (target && (!bot->IsWithinLOSInMap(target) || fabs(bot->GetPositionZ() - target->GetPositionZ()) > 5.0f)) { - PathFinder path(bot); + PathGenerator path(bot); path.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false); if (path.IsValid() && path.GetPathType() != PATHFIND_NOPATH) From b8c0a54f92dfe43539e9db80cf88ba73816849b5 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 09:03:20 -0300 Subject: [PATCH 07/10] .. --- src/strategy/actions/BattleGroundTactics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index ab7cc3ac..dfd50bf7 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4170,7 +4170,7 @@ bool ArenaTactics::Execute(Event event) PathGenerator path(bot); path.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false); - if (path.IsValid() && path.GetPathType() != PATHFIND_NOPATH) + if (path.GetPathType() != PATHFIND_NOPATH) { float x, y, z; target->GetPosition(x, y, z); From e92029dd6ebaf1a016831730a9308307b898bba6 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 11:48:15 -0300 Subject: [PATCH 08/10] The bot immediately moves to a new position if the target is lost by LoS even during the cast. --- src/strategy/actions/BattleGroundTactics.cpp | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index dfd50bf7..5beb9db7 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4150,10 +4150,6 @@ bool ArenaTactics::Execute(Event event) if (bot->isDead()) return false; - if (bot->isMoving()) - return false; - - // startup phase if (bg->GetStartDelayTime() > 0) return false; @@ -4163,19 +4159,27 @@ bool ArenaTactics::Execute(Event event) if (botAI->HasStrategy("buff", BOT_STATE_NON_COMBAT)) botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT); - // Repositioning if the target is out of line of sight Unit* target = bot->GetVictim(); - if (target && (!bot->IsWithinLOSInMap(target) || fabs(bot->GetPositionZ() - target->GetPositionZ()) > 5.0f)) + if (target) { - PathGenerator path(bot); - path.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false); + bool losBlocked = !bot->IsWithinLOSInMap(target) || fabs(bot->GetPositionZ() - target->GetPositionZ()) > 5.0f; - if (path.GetPathType() != PATHFIND_NOPATH) + if (losBlocked) { - 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); + PathGenerator path(bot); + path.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false); + + if (path.GetPathType() != PATHFIND_NOPATH) + { + // If you are casting a spell and lost your target due to LoS, interrupt the cast and move + if (bot->IsNonMeleeSpellCasted(false, true, true)) + bot->InterruptNonMeleeSpells(true); + + float x, y, z; + target->GetPosition(x, y, z); + botAI->TellMasterNoFacing("Repositioning to regain LoS"); + return MoveTo(target->GetMapId(), x + frand(-1, +1), y + frand(-1, +1), z, false, true); + } } } From e5f1446b9faf01e2ff4b55e6adb7c14f95d80a78 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 12:05:22 -0300 Subject: [PATCH 09/10] . --- src/strategy/actions/BattleGroundTactics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index 5beb9db7..c0042a8b 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4172,7 +4172,7 @@ bool ArenaTactics::Execute(Event event) if (path.GetPathType() != PATHFIND_NOPATH) { // If you are casting a spell and lost your target due to LoS, interrupt the cast and move - if (bot->IsNonMeleeSpellCasted(false, true, true)) + if (bot->IsNonMeleeSpellCast(false, true, true, false, true)) bot->InterruptNonMeleeSpells(true); float x, y, z; From b7b8c60d17b68330e5874ed49d0d0fd61d2e8090 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 12:12:53 -0300 Subject: [PATCH 10/10] Fix --- src/strategy/actions/BattleGroundTactics.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index c0042a8b..fab932f7 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -4150,6 +4150,10 @@ bool ArenaTactics::Execute(Event event) if (bot->isDead()) return false; + if (bot->isMoving()) + return false; + + // startup phase if (bg->GetStartDelayTime() > 0) return false; @@ -4177,7 +4181,7 @@ bool ArenaTactics::Execute(Event event) float x, y, z; target->GetPosition(x, y, z); - botAI->TellMasterNoFacing("Repositioning to regain LoS"); + botAI->TellMasterNoFacing("Repositioning to exit the LoS target!"); return MoveTo(target->GetMapId(), x + frand(-1, +1), y + frand(-1, +1), z, false, true); } }