- Joined
- Jun 29, 2014
- Messages
- 83
- Reaction score
- 31
- First Language
- English
- Primarily Uses
Random Encounter/Event Spawner
So you do not like the standard random encounter system, but evented encounters are too static. The solution is to have random evened encounters.
After looking at the script request forum I found requests for procedural flora and other things, making them should follow the same principle as this.
Things you will need:
Yanfly's Region Events
Hudell's Orange Custom Events
Orange Time System
Time System Events
Two Common Events
Once Switch
Two Variables
Two Maps
First make a map that will hold all of the events you wish to have spawn randomly. We will also need a map to spawn events onto, like a world map.
Common Event Setup:
Spoiler
Next open your Database and go to the Common Events tab. Make a new Common Event named “Event Spawner” or something similar.
We are going to make a switch named “Event Spawn” and a Variable Named “Encounter?”.
In our common event make a Conditional Branch for if “Event Spawn” is On, check Create Else Branch. In the Else branch you want to use Control Variables and set “Encounter?” to a random number from zero to ninety-nine. Create a Conditional Branch for if Variable “Encounter?” is greater than or equal to 49, check Create Else Branch. We will be using the If branch to keep encounters from spawning at every step, thus we will leave it blank. If you want to make events spawn less often increase the number, to make them spawn more often decrease the number. At this setting events have a 50% chance of spawning each step.
In the Else section we will set “Encounter?” to a random number between zero and ninety-nine again. This will be used to determine what event is to spawn. We will come back to this part later.

Next we will make a new Common Event named “Event Despawn”. This event will keep more than one event from spawning and despawn events that are not triggered.
First we will create a Conditional Branch for If “Event Spawn” is On. Within this we want to set a new variable named Spawn Counter to be incremented by one (add one to current value). Then another Conditional Branch for If “Spawn Counter” is less than or equal to 50, or however many seconds you want it to take to spawn a new event or an existing event to despawn.
Then you want to control switch “Event Spawn” to Off. Make the script call: $gameSystem.clearCustomEvents($gameMap._1);
Set 1 to the name of the map these events will spawn on and make multiple calls for each map that uses this system.
Then control variable “Spawn Counter” to equal zero.

Next open your Database and go to the Common Events tab. Make a new Common Event named “Event Spawner” or something similar.
We are going to make a switch named “Event Spawn” and a Variable Named “Encounter?”.
In our common event make a Conditional Branch for if “Event Spawn” is On, check Create Else Branch. In the Else branch you want to use Control Variables and set “Encounter?” to a random number from zero to ninety-nine. Create a Conditional Branch for if Variable “Encounter?” is greater than or equal to 49, check Create Else Branch. We will be using the If branch to keep encounters from spawning at every step, thus we will leave it blank. If you want to make events spawn less often increase the number, to make them spawn more often decrease the number. At this setting events have a 50% chance of spawning each step.
In the Else section we will set “Encounter?” to a random number between zero and ninety-nine again. This will be used to determine what event is to spawn. We will come back to this part later.

Next we will make a new Common Event named “Event Despawn”. This event will keep more than one event from spawning and despawn events that are not triggered.
First we will create a Conditional Branch for If “Event Spawn” is On. Within this we want to set a new variable named Spawn Counter to be incremented by one (add one to current value). Then another Conditional Branch for If “Spawn Counter” is less than or equal to 50, or however many seconds you want it to take to spawn a new event or an existing event to despawn.
Then you want to control switch “Event Spawn” to Off. Make the script call: $gameSystem.clearCustomEvents($gameMap._1);
Set 1 to the name of the map these events will spawn on and make multiple calls for each map that uses this system.
Then control variable “Spawn Counter” to equal zero.

Plugin configuration:
Spoiler
In the YEP_RegionEvents Plugin you want to pick a region that you want to have your events spawn in. Set the region's value to the Common Event ID of our “Event Spawner”. When the player moves over this region, “Event Spawner” will run.
In OrangeTimeSystemEvents you want to set onChangeSecond to our “Event Despawn” Common Event ID. Every game second the “Spawn Counter” variable will be incremented by one.
In the YEP_RegionEvents Plugin you want to pick a region that you want to have your events spawn in. Set the region's value to the Common Event ID of our “Event Spawner”. When the player moves over this region, “Event Spawner” will run.
In OrangeTimeSystemEvents you want to set onChangeSecond to our “Event Despawn” Common Event ID. Every game second the “Spawn Counter” variable will be incremented by one.
Event Setup:
Spoiler
Each Event you wish to have spawn needs at least two pages to work. The First page should be blank or, as a fail-safe, use these commands: Use the plugin command “delete this event”, control switch “Event Spawn” to Off, and use Erase Event. I like fail-safes.
On page two you want the condition switch “Event Spawn” set to On. The last things you want the event to run are a “delete this event” plugin command and control variable “Spawn Counter” to equal zero.


Back in our “Event Spawner” Common Event we want to setup a conditional branch for each of our events. Lets say that we have two events on our spawn map. We will say If encounter is greater than or equal to 49, check Create Else Branch.
For each event we will use the plugin command:
copy event ID from map ID to Region ID
Make sure your Region ID matches the one you set up earlier. So if we want to to copy event one from map two to region one we would use:
copy event 1 from map 2 to region 1
Then we want to control switch “Event Spawn” to On.
Each Event you wish to have spawn needs at least two pages to work. The First page should be blank or, as a fail-safe, use these commands: Use the plugin command “delete this event”, control switch “Event Spawn” to Off, and use Erase Event. I like fail-safes.
On page two you want the condition switch “Event Spawn” set to On. The last things you want the event to run are a “delete this event” plugin command and control variable “Spawn Counter” to equal zero.


Back in our “Event Spawner” Common Event we want to setup a conditional branch for each of our events. Lets say that we have two events on our spawn map. We will say If encounter is greater than or equal to 49, check Create Else Branch.
For each event we will use the plugin command:
copy event ID from map ID to Region ID
Make sure your Region ID matches the one you set up earlier. So if we want to to copy event one from map two to region one we would use:
copy event 1 from map 2 to region 1
Then we want to control switch “Event Spawn” to On.
On Map:
On your map simply paint the places you want your events to spawn in the region you set up earlier.
That is all there is to setting up random encounters. Not only does this give you the ability to make combat encounters, but now you can have interesting non-combat/role-playing encounters.
Notes:
You do not need most of the else branches in your Conditional Branches, I have them there in case I want to do something different.
You need to make an “Event Spawner” Common Event for every region and every map you want to use this system on. It sounds redundant and it is, but it keeps things nice and simple.
Keep your regions small. Events will only spawn in the regions you set them to. If your regions are too big, the player will not see some of your wonderfully crafted encounters.
I hope this helps you, thank you for your time.
Demo:
From MEGA
Credits:
Hudell and Yanfly for their wonderful plugins.
Matthew Lamont/Lamontgames for eventing, you do not need to credit me as this is something anyone could do, but I would appreciate it. It took me 864 words to make after all.




Last edited by a moderator:


