How can I make copies of NPCs do distinct things?

Jump to navigation Jump to search

To make copies of npcs do distinct (different) things, you have to store references to them in variables.

It is assumed that you already know how to

  • place npcs on a map
  • make npcs walk using plotscriting (if not I recommend you to do the plotscripting tutorial)

Let's say that you want the first copy of npc #3 walk to the south. Then, you want the second copy of npc #3 to face north, wait a few ticks, walk to the north and finally disappear.

# ed is copy 1, al is copy 2

variable (ed, al)

ed:= create npc (3, 4, 5) # first step: create the npcs
al:= create npc (3, 5, 6)

wait(5) #give them a bit of a delay

# you can also place the npcs in CUSTOM. If you do this, you would have to
# get a reference manually, like this:
# ed:= npc reference(3, 0)
# al:= npc reference(3, 1)

Here we are! Now you can manipulate the npcs as you usually do. Following our earlier example:

#second step, make them do stuff

walk npc (ed ,south, 3)
wait for npc (ed)

set npc direction (al, north)
wait (15) #pause for dramatic effect

walk npc (al, north, 3)
wait for npc (al)

destroy npc (al)

In Ubersetzung, Custom.exe will tell you the copy number of each npc so you can use it with npc reference.

Don't forget that if you store the npc reference in a local variable, they will not be available to other scripts. So, you must use npc reference again to get new references.

See also[edit]