Skip to content

fix: eliminate remaining unit drift and engagement failures in battle#1378

Merged
braedonsaunders merged 1 commit into
mainfrom
claude/fix-ai-unit-engagement-lzsHo
Feb 5, 2026
Merged

fix: eliminate remaining unit drift and engagement failures in battle#1378
braedonsaunders merged 1 commit into
mainfrom
claude/fix-ai-unit-engagement-lzsHo

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

Root causes of continued drift after initial fix:

  1. Arrival spreading applied to combat units: When attackmoving units got within 3.0 units of their target (enemy center), explicit arrival spread forces (strength 1.0 * multiplier 1.2) pushed them apart. Since all 20 units targeted the same point, all got spread. Fix: skip arrival spread for attackmoving/attacking/assault units.

  2. Separation strength priority order: getSeparationStrength checked arrival distance BEFORE combat state, giving attackmoving units arriving strength (1.0) instead of combat strength (0.3). Fix: reorder so combat/assault checks run before arrival check.

  3. AI coordinator skipped ALL logic when no buildings: Battle simulator has no buildings, so the entire AI update loop was skipped. Idle units never got re-commanded to attack. Fix: when no buildings, force attacking state and still run tactics.

  4. AIMicroSystem kiting/retreat cleared assault mode: MOVE commands from kite and retreat actions called setMoveTarget() which cleared isInAssaultMode. Units lost aggressive posture after micro actions. Fix: save and restore assault mode around kite/retreat MOVE commands.

  5. Attack-moving units had no pathfinding fallback: needsPath check only included moving/gathering/building states. If the Recast crowd failed, attackmoving units had no navmesh path to follow. Fix: add attackmoving to needsPath condition.

https://claude.ai/code/session_012Sc49F3UHGXxttLJpBPggB

Root causes of continued drift after initial fix:

1. Arrival spreading applied to combat units: When attackmoving units
   got within 3.0 units of their target (enemy center), explicit
   arrival spread forces (strength 1.0 * multiplier 1.2) pushed them
   apart. Since all 20 units targeted the same point, all got spread.
   Fix: skip arrival spread for attackmoving/attacking/assault units.

2. Separation strength priority order: getSeparationStrength checked
   arrival distance BEFORE combat state, giving attackmoving units
   arriving strength (1.0) instead of combat strength (0.3).
   Fix: reorder so combat/assault checks run before arrival check.

3. AI coordinator skipped ALL logic when no buildings: Battle simulator
   has no buildings, so the entire AI update loop was skipped. Idle
   units never got re-commanded to attack.
   Fix: when no buildings, force attacking state and still run tactics.

4. AIMicroSystem kiting/retreat cleared assault mode: MOVE commands
   from kite and retreat actions called setMoveTarget() which cleared
   isInAssaultMode. Units lost aggressive posture after micro actions.
   Fix: save and restore assault mode around kite/retreat MOVE commands.

5. Attack-moving units had no pathfinding fallback: needsPath check
   only included moving/gathering/building states. If the Recast crowd
   failed, attackmoving units had no navmesh path to follow.
   Fix: add attackmoving to needsPath condition.

https://claude.ai/code/session_012Sc49F3UHGXxttLJpBPggB
@braedonsaunders braedonsaunders merged commit f640f62 into main Feb 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants