Creating Enemy mobs in regions

I'm looking to use Yanfly's Spawn Event script to create enemies in specific regions.
Script here > https://yanflychannel.wordpress.com/rmvxa/utility-scripts/spawn-event/

I'm very confused about this concept, but it's one I need to use. I've got a large overworld map, and have far more mobs than lines in the Encounter list. And I'm using some Yanfly scripts already =)
I know my World Map's ID#. There are Region ID's on the Map, so far just a few.
I want events(enemy encounters) to spawn randomly within each Region.

Problem is, I have no idea what actually needs to be done to get this script to work.

How does it get Troop info?
Where do I put the "spawn_event_region(region_id, event_id, map_id)" information?
Where is it getting Event ID's from?
What should be in the Event itself?

Looked for a guide on how to use this script, can't find one. Any help is appreciated!
What do you want the trigger to be for spawning an event?
Um... whenever the world map loads, I guess. Does this impact the script? If so, how?
Sorry for the questions, I'm just trying to learn!
It doesn't impact the script, but it does impact how I answer your question.

So basically how I would do this is having an autostart event on the world map with a spawn_event_region script call for each enemy you want to have on the map, then turn off that page with a self switch to stop it running. That way your map will have that many enemy events spawned in those regions when it loads.
So what's an Autostart event?
An event with its trigger set to "Autorun".
Understood, found the drop down box at the bottom of an event page.
You say to use a "spawn_event_region script call". What is a script call? How is it done?
I know how to add scripts into the script editor, is there something that I am missing?
Script is one of the event commands, it's on the last page.
I'm still very much confused.
Where is the Original event supposed to be located? On the world map or a different map?

From Yanfly's page, regarding "spawn_event_region(region_id, event_id, map_id)"

"This causes a new event to be created at a random location with a matching region_id. The event to be created will use the event data from event_id. If no map_id is used, then the current map’s event will be used to spawn the new event. "

I would like events to be spawned onto region 1 of the world map, but hosted on a different map. This should be possible, according to what Yanfly says.

World Map is ID:001, Enemy host map is ID:002.
Event to be spawned is ID:001 on map ID:002.

Inside the scripting box that opens when you select "script" from page 3 of Event Commands:
spawn_event_region(region_id, event_id, map_id) has been pasted and changed to
spawn_event_region(1, 001, 001).

When I playtest, there is no event visible. Where am I going wrong?
That will only work if the player actually enters the enemy source map at some point. Is there any particular reason your source event needs to be on a map other than the world map?
What makes it only work if the player enters the source map? I am using a Map ID, shouldn't the event spawn there?
And I believe it will be easier to keep all my enemy troops organized on a separate map. How would you propose keeping all enemy spawn events on the world map outside of the player's view?

I've moved this thread to RGSSx Script Support. Thank you.

You use the source map for the enemy events themselves, which you've done. But the event with the command goes on the map you want the events to spawn in (the world map).
You use the source map for the enemy events themselves, which you've done. But the event with the command goes on the map you want the events to spawn in (the world map).

I'm confused; The event with the script being called inside it is on the source map. There is no event on the world map. What should the world map event look like, and where would it go?
Okay, the event you create on the source map is your enemy that's being spawned. That's what you set up with the graphic and whatever movement behaviour enemies will have.

Then you create an autorun event on the world map that has the script call; no graphic, and you can put it anywhere. Then turn on a self switch and create a new page with that self switch as the trigger so that it only runs once.
Create a new map just for events that house the battle processing, graphics, etc. Note the ID's of the events and the Map itself!
THEN
Create an Event (NO GRAPHIC) on the destination map with the script call

spawn_event_region(region_id, event_id, map_id) where:

Region ID is the region ID on the destination map
Event ID is the Event ID of the event to be copied to the Destination map
Map ID is the Map ID of the SOURCE map

Then have a self-switch turn on. Create a second tab in the script call event and check off the self-switch condition. touch nothing else.

These instructions are SUCCESSFUL!

except that it works once and once only. Once a mob is defeated, going into a town does not respawn the mob. I assume because of the self-switch. However, removing the self-switch results in a infinite spawn. Is there a way to refresh the mobs when the player moves back into the world map?
Yeah, it only works once for me as well. I'm not sure if that's a limitation of the script.

For the self switch thing, use "Erase Event" as the last command in the autorun rather than a self switch.
What if:
  1. I added a +1 to a variable (Spawn Variable) at the end of the spawn event?
  2. Then set the hidden spawn event as a conditional branch that only runs when Spawn Variable = 0?
  3. Use the transfer event out of towns, caves, etc moving back onto the world map to reset the variable to 0?
I'm thinking that this would cause the spawn event to activate exactly once and only when the player enters the world map. I'm out of the house now so I can't test, but do you think this would work?
If you're gonna do it like that you might as well just use a switch, since you only need two states anyway. But yeah, theoretically that should do what you're going for.
Doesn't work. Everything behaves on game startup, but enemy does not respawn on player re-entry. Confirmed that the switches are moving correctly. What's the problem now?

I really didn't think this would be S+difficulty, and I really appreciate your patience!

Original thread: https://forums.rpgmakerweb.com/threads/creating-enemy-mobs-in-regions.123359/