First, you need to set up a container map. This is a map that contains all of the events you'll want to spawn. First, make a new, empty map, and make a note of its number. Don't worry about naming it anything specific -- you can name it and really do anything you want with it -- this script only cares about events on this map.
Open up this script in your script editor, and navigate to the MAP_ID and MAP_NAME options, and change them to whatever number your map has.
NOTE: MAP_NAME is *not* the name you give it inside of RPG Maker! It is the file name of the map, without the .rvdata2 extension.
Now we get to actually make the events we will spawn! Make an event like normal on the container map. When you're satisfied with your event, add a comment at the very top of the event. Here, we're going to "tag" the event. Type this:
<beacontype: my_beacon_name>into the comment. This will let the script know that you now have an NPC named "my_beacon_name" that you want to spawn later!
The great thing about this script is that more than one NPC can have the same beacontype. If you gave three different NPCs the beacontype "my_beacon_name", the script would choose randomly between each one when spawning them. This is great for, say, spawning a town of NPCs that change each time the map loads!
There is one more tag you can put on these events. By default, this script assumes each NPC you're spawning is "generic" -- any number of them can spawn. You can instead put another tag next to your beacontype:
<unique>This tag tells the script that if the current NPC is already on the map, STOP the spawning! This NPC will only be one per map, no matter what. Great for story-specific items or NPCs.
NOTE: This script checks each *current* page for beacontypes! What this means is that if you set a variable/switch that makes your NPC change pages, this script will look at the new page to see if it has any beacontypes. So if you want the NPC to keep its beacontypes (and uniqueness) you'll need to copy and paste them onto each relevant page!
After you've set up whatever NPCs you want, then you can actually spawn them on a map! This is also done using event tags. On whatever map you want an NPC to spawn, just add a blank, empty event with the following tag (again, in a comment at the top of the event):
<beacon: my_beacon_name>Replacing "my_beacon_name" with whatever name you gave your NPC on the container map.
The cool thing about beacons is that the beacon also looks at what page it is on to see what beacontype it will spawn. So, for example, if you put a bunch of beacons in a town to spawn citizens, then that town gets taken over by goblins, you can set a switch and all of the beacons will now spawn goblins!
There is one last bit of functionality when using beacons. If you'd like a beacon to sometimes spawn a "rare" NPC some percent of the time, tag it like this:
<rare: another_beacon_name>Then, the spawner will roll a 100-sided die to see if the rare beacon is spawned. The default chance for a rare NPC to spawn from a raretype is 25%, but you can change this number with the BEACON_RARE_CHANCE option in the script.
NOTE: I say to use an empty event for your beacon, but you don't have to. You can give it a graphic, and even other event commands, but none of these will matter or show up in-game. When the game sees that it is a beacon, it will destroy the original event and replace it with the spawned NPC.
So how does that work out in the end? Here's our map inside of RPG Maker:
And here's the same map actually running:
