Repository navigation
Enemy turn replay: showing AI actions on the map instead of only in the notification log #15951
dicldiphtriclet
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
enemy-turn-animations.patch
Hi Unciv maintainers,
I would like to share a feature I added to a local 4.22.17 build, and to hear whether the approach is something you would consider upstream.
Motivation
Today the AI turn is computed on a background thread and the world screen is rebuilt afterwards with the final state. The player learns what happened from notifications and the movement-arrow overlay — in other words, by reading a log. That works, but it forces the player to reconstruct the turn mentally: which unit moved, from where to where, in what order, and what actually killed their scout or took their city.
Showing the enemy turn as a short animation is far better than reading that record. A line of text tells you that something happened; a moving unit tells you where, in what order and by whom — at a glance, without parsing several notifications. It conveys sequence, direction and causality that no list of messages can carry, and it makes the world feel alive between two player turns instead of snapping instantly to a new state. This is also broadly how Civilization II presented AI turns.
What it does
Records every tile-to-tile AI move and every AI attack while GameInfo.nextTurn runs, into a transient, non-serialized log.
Replays that log on the pre-turn world screen, one unit at a time, panning the camera to each action. Friendly units that will be destroyed and cities that will be captured are still present during the replay, so the player can actually watch them fall rather than arriving at a result already settled.
Only when the replay ends (or is skipped) is the calculated state loaded and the player's turn started, so decision popups appear afterwards rather than on top of the animation.
Combat shows sparks on both combatants' tiles; the number of bursts scales with damage (one per 20 HP), spread over one second. The same sparks accompany player-initiated combat.
Three options under Display (enable, camera follow, speed), a skip button / click-to-skip, and English + Simplified Chinese strings.
Design notes for reviewers
All new state is @transient; save files, the network protocol and the ruleset are untouched.
Recording is gated by a flag set only while the UI calculates a turn, so simulations, tests and multiplayer downloads are unaffected. Online multiplayer and AutoPlay bypass the replay entirely.
The replay uses purely visual Actors on tileGroupMap and never writes unit positions. Melee combatants remain on adjacent tiles: the charge animation stops short of the defender's hex and pulls back.
This does change core turn flow — WorldScreen.nextTurn now defers startNewScreenJob until the replay finishes. I would be glad to hear if you would prefer a different hook point or a thinner integration.
Known limitations
continuousRendering defaults to false; the replay forces it on for its duration, while player-initiated combat inherits the existing battle animation's rendering conditions.
During the replay UncivGame.Current.gameInfo still points to the pre-turn state (no loadGame yet), so a manual save at that moment would persist it. The normal autosave runs after loadGame.
Nuclear strikes go through Nuke.NUKE rather than Battle.attack, so AI nuclear attacks produce no replay entry.
Verified by build, packaging and launch smoke tests; broader in-game playtesting across map sizes and game speeds would be welcome.
Availability
Based on 4.22.17 (Kotlin 2.4.20 / Java 21), under MPL-2.0. A unified patch against pristine 4.22.17, the 15 modified source files, a prebuilt desktop jar, build scripts and a bilingual changelog are included in the accompanying release package. I am happy to open a PR, or to rebase the patch onto current master, if there is interest.
All reactions