fix: AI armies no longer get permanently stuck at enemy base positions#1414
Merged
braedonsaunders merged 1 commit intomainfrom Feb 10, 2026
Merged
Conversation
Three interacting bugs caused AI armies to march to an enemy base and idle there indefinitely until the enemy was fully eliminated: 1. Broken disengage timer: The timeout compared currentTick against lastEngagementCheck (updated every 10 ticks regardless of engagement state), so the duration was always ~10 and never exceeded the 100-tick threshold. Now tracks lastEngagedTick — the last tick engagement was actually true. 2. Re-command cycle reset assault idle timeout: The 20-tick re-command interval called setAttackMoveTarget() which reset assaultIdleTicks to 0, preventing CombatSystem's 120-tick timeout from ever clearing assault mode. Now skips re-commanding units already at the target position (within 8 units distance). 3. Position-only targeting in normal attacks: findEnemyBase() returned a cached basePosition with no entityId, forcing position-based ATTACK_MOVE instead of direct ATTACK commands. Now always queries live buildings and returns entityId for entity-targeted attacks, matching hunt mode behavior. Also filters out dead/non-operational buildings. Additionally, the disengage path now calls returnUnitsToBase() to clear assault mode and send units home instead of just changing state. https://claude.ai/code/session_01MwsxRyx6WEt2nw3dmG1nN4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three interacting bugs caused AI armies to march to an enemy base and idle there indefinitely until the enemy was fully eliminated:
Broken disengage timer: The timeout compared currentTick against lastEngagementCheck (updated every 10 ticks regardless of engagement state), so the duration was always ~10 and never exceeded the 100-tick threshold. Now tracks lastEngagedTick — the last tick engagement was actually true.
Re-command cycle reset assault idle timeout: The 20-tick re-command interval called setAttackMoveTarget() which reset assaultIdleTicks to 0, preventing CombatSystem's 120-tick timeout from ever clearing assault mode. Now skips re-commanding units already at the target position (within 8 units distance).
Position-only targeting in normal attacks: findEnemyBase() returned a cached basePosition with no entityId, forcing position-based ATTACK_MOVE instead of direct ATTACK commands. Now always queries live buildings and returns entityId for entity-targeted attacks, matching hunt mode behavior. Also filters out dead/non-operational buildings.
Additionally, the disengage path now calls returnUnitsToBase() to clear assault mode and send units home instead of just changing state.
https://claude.ai/code/session_01MwsxRyx6WEt2nw3dmG1nN4