fix: eliminate remaining unit drift and engagement failures in battle#1378
Merged
Conversation
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
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.
Root causes of continued drift after initial fix:
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.
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.
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.
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.
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