Dungeon Generator Script v1.0
What is it?
This script is one I have wanted to do since I started working with VX. It allows a random dungeon to be created from a number of rooms of any size and shape. This allows for more controllable dungeon design.
How can I use it?
To use this script, place it under “Materials” but above “Main”. To use a random dungeon, simply use the following script call:
- create_dungeon(length, alts, width, height)
After using this call, just transfer to a map tagged with “<random>” and the random dungeon will be created. The 4 arguments of the script call are meant to be numeric and are as follows.
- length – The total length of the main path of the dungeon. Using a higher number will create a larger dungeon.
- alts – The max number of treasure paths to create. These paths can be any length between 1 and “length” rooms and will start from any existing room EXCEPT the start and end rooms.
- width – The total allowed width of the dungeon in rooms. By default a buffer of one room is placed on each edge of the dungeon and includes empty rooms.
- height – Same as width only vertical.
Maps must be created with a total of 40 “rooms” that the dungeon selects to draw from. This creates a set of rooms that is 8 wide and 5 tall. Every room must be the same size, but the size of the rooms and the size of the set is pretty much infinite. The first 16 rooms are the standard rooms that will show up based on the random value you set in the config section.
The next 16 tiles follow the same pattern. These are the “uncommon” tiles that only appear with a certain chance based on the random value set in config.
The final 8 tiles are the start and end points. The first 4, your start points follow the pattern up, right, down, left. The last 4 are the end points and follow the same pattern.
The end result map should be something like this:
There are 2 types of special events that can be placed on a map. These are as follows:
- <super> – Any events with this in their name will get placed in the very upper left hand corner of the map. This is useful for parallel processes and other such events.
- <treasure> – The event with the lowest id and this in it’s name will get placed on all tiles in treasure rooms that have an ID of 3.
Regions are very important for telling the map where certain things should happen. The region tags that are reserved by the generator are 1, 2, 3, 4, 6, and 8.
Region 3 is used by the generator to determine where to put treasures. When a room is designated as a treasure room (the end of an alt path) it will search the room for a region 3 and place treasure chests on ANY found (see above for how to mark these).
Regions 1, 2, 4, 6, and 8 are used for the start points. As it is creating the dungeon, it will take the last of these regions that it copies and set it as the start point. As a general rule, only put one of any of these in each of the 4 start rooms. When using region 1, the player’s facing direction is determined by the transfer event. If you want the direction to change based on which room the player ends up in, user 2, 4, 6, or 8. These will set the player to face the same direction as the same number on the numpad, for example, region 8 will place the player facing up.
All other events work normally. When a room is copied over to the newly created map, all events are taken with it and placed in exactly the same spot. The only exceptions are events marked as treasures and events marked as super.
What does it work with?
This script may not work with scripts that modify how maps, tilesets, or events work.
This script adds an additional command to my Basic Console script that allows you to see a map of the dungeon generated. To do this, type “map” in the console screen.
I would like to use this code.
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Permissions beyond the scope of this license may be available at https://cphouseset.wordpress.com/liscense-and-terms-of-use/.
I had created a similar dungeon generator to this with events in rpg maker 2k3 and it actually worked really well! Of course with scripts it’s a lot more controllable. The main focus of this dungeon generator is to allow large dungeons with multiple “rooms” to be created which allows more control to the shape of dungeons. The result is random dungeons similar to Persona 4. Rather than being small, ugly paths, you can create large, robust rooms, and due to standard and special rooms, you can even have some simple little challenges in some of those rooms. This may be a bit tricky to use, so I included a demo which shows how several aspects of the script work. If you’re having trouble, be sure to check that out. As always, enjoy!