Sewers, Force Fields and Freezing Vapour


For more than a year I've been focused on developing levels in caves based on the 'ol ceullar automata algorithm. But I don't want the whole game to take place in caves and in fact I've written lots of code in the past to generate other styles of levels which I haven't been using.

Since this is a difficult game and the player will die a lot, I would like there to be some variety in the early game levels. I envisage four different level types that might appear at level 1: caves, sewers, catacombs or mines.

Anyway, I decided to whip up some methods for generating some early game sewer levels. I managed to leverage enough existing code that I could do it without too much difficulty. The results are shown above.

[White on red tiles are traps. Light blue tiles are secret doors of various kinds.]

The first three images are shown with some debug options on to show all cells on the level in full brightness. The last image shows what it would actually look like in game while making your way through the tunnels.

The algorithm works like this:

1. The map is cleared with solid rock tiles.

2. For the major tunnels (5-7 cells wide), a pattern is chosen from a small selection (e.g., S-shaped, E-shaped, vertical lines, etc.).

3. For the minor tunnels (2-3 cells wide), a graph is prepared using a classic maze generation algorithm. This ensures that all tunnels are connected.

4. The major and minor tunnels are both drawn on the map.

5. Streams of shallow water one cell wide are drawn over the minor tunnels.

6. Channels of deep water are drawn over the major tunnels, 2 cells slimmer than the full tunnel.

7. Rooms are randomly added randomly throughout the remainder of the level. To add a room, the game looks for a single cell surrounded by solid rock that is two cells away from a floor tile. It then tries to grow the room out in three directions until it is stopped by another tunnel or another room.

8. Some rooms get ordinary doors, some get empty archways. Some rooms get locked doors with keys hidden away in other rooms. Some rooms are hidden behind loose bricks, others by secret panels that slide upon when hidden buttons are pushed, and others are behind protcullises that open when hidden cranks are turned.

9. Small tunnels are added between rooms where small-sized monsters can take short-cuts.

9. All solid rock tiles that are adjacent to any tiles other than rock are converted into brick wall tiles.

10. The rooms are populated. They could be treasure rooms, monster rooms, trap rooms, rooms with special magic items, rooms with magic flowers that make your stats go up, magic fountain rooms, etc.

11. The up and down staircases are added at the ends of randomly placed tunnels.

12. Sprinkle in extra traps and monsters to taste.

I'm pleased with the results so far. I'd like to eventually set it up so that a series of steps might be needed to access the down staircase. I.e., the staircase is behind a locked door; the key is at the end of a long underwater tunnel; to swim to the key you need to drink from the magic fountain that lets you breathe underwater; the magic fountain is in a room guarded by a disgruntled wumpus; the wumpus' lair is on the other side of rusty portcullis; the portcullis is opened with a crank hidden at the end of corridor behind a secret door, etc.

Other recent goodies:

1. The wand of containment - This wand creates an impenetrable forcefield around a single creature, keeping the creature immobilized for a good while. The force field also blocks all melee attacks, projectiles, beams, explosions, or other effects that cause damage over a broad area, but does not block enchantments or gaze-based attacks. The most obvious use would be to stop a monster while fleeing, but the player might also use it to avoid fighting two things at once, or use it on themself to protect against an unavoidable blast. It is also very useful to rescue an ally who is under attack.

2. Freezing vapour - A new gas type. Freezing vapour causes lots of cold damage and freezes tiles. It's now available as a trap, as a potion, or as a monster attack (icy breath).

Get Sunlorn

Leave a comment

Log in with itch.io to leave a comment.