Files
TravianZ/GameEngine
Ferywir 91a980fa3d fix(combat): keep the hero casualty when rams force a battle recalculation [#372] (#373)
When rams change the wall level, applyRamDamage() replays the whole battle
through calculateBattle(). That helper WRITES to the hero table, so the replay
applied the hero damage a second time: applyHeroBattleDamage() only looks up
heroes with dead = 0, so the hero who had just died on the first pass was no
longer found, the call returned null and casualties_attacker[11] was never set.

Consequences, all visible in the screenshots of the issue: the report showed the
hero alive and "gained XP" instead of "died", modifyAttack3() never decremented
t11, and returnunitsComplete() added the hero back to units.hero - a hero dead in
the hero table but still displayed in dorf1 and in the rally point. Defender
heroes were also charged their health damage twice.

calculateBattle() now takes an optional $previousHeroOutcome: when the caller
hands over the first pass result, the hero damage is not applied again and the
first verdict (attacker / defender / reinforcement heroes) is carried over.

Also:
- drop the temporary [TravianZ][EROU] error_log() debug traces;
- 37_revive.tpl: only render a revive row for a hero that is actually dead
  (the revive action itself was already gated on dead = 1).

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Catalin Novgorodschi <cata7007@gmail.com>
2026-08-09 20:20:37 +03:00
..
2026-08-05 14:45:18 +03:00
2026-08-04 07:54:47 +03:00
2026-08-09 16:14:01 +03:00
2026-05-15 08:17:14 +03:00
2026-08-04 11:05:54 +03:00
2026-05-07 08:24:40 +03:00
2026-07-17 07:49:20 +03:00
2026-07-28 13:32:10 +03:00
2026-08-09 09:22:43 +03:00
2026-08-03 08:39:26 +03:00
2026-08-09 19:37:51 +03:00
2026-07-20 07:09:06 +03:00
2026-07-24 08:34:50 +03:00
2026-07-01 07:59:05 +03:00
2026-08-08 20:45:23 +03:00
2026-08-03 07:58:30 +03:00
2026-05-15 08:17:14 +03:00
2026-07-01 07:59:05 +03:00
2026-08-05 10:39:38 +03:00
2026-08-05 10:21:53 +03:00
2026-08-05 12:03:09 +03:00
2026-07-01 07:59:05 +03:00
2026-07-16 14:08:05 +03:00
2026-08-09 16:14:01 +03:00
2026-08-05 10:39:38 +03:00
2026-08-05 10:39:38 +03:00
2026-08-05 14:14:10 +03:00
2026-07-24 08:34:50 +03:00