fix(movement): lock target during ram — no switching until target dies or ram exits
This commit is contained in:
@@ -174,6 +174,8 @@ method onBotDeath*(bot: ModularBot, e: BotDeathEvent) =
|
|||||||
bot.enemyTracker.markDead(e.victimId)
|
bot.enemyTracker.markDead(e.victimId)
|
||||||
if bot.enemyCount > 0:
|
if bot.enemyCount > 0:
|
||||||
dec bot.enemyCount
|
dec bot.enemyCount
|
||||||
|
if e.victimId == bot.currentTargetId:
|
||||||
|
bot.isRamming = false
|
||||||
|
|
||||||
method onGameStarted*(bot: ModularBot, e: GameStartedEventForBot) =
|
method onGameStarted*(bot: ModularBot, e: GameStartedEventForBot) =
|
||||||
# minNumberOfParticipants == maxNumberOfParticipants for fixed battles; self is -1
|
# minNumberOfParticipants == maxNumberOfParticipants for fixed battles; self is -1
|
||||||
@@ -256,13 +258,14 @@ method run*(bot: ModularBot) =
|
|||||||
setRadarTurnRate(radarRate)
|
setRadarTurnRate(radarRate)
|
||||||
go()
|
go()
|
||||||
|
|
||||||
# --- Target selection (sticky) ---
|
# --- Target selection (sticky) --- lock target during ram to prevent dangerous switch
|
||||||
let candidateId = selectTarget(bot.enemyTracker, getX(), getY(), tmClosest)
|
if not bot.isRamming:
|
||||||
if bot.shouldSwitchTarget(candidateId):
|
let candidateId = selectTarget(bot.enemyTracker, getX(), getY(), tmClosest)
|
||||||
if candidateId != bot.currentTargetId:
|
if bot.shouldSwitchTarget(candidateId):
|
||||||
bot.currentTargetId = candidateId
|
if candidateId != bot.currentTargetId:
|
||||||
bot.targetSwitchTick = bot.tick
|
bot.currentTargetId = candidateId
|
||||||
bot.printConfig("target")
|
bot.targetSwitchTick = bot.tick
|
||||||
|
bot.printConfig("target")
|
||||||
|
|
||||||
# --- Aim + fire from tracked state (not scan event) ---
|
# --- Aim + fire from tracked state (not scan event) ---
|
||||||
let tid = bot.currentTargetId
|
let tid = bot.currentTargetId
|
||||||
|
|||||||
Reference in New Issue
Block a user