From 7657699531aea1ab7cc1133bb4a1171b3c630795 Mon Sep 17 00:00:00 2001 From: Davide Cappellini Date: Sun, 20 Sep 2026 12:39:11 +0200 Subject: [PATCH] =?UTF-8?q?fix(movement):=20lock=20target=20during=20ram?= =?UTF-8?q?=20=E2=80=94=20no=20switching=20until=20target=20dies=20or=20ra?= =?UTF-8?q?m=20exits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ModularBot_garage/src/ModularBot.nim | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ModularBot_garage/src/ModularBot.nim b/ModularBot_garage/src/ModularBot.nim index 9818f32..bf4c057 100644 --- a/ModularBot_garage/src/ModularBot.nim +++ b/ModularBot_garage/src/ModularBot.nim @@ -174,6 +174,8 @@ method onBotDeath*(bot: ModularBot, e: BotDeathEvent) = bot.enemyTracker.markDead(e.victimId) if bot.enemyCount > 0: dec bot.enemyCount + if e.victimId == bot.currentTargetId: + bot.isRamming = false method onGameStarted*(bot: ModularBot, e: GameStartedEventForBot) = # minNumberOfParticipants == maxNumberOfParticipants for fixed battles; self is -1 @@ -256,13 +258,14 @@ method run*(bot: ModularBot) = setRadarTurnRate(radarRate) go() - # --- Target selection (sticky) --- - let candidateId = selectTarget(bot.enemyTracker, getX(), getY(), tmClosest) - if bot.shouldSwitchTarget(candidateId): - if candidateId != bot.currentTargetId: - bot.currentTargetId = candidateId - bot.targetSwitchTick = bot.tick - bot.printConfig("target") + # --- Target selection (sticky) --- lock target during ram to prevent dangerous switch + if not bot.isRamming: + let candidateId = selectTarget(bot.enemyTracker, getX(), getY(), tmClosest) + if bot.shouldSwitchTarget(candidateId): + if candidateId != bot.currentTargetId: + bot.currentTargetId = candidateId + bot.targetSwitchTick = bot.tick + bot.printConfig("target") # --- Aim + fire from tracked state (not scan event) --- let tid = bot.currentTargetId