Making Forests and Caves Part 4 – Eventing

In the last Part we finally made a generated Map, but there’s still one thing missing: Once on the Map, we cannot continue our journey.

If not already done, let’s move the JavaScript Code or Plugin Call into a Common Event, so we don’t need to copy-paste stuff.

On the Space Map, place an Event and make it parallel process. This Event checks if the Player touches the Map’s border and will then transfer him to the next stage. That can be a new randomized or an ordinary Map.

We check whether the player has reached the outline of the map by regularly querying his position and comparing it with the size of the map. In our example, having a road from south to north, we only need to check the Player’s Y coordinate, however, if you have a map with exits to any other directions, you will need to check them aswell.

  1. Using Variable Operation we store the Player’s X and/or Y coordinate
  2. Make a Conditional Branch
  3. To check if the Player has reached north or west is simple. Just check if his X or Y coordinate is < 1.
  4. To check if the Player has reached south or east, you can insert a Script Call in the Condition Branch (Tab 4) and paste this:
    east: $gamePlayer.x + 1 == $gameMap.width()
    south: $gamePlayer.y + 1 == $gameMap.height()
  5. Inside the Branch, you can do some calculations to determine where the Player will be transferred. For instance, you can add a „progression counter“, that adds 1 until the Player reached the required level to escape from the dungeon.
    If you want to generate a new random Map, just call the Common Event.
    If you want the Player to escape from the Dungeon, just transfer him to any other Map.