Eventing (RPG Maker MV)

You will find all the necessary commands to generate a dungeon or map in MK_RNGMaps_Core. In this article, we demonstrate the two essential actions regarding map generation.

  • Generate Map (when the player is on a regular map and enters the generated area)
  • Regenerate Map (when the player is on a generated map and enters, e.g., the next floor)

Preparation

Before you start, grab a pen and a sheet of paper (yes, a real one!), and note down all the Map IDs of your Space Map(s). We need them in the next step.

Generate

This Plugin Command generates a map and transfers the player to it. You can call this command at any time in your game.

RandomMaps.generate({
  mapId: 1,
  useSnippets: true,
  templateName: 'Imperfect Maze',
  seedVariableIds: [ ],
  roomLayout: '5 floor Tower',
  exits: ['top', 'bottom'],
  enterFrom: 'bottom',
});
Map ID

In this section, provide the Map ID of your dungeon’s Space Map.

Use Snippets

Type true when your dungeon generation is using Snippets or false otherwise.

Template

Templates provide additional information and parameters to the map generator. This plugin series already comes with many Templates to kick off, but of course, you can also create your own in the Plugin Manager.

Here’s a list of Templates that the plugin offers from the start:

When using Snippets:
Classic Maze
Imperfect Maze
Sewers
Cave
Castle
Road
Town

When NOT using Snippets:
Static Map
Cave
Flooded Cave
Forest
Swamp
Castle
WorldMap
Village
Room Layout

Jump to: Room Layouts

This plugin series comes with a Room Layout feature. You can start with the Room Layouts that the Plugin Command already provides or create your own in the Plugin Manager.

When you don’t want to use this feature and simply want a single map, choose „Single Room“.

Here’s a list of Layouts that the plugin offers from the start:

Single Room
5 floor Tower
10 floor Tower
3x3 Grid
4x4 Grid
5x5 Grid
3x3 Maze
3x3 Imperfect Maze
Imperfect Maze
Vertical Road
Seed Variables

When leaving empty, the generator generates a fresh new dungeon when this Plugin Command is called.

When you add one or multiple Seed Variables, the generation depends on their values. Using the same values when generating a dungeon, the dungeon will look the same.

Exits

Here, you define in which direction(s) the generated dungeon will have exits.

This parameter is an array. Example value:

exits: ['top', 'bottom']

Available directions:

'top', 'bottom', 'left', 'right'

Remember that the entrance is treated as an exit, too! For example, when the player enters the dungeon from the bottom and should not be able to escape, still include „bottom“.

Enter from

Here, you decide from which direction the player will spawn. Choose from

'top', 'bottom', 'left', 'right'

Going to the next Room (also called Floor)

This is the eventing that you want to put to the exits from your asset map.

Most dungeons consist of multiple rooms; for example, a mystic tower will have multiple floors to challenge. This plugin series comes with functions to make it simple to control which room the player is in and also memorizes all Event states (i.e., Self-Switches).

An exit usually comes with this array of commands:

  • Tell the plugin in which direction the player goes
  • Queries the plugin whether the following room or floor is still inside the dungeon or not
    • If yes, tell the plugin to generate the next map (regenerate)
    • If not, transfer the player to any other map
  • Optional: Sound Effects

Go To

RandomMaps.goTo(direction)

Replace direction with either 'top', 'bottom', 'left', or 'right'.

Conditional Branch

In this Conditional Branch, go to Tab 4, „Script“ and type:

RandomMaps.willStayInDungeon()

Don’t forget to check „Create Else Branch“.

Regenerate

Make another Script Call and type:

RandomMaps.regenerate()

Determine whether Player touches Map’s End

Sometimes, you must check whether the player touches the map’s end. For example, when you are not using door or corridor tiles.

We achieve that by making an invisible event on the Space Map running on „parallel process“. Here’s a brief overview:

Let’s go through step by step:

Get Player’s X and Y position

We do that via Variable Operations.

Conditional Branches

We need 4 of them, one for each direction (top, bottom, left, right).

Determining whether the player is on the top or left is rather simple; just check whether their X or Y coordinate is less than 1.

We don’t need an Else Branch here, by the way.

To check whether the player is on the bottom, you need to copy-paste this script into Conditional Branch, Page 4, Script:

$gamePlayer.y == $gameMap.height() - 1

And for the right end:

$gamePlayer.x == $gameMap.width() - 1

Inside the Conditional Branches, we put the Eventing as explained in „Going to the Next Room“.