Skip to content

Make all traps attackable and give them configurable HP - #32

Open
Upabjojr wants to merge 1 commit into
tomluchowski:shaders-improvementfrom
Upabjojr:split/traps-destructible
Open

Make all traps attackable and give them configurable HP#32
Upabjojr wants to merge 1 commit into
tomluchowski:shaders-improvementfrom
Upabjojr:split/traps-destructible

Conversation

@Upabjojr

@Upabjojr Upabjojr commented Aug 6, 2026

Copy link
Copy Markdown

Proposal 1 of a set of PRs following the mechanics discussion in #23 (#23 (comment)) — this one covers the part Tom was certain about: "anyway Traps should be destructible".

It turns out the attack machinery for traps already exists end to end (per-tile HP, Building::takeDamage, target discovery in GameMap::getVisibleForce, fight actions) — but TrapSpike and TrapBoulder override isAttackable() to false, so only cannons and wooden doors could actually be fought. This PR:

  • Removes those two overrides, so spike and boulder traps can be attacked and destroyed like cannons already could. The vision gate in Trap::isAttackable is deliberately kept: a trap that a player has never seen trigger stays invisible and unattackable for them, so hidden traps remain a real threat.
  • Makes trap HP configurable per trap type. Tile HP was a flat Building::DEFAULT_TILE_HP = 10.0 for every building in the game. Traps now read BoulderHP, CannonHP, SpikeHP, WoodenDoorHP from traps.cfg via a new getTrapConfigDoubleOrDefault(), which falls back to the old value of 10 when the entry is missing — older/custom config files keep working unchanged.

The shipped values (Spike 10, Boulder 15, Cannon 20, WoodenDoor 25) are conservative first guesses to make sturdiness roughly track cost — obviously up for balance discussion, that's why they're config entries.

Not touched here: traps were already claimable tile-by-tile by enemy workers (Trap::claimForSeat destroys the danced tile), and that stays as it is.

Validated: builds and the full test suite passes (including ab-TestTraps) via ctest.

🤖 Generated with Claude Code

Traps had the full attack machinery wired (per-tile HP, takeDamage,
target discovery) but TrapSpike and TrapBoulder overrode isAttackable
to false, so only cannons and doors could ever be fought. Remove those
overrides: every trap can now be attacked once the attacking seat has
seen it trigger (the vision gate in Trap::isAttackable is kept, so
hidden traps stay safe).

Tile HP was a flat Building::DEFAULT_TILE_HP = 10 for everything. Add
Trap::getTileHP() overridden per trap type from traps.cfg (BoulderHP,
CannonHP, SpikeHP, WoodenDoorHP), read through a new
getTrapConfigDoubleOrDefault so older config files without the new
entries keep the old value of 10 instead of breaking.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tomluchowski

Copy link
Copy Markdown
Owner

For destructible traps I am by whole heart .... For the destructible rooms I feel the opposite: they should only be reclaimable between players. That needs to be discussed, but no one says anything at our discord channel.

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