beastmaster


Author: jstmemage
Created: 2014-01-02T10:40:22-0500
Edited: 2014-01-02T10:40:22-0500
Denizen Version: 0.9
Views: 6
Downloads: 819
Likes: 0


WGET
Description: this is an altered version of Mythanical's Mercenary Leader script for a beast master

# This is me stripping down the Mercenary Leader script from Mythanical so it is an animal handler
#
# 
"beastmaster":
  type: assignment
  
  default constants:
    #This is the Name of the animal type the player will be hiring.
    beast1 Name: Chicken
    beast2 Name: Bobcat
    beast3 Name: Hellhound
 
    #This is the Strength or damage one of the animals does.
    beast1 Strength: 1
    beast2 Strength: 3
    beast3 Strength: 5
 
    #This is the Armor of each animal type
    beast1 Armor: 1
    beast2 Armor: 4
    beast3 Armor: 7
 
    #This is te Price of the animal to be hired.
    beast1 Price: 25
    beast2 Price: 150
    beast3 Price: 500
  
  interact scripts:
  - 10 hire a beast
  
  actions:
    on assignment:
    # These triggers enable interaction with an NPC via chatting, clicking, entering proximity and when damaging the NPC.
    - trigger name:chat toggle:true
    - trigger name:click toggle:true
    - trigger name:proximity toggle:true
    
"hire a beast":
  type: interact
  
  steps:
    1:
      proximity trigger:
        entry:
          script:
          #On entering proximity this will make the NPC check to see if you already have a beast and then 
          # run a script called "Greeting Requirements"
          - ^runtask "script:Greeting Requirements"
          
      click trigger:
        script:
        # On clicking, run a slightly different script to check some requirements to see what dialog
        # the player should be presented with.
        - ^runtask "script:Beast Requirement Check"

    2:
      chat trigger:
        'Which Beast':
          Trigger: I am interested in hiring '/REGEX:^\w+$/'.
          script:
          # When the player enters the name of the animal they want to hire, the following logic kicks in.
          # The following options exist:
          # 1) If they typed the name of the first beast option and have enough money, then run the script to create the beast.
          # 2) Else if they typed the name of the second, have enough money, then run script to create beast.
          # 3) ...................................third etc
          # 4) Else if they typed the name of the first beast option BUT do NOT have enough money, then tell them how much they have and how much the beast is.
          # 5) ...................................second etc
          # 6) ...................................third etc
          # 7) Else if nothing matches the 6 points above, assume the player typed in something wrong and repeat back what they typed.
          - ^if "<player.chat_history>" == "<cons:beast1 Name>"
            && "<player.money>" >= "<cons:beast1 Price>" runtask "script:Assign Beast One"
            else if "<player.chat_history>" == "<cons:beast2 Name>"
            && "<player.money>" >= "<cons:beast2 Price>" runtask "script:Assign Beast Two"
            else if "<player.chat_history>" == "<cons:beast3 Name>"
            && "<player.money>" >= "<cons:beast3 Price>" runtask "script:Assign Beast Three"
            else if "<player.chat_history>" == "<cons:beast1 Name>"
            && "<player.money>" < "<cons:beast1 Price>"
            narrate "<red>You have <gold><player.money.asint><red> <player.money.currency.plural>, but need <gold><cons:beast1 Price><red> <player.money.currency.plural><red> to pay <npc.name>."
            else if "<player.chat_history>" == "<cons:beast2 Name>"
            && "<player.money>" < "<cons:beast2 Price>"
            narrate "<red>You have <gold><player.money.asint><red> <player.money.currency.plural>, but need <gold><cons:beast2 Price><red> <player.money.currency.plural><red> to pay <npc.name>."
            else if "<player.chat_history>" == "<cons:beast3 Name>"
            && "<player.money>" < "<cons:beast3 Price>"
            narrate "<red>You have <gold><player.money.asint><red> <player.money.currency.plural>, but need <gold><cons:beast3 Price><red> <player.money.currency.plural><red> to pay <npc.name>."
            else chat "I'm sorry <yellow><player.name><green>, but I don't know who or what <white>'<player.chat_history>'<green> is."
            
      click trigger:
        script:
        # I add this here, in case someone clicks the NPC while it's waiting for them to respond.
        # so that they don't forget where they are in the dialog or forgot what they were supposed to
        # be responding with.
        - ^runtask "script:Beast Requirement Check"

      proximity trigger:
        exit:
          script:
          # When player leaves NPC proximity, put them back to step 1 in 'hire a beast' script so
          # it'll be a fresh new conversation when they come back.
          - ^zap "step:1" "script:hire a beast"
          
    3:
      chat trigger:
        'Lost NPC':
          Trigger: "/Yes/ please, track him down and bring him back."
          script:
          # When the beast is created, they add their own NPC ID into a player flag. This flag is then used to
          # provide the NPC ID in the teleport command and teleport them back to the same location as the player.
          - engage
          - random 3
          - chat "Ok <yellow><player.name><green>, we're tracking him down now..."
          - chat "I'm sending word now.. your beast is on their way back."
          - chat "I have informed the network of your missing beast, they are searching for them now."
          - wait 5
          - random 3
          - chat "Found 'em!"
          - chat "Ah good, they are still alive. Here you go <yellow><player.name><green>."
          - chat "Welcome back beast."
          - teleport "targets:n@<flag.p:BeastId>" "location:<player.location>"
          - disengage
        'Leave NPC':
          Trigger: /No/ thank you, I want to leave them where they are.
          script:
          - engage
          - chat "No problem <yellow><player.name><green>, come see me if you want them brought back."
          - disengage

        'What Did You Say':
          trigger: /REGEX:\w+/
          # This is a catch-all trigger that will repeat what the player said if what they
          # typed didn't match any of the chat triggers above.
          script:
          - engage
          - chat "Sorry <yellow><player.name><green>, but I don't what '<white><player.chat_history><green>' means."
          - disengage

      click trigger:
        script:
        - ^runtask "script:Beast Requirement Check"

      proximity trigger:
        exit:
          script:
          - ^zap "step:1" "script:hire a beast"

"Greeting Requirements":
  type: task
  speed: 0

  script:
  # The following options exist here (only really for player immersion)
  # 1) If a beast has been hired already, greet them with the 'Beastmaster Hired Beast Chat' script.
  # 2) else simply greet them with the 'Beastmaster General Chat'.
  - if <flag.p:Beast> = 'Hired' runtask "script:Beastmaster Hired Beast Chat"
    else runtask "script:Beastmaster General Chat"
    
"Beastmaster General Chat":
  type: task
  speed: 0

  script:
  # The 'random 6' means it will pick any one of the 6 lines below the random command and run it. They don't all HAVE to be 'chat' commands.
  - ^random 6
  - ^chat "Are you interested in a faithful animal? Come chat to me."
  - ^chat "Hi <yellow><player.name><green>, need someone to help you out? I can provide a beast at a reasonable price."
  - ^chat "Seems to me like you can use a beast <yellow><player.name><green>."
  - ^chat "Help is hard to find these days, except when you've got coin. Let's talk business."
  - ^chat "Are you an important public figure? Someone wants you dead? Don't worry, I've got a solution."
  - ^chat "Small zombie hordes knocking at the door? Our beasts will be gnawing on their skulls instead."
  
"Beastmaster Hired Beast Chat":
  type: task
  speed: 0

  script:
  # If the player has a beast currently, say something that relates to that fact.
  - ^random 6
  - ^chat "Welcome back <yellow><player.name><green>, hope all is going well with your animal?"
  - ^chat "Hi <yellow><player.name><green>, how is it going with your beast? Are you just checking in?"
  - ^chat "If you ever lose that animal of yours, just come talk to me and I can track them down for you."
  - ^chat "These beasts are great fighters, but not the smartest. If they ever get lost, just come chat to me."
  - ^chat "Ah <yellow><player.name><green>, I see on the list you've employed one of our fine beasts. Hope all is well."
  - ^chat "Hope your beast has been a great help cracking zombie skulls."
  
"Beast Requirement Check":
  type: task
  speed: 0

  script:
  # When the player clicks the Beastmaster to interact, this script simply checks to see if the player currently has a beast.
  # If they do, it will present them the option to "teleport" the beast back (in case the player left the beast
  # somewhere and forgot where).
  # If they do NOT have a beast, it will present the player with the types of beasts available.
  - if <flag.p:Beast> = 'Hired' runtask "script:Teleport Beast"
    else runtask "script:Beast Options"
    
"Beast Options":
  type: task
  speed: 0

  script:
  # Here the player is presented with the different options for beasts. The script knows what the beasts are called 
  # and how much they cost because it uses the constant values you specified in the 'default constants' section at
  # the top of the script.
  # The script then zap's to the relevant chat trigger so it'll match what the player said with what the NPC is expecting
  # as a reply.  
  - engage
  - random 3
  - chat "<green>These beasts will protect you..for a price."
  - chat "<green>The more coin you have, the better protection you can buy."
  - chat "<green>You have three options to pick from."
  - chat '<green>What type of help are you looking for?'
  - ^narrate "<red>Say:"
  - ^narrate "  <gray>'<blue><cons:beast1 Name><gray>'  - Low Level - <gold><cons:beast1 Price> coins"
  - ^narrate "  <gray>'<yellow><cons:beast2 Name><gray>'   - Mid Level  - <gold><cons:beast2 Price> coins"
  - ^narrate "  <gray>'<red><cons:beast3 Name><gray>' - High Level - <gold><cons:beast3 Price> coins"
  - ^disengage
  - ^zap "step:2" "script:hire a beast"
  
"Assign Beast One":
  type: task
  speed: 0

  script:
  #this description not entirely accurate!!!!
  # This section deals with the actual creation of bodyguard. In this case 'Bodyguard One'.
  # There are a few things that happen here and uses functions from Citizens, Sentry and Denizen.
  # 1) The mercenary takes the amount of money you specified in the 'Bodyguard One Price' constant value at the top.
  # 2) It then creates the new NPC and gives it the name you specified in the 'Bodyguard One Name' constant value.
  # 3) Makes the NPC vulnerable so they can get hurt and take damage.
  # 4) Gives gives it the Denizen 'health' trait to also have it interpret damage.
  # 5) Tell Citizens to not respawn the NPC when they die.
  # 6) Assign a script called 'Bodyguard Life and Death' which will go into detail in that section.
  # 7) Set the walking speed only (I believe) in both Citizens and Sentry for the NPC.
  # 8) Give it the Sentry strength value specified in the 'Bodyguard One Strength' constant value at the top.
  # 9) Give it the Sentry armor value specified in the 'Bodyguard One Armor' constant value.
  # 10) Equip the Sentry with the sword type specified in the 'Bodyguard One Sword' constant value.
  # 11) Equip the type of head, chest, leg and foot armor specified in the 'Bodyguard One Appearance' constant value.
  # 12) Tell the Sentry to guard the player. This will make the bodyguard follow the player around and attact mobs that are
  #   attacking the player.
  # 13) Set a flag on the player that indicates they currently have a bodyguard.
  - ^engage
  - ^chat "Alright, <yellow><player.name><green>. His life is in your hands. Try not to get him killed too quickly."
  - take money "qty:<cons:beast1 Price>"
  - narrate "<red>You pay <npc.name> <gold><cons:beast1 Price><red> coins."
  - ^execute as_npc "npc create <cons:beast1 Name> --type chicken"
  - ^execute as_npc "npc owner <player.name>"
  - ^execute as_npc "npc vulnerable"
  - ^execute as_npc "trait health"
  - ^execute as_npc "npc health --respawndelay 0"
  - ^execute as_npc "trait sentry"
  - ^execute as_npc "sentry respawn -1"
  - ^execute as_npc 'npc assign --set "Beast Life and Death"'
  - ^execute as_npc "npc speed 1.2"
  - ^execute as_npc "sentry speed 1.2"
  - ^execute as_npc "sentry target add entity:monster"
  - ^execute as_npc "sentry health 15"
  - ^execute as_npc "sentry strength <cons:beast1 Strength>"
  - ^execute as_npc "sentry armor <cons:beast1 Armor>"
  - ^execute as_npc "sentry guard <player.name>"
  - ^flag player "Beast:Hired"
  - disengage
  
"Assign Beast Two":
  type: task
  speed: 0

  script:
  # Same as in 'Assign Beast One' task above, but using constant values for 'beast2' instead.
  - ^engage
  - chat "Alright, <yellow><player.name><green>. <cons:beast2 Name> is ruthless - but not too smart."
  - take money "qty:<cons:beast2 Price>"
  - ^narrate "<red>You pay <npc.name> <gold><cons:beast2 Price><red> coins."
  - ^execute as_npc "npc create <cons:beast2 Name> --type ozelot"
  - ^execute as_npc "npc owner <player.name>"
  - ^execute as_npc "npc vulnerable"
  - ^execute as_npc "trait health"
  - ^execute as_npc "npc health --respawndelay 0"
  - ^execute as_npc "trait sentry"
  - ^execute as_npc "sentry respawn -1"
  - ^execute as_npc 'npc assign --set "Beast Life and Death"'
  - ^execute as_npc "npc speed 1.2"
  - ^execute as_npc "sentry speed 1.2"
  - ^execute as_npc "sentry target add entity:monster"
  - ^execute as_npc "sentry health 25"
  - ^execute as_npc "sentry strength <cons:beast2 Strength>"
  - ^execute as_npc "sentry armor <cons:beast2 Armor>"
  - ^execute as_npc "sentry guard <player.name>"
  - ^flag player "Beast:Hired"
  - disengage
  
"Assign Beast Three":
  type: task
  speed: 0

  script:
  # Same as in 'Assign Beast One' task above, but using constant values for 'beast3' instead.
  - ^engage
  - chat "Alright, <yellow><player.name><green>. You shouldn't be worried about zombies for a while, this <cons:beast3 Name> can handle his own..."
  - take money "qty:<cons:beast3 Price>"
  - ^narrate "<red>You pay <npc.name> <gold><cons:beast3 Price><red> coins."
  - ^execute as_npc "npc create <cons:beast3 Name> --type wolf"
  - ^execute as_npc "npc owner <player.name>"
  - ^execute as_npc "npc effect --play flame --delay 20"
  - ^execute as_npc "npc vulnerable"
  - ^execute as_npc "trait health"
  - ^execute as_npc "npc health --respawndelay 0"
  - ^execute as_npc "trait sentry"
  - ^execute as_npc "sentry respawn -1"
  - ^execute as_npc 'npc assign --set "Beast Life and Death"'
  - ^execute as_npc "npc speed 1.2"
  - ^execute as_npc "sentry speed 1.2"
  - ^execute as_npc "sentry target add entity:monster"
  - ^execute as_npc "sentry health 40"
  - ^execute as_npc "sentry strength <cons:beast3 Strength>"
  - ^execute as_npc "sentry armor <cons:beast3 Armor>"
  - ^execute as_npc "sentry guard <player.name>"
  - ^flag player "Beast:Hired"
  - disengage
  
"Teleport Beast":
  type: task

  script:
  # If the player has already got a beast, present them a 'yes' or 'no' option and then zap to step 3
  # in the 'hire a beast' interact script above.
  - ^engage
  - random 3
  - chat "Hi <yellow><player.name><green>, did you lose your beast? We can use our network of animals to track him down."
  - chat "Are you here because your beast is missing? I can find him for you."
  - chat "I never said these animals were smart. Did you want me to bring him back?"
  - ^narrate "<red>Say:"
  - ^narrate "  <blue>Yes<blue> <gray>or<red> No"
  - disengage
  - ^zap "step:3" "script:hire a beast"
 
# The following assignment is given to the beast and controls the living and dying aspects of it.

'Beast Life and Death':
  type: assignment
  actions:
    on assignment:
    # This assignment only has one trigger and that's so the beast can be instructed to follow the player
    # or stay in one spot.
    - trigger name:click toggle:true
    # Because the player didn't create this beast, we need to tell the flag specifically who it should be
    # setting the flag against. The mercenary initially assigned the owner and now this command will put a
    # flag on the owner that holds the NPC ID for the beast. This is so the mercenary will know which NPC
    # it's supposed to teleport back.
    - flag player:<^npc.owner> "BeastId:<npc.id>"
    # This sets the flag status of the beast to 'true' initially, because it's guarding the player.
    - flag npc "Guarding:true"
    
    on death:
    # When the beast dies, it will send a message to the owner. Then it runs a script which
    # clears all the flags (so another beast can be hired) and also removes the NPC from Citizens.
    - ^narrate player:<^npc.owner> "<red>Your beast, <aqua><npc.name><red>, has died."
    - ^flag player:<^npc.owner> "Guard:!"
    - ^flag player:<^npc.owner> "BeastId:!"
    - runtask "script:So It Dies" queue delay:10s
    
  interact scripts:
  - 10 Beast

"Beast":
  type: interact
  
  steps:
    1:
      click trigger:
        script:
        # When a player clicks the beast and they are not the owner, it will tell them who the owner is.
        # Else if they are the owner and the 'Guarding' flag is set to 'true' (which it is initially), run the 'Beast Stop Guarding' script.
        # Otherwise, if no criteria is met, run the 'Beast Start Guarding' script.
        - if <npc.owner> != <player.name> chat "I'm sorry <yellow><player.name><green>, but I work for <yellow><npc.owner><green> so I'm not going to take orders from you."
          else if "<flag.n:Guarding>" == "true" runtask "script:Beast Stop Guarding"
          else runtask "script:Beast Start Guarding"
          
"So It Dies":
  type: task
  speed: 0

  script:
  # When the beast dies, clear the two player flags (so a new beast can be hired) and run the "remove" command
  # to properly get rid of the NPC from Citizens.
  - ^flag player:<^npc.owner> "Guard:!"
  - ^flag player:<^npc.owner> "BeastId:!"
  - ^remove
    
"Beast Stop Guarding":
  type: task
  speed: 0

  script:
  # When the beast is instructed to stop guarding, say something to the player to advise them what the beast
  # is doing and change the 'Guarding' flag to 'false'.
  - random 6
  - ^chat "Oh ok boss, I'll wait back here for you."
  - ^chat "Don't worry about me, I'll stay back here. Please don't forget about me."
  - ^chat "I'll wait around for you..but please don't forget about me."
  - ^chat "You want me to hang back? Ok, no problem."
  - ^chat "Ok, I'll guard this spot."
  - ^chat "I'll stand here and wait until you come get me again."
  - ^execute as_npc "npc sel <npc.id>"
  - ^execute as_npc "sentry guard"
  - ^flag npc "Guarding:false"
  
"Beast Start Guarding":
  type: task
  speed: 0

  script:
  # Similar to above, but to indicate the beast is now following the player and change the 'Guarding'
  # flag to 'true'.
  - random 6
  - ^chat "Ok, I'm following you."
  - ^chat "Great <yellow><player.name><green>, I'm right behind you."
  - ^chat "You lead the way boss."
  - ^chat "Watching your back. Let's go."
  - ^chat "Great, let's go for a walk."
  - ^chat "Hope we're going to crush some zombie skulls. Let's move."
  - ^execute as_npc "npc sel <npc.id>"
  - ^execute as_npc "sentry guard <npc.owner>"
  - ^flag npc "Guarding:true"




Comments
No one has posted a comment! Post one below: