Birdoggydog's Builds

Building timed doors and multi-switch doors for dungeons

A door that shuts on a game-clock countdown but never on the party, a door with a lamp per switch it waits for, and a test that stopped trusting real seconds.

Dungeons have two new doors. A timed door opens from a lever and shuts again after a set number of game seconds, so you have to get there in time. A door that needs all stays sealed until every switch, key or story flag it wants is done, and it shows a lamp for each one.

66 seconds. The party throws a lever and runs to a timed door, stands in the doorway while it ticks down and holds, then walks through as it shuts. On a second try it dawdles and the door shuts in front of it. Then a door with three lamps lights them one switch at a time and opens.
Eight first-person frames in a blue-gray metal hall: a double door far off with a lever nearby, the open doorway from inside, the door shut behind the party, then a second door with three small lamps above it lighting one by one, and the open room past it.

The film’s frames in order. Watch the lamps over the second door’s lintel go from dark to lit.

Both were on the list of pieces missing from the dungeon kit, which I’m working through in order.

How does a timed door decide when to shut?

A door a switch opens can have closes_after, from 3 to 600 game seconds. Once it opens, a countdown runs on the game clock, not real time, and it’s saved, so a load picks up where it was. For the last 4 seconds the door’s lamp blinks amber every quarter second and it ticks once a second.

I didn’t want it to crush anyone or trap the party. So a body in the doorway, the party’s or a monster’s, holds it open. It tries again every half second and shuts the moment the way is clear, saying “// DOORWAY OBSTRUCTED. CYCLE HELD.” while it waits. Once it shuts, it seals and its lever springs back, so you can throw it and try again. From the far side the door opens by hand, sealed or not, so getting through and then needing to come back is never a dead end.

The dungeon planner also refuses a timed door you can’t physically make. It works out the walk from the lever as 3 meters per square at 5 meters per second, plus 1.5 seconds to turn around and 0.6 seconds for the doors to open. If the timer is shorter than that, the dungeon doesn’t build.

How does a door that needs all work?

The needs_all field is a list of parts: switch ids, key ids, and flag:<id> for a story flag set somewhere else. The door stays sealed and has a strip of lamps under its lintel, one per part. A lamp turns amber when its part is done, all of them go green when the last one is, and then the door opens for good. Its line keeps count: “Sealed. 1 of 3. It wants 2 more”.

A part that isn’t in the dungeon at all is an error. A part the party can never reach gets a warning, because then the door can never open.

How does the generator use them?

Both the game’s planner and the Python checker the generator uses understand the two doors, and the checker has a new gate type for need-all. The generator’s step runs while a floor is being stocked. It adds each kind of door on about 1 floor in 5 and keeps the change only if the floor still passes its hard checks. Over 20 generated dungeons, 6 got a timed door and 3 got a need-all door. The numbers are placeholders until I’ve played them.

Why did the test fail on a busy machine?

The test for the timed door ran the game clock at 4x and expected the door to shut 2 to 4 real seconds after the lever. On a loaded machine it took 4.95 seconds and failed, even though the door was doing exactly what it should. The door runs on game time, so the test was measuring the wrong clock. It now reads the game clock and expects the door to shut between 9.5 and 16 game seconds after the lever, and a slow machine can’t fail it anymore.