In this tutorial, we build our first random dungeon by using the „Snippets“-technique.
The idea is to pre-define Snippets which this plugin will randomly connect to create appealing dungeons to explore. A snippet is a fundamental base element of the resulting maze, in detail: straights, turns, dead-ends, T-forks, and one crossing.
- We decide the size of all the snippets, let’s use 7 for both width and height.
- Create a map called „snippets“ (exactly this name). This map has a width of
(4 * snippet's width) + 5
and height respectively, in our case that’s 33 for both, width and height.
- Draw snippets as shown in the picture below.
The technique the plugin uses is pretty straightforward: It expects each primitive element (straight, curve, fork, …) in a specific place, which means to get a logical map you must stick with this arrangement.
However, you are free to draw whatever you wish. For example, it is not required for the blank tile to be completely black. When designing a forest, it could be nice to use grass here, which is passable for the player.
- The yellow sand helps you to frame your snippets. You can use any tile here; just pick one with high contrast.
- This plugin uses functions to fix autotiles, so you don’t have to worry about them.
- The same goes for shadows, they will be automatically erased when the map is generated.
- You maybe wondered if the map will later look clipped or repetitive. To get some more variety, you can repeat step 3 and make another map with Snippets.
Important: Name them „Snippets2“, „Snippets3“, and so on. This plugin then will randomly pick from your maps.
Create a new map with these settings:
- You can give it any name.
- Decide on the size of the generated dungeon, ie. how many snippets are there for any column and line, let’s use 6 for both.
By default, the plugin draws a margin around the map; hence, the formula for the map dimension is
snippet's width * columns + 2
and for the height respectively. In our example, that’s 44 for both.
- Use the same Tileset as in the Snippet Map.
- Feel free to choose BGM, display name, encounters, parallax (hey, why not?), …
Confirm and close this dialog.
Fill this map with the black Tile that you used in your Snippet on the top left.
Entrance, Exits, Events, and Other Objects
Right-click your Space Map and create a new Map.
- Call it „Assets“ (exactly this name)
- Choose the same Tileset as before
In this map, we may define an entrance, an exit, gameplay-related objects like mobs, chests, switches, keys, …, and decorative objects.
Let’s have a look at this example:
Let’s break it down, row by row. Each one consists of:
- Region Tiles on the left. Please ignore the 6 on the top, we come back to this later. The Region Tiles have these purposes:
- They assign each row with a unique number, so we can easily refer back to them later.
- They define the width and height of their corresponding object.
- At least one object. That could be anything like common Tiles or Events. When you put more than one object, the plugin randomly picks every time.
Entrance and Exits
The entrance and exits have a special role. First of all, the plugin sees no big difference between an entrance and an exit. (I mean, when you leave through a door and re-enter a second after, is that door an entrance or exit door?)
You can have up to 4 exits; one in each direction (north, west, east, south). Each exit has its reserved Region Id, that you can look up:
- 5: Southern Exit
- 13: Northern Exit
- 8: Western Exit
- 15: Eastern Exit
For our first dungeon, we pick 2: The southern one where the player will spawn, and the northern one where the player continues their journey. Draw something like this:
Feel free to choose a different width or height, e.g. having a larger door. If you don’t want to visually emphasize where the player spawns, you can safely keep this tile blank.
Usually, all exits have one Spawn Location defined. This is required so the plugin knows where exactly the player should spawn. A Spawn Location is a single Region Tile with a specific Id.
- 6: Southern Spawn Location
- 14: Northern Spawn Location
- 9: Western Spawn Location
- 16: Eastern Spawn Location
When is a Spawn Location required?
For our first dungeon, we let the player only spawn from the southern exit, so we can leave the spawn location out from the northern exit.
Tip: Slightly move the Spawn Location
It usually looks more appealing when the player spawns one tile below the gate.
Now, you may define more decorative objects.
By default, you can use Region Ids from 1, 2, 3, and 4. All of them are optional.
How can I add new rows?
You may use any other Region Id. To add or change Region Ids go into Templates/Plugin Manager.
Monsters, Chests, and other Gameplay related Objects
As you can see in the screenshot above, you may add gameplay-related objects. By default, this plugin offers you 3 reserved Ids:
- 20: loot chests
- 21: enemies
- 22: a single switch (e.g. for puzzles)
How can I change the number of spawns and how can I add new assets?
You may use any other Region Id. To add or change Region Ids, or to change the number of how often an object spawns, go into Templates/Plugin Manager.
Below is a table of the default Region Ids and their function.
Some Region Ids are reserved for special functions. You may change them in the Plugin Manager („RNGMaps“, and in the Templates inside of „RNGMaps_withSnippets“).
|6||Southern Spawn Location|
|14||Northern Spawn Location|
|9||Western Spawn Location|
|16||Eastern Spawn Location|
|1 – 4||Decorative Objects|
|22||Switch (e.g. for Puzzles)|
Multiple Assets in one Row
As you can see, you can always put more than one object in one row. You can also duplicate objects to easily make ratios. In this example, it’s more likely that a grey chest appears rather than the blue one.
Can I put empty objects on purpose?
By default, the plugin scans for the last asset of a row. You may use the Stopper Region Id (61 by default, which can be changed in the Plugin Manager) to tell the plugin where it should stop scanning. That is useful when you want to allow an asset to not spawn at all.
Put Region Tiles on the Snippets
By putting Region Tiles on your Snippets, you define where objects spawn. In detail, you place one Region Tile for one asset (regardless of its size).
Let’s go through all the different asset types. I recommend you to start with the exits first.
Exits have special rules. It is essential for the plugin that it is able to spawn all mandatory exits; otherwise, your player cannot spawn correctly or find an exit to escape from your dungeon. At this point, I don’t know which is worse.
Ensure that the generator is always able to spawn all the exits! For that, put one spawn point for the southern exit on every Snippet that has a wall on its bottom, and for the northern one, respectively, on all Snippets having a wall on their top.
You can put all the other objects anywhere you want; just don’t block the player.
Now when we have all the required Maps, we need to arrange them. All we have to do is to make the Space Map become the parent map of the maps we created in this tutorial. As soon as the player enters the Space Map, the plugin will scan its child maps and load them.
Finally, we can write the event command to start the generator. You can use Common Events to re-use your commands.
The player must be on the Space Map before you invoke the generator. The plugin relocates the player for you, so your transfer event can point anywhere on your Space Map.
Your (common) event, therefore, consists of:
- a Transfer Event (any position on the Space Map)
- a Script Call (MV)
- Plugin Command (MZ)
It’s useful to add some fade-in and fade-out effects to wrap everything.
MZ: Plugin Command
Here you define the directions into which your dungeon has exits. Note, that the entrance is treated as an exit, too. You also define from which direction the player spawns.
Non-Programmers, don’t be afraid. You don’t need any programming knowledge.
Make a Script command and copy-paste this:
$dungeonGenerator.template("Imperfect Maze") .withExit("top") .withExit("bottom") .spawnPlayerAt("bottom") .finalize()
You can have the line
.withExit(x) up to 4 times; one for each direction (top, left, right, bottom).
Spawn Player at:
You can pass a direction (top, left, right, or bottom) or an x, y-pair. Example:
Replace 1 and 2 with your Variable Ids.