Paste #51228: Edit of P#51116 Random NPC Spawn

Date: 2018/12/25 12:51:26 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


spawn_random_npcs:
  type: task
  debug: false
  script:
    #CHOOSE THE FORK OF NPC SPAWNED AS SAME TIME
    - define min_npc 3.0
    - define max_npc 7.0
    ###############################################
    - flag server nb_npc_st:<util.random.int[<def[min_npc]>].to[<def[max_npc]>]>
    - flag server nb_npc_sp:<server.flag[nb_npc_st]>
    - while <server.flag[nb_npc_sp].is[MORE].than[0]>:
      #CHOOSE THE FORK OF NPC'S ID
      - define min_id 0
      - define max_id 29
      - define ids <util.random.int[<def[min_id]>].to[<def[max_id]>]>
      ##########################################
      - flag server npc_no_<server.flag[nb_npc_sp]>:<def[ids]>
      - execute as_server "npc spawn <def[ids]>"
      - flag server nb_npc_sp:--

delete_random_npcs:
  type: task
  debug: false
  script:
    - flag server nb_npc_ds:<server.flag[nb_npc_st]>
    - while <server.flag[nb_npc_ds].is[MORE].than[0]>:
      - execute as_server "npc despawn <server.flag[npc_no_<server.flag[nb_npc_ds]>]>"
      - flag server nb_npc_ds:--

actions_npcs:
  type: world
  debug: false
  events:
    on system time hourly:
    - run delete_random_npcs instantly
    - wait 10s
    - run spawn_random_npcs instantly