I was going to make this post in a few weeks when I was done the current part of my project, but I’d better post this now while I still can.
This is a method I’ve discovered for recreating and duplicating the functionality of RPG Maker MZ’s default random encounter system in a parallel event. Why would someone want to do this? I’ll explain what led me to this method.
I’m creating a large grounded near-future scifi game, but part of the setting is a venue on a space station that offers “VR Simulations” for the player to engage in. These are entire games within games, as you can read from this forum post I made about that at the end of March:
https://forums.rpgmakerweb.com/threads/a-game-within-a-game-in-rpg-maker-mz.183060/
I quickly discovered that I can not use the default random encounter system in these VR simulations for one particular reason: If the player loses the game during battle, this will result in a game over. Inside a VR simulation, that must be a “fake” game over that merely sends the player back to the entertainment venue on the space station where the VR simulation was started.
So I set about making a parallel event that replicates the random encounter system. Here is a breakdown of how this parallel event is structured in the current VR simulation I’m working on. This parallel event is on the overworld map, where most of the battles occur:
1) Script command that changes Battle Start Music:
$dataSystem.sounds[7] = {name: "ForeverBattleStart", volume: 100, pitch: 100, pan: 0};
2) Change Battle BGM command
3) Control Variable command that chooses a random number from 1 to 5
4) Five sequential conditional branches based on values of this variable from 1 to 5. These make the parallel event wait a seemingly random duration of time, from 200 frames to 999 frames
5) Three Control Variable commands that store Player X, Player Y, and MapID into three different variables
6) A number of sequential conditional branches with javascript like this as the condition:
$gameMap.regionId($gamePlayer.x, $gamePlayer.y) === 4
These detect which region of the map the player is currently on. The map must be painted with regions accordingly.
7) Control Variable command inside the above javascript conditional branch. This Control Variable command selects a random number from 1 to 4
8) Change Battleback command to ensure that the right battleback appears in the upcoming battle, be it grassland, snow, water, etc.
9) Four conditional branches based on the value of the most recent random number selection. Each conditional branch contains a Battle Processing command, with “Can Escape” and “Can Lose” checked. The battle processing commands make one of the troops for the current region appear in battle. There is nothing specified for the Escape branch, but the Lose branch activates a particular switch – more about this later.
10) a Wait for 1 frame command
This isn’t all that’s in my parallel event, but it clearly shows the basics of how I recreated the functionality of the random encounter system. Of course, the map itself must not have random encounters built into it in the Encounters part of the Map Properties page, nor should the map specify a battleback.
You will also notice that this random encounter parallel event works based on randomly selected spans of time to pass before the next battle. This method could easily be re-worked to count the number of steps taken, but I chose not to use this method as map traversal on vehicles (boat, ship, airship) does not count as steps.
As long as the map has been painted with regions, and as long as those regions each have their javascript-based conditional branches which call randomized battles with the appropriate enemies inside them, then this all works perfectly and is in many cases indistinguishable from the default random encounter system. It “feels” like the player is traveling on the overworld map and that battles happen at a random pace.
There are a couple of embellishments I’ve included in the particular parallel event on the overworld map I’m making. In my case, right before step number 3, I use four Control Variable commands to store the current levels of each party member in four different variables. Then after step number 9, I have logic and conditional branches which gets the resulting level of all party members, stores those levels as values in four new variables, and then compares the earlier level to the current level. By this method, I can detect if the party member leveled up, and if so, I can control what happens.
For instance, I have a variable based difficulty system in this VR Simulation. If difficulty is Easy (1), then all bad states are cleared and HP is restored to max. If difficulty is Normal (2), then only HP is restored. If difficulty is Hard (3), then neither of these things occur.
But my favourite addition to this parallel event is the integration of “friendly” encounters that use the battle system, enemies, and troops, but are not actually battles. For these, I have the random number in step number 3 set to choose from 1 to 5, with the 5th conditional branch that follows being one of these friendly encounters. I then have another randomized one in three chance of either the Wandering Merchant, the Traveling Pilgrim, or the Injured Knight appear. The Start Battle Music and Battle BGM are changed to something upbeat and happy for these friendly encounters. Then a Show Text command is used to tell the player that a Wandering Merchant or Traveling Pilgrim or Injured Knight has appeared.
The merchant offers a region-based list of armor and weapons at a discount, the pilgrim offers to heal or to restore MP for gold, and the Knight asks for a specific randomly selected healing item. All of these are done by battle events which make the Show Text boxes, the Show Choice commands, and more appear during the “battle”. When the interaction is over, the Abort Battle command is used, and the player is back on the overworld map.
I don’t think I could have integrated such “friendly” encounters if I were using the default random encounter system, at least not to the customizable degree that the parallel event affords.
All of this functionality, except for battle events and the common events they call, is in Page 1 of the parallel event. Some more considerations that I needed to include in this system are Page 2, 3, and 4. These are what those pages contain:
Page 2: an empty page conditional on a “Battle Halt” switch being ON. This works with a special item in the game that stops random encounter battles for a time.
Page 3: game logic that is activated when the player is defeated. This is activated by a particular switch that is turned on, which was mentioned in step number 9. Page 3 is set to autorun, and contains visual scripting commands which preserve simulation state, handles vehicle state, puts up the fake game over screen graphic and music, and calls the common events which handle inventory and actor swaps while exiting the simulation and returning to the base game.
Page 4: another empty page conditional on a “Battle Paused” switch being ON. This switch is turned on during entrance to towns and dungeons, during certain character interactions, and a few other times. This ensures that these scenes are not interrupted by sudden random battles. This switch is turned OFF again when these scenes are done, or when the player leaves towns and dungeons.
So that’s the basics of my parallel event based random encounter system. I’ve gone from thinking of replacing the default system with my parallel event as a necessary evil, to something that I actually prefer in this simulation due to the full control over everything that happens before, during, and after battle. Thanks for reading, and I hope someone finds this useful and considers the merits of doing this kind of thing in their own RPG Maker game.
This is a method I’ve discovered for recreating and duplicating the functionality of RPG Maker MZ’s default random encounter system in a parallel event. Why would someone want to do this? I’ll explain what led me to this method.
I’m creating a large grounded near-future scifi game, but part of the setting is a venue on a space station that offers “VR Simulations” for the player to engage in. These are entire games within games, as you can read from this forum post I made about that at the end of March:
https://forums.rpgmakerweb.com/threads/a-game-within-a-game-in-rpg-maker-mz.183060/
I quickly discovered that I can not use the default random encounter system in these VR simulations for one particular reason: If the player loses the game during battle, this will result in a game over. Inside a VR simulation, that must be a “fake” game over that merely sends the player back to the entertainment venue on the space station where the VR simulation was started.
So I set about making a parallel event that replicates the random encounter system. Here is a breakdown of how this parallel event is structured in the current VR simulation I’m working on. This parallel event is on the overworld map, where most of the battles occur:
1) Script command that changes Battle Start Music:
$dataSystem.sounds[7] = {name: "ForeverBattleStart", volume: 100, pitch: 100, pan: 0};
2) Change Battle BGM command
3) Control Variable command that chooses a random number from 1 to 5
4) Five sequential conditional branches based on values of this variable from 1 to 5. These make the parallel event wait a seemingly random duration of time, from 200 frames to 999 frames
5) Three Control Variable commands that store Player X, Player Y, and MapID into three different variables
6) A number of sequential conditional branches with javascript like this as the condition:
$gameMap.regionId($gamePlayer.x, $gamePlayer.y) === 4
These detect which region of the map the player is currently on. The map must be painted with regions accordingly.
7) Control Variable command inside the above javascript conditional branch. This Control Variable command selects a random number from 1 to 4
8) Change Battleback command to ensure that the right battleback appears in the upcoming battle, be it grassland, snow, water, etc.
9) Four conditional branches based on the value of the most recent random number selection. Each conditional branch contains a Battle Processing command, with “Can Escape” and “Can Lose” checked. The battle processing commands make one of the troops for the current region appear in battle. There is nothing specified for the Escape branch, but the Lose branch activates a particular switch – more about this later.
10) a Wait for 1 frame command
This isn’t all that’s in my parallel event, but it clearly shows the basics of how I recreated the functionality of the random encounter system. Of course, the map itself must not have random encounters built into it in the Encounters part of the Map Properties page, nor should the map specify a battleback.
You will also notice that this random encounter parallel event works based on randomly selected spans of time to pass before the next battle. This method could easily be re-worked to count the number of steps taken, but I chose not to use this method as map traversal on vehicles (boat, ship, airship) does not count as steps.
As long as the map has been painted with regions, and as long as those regions each have their javascript-based conditional branches which call randomized battles with the appropriate enemies inside them, then this all works perfectly and is in many cases indistinguishable from the default random encounter system. It “feels” like the player is traveling on the overworld map and that battles happen at a random pace.
There are a couple of embellishments I’ve included in the particular parallel event on the overworld map I’m making. In my case, right before step number 3, I use four Control Variable commands to store the current levels of each party member in four different variables. Then after step number 9, I have logic and conditional branches which gets the resulting level of all party members, stores those levels as values in four new variables, and then compares the earlier level to the current level. By this method, I can detect if the party member leveled up, and if so, I can control what happens.
For instance, I have a variable based difficulty system in this VR Simulation. If difficulty is Easy (1), then all bad states are cleared and HP is restored to max. If difficulty is Normal (2), then only HP is restored. If difficulty is Hard (3), then neither of these things occur.
But my favourite addition to this parallel event is the integration of “friendly” encounters that use the battle system, enemies, and troops, but are not actually battles. For these, I have the random number in step number 3 set to choose from 1 to 5, with the 5th conditional branch that follows being one of these friendly encounters. I then have another randomized one in three chance of either the Wandering Merchant, the Traveling Pilgrim, or the Injured Knight appear. The Start Battle Music and Battle BGM are changed to something upbeat and happy for these friendly encounters. Then a Show Text command is used to tell the player that a Wandering Merchant or Traveling Pilgrim or Injured Knight has appeared.
The merchant offers a region-based list of armor and weapons at a discount, the pilgrim offers to heal or to restore MP for gold, and the Knight asks for a specific randomly selected healing item. All of these are done by battle events which make the Show Text boxes, the Show Choice commands, and more appear during the “battle”. When the interaction is over, the Abort Battle command is used, and the player is back on the overworld map.
I don’t think I could have integrated such “friendly” encounters if I were using the default random encounter system, at least not to the customizable degree that the parallel event affords.
All of this functionality, except for battle events and the common events they call, is in Page 1 of the parallel event. Some more considerations that I needed to include in this system are Page 2, 3, and 4. These are what those pages contain:
Page 2: an empty page conditional on a “Battle Halt” switch being ON. This works with a special item in the game that stops random encounter battles for a time.
Page 3: game logic that is activated when the player is defeated. This is activated by a particular switch that is turned on, which was mentioned in step number 9. Page 3 is set to autorun, and contains visual scripting commands which preserve simulation state, handles vehicle state, puts up the fake game over screen graphic and music, and calls the common events which handle inventory and actor swaps while exiting the simulation and returning to the base game.
Page 4: another empty page conditional on a “Battle Paused” switch being ON. This switch is turned on during entrance to towns and dungeons, during certain character interactions, and a few other times. This ensures that these scenes are not interrupted by sudden random battles. This switch is turned OFF again when these scenes are done, or when the player leaves towns and dungeons.
So that’s the basics of my parallel event based random encounter system. I’ve gone from thinking of replacing the default system with my parallel event as a necessary evil, to something that I actually prefer in this simulation due to the full control over everything that happens before, during, and after battle. Thanks for reading, and I hope someone finds this useful and considers the merits of doing this kind of thing in their own RPG Maker game.