RPG Maker VX Ace

Add unique, procedurally generated dungeons into your game!

Kai Monkey's Random Dungeons
Welcome to Kaimonkey's Random Dungeons. With this script you can have the game randomly produce floor after floor of unique environments for your player to explore. Forest, sewers, caves, mines and more can all be generated, and all options can be fine-tuned to get the perfect dungeon for your game!

  • Generate an infinite number of randomly generated dungeons for you to explore.
  • Have different settings for different dungeons, allowing your "Happy Forest" dungeon to be entirely different from your "Deep Hell" dungeon (And your players would expect not less) 
  • Populate your dungeon with events: Anything which can be built using events can be generated straight into your dungeon!
  • Use a powerful Room system to create unique features in your game
    New in Version 1.1:
  • Create rooms in rectangular shapes, not just squares!

Demo here!

Alright, I admit it, there is quite a lot of work required to get the most out of this script. For this reason I will be posting a number of step-by-step lessons on how to best use KaiMonkey's Random Dungeons. Lessons 1,2,3 and 4 must be taken in order, although the optional lessons can be taken in any order

Lesson 1: Building the tiles

The random generator works by piecing together pre-built map segments (Which I will refer to as tiles) to build up the dungeon in a maze like fashion. 
At the end of this lesson you should have something which looks like this:
Although this may look basic and boring. That is because it is, but this is only lesson one. Each of the option lessons which follow will allow the extra detail you need to create the perfect dungeons for your game!
  1. Decide your dungeons Tile-Size; how big your tiles are going to be. Bigger tiles mean you can have more detailed tiles, but also tends to produce simpler dungeons. Note, that you can have small dungeons with big tiles, and vice-versa. For your first dungeon, I suggest a size of seven.
  2. Create a new map (and call it something like DungeonTiles) Make note of its ID, which is at the top of it's property panel. It should be a three digit number like "004". We will call this number the Tile Map ID
  3. Set both the width and the height of the map to be equal to (Tile-Size x 4) + 5. So if you are using a tile-size of seven, that means the map is going to be (7 x 4) + 5 = 28 + 5 = 33 tall and 33 wide.
  4. Use any terrain draw a 4x4 grid on the map. This will not show up in game, and is just there to visually show you, the designer, where each tile is. 
  5. In each tile draw out the segment of the maze. You can put anything you want here (even events!). 
  6. Refer to the screenshot in the hide to ensure you place the right tile in the right place. For example, the top right corner should only have exits to the top and right. If you do not follow the same placement pattern as this template, there generation will not work

This blog post discussing Shift-Click mapping, which is a very useful tool in ensuring that that the tiles seamlessly connect. 

Lesson 2: Building the Floor Entrances and Exits

When the player starts a dungeon, whichever tile they start on will have a special overlay placed onto it. (This can, of course, be empty, if you do not want to mark the floor starting point in anyway). Similarly the  a random tile in the dungeon is designated to be the floor's exit. One this tile, we want an event to appear which either transfers the player out of the dungeon (Perhaps to a boss fight, or back to the main map) See the optional lessons on how have the exit event generate a new floor, allowing for dungeons with multiple floors.

In this dungeon we have a rope event at the end of each dungeon, and a section of darkened dirt at the start.

  1. Create a new map (call it something like DungeonDetails. I suggest putting it "inside" the map where you designed the tiles, by right clicking on that map and selecting new map, to keep your game organized). Make note of it's ID also, we will call this number the Detail Map ID
  2. Ensure that the tileset in use is the same as you used when you designed your tiles
  3. Set the map's size to be atleast Tile-Size + 2 in height, and Tile-Size x 2 + 3 in width. So if we are using tile-size of seven this means our detail map will be 17 wide and 9 tall. Ofcourse, this is too small for RPGMaker, so the default of 17x13 is fine.
  4. Like we did for our tile map, use any terrain to draw a grid, this time with 2 squares, side by side, each the same size as your tiles
  5. In the right most tile place anything you want to appear exactly once per dungeon floor. This should include some way of your player leaving the dungeon, such as being transferred to a different map. See the option lessons for creating dungeons which have multiple floors.
  6. In the left most tile, place anything which you want to appear on the tile where the players starts the floor. If you want nothing special to appear, just leave that section blank

Lesson 3: Creating the Dungeon Space

Here we are going to create the map which your dungeon will be generated into.
  1. Create yet another new map. (Name it something like Dungeon) The good news is you don't need to remember the ID of this one!
  2. Decide how many tiles you want it to be wide. Set it's width to be Tile-Size x Your Width in Tiles
  3. Decide how many tiles you want it to be high. Set it's height to be (Tile-Size x Your Width in Tiles) + 2
  4. Why plus two? This allows for a one square space at the top and bottom of the map.
  5. Fill the whole map with the "Ceiling" terrain. This is useful because it allows you to use the full height of the tile-size whilst designing tiles. 
  6. Finally set up any map settings which you want to apply to this dungeon, such as Parallax, Random Encounters, Background music, ect.
  7. If you wish to have any parallel events* running while the player is in this map, those events must have  

    in their name, or they will be removed when the dungeon is generated

*Or any other events you do not want removed by the dungeon generator

Lesson 4: Finally Generating the Dungeon (Now up-to-date!)

 Here we are, it's taken us quite a bit of work, but we are finally ready to transport the character to the dungeon and have them explore! This lesson will show you how to create an event which transports your player to a newly created unique dungeon
Step 1: Creating the Dungeon Door:
  1. Create the event which will transport the player to the dungeon, such as a door, cave entrance or over-world location. 
  2. Run any event-commands you want to run on that event before you start the dungeon (Such as showing an "Are you sure" message, or checking the player meets the dungeon requirements)
  3. Run the "Fade-Out Screen" command
  4. Transport your player to any part of your Dungeon Space
  5. Set a switch to true (Call this switch "Dungeon Starter", it will be tell the script that you are about to run the script, but on a different map.

Step 2: Adding the script call
  1. Go to the Dungeon Space map
  2. Add somewhere in the top line, and name it

  3. On the conditions panel on the top-left, set " ☑ Switch: Dungeon Starter" 
  4. On the trigger panel on the bottom-left, set the trigger to "Autorun"
  5. Add the first event command to "Advanced -> Script" and type:

    You MUST replace "001" with the map id of your tile-map, "002" with your detail map, and 7 to your tile-size!
    If you do not do this the code will not work.
  6. Set the Dungeon Starter switch to off.
  7. Fade in the screen!

And that's it! Enjoy your dungeon!

By following Lessons 1,2,3 and 4 you will have a basic dungeon generator. It will, however, look rather plain (and/or repetitive). The following Optional Lessons help add the depth the map generation which players expect
Optional Lesson 1: Using multiple Tile Maps:

To add more variation to the dungeons generated, you can tell the script to randomly pick between a number of different Tile Maps.
  1. Copy the first Tile-Map used for this dungeon. Make note of it's Map ID. 
  2. Make the changes you desire to this version of the tile-map. Refer to the above image for inspiration. 
  3. Repeat this process to create any number of Tile-Maps you need. These do take quite a while to make, but the more you create the less repetitive your dungeons will be.
  4. Modify the code used to generate the dungeon to:

    Where inside the square brackets you list all the ID's of the Tile-Maps used, in quotes, separated by commas. Replaced the 012 with your Detail-Map ID and the 7 with your Tile Size as usual.
  5. The dungeon will now randomly choose from both sets of tiles. Note that only the first set in the list (In the example, that would be 006) is chosen for the Start and Exit tiles, so you do not need to worry about whether your detail overlays will overlay nicely over your additional tiles, only the first one (For example, if the exit is placing a ladder in the centre of the tile, only the first tile-set NEEDS to have access to the middle tile)

Optional Lesson 2: Making use of the Room system:

The room system is a powerful system for creating elements which repeat in your dungeon (Or, perhaps, multiple dungeons). These can be as simple as single tile events (such as treasure chests), terrain decorations, or entire areas taking up most of a tile's space. In this lesson we will design these rooms, and then go back to our tile-map designs, and tell the script where we want these rooms to generate.
  1. Decide your rooms width and height. This can be anything from the full size of a tile, to a single square. 
  2. Make a map of any size (It can be expanded at any time during development to accommodate more different variety of rooms). Make note of this maps Map ID.
  3. Using any terrain type, build a grid of cells the same size as you want your rooms to be. In the example, each room is 5x5, and there 9 rooms. If there is not enough room, and one or more rooms are cut in half, expand the room so that only whole rooms are on the map
  4. In each room, design the features which you wish to appear throughout your map. 
  5. Go back to your Tile-Map. At each point where you wish to place a room in your dungeon, create an event in the top-left corner of where you wish a random room to appear. The event settings do not matter, as this event is only a placeholder, and will never be seen in game. 
  6. Set the events name to match the following:

    Where 011 is replaced with the ID of the map with the room designs, 5 is replaced with the width of the room, and 6 is replaced with height of the room.
  7. These rooms will not populate your dungeons! Note: You can have any number of different types of rooms, of different sizes, appearing in your map.
  8. Also note that rooms will never appear where the entrance or exit to the floor is.

Optional Lesson 3: Making Dungeons with Multiple Floors

In this lesson, we will create a dungeon which has multiple floors, and only after every floor is complete, has the player completed the whole dungeon.
  1. Modify the Event which transports the player to the dungeon to set a new Variable to 1. Call this variable "Floor Number" 
  2. Modify the Event which is placed at the exit of the dungeon to, instead:
    1. Check if the floor Number is equal to the number of floors in the dungeon
    2. If it is, transport the player out of the dungeon as normal (To the boss fight, cut scene, or dungeon entrance ect.)
    3. If it is not, add one to the "Floor Number". Then fade to black, call the same script used to generate the dungeon originally (e.g. rand_dungeon("015","016",10)), then fade back to normal
  3. You now have a dungeon with a set number of floors!


  • My Tile-Map has decorations from layers B,C,D and E, but sometimes I want rooms to remove them, like if I have a building or big hole in that room?: Ah, in that case all you need to do is go to that room, and use the Region tool to mark those squares at region 63. On these squares any terrain that is not from page A will be removed.
  • I have a script or parallel process system that works using Region ID's, will this still work for randomly generated dungeons: With the exception of region 63 (See above), Absolutely! Remember that the region ID of the room takes precedent over the region ID of the tile it is placed on.
  • Can I have dungeons generate differently depending on which floor I am on? Of course! All this requires is some clever eventing to change which script you run. Want to have different tiles appear when you are above floor 10? Just check the floor variable and tell it to run a script with different list of tile ID's. You can also have events that appear in your rooms and tiles check the floor number and behave differently depending. Using this technique you can also have the dungeon change depending on other factors, not just floor number. Want the dungeon to produce more treasure chests if the player has the magic amulet on? Simply make the event check for the item, and if the player does, then call the script which also has the tile-set which has more treasure in it's list!
  • Oh no! My tile's have really clear edges, and look like they have been clicked together! Other than the fact I think this looks quite nice, there problem here is one of autotiles.This blog post discussing Shift-Click mapping, which is a very useful tool in ensuring that that the tiles seamlessly connect. 
  • Oh no again! There are shadows in the middle of corridors when tiles connect to the right! Okay, this one DOESN'T look nice, but it is easy to fix. Simply go to the tile map, and use the shadow tool to remove those pesky shadows on the right side of the bottom eight tiles!

Terms of Use:
Covered by Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).

This means it isf ree to use for non-commercial projects, however you should contact me at kaisalmon@hotmail.com about licensing for commercial projects.
This script has been the biggest project I have every created for the RPGMaker community. I would really appreciate people taking the time to try and use this to it's fullest. In exchange I will be as active on this site as I can. I really would like to improve this script, and make it into something great If you have any suggestions, find any bugs, or just want to ask a simple question (Remember, no such this as a dumb question!) just post it right here!