Posted November 24, 2023 by madodev
For a game called Ero Dungeons, the dungeons were rather paltry up to now. They were long corridors with fights. However, that changes now. Dungeons are now actual dungeons. In this devlog I'll explain how the dungeon algorithm creates something like this:
But first, something completely different.
It is well known that not all goals are created equally. Neither are all moves equally good. As a dev it's very difficult to balance these things without objective usage data. That's where analytics come in. If you accept it, the goals you complete, the classes you pick and the moves you make will be sent out and aggregated. This allows me to see which goals are never completed, or which moves are never used, and give me more tools for knowing what and how to balance.
Of course, I need your permission for those things. So click on the Accept button of this large pop-up (or don't if you don't want to).
Even before the first public release of Ero Dungeons I had plans for non-linear randomly generated dungeons. However, as you know, it didn't work out. I originally started with the starting room, and then added a new room from a set of possible rooms. Repeat until you get a full dungeon. Unfortunately, this was very convoluted. It was very hard to get a neat condensed layout without long winding paths, it was also difficult to put special rooms in good locations. All in all, it didn't work, and I switched to the current layout.
To fix it I decided to start from a grid, and built the thing with moddability in mind. Any capital letter is a moddable parameter. You start with an X by Y grid and fill it with rooms. Then you do Z steps, where in each step you either (with a W% chance) remove an entire room, or (with a V% chance) remove a connection between two rooms. After each step we check whether the start and end room are still connected, and if not, undo the step.
After all this, we remove all disconnected rooms. Checking connection is very simple since Godot has a built-in Astar2D node which does all that work for us.
I originally thought to create rooms using perlin noise. It would give a very random result, but still tie everything nicely together. It didn't work at all. The results were hard to work with, especially ensuring that the rooms would connect correctly on the corridors. So I switched to a different method.
A room consists of a center part and side corridors. The center part could be a square, or a rectangle (all moddable) where the main attraction of the room is. This contains a combat encounter, or (soon) a curio, or a combination (or nothing). This is drawn out first.
Then, depending on the surrounding rooms, corridors are drawn from the sides to the center (the width is also moddable). And that's how you get the rooms. It's a pretty simple process, but it works.
The algorithm above allows variety between different dungeon types.
A machine dungeon has few removed rooms, and is very packed. Here's an adept lab dungeon:
A spider dungeon covers a large area, but has many removed rooms and connections, as well as many empty rooms. Making it feel cavernous. Here's a veteran caverns dungeon:
A ratkin dungeon lies between the two, and is average on both. Here's an elite ratkin dungeon:
As you see, the dungeons become larger and more complex as the difficulty increases.
Content:
Minor:
Bugs: