Birdoggydog's Builds

Adding pits and rest stations to generated dungeons

Floor plates that give way and drop the party a floor, fonts that heal half and then run dry for eight game hours, and a patrol route bug the pits uncovered.

Dungeons now have pits that drop the party to the floor below, and rest stations that heal them. Step on a pit’s plates and they give way, everyone takes fall damage, and there’s no climbing back up. A rest station restores half of everyone’s health and power, then runs dry for 8 hours of game time.

40 seconds. Cracked plates in a corridor, the fall to the floor below, the hole and its tube from underneath, then a nutrient font healing the party, refusing a second use, and working again after the clock is sped up.
Eight first-person frames: a long metal corridor with sparkles rising from the floor ahead, an empty corridor below after the fall, a square shaft with a red lamp seen from underneath, and a rusty basin on a wall with a green lamp that turns amber after use.

The film’s frames in order. Watch the party’s health bars drop after the fall and come back at the font.

Both were on the list of pieces missing from the dungeon kit. On pits I’d already decided that they’re allowed but should be rare, and usually give some sign they’re there.

How does a pit work?

A pit is a square of floor plates over a hole. By default you can see it coming: the plates are cracked and buckled, the seams glow, and a draught pushes motes up through them with a hiss. Putting the crosshair on it gives a line. A rare hidden pit just looks like normal floor, but I only draw those by hand. The generator never places one.

The plates give way once the middle of the party is 0.55 meters inside the square. The party then drops through a smooth tube with a dim red lamp onto the square straight below. Everyone still alive takes 2 blunt damage per meter fallen, and armor takes its share, so a 6 meter drop costs about 10 to 12 each. The open hole is saved, so it stays open after a load.

Walking monsters go around a pit square and flyers pass over it. Nothing follows the party down yet.

The dungeon importer refuses a pit that can’t work: one on the bottom floor, one over rock or a wall below, one over a lift, ladder or stair stop below, and one whose landing can’t walk to any way back up. Whatever a pit leads to has to have a way out. It also warns about squares on the pit’s floor that you can only reach by crossing the pit, since nobody can walk over it.

How do rest stations work?

A rest station is a fixture against a wall, in one of three looks: a font, a drip bench or a nutrient tap. Using it gives each living member half their maximum health and half their maximum power. It doesn’t cure conditions or diseases or bring anyone back, because that’s the surgery’s job. Then it’s dry for 8 hours on the game clock, and its line counts down: “// BASIN DRY. PRESSURE BACK IN 8 H 00 M.” The lamp is green when it’s ready and amber when it’s spent, and when it was last used is saved.

Where does the generator put them?

Pits replace the old “PIT WANTED” notes the generator used to leave, at the same chance of one floor in four, but only on floors that have a floor below. A pit goes on a corridor square the floor can be walked around, or else in the middle of a room. Then place_pits() checks the floor below. If the square underneath isn’t open floor it tries up to 48 other candidates, and if none work it drops the pit. Over 20 seeds of three floors, pits landed on 5 of 40 floors with a floor below, so 12%, and every one was over open floor. Rest stations went on 30 of 60 floors, always by the wall of a room off the main way.

All of these numbers are placeholders until I’ve played with them.

Why did one generated dungeon break?

The second worker on this found that one generated dungeon was refused by the importer because a patrol route pointed at a square of rock. On main, that dungeon’s third floor never got monsters at all, so the bug was hiding. With the pits and stations in, the floor got stocked and the bug showed up.

The cause was in the generator’s Grid.grow(). When a sheet grows to the left or top, it shifts every thing’s x and y so they stay in place, but it didn’t shift a patrol pack’s route. That floor grew by 5 squares in x, so two routes ended up 5 squares off, inside rock. Two lines in grow() now shift the route too, and the dungeon imports with no complaints.