Randomly Numbers & Correct Positioning
One common event I created is a system to constantly track the player's whereabouts. We'll call this the Stepping System. It runs every 5 frames. There are 60 frames in a second. When the player triggers an exit event (the edge of the map, for example) the local event calls a common event that searches for a random map which then calls another common event specifically for handling transfers to new maps. The player is transferred to the new map.
This common event does the following:
- Generates a random number
- Makes that random number equivalent to a map id. (for example, random number 12 is also map 12)
- Then calls in the Coordinate Transfer System (a separate common event)
- Then ends itself so it doesn't jump the player all over the place.
- The event loads information about the map the player is about to enter.
- It takes the height and width information and dumps it into two variables so I can manipulate the information later.
- I deduct 2 from each of the height and width variables. Why? Because although a map may be 20x20, the useable area will only be 19x19 and I also want a 1 square space between the player and any borders (again so they don't end up teleporting all over the place)
- Now the event loads all the information about the current map. The map's dimensions and the player's coordinates are dumped into their own variables.
- Again, I deduct 2 from the map's dimensions. This is in order to enable proper re-positioning when a player moves from either the far X (right) or far Y (down) on map 1 and wants to arrive in the correct spot on map 2.
- Here are the conditions by which the new coordinates will be picked. They are all dependant on the player's current X and Y coordinates, and the Height and Width of the map they are about to arrive in.
- I added the Jump To label function because once the coordinates have been picked, I don't want the event to run through them again and alter them twice. I'm not actually sure if I need that in there, but it's a remnant from lots of testing and it does no harm so I left it in.
- The event jumps to the Transfer label.
- The player is transferred using the variables established by the random number generated (representing the Map ID), the new map X coordinates, and the new map y coordinates.
- Now, when a player exits a map from the left they will appear on the new map on the right hand side. If they leave from the top part of the map they arrive in the bottom part of the next map. And it's all automated now.