Paste #15423: Zombie Killer!

Date: 2015/05/02 07:49:53 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


MSMayor:
  type: assignment
  debug: false
  default constants:
    ZombiesQty: 10
    RepeatTimer: 600
    TownName: 'Misty Shores'

  interact scripts:
  - 10 MSZombieKillerInteract

  actions:
    on assignment:
    - ^flag global msmayor_npc:<npc>
    - ^flag <npc> spawnpoint:l@-1332,70.0,-65,survive
    - ^adjust <npc> skin:Tasuit
    - ^trigger name:chat toggle:true radius:5 cooldown:30
    - ^trigger name:click toggle:true
    - ^trigger name:proximity toggle:true radius:5
    - ^trigger name:damage toggle:false
    - ^health 100 target:<npc>
    - ^heal <npc>
    - ^health state:false
    - ^vulnerable state:true
    - ^lookclose state:true range:5 realistic
    - ^execute as_server "trait mobprox"
    - ^adjust <npc> can_pickup_items:false
    - ^equip hand:i@stick
    - ^execute as_server "denizen save"

    on push:
    - walk <npc> <npc.flag[spawnpoint]>

    on spawn:
    - ^teleport <npc> <npc.flag[spawnpoint]>
    - ^health 100 target:<npc>
    - ^heal <npc>
    - ^health state:false
    - ^vulnerable state:true

    on death:
    - ^despawn <npc>
    - ^announce "<red><npc.name> has been slain!!"
    - ^run s@RespawnNPC d:<npc> delay:120

    on no click trigger:
    - if <s@MSZombieKillerInteract.cooldown[<player>].in_seconds.is[MORE].than[0]> {
      - ^chat "Hi <player.name.display><&e>!  Thanks for your help with the zombies.  Please come back later if you want to help some more." targets:<player>
      - ^narrate "<&b>You must wait <&2><s@MSZombieKillerInteract.cooldown[<player>].formatted> <&b>before you may attempt this quest again!" targets:<player>
      - ^queue clear
      }

    # on mob move proximity:
    # - if <context.entity.entity_type.contains_any[BAT|BLAZE|CAVE_SPIDER|CREEPER|ENDERMAN|ENDERMITE|GHAST|GIANT|MAGMA_CUBE|PIG_ZOMBIE|SILVERFISH|SKELETON|SLIME]>
    # - attack target:<context.entity>

    on enter proximity:
    - random 6
    - chat "And then he said 'She ate the rat!'. Hahahaha.. oh, sorry. Didn't see you there <player.name.display><&e>." targets:<player>
    - chat "Ahhhhh <&b><npc.constant[Townname]><&e>.. it grows on you. Beautiful town, nice people and pesky zombies!!" targets:<player>
    - chat "Some days I hate my job, but then I say 'No <&a><npc.name.nickname><&e>, you love your job' and then I love it again." targets:<player>
    - chat "Rats, Zombies, cats and giant gnats. I kill them all.. it's great because I get paid to hunt for my own food!" targets:<player>
    - chat "The smell from those zombies will get into your clothes. Remember to put your clothes in a bucket of water for 3 days, then wash it with soap." targets:<player>
    - chat "Stay in <&b><npc.constant[Townname]> <&e>long enough and it will grow on you. Much like the moss on these bricks.." targets:<player>



MSZombieKillerInteract:
  type: interact
  debug: false
  steps:
    1:
      click trigger:
        script:
        - random 5
        - chat "Hello there <player.name.display><&e>! Can you please help me get rid of these darn zombies?" targets:<player>
        - chat "Oh hey <player.name.display><&e>, there are some nasty zombies around the town again. Will you go kill some for me?" targets:<player>
        - chat "Zombies... Zombies everywhere! Their squeaky high-pitched noises driving me nuts. Kill some for me?" targets:<player>
        - chat "These Zombies carry the plague! We need to exterminate them. Will you help me?" targets:<player>
        - chat "Feel like slicing and dicing some Zombies? Grab yourself a sword and pretend you are a fruit ninja!" targets:<player>
        - wait 1
        - random 2
        - chat "I will pay you some gold coins if you kill <npc.constant[ZombiesQty]> zombies for me." targets:<player>
        - chat "How does some gold coins sound for <npc.constant[ZombiesQty]> zombies sound to you?" targets:<player>
        - wait 1
        - narrate "<&6>Please answer <&e>Yes<&6> or <&e>No"
      chat trigger:
        1:
          trigger: /Yes/, I am interested.
          script:
          - engage
          - chat "Great! come back to me once you've killed <npc.constant[ZombiesQty]> <&e>zombies."
          - wait 1
          - ^narrate "<&d>---------------------------------------------"
          - ^narrate "<&6>Quest added <&8>| <&6><&o><npc.constant[TownName]> Zombie Killer"
          - ^narrate "<&6> * Kill <&e><npc.constant[ZombiesQty]> Zombies"
          - ^narrate "<&d>---------------------------------------------"
          - ^flag player MSZombieKillerCount:0
          - ^zap step:2
          - ^flag player activequests:->:mszombiekiller
          - ^execute as_server "denizen save"
          - disengage
        2:
          trigger: /No/, I am not interested.
          script:
          - random 3
          - chat "Oh ok, don't come crying to me if the noise these Zombies make wake you up at night." targets:<player>
          - chat "That is really unfortunate, but OK. Come back to me when you change your mind." targets:<player>
          - chat "It would've been a great help if you could get rid of these plagued Zombies. Please come back later." targets:<player>
          - zap step:1
    2:
      click trigger:
        script:
        - if <player.flag[MSZombieKillerCount].as_int> >= <npc.constant[ZombiesQty].as_int> {
          - ^run s@timed_effect d:<npc.location>|heart|25|0|0.5|10
          - ^define money <util.random.int[100].to[300].as_int>
          - random 3
          - chat "Haha, good job <player.name.display><&e>, you got those Zombies good! You can come back and help me in a little while." targets:<player>
          - chat "Well done <player.name.display><&e>, that will teach those pesky Zombies! You can come back and help me again in a little while." targets:<player>
          - chat "Fantastic <player.name.display><&e>, but they will be back soon. Please come help me again and I'll pay you for the service." targets:<player>
          - ^give exp qty:80
          - ^give money qty:<def[money]>
          - wait 1
          - ^narrate "<&d>---------------------------------------------"
          - ^narrate "<&6>Quest <&8>| <&6><&o><npc.constant[TownName]> Zombie Killer | <&d>COMPLETE"
          - ^narrate "<&6>Reward <&8>| <&e>$<def[money]> <&8>| <&e>80 exp"
          - ^narrate "<&d>---------------------------------------------"
          - announce "<&6>**<player.name.display> <&6>has completed <&o><npc.constant[TownName]> Zombie Killer <&6>quest!**"
          - ^cooldown <npc.constant[RepeatTimer]> s:MSZombieKillerInteract
          - ^flag npc money:!
          - ^flag player MSZombieKillerCount:!
          - ^zap s:MSZombieKillerInteract 1
          - ^flag player activequests:<-:mszombiekiller
          - ^execute as_server "denizen save"
          }
          else {
          - chat "Please return once you've killed all <npc.constant[ZombiesQty]> zombies!" targets:<player>
          }

MSZombieKiller_World:
  type: world
  debug: false
  events:
    on player kills zombie:
    - if <context.damager.has_flag[MSZombieKillerCount]> {
      - ^flag <context.damager> MSZombieKillerCount:+
      - ^execute as_server "denizen save"
      - if <context.damager.flag[MSZombieKillerCount].as_int> < <s@MSMayor.constant[ZombiesQty].as_int> {
        - ^narrate "<&6>You have killed <&e><context.damager.flag[MSZombieKillerCount].as_int>/<s@MSMayor.constant[ZombiesQty]> <&6>zombies!" targets:<context.damager> }
        else if <context.damager.flag[MSZombieKillerCount].as_int> == <s@MSMayor.constant[ZombiesQty].as_int> {
        - ^narrate "<&6>You have killed all of the zombies!  Return to <&a><global.flag[msmayor_npc].as_npc.name> <&6>to collect your reward." targets:<context.damager> }
      }