Plot:NPC copy count

From OHRRPGCE-Wiki

Jump to: navigation, search
NPC copy count (ID)

This command tells you how many copys of a particular NPC ID exist on the map. This can be very useful if you want apply the same action to each copy of an NPC on the map.

[edit] Examples

include,plotscr.hsd
#---NPC copy count example---

plotscript,every NPC example,begin

  variable(loop,guard count,current guard)

  # the guard is NPC 10, and there are many copies of him on the map
  set variable(guard count,NPC copy count(10))

  # this loop repeats once for each copy of NPC 10
  for(loop,0,guard count) do,begin

    set variable(current guard,NPC reference(10,loop))
    walk NPC(current guard,south,4)
    # if we added a "wait for NPC(current guard)" right here
    # then the guards would walk one t a time

  end

  # but we want them to all walk at the same time,
  # so we just wait here
  wait for all

end
Personal tools