This is so if it is within the dungeon bounds (guaranteed if your random boundaries are carefully calculated), and if it does not overlap an already existing room. The findSpace() function takes a rectangle (room), generates a random coordinate for the top-left of that room, and tests to see if the room fits. Placing larger rooms first results in less failures in the next step: finding a space for the rooms. These rectangles are sorted by area, larger to smaller, to aid placement. Then, generate that number of rectangles, with a width and height between a preset min and max, and throw them into an array. The first thing I do is decide how many rooms to place (between a constant min and max). Steps #2 and #3 are the tougher parts of the whole process, so they warrant a bit of fleshing out: Connect the rooms with halls until the whole dungeon is connected.Generate random rooms and place them randomly.While it relies greatly on brute force searches, especially for connectivity, I am quite happy with it, and it definitely gets the job done!įrom a bird’s eye view, it is a pretty straightforward carving algorithm with the following steps: The padding is intended to be used for staging tokens and tiles waiting to be used in a scene, or as extra side-rooms or hidden spaces.Although I have worked on two (albeit short-lived) roguelikes prior to Dance of Death, this is the first to feature a dungeon generation algorithm.
This padding space treats everything as unlit and hidden unless lights and an actor with vision is in that padding area.
#Dungeon generator algorithm how to#
You can find out how to use each file in the Frequently Asked Questions page. Foundry will generate a JSON file, Fantasy Grounds an XML file and Roll20 both a TXT file and allow you to copy the text directly on this page for easier access.Improvements will be made to support different types of walls in the platforms that have access to them. Masking the walls works much better for outdoor maps as it will shrink the positions where the solid colors are to create the path, so you'll see more of the rocks or trees or any other obstacle that needs dynamic lighting. Masking the floor works great for indoor maps like Dungeons, Caves or Buildings as it expands to create the path for the walls.
Avoid shadows or any other blurring effects it'll still work but might hamper the algorithm slightly. Tile Size: Used to determine wall distance and automatically sets the tile size on Foundry after importing the.A quick example you can even generate on DunGen are dungeons using the Mask for Image Editors theme. Requirements: The only requirement to use the tool is to mask either the floor or the walls with a solid color.