Spawning NPCs on other maps

I'm working on a game where I generate about 5-8 NPCs up front (on creating a new game). I also have a known set of maps. I need to distribute my NPCs to different maps.

I can't do this through the visual editor, because the NPCs don't exist until the game runs (each new-game creates a random/different set of NPCs).

I'm using Archeia's spawn-event script here, if that matters. Fundamentally, though, I don't see a way to load a game map (other than the current one in $game_map) and spawn the event there. Even if I did, would it persist (when the player goes to that map, the event is there)?

How can I solve this problem, other than a script on every map that says "when the player enters this map, spawn any NPCs that are on this map?" -- I don't like duplicating stuff everywhere :/
Did you try using switches to make them visible/non visible depending on the case ? You can later the switches within scripts too.
Maps (and events on them) do not exist when the player is not on them, and are always only loaded when the player enters them.


I suggest you make placeholders on those maps, then use a common event to check if a map is loaded for the first time and if yes, place the events for the NPCs then and use something like Shaz' remember event position script to store the data for later entering of those maps.
I solved this. I didn't use placeholders, but I did end up using a common event like @Andar suggested. (I have code already to place them randomly/consistently, so I don't need to use placeholders.)

Thanks for the help!

Original thread: https://forums.rpgmakerweb.com/threads/spawning-npcs-on-other-maps.44115/