From e92029dd6ebaf1a016831730a9308307b898bba6 Mon Sep 17 00:00:00 2001 From: EricksOliveira Date: Mon, 28 Jul 2025 11:48:15 -0300 Subject: [PATCH] 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); + } } }