Skip to content

Hurt units show only the figures still alive - #157

Open
MortenLyhr wants to merge 1 commit into
bssth:masterfrom
MortenLyhr:fix/damaged-figures
Open

MortenLyhr wants to merge 1 commit into
bssth:masterfrom
MortenLyhr:fix/damaged-figures

Conversation

@MortenLyhr

@MortenLyhr MortenLyhr commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

The original draws a hurt unit with fewer figures. OpenCiv4 always drew the whole formation.

What the original does (measured in Wine, BtS 3.19, plain game): the number of figures is the game core's own CvUnit::getSubUnitsAlive (exported for the engine): max(1, (G·(HP−damage) + HP/(2G+1)) / HP) for a formation of G figures. Rows of units at damage 0, 3, 10, 11, 27, 28, 38, 39, 52, 53 and 90:

unit (figures) figures shown
warrior, archer (3) 3 up to 4 damage, 2 up to 38, then 1
chariot, catapult, worker (2) 2 up to 10, then 1
settler (4) 4, 3 up to 27, 2 up to 52, then 1

A change in damage (healing, or a hurt unit) shows at once. In a battle a hurt unit fights with the figures it has (an axeman attacking a warrior at 39 damage: one warrior figure), and the figures killed in the battle fall. The last figure alive is drawn as large as the others were, not at the larger scale of a one-figure unit.

The change:

  • MapCapture: outside a battle, the unit's figures are cut to getSubUnitsAlive(). The required art definitions stay first, so a settler loses its children before the adults. In a battle all figures stay, as before: the battle's rounds already hide the figures dead before it and those killed in it.
  • UnitView::formation (the formation's full size) decides the one-figure scale (SINGLE_UNIT_GFX_EXTRA_SCALE), instead of the number of figures drawn.

Checks: ctest 15/15 (rebased on master 8b7d8557); sync checksums --turns 100 --map Fractal --size STANDARD --seed 7 equal master's (D7D43800).

Pictures (Wine left, OpenCiv4 right; rows: chariots, archers, warriors; damage rising to the right):

After:
after

Before:
before

More damage levels (left to right 27…90):
right

Settlers, workers, catapults (OpenCiv4's tighter grid hides a settler's children behind the adults; the count is the same):
settlers

Healing: the first warrior hurt to 53 (one figure), the one at 39 healed to 0 (three):
heal

Wine, a battle: the warrior at 39 damage defends with its one figure:
battle

Not changed: how the figures stand (OpenCiv4 puts them in a tight grid where the original spreads them out).

🤖 Generated with Claude Code

The original draws a hurt unit with fewer figures: as many as
CvUnit::getSubUnitsAlive gives (the game core's own rule, exported for the
engine). Measured in Wine on 2-, 3- and 4-figure units at damage 0-90: a
warrior or archer shows 3 up to 4 damage, 2 up to 38, then 1; a chariot,
catapult or worker 2 up to 10, then 1; a settler 4, 3 up to 27, 2 up to 52.
A change of damage (healing) shows at once. In a battle all the figures
stay, as before: the battle's rounds fell those dead before it and in it.
The last figure alive is drawn as large as its fellows were (Wine), not
with the larger scale of a one-figure unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant