Paste #38092: Untitled Paste

Date: 2016/12/02 10:58:54 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Once the server starts, it gets the loop for NPC-actions going. You can also just write /ex run s@NPCKampfLoop_Soldat
# Notice that I basically removed like every security check to not blow up the script for testing

"One Big NPC Fighting Loop":
  type: world
  debug: false
  events:
    on server start:
    - run s@NPCKampfLoop_Soldat delay:10s

# Command I use for testing and creating NPC real quick /createsoldier
    on createsoldier command:
    - create player <red>Soldat <player.location> traits:health save:newNPC
    - wait 1t
    - adjust <npc[<entry[newNPC].created_npc>]> skin:NikolaiSergeyev
    - vulnerable state:true npc:<npc[<entry[newNPC].created_npc>]>
    - equip <npc[<entry[newNPC].created_npc>]> head:chainmail_helmet chest:chainmail_chestplate legs:chainmail_leggings boots:chainmail_boots
    - flag <entry[newNPC].created_npc> Soldat:true
    - flag <entry[newNPC].created_npc> Respawnposition:<player.location.simple>

# Every NPC flagged Soldat should move around

NPCKampfLoop_Soldat:
  type: task
  debug: false
  script:
  - foreach <server.get_spawned_npcs_flagged[Soldat]> {
    - run s@NPCAction_Soldat def:%value%
    }
  - run s@NPCKampfLoop_Soldat delay:1s

NPCAction_Soldat:
  type: task
  debug : false
  script:
  - walk <def[1]> <def[1].location.center.find.surface_blocks.within[5].random.add[0,1,0]> speed:0.9 radius:25

# Now this is the simple action that runs, once the NPC dies. Since The NPC have the health trait and a respawn time of 15 minutes, I respawn them manually for testing faster after only 10 seconds.

"TheOneAndOnlyNPCDeathEvent":
  type: world
  debug: false
  events:
    On npc dies:
    - if <npc.has_flag[Soldat]> {
      - run s@ReplaceDeadSoldier def:<npc> delay:10s
      - determine passively no_drops
      - determine "<gray>[Ger<&uuml>cht] Es finden K<&auml>mpfe auf einer Milit<&auml>rbasis statt."
      }

ReplaceDeadSoldier:
  type: task
  debug: false
  script:
  - spawn <def[1]> <def[1].flag[Respawnposition]>