Simple Event-Based Random Teleport Tutorial (RMXP)

This article needs an update because the information here is now out-of-date.

As a continuation of the Fun With Variables tutorial, I thought I’d try something a little different.

What if you wanted to create a simple but effective event-based map teleporter? Of course, a more complex teleport system is possible using scripts, but for the purposes of keeping things simple, events are better.

This will work in RMXP and RMVX, and it should in RMVXA, although it won’t the same way in RM2K3.

Variables Setup

To achieve this, we’ll need to create 4 variables:

  • 0001: Randomize
  • 0002: Coord-X
  • 0003: Coord-Y
  • 0004: Map ID

Map Setup

Next, we’ll need our maps to teleport between. For this tutorial, we’ll be using two maps and teleporting (randomly) between the two. Let’s create the first one, setting the dimensions to their minimums – 20×15 (RMXP) and 17×13 (RMVX). Make a note of these numbers (the maximum x-value and y-value), as we’ll need them later.

In the center of the map, create an event (called Teleporter or something similar) with an appropriate graphic for the Teleporter event. This can be a path tile or animated event graphic, or it can be blank for the element of surprise. Set the “Trigger” to “Player Touch”. In RMVX, you might want to set the “Priority” to “Below Characters” as well. Leave the Event Commands blank for now; we’ll come back to that shortly.

You might also want to place a flower tile or event or other feature to distinguish this map from the second one. Simply copy and paste this first map, then change the flower tile, event or feature to something else. That way when teleporting between the maps you’ll know which one you’re on.

Teleport Setup

In the Database, create a Common Event, called something like Teleport. In the Events Commands, we’ll need the following:

  • Set the variable Randomize to a number between 0 and the maximum x-value (from earlier), subtracting 1 because the coordinates actually start at 0, of the map. (If in doubt, in the Events Mode click on any of the right-most squares and note the first number.)
  • Set the variable Coords-X to Randomize.
  • Set Randomize to a number between 0 and the maximum y-value from earlier, again subtracting 1, of the map. (If in doubt, in Events Mode click on any of the bottom-most tiles to note the second number.)
  • Set Coords-Y to Randomize.
  • Finally, “Transfer Player” to their corresponding map and x/y coordinates. Select “Appoint With Variables” (RMXP) or “Designation With Variables” (RMVX). “Map ID”, “Map X” and “Map Y” is set to their corresponding variables (i.e. 0004: Map ID, 0002: Coords-X and 0003: Coords-Y respectively.

Finalization

Before we can do anything, we’ll need to go back to the Teleport Events on both maps and in the Event Commands, add a “Call Event” set to our “Teleporter” event from the Database.

When the game is run, every time the player steps on the "teleporter" it will transfer him to a random location on either map. If you added a distinguishing tile or feature to the map, you’ll be able to tell which map you’ve been transported to.

One possible application for this could be for a maze-like series of maps, adding switches to the Event Commands according to which map you’re on to trigger other events.

Leave a Reply