Skip to content

Doors and Traps

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

Doors and traps

Research: read · Simulation: built · Verified vs original: spot-checked · Presentation: partial

Door and trap placement, manufacture, triggering and effects: what a keeper's blueprints become, how a door opens, locks and is fought, and how every shipped trap fires.

Behaviour, in our words

Placement and construction. A door or trap starts life under construction: the level loaders seed that state from one door flag bit and, for traps, from the field the parser calls NumberOfShots, which DK2 reads only as a yes/no "already built" marker (STRONGLY INFERRED, binary). A keeper places a blueprint on its own open floor, a door only between two walls unless it is a Barricade (STRONGLY INFERRED), and the gold is taken at once (CONFIRMED, owner 2026-09-26). Imps then build it like an authored one.

Doors. Whether a door is open is recomputed every update: a running lock-pick countdown forces it open, lock mode 3 shuts it, otherwise it is open while a friendly creature stands on the door tile or the two tiles beside it (STRONGLY INFERRED). A built, locked door that is not a Barricade also shoves each creature standing on its tile out along the passage, toward the nearer mouth (STRONGLY INFERRED). The player's lock command turns an unlocked door (mode 0) to mode 3 and any other mode to 0. A hostile creature that walks into a door makes it its forced target and fights it, with no test that the door is shut (STRONGLY INFERRED). The owner saw an enemy stop to attack a door held open by its owner's creature (CONFIRMED, Q454) and saw a door die when the wall beside it was dug out (CONFIRMED). A dead door leaves the world in the turn it dies (STRONGLY INFERRED).

Traps. A completed trap picks a victim with a sight, tile or Trigger selector, charges, checks mana and fires its shot; the shot's own kind decides the effect (STRONGLY INFERRED). A Sentry shot a Goblin six tiles away, past its nominal range (CONFIRMED, Q452); the binary explains it, since a turning trap looks two tiles further (STRONGLY INFERRED). Another Goblin, four tiles away, walked toward the trap and fled when hit, and the fear lasted all session (CONFIRMED, Q513 b and c); nothing read clears it. A hidden trap is revealed by firing, or by a Troll, Thief, Rogue or Guard passing it (STRONGLY INFERRED). A creature with nobody else to fight then attacks a revealed enemy trap; level-10 creatures were watched walking up and destroying a Hero Sentry (CONFIRMED, Q362). A hero trap on a Neutral-owned tile is destroyed on its first update (CONFIRMED, Q513a). The Boulder held to its predictions in play for Q520 (a) to (d) (CONFIRMED); (e) is unwatched; Q737's closure is in boulder §9c, while Q524 remains a comparison.

Disarming. No fresh v1.70 game with shipped data was found to start a disarm, and the advertised NUM 0 control is inert, so we do not build it (STRONGLY INFERRED, scoped: a restored save could carry the state; ADR-0329).

Numbers from the game database

  • TrapDef (from Traps.kwd, parsed by KwdTraps): GoldCost, Health, HealthGain, ManufactureRequired, ManaUpkeepPerSecond, ManaCostToFire, RangeTiles, RechargeSecondsRaw, ChargeSecondsRaw, ThreatSecondsRaw, TriggerType (the selector), Flags, and ShotTypeId with ShotData1/2 and the shot offsets. ShotTypeId points into Shots.kwd, which owns each effect's damage type and process.
  • DoorDef: Health, HealthGain, GoldCost, ManufactureRequired and DoorFlags (Secret Door, Barricade, Hero Barricade, Hero Portcullis).
  • Global variables: DoorPickedTimeSeconds (lock-pick duration), TriggerTrapTriggerSpeedTilesPerSecond (Trigger countdown) and BoulderToCreatureDamagePercentage, read through the database and never copied into code.
  • Placed records come from the level THINGS files; PlacedThingsOnRealDataTests compares every one with its source. The per-trap table of selector, recharge, mana and shot is traps.md section 12.

Evidence

What Where
Door update: open order, support, recovery, death 004A55F0
Door and trap THINGS loaders (construction markers) 00520F40, 00520E50
Trap update, in order 004A84E0
Trap readiness and firing 004A7D10, 004A7FD0
The target's answer to a trap's shot 0045AA20
Victim selection, including scan D (traps) 0045CB00
Authored state, door opening and locking doors-and-traps.md
Door contact, the door fight and death door-blocking.md
Trap firing, Trigger, reveal, disarm; play observations (section 14) traps.md
Boulder and Jack In The Box, with their play sections boulder.md, jack-in-the-box.md
Blueprint placement, drawing blueprint-placement.md, structure-drawing.md
Owner observations Q454, Q452, Q513, Q362, Q520, Q524 in open-questions.md

Our implementation

Divergences and open questions

  • Disarming is not built (ADR-0329, Q455): no initiator was found, so we invent none. Q451, whether a failed disarm fires the trap, waits on it.
  • Left unbuilt by choice or for lack of a read: a closed door pushing creatures off its tile, the Secret Door reveal, effects, sounds and animations, and shot heights (moved to a later milestone, ADR-0341, Q398). See the "Built and left" sections of door-blocking.md and traps.md.
  • Ours against play: current trap-fight results and remaining limits are in combat spells §5 (Q732). The native Boulder-stun explanation and its scope are in boulder §9c (Q737); wear accounting remains Q725.
  • Q450 lists what is left of trap firing. Q524 records that DK2's Jack reaches a heart corner that ours first could not; ours settles there since ADR-0627.

All open questions are in Open Questions; terms are in the Glossary.


Last verified against 2f91419d on 2026-11-05.

Clone this wiki locally