RPG Maker MV Guide

Region ID Checks - The first thing to do after starting a new project! for RPG Maker MV

Region ID Checks – The first thing to do after starting a new project!

Overview

Region IDs play a huge role in RPG Maker but many new creators still don’t use them. I think setting up a Region ID Check is the first thing you should do after starting a new project. It makes many events a lot easier to trigger and only takes a moment to set up. Here’s how:

What this is good for (Example)

Imagine you want to prevent the player to get to the other side of the map (in this case a beach). The first picture shows how many people that are new to RPG Maker (I did it too) tend to solve this problem: Countless events that’ll trigger On Touch and send the player back. If used on a large map, this can get really confusing and is unnecessary. A way simpler method is to just mark the specific region(s) with Region IDs and then add a single event that’ll constantly check the Region ID the player is currently standing on.

You could label as many tiles with a Region ID as you like and you’d still get the same effect for every Region ID. No tedious copy-pastes of events anymore.

Note: For this guide I’ll use Region ID 7. It’s entirely up to you what value you use.

Declaring variables


First you need to create three new variables. Since it’s best to do this right after you’ve started a new project, it should be the first three variables. You can use any other variable slot as well.

First variable: Player X
Second variable : Player Y
Third variable: Player Region ID

Creating a common event


Next up is creating a new common event that’ll do the actual work: Giving us the Region ID the player is currently standing on. Putting the necessary commands into a common events allows us to simply call the event from anywhere on the map. It works like a shortcut. We’ll name it Get Region ID.

The first thing we’ll add to our common event is a Control Variables. Set the variable to our first variable (Player X), the operation to Set and the operand to Game Data. Click on the Game Data line so that the Game Data window opens. In the new window choose Character and Player -> Map X. This will set the Game Data line to Map X of Player.

Do the same thing for our second variable (Player Y) and replace
Player -> Map X with
Player -> Map Y

The last line

Next up we’ll add our final line to the common event. Choose Get Location Info… and in the window that opens next:

  • Variable: Player Region ID
  • Info Type: Region ID
  • Location: Designation with variables
  • X: Player X
  • Y: Player Y

After that your common event should look like this:

What this is doing: The event saves the value of the X-coordinate of the player’s position into the first variable and the Y-coordinate into the second variable. The third line grabs the Region ID of a tile and we specifically tell the event to determine what tile to use by using two variables as coordinates. Since our variables contain the coordinates of the player’s position, the event grabs the Region ID the player is currently standing on.

Rules for Region IDs


Create a new event on the map that you want to use Region IDs on.
Set it’s trigger to Parallel Process and add our common event to the event code.

Now all you have to do is add a new conditional branch that checks, if our third variable (Player Region ID) equals the value of the Region ID you used on the map. (In our case Region ID = 7)


If the player stands on a tile that is labeled as Region ID 7, the conditional branch is true and the event will run its content: In this case moving the player a tile back

In this Region ID Check event you can add as many conditional branches as you want. That way you only have one event that’ll handle all the Region IDs and what happens if the player steps on a tile with a Region ID.

Edit
Thanks for the positive feedback. Someone pointed out that a constant parallel process can make the gameplay a bit laggy, especially on mobile devices. You can fight that by adding a Wait operation at the end of the event. Make the event wait a couple frames before it starts checking again.

Users Cxero and Ghost have pointed out a much faster way to do this. You can also just create a conditional branch with a Script command. Paste the following script into the window:

$gameMap.regionId($gamePlayer.x, $gamePlayer.y) === z

and replace the z with the Region ID you want to check for.

SteamSolo.com