How can I make copies of NPCs do the same thing?
Normally, plotscripting commands that control NPC's such as walk NPC or wait for NPC use an ID number to identify which NPC to control. If more than one copy of the same NPC exists on the map, the command will only apply to the first copy of the NPC with that ID number.
How then, can you make more than one copy of the same NPC move?
The key is using NPC references. AN NPC reference is a unique identifier for one specific NPC. You can use a NPC reference anywere that you would normally use an NPC ID number.
Here is an example of a plotscript that uses the NPC reference command to make the first three copies of the same NPC all walk at the same time.
plotscript, example, begin # make three variables to hold the references variable(a,b,c) # store references to the first three copies of NPC ID 5 a := NPC reference (5,0) b := NPC reference (5,1) c := NPC reference (5,2) # walk all three NPCs 2 steps south walk NPC (a,south,2) walk NPC (b,south,2) walk NPC (c,south,2) # wait for the NPCs to finish walking wait for NPC (a) wait for NPC (b) wait for NPC (c) # NOTE: since all three NPC's are walking the same distance at the same speed, # we really only need to wait for one of them since they will all stop walking # at the same time, but waiting for all of them does no harm. end
Note that if you just want to change the "settings" of the NPCs (E.g: change the sprite or speed, etc.) you don't need to loop through all the copies (or name them explicitly, as the script does). Just use the alter NPC command, as it affects all NPCs of that ID.