I always intended to have support for some form of custom rooms in my dungeon generator. The idea is similar to Angband’s vault system, but a lot more generalized. Instead of using custom rooms or prefabs for vault encounters, I wanted to supplement the dungeon generation with custom built rooms or sets of rooms.
These dungeon prefabs required me to implement a file format in XML that would represent the prefab structure. My schema allows me to set up the layout, specify light sources, and connectors.
The function of the connectors tag is to give the dungeon generation algorithm some guidance in placing the prefab within the dungeon. The algorithm will try to place a prefab with each connector located next to a corridor within the dungeon. Locations with no connected connectors are rejected.
The added benefit of the prefab implementation is that I now have serialization for most of my dungeon data. This means that I can easily save a generated dungeon which will be useful for save files in the future.
I hacked the prefab generation into my existing dungeon generation code, but it soon became a mess. This led me to revisit the room and door generation code.
The room and door generation code now has a nice set of unit tests. The algorithms for each are also a bit more purposeful in terms of placing rooms and creating doors in an intelligent manner.
I am not 100% happy with it yet, but its a substantial improvement. I will need to implement some form of maze (or dungeon) solving algorithm to make it smarter.
There are still a few issues with the lighting system, but I want to implement some new functionality before I continue tweaking. It’s really boring running around dungeons without any monsters.
I hope to have a new tech-demo ready for download in the next few days. I am just doing some Linux testing before I upload.