Assassination Handler 1.0


Author: davidcernat
Created: 2013-01-28T13:22:24-0500
Edited: 2013-09-21T16:08:37-0400
Denizen Version: 0.8.8
Views: 309
Downloads: 1097
Likes: 7


WGET
Description: ////////
WARNING! This script is outdated. Using this script may require modifications for recent versions of Denizen.
If you are the script owner, simply update your script and remove this warning. This script has also been marked private as to avoid the front page.
////////

Have you ever wanted to hire players to kill other players in a way that was completely immersive, interactive and well-suited for role-playing? Now you can.

Assassination Handler for Denizen 0.8.8+ is the first Denizen script with as much functionality as a small Bukkit plugin. In fact it aims to end up having more features than the Assassins plugin for Bukkit and to be more fun by not requiring the use of any chat window commands that ruin suspension of disbelief.

It doesn't require any other plugins or scripts, just Denizen, Vault and an economy plugin. You also don't have to set anything anywhere. Just assign it to an NPC using this command:

/npc assignment --set "Assassination Handler"

And you are done.

But if you want to, you can easily choose the maximum number of assassination contracts that you want to exist at once, the fee charged when a contract is created, and the minimum bounty that can be placed on a player in a contract. Simply adjust these variables at the top of the script, at "default constants."

Make sure you always use the latest development build of Denizen with this script. And please note that, once you place a contract on a player, you cannot take that contract yourself. You also cannot see contracts that have been placed on you. You can, however, place a contract on yourself (with dialogue unique to such a situation).

If you are looking for a good skin for the Assassination Handler, try giving it the names Therocyn or Olirus.

Feel free to post any comments and suggestions.

Version history:

1.0 - Updated to use procedure scripts newly added to Denizen 0.8.8.
0.9 - Added Track dialogue option. Agents can now pay a fee to find out the approximate locations of their targets.
0.8 - First release.

# ASSASSINATION HANDLER is a complex Denizen character that lets you place
# assassination contracts on players or complete the contracts placed by
# others. It uses several loops for reading and creating contracts and has
# dialogue for different situations.
#
# Please leave a comment on the Citizens Repo if you would like any new
# features or if you find any bugs.
#
# Big thanks to mythanical for helping me out with bug fixing.
#
# @author David Cernat
# @version 1.0.1
# @last-updated Mar 10 2013

"Assassination Handler":
    type: assignment

    default constants:
        # Feel free to adjust the variables here to your own liking
 
        # The contract limit is the maximum number of contracts that can exist
        # at one time
        Assassination Handler Contract Limit: 8
        # The contract fee is the sum of money charged for creating a new contract.
        Assassination Handler Contract Fee: 500
        # The minimum bounty is the smallest bounty that can be placed when
        # creating a new contract
        Assassination Handler Minimum Bounty: 100
        # The tracking fee is the sum of money charged for telling a player
        # where a target is.
        Assassination Handler Tracking Fee: 100
 
 
# Below this point you probably should not try to modify anything unless you
# are an advanced user of Denizen

    actions:
        on assignment:
        # The script ensures the NPC has these triggers activated
        - trigger name:click toggle:true
        - trigger name:chat toggle:true

    interact scripts:
    - 10 Assassination Handler Conversation

"Assassination Handler Conversation":
    type: interact

    steps:
        "Greeting*":
            Click Trigger:
                script:
                # There are 7 possibilities here
                # 1) If the player has just finished a contract, reward him/her
                # 2) Else, if the player has just failed a contract, let him/her know about it
                # 3) Else, if a contract placed by this player on himself/herself has been finished, act surprised that the player is alive
                # 4) Else, if a contract placed by this player has been finished, let him/her know
                # 5) Else, if the player has an active contract whose the target is nearby, comment on that
                # 6) Else, if the player has an active contract, ask if he/she wants to cancel it
                # 7) Else ask the player if he/she wants to take or place a contract (this is the initial state)
                - ^if "<flag.p:Assassination Contracts Finished as Agent.size || 0>" > 0
                  runtask "script:Assassination Handler Agent Receive Reward" instantly
                  else if "<flag.p:Assassination Contracts Failed.size || 0>" > 0
                  runtask "script:Assassination Handler Agent Announce Failure" instantly
                  else if "<flag.p:Assassination Contracts Finished as Client.size || 0>" > 0 && "<flag.p:Assassination Contracts Finished as Client[1]>" == "<player.name>"
                  runtask "script:Assassination Handler Client Was Killed" instantly
                  else if "<flag.p:Assassination Contracts Finished as Client.size || 0>" > 0
                  runtask "script:Assassination Handler Client Announce Success" instantly
                  else if "<flag.p:Assassination Current Contract.size || 0>" > 0
                  && "<location[<npc.location>].distance[<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location>] || 1000>" < 20
                  runtask "script:Assassination Handler Agent Target Nearby" instantly
                  else if "<flag.p:Assassination Current Contract.size || 0>" > 0
                  runtask "script:Assassination Handler Agent Contract Ongoing" instantly
                  else runtask "script:Assassination Handler Initial Greeting" instantly
            Chat Trigger:
                "Take":
                    Trigger: I want to /take/ a contract.
                    Script:
                    # There are 2 possibilities here
                    # 1) If the player has an active contract, do not let him/her take another one
                    # 2) Else, trigger contract display loop and let him/her take one
                    - if "<flag.p:Assassination Current Contract.size || 0>" > 0
                      runtask "script:Assassination Handler Agent Cannot Take Contract" instantly
                      else runtask "script:Assassination Handler Agent Can Take Contract" instantly
                "Place":
                    Trigger: I'm here to /place/ a contract.
                    Script:
                    # Zap to the "Place contract target" step and let the player choose the name of the target
                    - ^zap "step:Place contract target"
                    - random 2
                    - chat "<white>Tell us the name of the one who must be slain."
                    - chat "<white>What is the name of the one whom you want dead?"
                "Cancel":
                    Trigger: I have decided I want to /cancel/ my current contract.
                    Script:
                    # There are 2 possibilities here
                    # 1) If the player has an active contract, cancel it
                    # 2) Else, tell the player he/she has no active contract
                    - if "<flag.p:Assassination Current Contract.size || 0>" > 0
                      runtask "script:Assassination Handler Agent Cancel Contract" instantly
                      else chat "<white>You are not working for us at the moment."
                "Track":
                    Trigger: Help me /track/ down my target.
                    Script:
                    # There are 3 possibilities here
                    # 1) If the player has an active contract and its target is very close-by, let the player know
                    # 2) Else, if the player has an active contract, ask the player to pay the tracking fee for it
                    # 3) Else, tell the player he/she has no target
                    - if "<flag.p:Assassination Current Contract.size || 0>" > 0
                      && "<location[<npc.location>].distance[<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location>] || 1000>" < 20
                      runtask "script:Assassination Handler Agent Target Nearby" instantly
                      else if "<flag.p:Assassination Current Contract.size || 0>" > 0
                      runtask "script:Assassination Handler Agent Track Target Charge Fee" instantly
                      else chat "<white>You do not have a target."
        "Track target fee":
            Click Trigger:
                script:
                - chat "<white>Will you pay <yellow><cons:Assassination Handler Tracking Fee> <white><player.money.currency> to find out where <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is?"
                - narrate "<red>Hint - You can say <yellow>yes<red> or <yellow>no<red>."
                # Replace the narrate here with a hint once hints are added to Denizen again
            Chat Trigger:
                "No":
                    Trigger: /No/, I would rather not use your magic for now.
                    Script:
                    - ^zap "step:Greeting"
                    - chat "<white>Let us hope you can find the target on your own then."
                "Yes":
                    Trigger: /Yes/, here is your fee.
                    Script:
                    # There are 4 possibilities here
                    # 1) If the player has enough money, take it
                    # 2) Else, if the player doesn't have any money, do not proceed
                    # 3) Else, if the player has a balance of just 1, do not proceed
                    # 4) Else, if the player doesn't have enough money, do not proceed
                    - if "<player.money>" >= "<cons:Assassination Handler Tracking Fee>"
                      runtask "script:Assassination Handler Agent Take Tracking Fee" instantly
                      else if "<player.money>" <= 0
                      chat "<white>You do not have any <player.money.currency> at all. Go find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>by yourself."
                      else if "<player.money>" == 1
                      chat "<white>You have just one <player.money.currency.singular>. Find the target by yourself."
                      else chat "<white>You only have <player.money.asint> <player.money.currency>. Find <flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> on your own."
        # In this step the player chooses which contract to take
        "Take contract target":
            Click Trigger:
                script:
                - chat "<white>Which target do you want to go after?"
                # Replace the narrate here with a hint once hints are added to Denizen again
                - narrate "<red>Hint - You can say a name or <yellow>nevermind<red>."
            Chat Trigger:
                "Nevermind":
                    Trigger: /Nevermind/, I'd rather not take a contract.
                    Script:
                    # Delete temporary contract flags
                    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly
                    - ^zap "step:Greeting"
                    - chat "<white>Return once you are willing to act as death's hand."
                "Target":
                    Trigger: I'll take the contract on /REGEX:^\w+$/.
                    Script:
                    - ^flag player "Assassination Target:<player.chat_history>"
                    - ^flag player "Assassination Iterator:0"
                    - ^runtask "script:Assassination Handler Agent Target Validate Loop" instantly
        "Place contract target":
            Click Trigger:
                script:
                - chat "<white>Who needs to die?"
                - narrate "<red>Hint - You can say a name or <yellow>nevermind<red>."
                # Replace the narrate here with a hint once hints are added to Denizen again
            Chat Trigger:
                "Nevermind":
                    Trigger: I've reconsidered, /nevermind/.
                    Script:
                    - ^zap "step:Greeting"
                    # Delete temporary contract flags
                    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly
                    - chat "<white>Return once you are comfortable with the weight of death."
                "Target":
                    Trigger: The name is /REGEX:^\w+$/.
                    Script:
                    # There are 3 possibilities here
                    # 1) If the player tries to set the assassination handler as his/her target, get dialogue for that
                    # 2) Else, if the player's target exists as an online or offline player, proceed
                    # 3) else let the player know that no such target exists
                    - ^flag player "Assassination Target:<player.chat_history>"
                    - ^flag player "Assassination Iterator:0"
                    - if "<flag.p:Assassination Target>" == "<npc.name>"
                      runtask "script:Assassination Handler Client Target Is Handler" instantly
                      else if "<flag.p:Assassination Target>" matches offlineplayer
                      runtask "script:Assassination Handler Client Target Validate Loop" instantly
                      else runtask "script:Assassination Handler Client Target Is Inexistent" instantly
        "Place contract fee":
            Click Trigger:
                script:
                # There are 2 possibilities here
                # 1) If the player chose himself/herself as the target, ask if he/she still wants to pay the contract placement fee using special dialogue
                # 2) Else, if the player's target is someone else, ask the player about the contract placement fee using regular dialogue
                - if "<flag.p:Assassination Target>" == "<player.name>"
                  chat "<white>Do you still wish to place a contract on yourself by paying our <yellow><cons:Assassination Handler Contract Fee> <white><player.money.currency> fee?"
                  else chat "<white>Do you wish to pay our fee of <yellow><cons:Assassination Handler Contract Fee> <white><player.money.currency> and put a contract on <yellow><flag.p:Assassination Target><white>'s head or not?"
                - narrate "<red>Hint - You can say <yellow>yes<red> or <yellow>no<red>."
                # Replace the narrate here with a hint once hints are added to Denizen again
            Chat Trigger:
                "No":
                    Trigger: /No/, I guess not this time.
                    Script:
                    - ^zap "step:Greeting"
                    # Delete temporary contract flags
                    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly
                    - chat "<white>Speak to us once you are certain of your intentions."
                "Yes":
                    Trigger: /Yes/, here is your fee.
                    Script:
                    # There are 4 possibilities here
                    # 1) If the player has enough money, take it
                    # 2) Else, if the player doesn't have any money, do not proceed
                    # 3) Else, if the player has a balance of just 1, do not proceed
                    # 4) Else, if the player doesn't have enough money, do not proceed
                    - if "<player.money>" >= "<cons:Assassination Handler Contract Fee>"
                      runtask "script:Assassination Handler Client Take Contract Fee" instantly
                      else if "<player.money>" <= 0
                      chat "<white>You do not have any <player.money.currency> at all and yet you claim to be able to pay our fee. How pathetic."
                      else if "<player.money>" == 1
                      chat "<white>You have just one <player.money.currency.singular> and yet you think you can pay the fee? Begone."
                      else chat "<white>You only have <player.money.asint> <player.money.currency>. Come back when you can pay the fee."
        "Place contract bounty":
            Click Trigger:
                script:
                - if "<flag.p:Assassination Target>" == "<player.name>"
                  chat "<white>What sum of <player.money.currency> do you want to invest in your own death?"
                  else chat "<white>What sum of <player.money.currency> are you offering for <yellow><flag.p:Assassination Target><white>'s death?"
                - narrate "<red>Hint - You can say a sum of money or <yellow>nevermind<red>."
                # Replace the narrate here with a hint once hints are added to Denizen again
            Chat Trigger:
                "Nevermind":
                    Trigger: /Nevermind/, maybe some other time.
                    Script:
                    - ^zap "step:Greeting"
                    # Delete temporary contract flags
                    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly
                    - chat "<white>You should know what you want before you waste our time."
                    # Give back the assassination fee to the player
                    - ^give money "qty:<cons:Assassination Handler Contract Fee>"
                    - ^narrate "<red>You have received <yellow><cons:Assassination Handler Contract Fee> <red><player.money.currency> back from <yellow><npc.name><red>."
                "Bounty":
                    Trigger: I'm putting up a bounty of /REGEX:^\d+(\.)?(\d)?(\d)?$/ <player.money.currency>.
                    Script:
                    # Set the bounty to the player's numerical input
                    - ^flag player "Assassination Bounty:<player.chat_history>"
                    # There are 5 possibilities here
                    # 1) If the player offers a bounty of 0, do not proceed
                    # 2) Else, if the bounty gets stuck with the second-to-last chat history message ("yes"), ask for new input
                    # 3) Else, if the player offers less than the minimum bounty, do not proceed
                    # 4) Else, if the player doesn't have enough money, do not proceed
                    # 5) else take bounty from player and proceed to contract creation
                    - if "<flag.p:Assassination Bounty>" == 0
                      chat "<white>You cannot ask our agents to kill for free."
                      else if "<flag.p:Assassination Bounty>" == "yes"
                      chat "<white>Can you please repeat that?"
                      else if "<flag.p:Assassination Bounty>" < "<cons:Assassination Handler Minimum Bounty>"
                      chat "<white>That is too small a bounty. Our guild requires that you offer at least <yellow><cons:Assassination Handler Minimum Bounty> <white><player.money.currency>."
                      else if "<flag.p:Assassination Bounty>" > "<player.money>"
                      chat "<white>You only have <player.money.asint> <player.money.currency>. Choose a smaller bounty."
                      else runtask "script:Assassination Handler Client Take Bounty" instantly
        "Add contract bounty":
            Click Trigger:
                script:
                # There are 2 possibilities here
                # 1) If the player chose his/her name as the target, ask him/her for the sum to add to the bounty using special dialogue
                # 1) If the player chose someone else as the target, ask him/her for the sum to add to the bounty using regular dialogue
                - if "<flag.p:Assassination Target>" == "<player.name>"
                  chat "<white>What sum of <player.money.currency> do you want to add to your bounty?"
                  else chat "<white>What sum of <player.money.currency> do you want to add to <red><yellow><flag.p:Assassination Target><white>'s bounty?"
                - narrate "<red>Hint - You can say a sum of money or <yellow>nevermind<red>."
                # Replace the narrate here with a hint once hints are added to Denizen again
            Chat Trigger:
                "Nevermind":
                    Trigger: /Nevermind/, I don't want to add to the bounty.
                    Script:
                    - ^zap "step:Greeting"
                    # Delete temporary contract flags
                    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly
                    - chat "<white>As you wish."
                "Bounty":
                    Trigger: I'll increase the bounty by /REGEX:^\d+(\.)?(\d)?(\d)?$/ <player.money.currency>.
                    Script:
                    # Set the bounty to the player's numerical input
                    - ^flag player "Assassination Bounty:<player.chat_history>"
                    # There are 3 possibilities here
                    # 1) If the player offers no bounty increase, zap back to the "Greeting" step
                    # 2) Else, if the player doesn't have enough money, do not proceed
                    # 3) else try to add the sum of money from the player to the target's bounty
                    - if "<flag.p:Assassination Bounty>" <= 0
                      runtask "script:Assassination Client No Bounty Increase" instantly
                      else if "<flag.p:Assassination Bounty>" > "<player.money>"
                      chat "<white>You only have <player.money.asint> <player.money.currency>. Choose a smaller sum to add to the bounty."
                      else runtask "script:Assassination Handler Client Try Bounty Increase" instantly

"Assassination Handler Client Take Contract Fee":
    type: task

    script:
    # Zap to the "Place contract bounty" step and let the player choose a bounty
    - ^zap "step:Place contract bounty" "script:Assassination Handler Conversation"
    # Take the fee from the player
    - ^take money "qty:<cons:Assassination Handler Contract Fee>"
    # Let the player know the fee has bee given
    - ^narrate "<red>You have given <yellow><cons:Assassination Handler Contract Fee> <red><player.money.currency> to <yellow><npc.name><red>."
    # There are 2 possibilities here
    # 1) If the player chose himself/herself as the target, tell him/her to set a bounty using special dialogue
    # 2) Else, if the player's target is someone else, ask the player to set a bounty using regular dialogue
    - if "<flag.p:Assassination Target>" == "<player.name>"
      chat "<white>You must now place a bounty on yourself which an agent of death will collect upon slaying you. Again, we do not care about your motivations for inviting death. Simply tell us, what sum of <player.money.currency> should your killer get?"
      else chat "<white>Very well. Now you must place a bounty on your target. This is the amount of <player.money.currency> that our agent of death will collect upon completing the job. Larger bounties lead to swifter deaths. What sum of <player.money.currency> are you willing to invest in <yellow><flag.p:Assassination Target><white>'s demise?" 

"Assassination Handler Client Take Bounty":
    type: task

    script:
    # Zap back to the "Greeting" step now that the contract has been created
    - ^zap "step:Greeting" "script:Assassination Handler Conversation"
    # Take the bounty from the player
    - ^take money "qty:<flag.p:Assassination Bounty>"
    # Start contract creation loop
    - ^flag player "Assassination Iterator:0"
    - ^runtask "script:Assassination Handler Client Create Contract Loop" instantly

"Assassination Handler Agent Target Nearby":
    type: task

    script:
    # There are 2 possibilities here
    # 1) If the target is very close to the NPC, berate the player
    # 2) Else, make a milder comment
    - ^if "<location[<npc.location>].distance[<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location>]>" < 8
      runtask "script:Assassination Handler Agent Target Is Here" instantly
      else runtask "script:Assassination Handler Agent Target Is Around" instantly

"Assassination Handler Agent Target Is Here":
    type: task

    script:
    # Display random message about the player's target being right there
    - ^random 8
    - ^chat "<white>Are you blind?"
    - ^chat "<white>How daft can you be?"
    - ^chat "<white>Act already!"
    - ^chat "<white>What are you waiting for?"
    - ^chat "<white>Complete your job!"
    - ^chat "<white>Finish the contract!"
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || Someone> <white>is right next to us!"
    - ^chat "<white>Stop staring at me like a fool and deal with <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target><white>!"

"Assassination Handler Agent Target Is Around":
    type: task

    script:
    # Display random message about the player's target being around
    - ^random 6
    - ^chat "<white>Take a look around. Do you recognize anyone you should recognize?"
    - ^chat "<white>Now is not the time for chit-chat."
    - ^chat "<white>A familiar face is in our immediate vicinity. Perhaps you should do something."
    - ^chat "<white>Your friend <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is paying us a visit. Act now."
    - ^chat "<white>Do you not realize <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is right here?"
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || The target> <white>is here. Make your move."

"Assassination Handler Agent Track Target Charge Fee":
    type: task

    script:
    # Zap to the "Track target fee" step and let the player decide if he/she wants to pay the fee
    - ^zap "step:Track target fee" "script:Assassination Handler Conversation"
    # Display random message
    - ^random 2
    - ^chat "<white>We can use our death magic to help you find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target><white>, yet this comes at a cost. Will you pay the <yellow><cons:Assassination Handler Tracking Fee> <white><player.money.currency> fee that we charge for this service?"
    - ^chat "<white>You can call upon our death magic to discover where <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is, as long as you pay <yellow><cons:Assassination Handler Tracking Fee> <white><player.money.currency>. Will you pay this sum?"

"Assassination Handler Agent Take Tracking Fee":
    type: task

    script:
    # Zap back to the "Greeting" step now that the fee has been paid
    - ^zap "step:Greeting" "script:Assassination Handler Conversation"
    # Take the fee from the player
    - ^take money "qty:<cons:Assassination Handler Tracking Fee>"
    # Use spooky vision effects for the player for several seconds
    - ^cast blindness power:5 duration:7
    - ^cast confusion power:5 duration:7
    # Play ominous sounds
    - ^playsound "location:<npc.location>" "sound:portal_travel" volume:3 pitch:3
    - ^playsound "location:<npc.location>" "sound:portal_trigger" volume:3 pitch:3
    # Wait a little before replying
    - wait 3
    # Let the player know the fee has bee given
    - narrate "<red>You have given <yellow><cons:Assassination Handler Tracking Fee> <red><player.money.currency> to <yellow><npc.name><red>, who has cast a death magic tracking spell."
    # There are 3 possibilities here
    # 1) If the target is online, get his/her location
    # 2) Else, if the target is offline but has a bed, check for his/her bed instead
    # 3) Else, let the player know the target cannot be found
    - if "<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.is_online>" == "true"
      runtask "script:Assassination Handler Agent Track Target Online" speed:1
      else if "<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.is_online>" == "false"
      && "<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.bed_spawn || false>" !== "false"
      runtask "script:Assassination Handler Agent Track Target Offline Has Bed" speed:1
      else runtask "script:Assassination Handler Agent Track Target Offline No Bed" speed:1

"Assassination Handler Agent Track Target Get Distance":
    type: procedure

    script:
    # Return the horizontal multiworld distance between the NPC and the player's target
    - ^flag player "Assassination Target Distance:<location[<npc.location>].distance[<flag.p:Assassination Target Location>].horizontal.multiworld>"
    # Turn the numerical value of the distance into words
    - ^if "<flag.p:Assassination Target Distance>" > 3000
      determine "extremely remote"
      else if "<flag.p:Assassination Target Distance>" > 2000
      determine "very distant"
      else if "<flag.p:Assassination Target Distance>" > 1000
      determine "far"
      else if "<flag.p:Assassination Target Distance>" > 500
      determine "moderately far"
      else if "<flag.p:Assassination Target Distance>" > 200
      determine "nearby"
      else if "<flag.p:Assassination Target Distance>" > 50
      determine "immediate"
      else determine "very immediate"

"Assassination Handler Agent Track Target Get Additional Info":
    type: procedure

    script:
    # Save the light from the sky at the target's location in its own flag
    - ^flag player "Assassination Target Skylight:<location[<flag.p:Assassination Target Location>].light.sky>"
    # Save the light at the target's location in its own flag
    - ^flag player "Assassination Target Light:<location[<flag.p:Assassination Target Location>].light>"
    # Save the Z coordonate of the target's location in its own flag
    - ^flag player "Assassination Target Y:<location[<flag.p:Assassination Target Location>].y>"
    # Get some vague but useful additional information for the player based on the target's Y coordinate and light level
    - ^if "<flag.p:Assassination Target Y>" > 200
      determine "high in the sky"
      else if "<flag.p:Assassination Target Y>" > 135
      determine "in the clouds"
      else if "<flag.p:Assassination Target Y>" > 96
      determine "close to the skies"
      else if "<flag.p:Assassination Target Skylight>" > 11
      && "<location[<flag.p:Assassination Target Location>].time.period>" == "day"
      determine "in the sunlight"
      else if "<flag.p:Assassination Target Skylight>" > 11
      && "<location[<flag.p:Assassination Target Location>].time.period>" == "night"
      determine "in the moonlight"
      else if "<flag.p:Assassination Target Y>" < 17
      && "<flag.p:Assassination Target Light>" < 2
      determine "in the deepest, darkest underground"
      else if "<flag.p:Assassination Target Y>" < 17
      determine "in the deepest underground"
      else if "<flag.p:Assassination Target Y>" < 33
      && "<flag.p:Assassination Target Light>" < 2
      determine "in the deep, dark underground"
      else if "<flag.p:Assassination Target Y>" < 33
      determine "in the deep underground"
      else if "<flag.p:Assassination Target Y>" < 50
      && "<flag.p:Assassination Target Light>" < 2
      determine "in the dark underground"
      else if "<flag.p:Assassination Target Y>" < 50
      determine "in the underground"
      else if "<flag.p:Assassination Target Y>" < 58
      && "<flag.p:Assassination Target Light>" < 2
      determine "in a dark place beneath the ground"
      else if "<flag.p:Assassination Target Y>" < 58
      determine "beneath the ground"
      else if "<flag.p:Assassination Target Light>" < 2
      determine "in a very dark place"
      else if "<flag.p:Assassination Target Light>" < 4
      determine "in a dark place"
      else if "<flag.p:Assassination Target Light>" > 14
      determine "in a well-lit place"
      else determine "in a lit place"

"Assassination Handler Agent Track Target Get Equipment":
    type: procedure

    script:
    - determine "<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.item_in_hand.material.formatted>"

"Assassination Handler Agent Track Target Get World":
    type: procedure

    script:
    - ^flag player "Assassination Target World:<location[<flag.p:Assassination Target Location>].world>"
    # There are 3 possibilities here
    # 1) If the name of the target's world is "world_nether", display it as "the Nether"
    # 2) Else, if the name of the target's world is "world_end", display it as "the End"
    # 3) Else, if the name of the target's world is "world", display it as "the Motherworld"
    - ^if "<flag.p:Assassination Target World>" == "world_nether"
      determine "the Nether"
      else if "<flag.p:Assassination Target World>" == "world_end"
      determine "the End"
      else if "<flag.p:Assassination Target World>" == "world"
      determine "the Motherworld"
      else determine "<flag.p:Assassination Target World>"

"Assassination Handler Agent Track Target Online":
    type: task

    script:
    # Save the target's location in a flag
    - ^flag player "Assassination Target Location:<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location>"
    # Get information about the distance to the target
    - ^flag player "Assassination Target Distance:<proc:Assassination Handler Agent Track Target Get Distance>"
    # Get additional vague information about the target's location
    - ^flag player "Assassination Target Additional Info:<proc:Assassination Handler Agent Track Target Get Additional Info>"
    # Get information about the target's equipment
    - ^flag player "Assassination Target Holding:<proc:Assassination Handler Agent Track Target Get Equipment>"
    # Decide which text to display depending on the variables above
    # There are 3 possibilities here
    - ^if "<location[<flag.p:Assassination Target Location>].world>" !== "<location[<npc.location>].world>"
      runtask "script:Assassination Handler Agent Track Target Online Other World" instantly
      else if "<flag.p:Assassination Target Distance>" == "very immediate"
      runtask "script:Assassination Handler Agent Track Target Online Insufficiently Far" instantly
      else runtask "script:Assassination Handler Agent Track Target Online Sufficiently Far" instantly

"Assassination Handler Agent Track Target Offline Has Bed":
    type: task

    script:
    - ^flag player "Assassination Target Location:<[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.bed_spawn>"
    # Get information about the distance to the target
    - ^flag player "Assassination Target Distance:<proc:Assassination Handler Agent Track Target Get Distance>"
    # Get additional vague information about the target's location
    - ^flag player "Assassination Target Additional Info:<proc:Assassination Handler Agent Track Target Get Additional Info>"
    - ^if "<location[<flag.p:Assassination Target Location>].world>" !== "<location[<npc.location>].world>"
      runtask "script:Assassination Handler Agent Track Target Offline Other World" instantly
      else if "<flag.p:Assassination Target Distance>" == "very immediate"
      runtask "script:Assassination Handler Agent Track Target Offline Insufficiently Far" instantly
      else runtask "script:Assassination Handler Agent Track Target Offline Sufficiently Far" instantly

"Assassination Handler Agent Track Target Offline No Bed":
    type: task

    script:
    - ^random 2
    - ^chat "<white>We cannot find any trace of <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || Someone><white>, not even their last abode. This is unexpected."
    - ^chat "<white>It would appear that <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || they> <white>has somehow vanished from this world or been masked from our death magic. Let us hope they will resurface."

"Assassination Handler Agent Track Target Online Other World":
    type: task

    script:
    - ^flag player "Assassination Target World:<proc:Assassination Handler Agent Track Target Get World>"
    - ^random 2
    - ^chat "<white>It seems <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || The target> <white>is not in our dimension, but in one known as <yellow><flag.p:Assassination Target World><white>. Were you there at the same geographical coordinates that we are at here, you would find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || The target> <white>towards the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]> <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted>, on <[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.standing_on.formatted> holding <flag.p:Assassination Target Holding || nothing>."
    - ^chat "<white>Our death magic shows that <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is on a different plane of existence known as <yellow><flag.p:Assassination Target World><white>. Were you at the same longitude and latitude there that we are at here, you would have to look to the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]> <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted> to find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>standing on <[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.standing_on.formatted> wielding <flag.p:Assassination Target Holding || nothing>."
    - ^runtask "script:Assassination Handler Delete Temporary Tracking Flags" instantly

"Assassination Handler Agent Track Target Offline Other World":
    type: task

    script:
    - ^flag player "Assassination Target World:<proc:Assassination Handler Agent Track Target Get World>"
    - ^random 2
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || The target> <white>is nowhere to be found, and the last trace our magic can find of them is in another dimension known as <yellow><flag.p:Assassination Target World><white>. Were you to somehow travel to the same geographical coordinates there that we are at here, you would then have to go to the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]> <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted> to find that last trace."
    - ^chat "<white>We cannot find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>anywhere in the realms of existence, though their last resting place was on the world known as <yellow><flag.p:Assassination Target World><white>. If you could travel to the same longitude and latitude there that we are at here, you would then have to look to the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]> <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted> to find it."
    - ^runtask "script:Assassination Handler Delete Temporary Tracking Flags" instantly

"Assassination Handler Agent Track Target Offline Sufficiently Far":
    type: task

    script:
    - ^random 2
    - ^chat "<white>Our magic can reach beyond worlds, yet it cannot find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target><white>. That is peculiar. We have, however, found their last resting place. Look for it <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted> in the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]>."
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || The target> <white>eludes our death magic somehow. Perhaps they are not currently part of existence? We cannot explain it. Though you may find clues to their whereabouts <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted> in the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]>, where their last resting place lies."
    - ^runtask "script:Assassination Handler Delete Temporary Tracking Flags" instantly

"Assassination Handler Agent Track Target Offline Insufficiently Far":
    type: task

    script:
    - ^random 2
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is nowhere to be found, yet the last place where they slept is only slightly <location[<npc.location>].direction[<flag.p:Assassination Target Location>]> of here."
    - ^chat "<white>We cannot find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>anywhere, but their last resting place was only a little to the <location[<npc.location>].direction[<flag.p:Assassination Target Location>]>."
    - ^runtask "script:Assassination Handler Delete Temporary Tracking Flags" instantly

"Assassination Handler Agent Track Target Online Sufficiently Far":
    type: task

    script:
    - ^random 2
    - ^chat "<white>You must head for the <location[<flag.p:Assassination Target Location>].biome.formatted> in the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]> and search <flag.p:Assassination Target Additional Info>, where <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>stands on <[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.standing_on.formatted> wielding <flag.p:Assassination Target Holding || nothing>."
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || The target> <white>is in the <flag.p:Assassination Target Distance> <location[<npc.location>].direction[<flag.p:Assassination Target Location>]>, <flag.p:Assassination Target Additional Info> of the <location[<flag.p:Assassination Target Location>].biome.formatted>, standing on <[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.standing_on.formatted> holding <flag.p:Assassination Target Holding || nothing>."
    - ^runtask "script:Assassination Handler Delete Temporary Tracking Flags" instantly

"Assassination Handler Agent Track Target Online Insufficiently Far":
    type: task

    script:
    - ^random 2
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is very near us, merely a little to the <location[<npc.location>].direction[<flag.p:Assassination Target Location>]>, <flag.p:Assassination Target Additional Info>, on <^flag.p:Assassination Current Contract>[1]>] player.location.standing_on.formatted> wielding <flag.p:Assassination Target Holding || nothing>."
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || the target> <white>is right here <flag.p:Assassination Target Additional Info>, standing on <[player.<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0>[1]>] player.location.standing_on.formatted> holding <flag.p:Assassination Target Holding || nothing>. Search slightly to the <location[<npc.location>].direction[<flag.p:Assassination Target Location>]>."
    - ^runtask "script:Assassination Handler Delete Temporary Tracking Flags" instantly

"Assassination Handler Initial Greeting":
    type: task

    script:
    # Display random ongoing contract message
    - ^random 2
    - ^chat "<white>What brings you here, <player.name>? Are you here to <red>take<white> a contract and work as one of our agents of death? Or have you come to <red>place<white> a contract on the head of an enemy?"
    - ^chat "<white>What business do you have with us, <player.name>? Have you come to <red>take<white> a contract and work for us? Or are you here to <red>place<white> a contract on a foe?"

"Assassination Handler Agent Receive Reward":
    type: task

    script:
    # Display random reward message
    - ^random 2
    - ^chat "<white>Well done, <player.name>. You have slain <yellow><flag.p:Assassination Contracts Finished as Agent[1] || no one> <white>for us and therefore the bounty is yours."
    - ^chat "<white>Good job, <player.name>. We are pleased we could rely on you to kill <yellow><flag.p:Assassination Contracts Finished as Agent[1] || no one><white>. Here is your reward."
    # Let the player know that the bounty has been received
    - ^narrate "<red>You have received <yellow><flag.p:Assassination Contracts Finished as Agent[2] || 0> <red><player.money.currency>."
    # Give the bounty to the player
    - ^give money "qty:<flag.p:Assassination Contracts Finished as Agent[2] || 0>"
    # Remove this contract's target and bounty from the player's list of finished contracts
    - ^flag player "Assassination Contracts Finished as Agent:<-:<flag.p:Assassination Contracts Finished as Agent[1]>"
    - ^flag player "Assassination Contracts Finished as Agent:<-:<flag.p:Assassination Contracts Finished as Agent[1]>"
    # Clear current contract now that it is over
    - ^flag player "Assassination Current Contract:!>"

"Assassination Handler Agent Announce Failure":
    type: task

    script:
    # Display random failure message
    - ^random 2
    - ^chat "<white>You have failed, <player.name>. Another agent has killed <yellow><flag.p:Assassination Contracts Failed[1] || no one> <white>first and the bounty is all theirs."
    - ^chat "<white>Your contract is over, <player.name>. Someone else has slain  <yellow><flag.p:Assassination Contracts Failed[1] || no one> <white>and the reward belongs to them."
    # Let the player know that the contract has been terminated
    - ^narrate "<red>You have failed in killing <yellow><flag.p:Assassination Contracts Failed[1] || 0> <red>."
    # Now that the player has been informed about the failure, remove this contract's target and bounty from the player's list of failed contracts
    - ^flag player "Assassination Contracts Failed:<-:<flag.p:Assassination Contracts Failed[1]>"
    - ^flag player "Assassination Contracts Failed:<-:<flag.p:Assassination Contracts Failed[1]>"

"Assassination Handler Client Announce Success":
    type: task

    script:
    # Display random success message
    - ^random 2
    - ^chat "<white>Congratulations, <player.name>. One of our agents of death has slain <yellow><flag.p:Assassination Contracts Finished as Client[1] || no one> <white>for you."
    - ^chat "<white>I have good news, <player.name>. As you requested,  <yellow><flag.p:Assassination Contracts Finished as Client[1] || no one> <white>is now dead."
    # Now that the player has been informed about the success, remove this contract's target and bounty from the player's list of finished contracts
    - ^flag player "Assassination Contracts Finished as Client:<-:<flag.p:Assassination Contracts Finished as Client[1]>"
    - ^flag player "Assassination Contracts Finished as Client:<-:<flag.p:Assassination Contracts Finished as Client[1]>"

"Assassination Handler Client Was Killed":
    type: task

    script:
    # Display random success message
    - ^random 3
    - ^chat "<white>You're still alive, <player.name>? I thought the agent you hired to kill you had finished the job..."
    - ^chat "<white>Back from the dead, <player.name>? Maybe you should not place contracts on yourself in the future."
    - ^chat "<white>We know our agent killed you, <player.name>. As such, we are not sure what to make of your reappearance."
    # Now that the player has been informed about the success, remove this contract's target and bounty from the player's list of finished contracts
    - ^flag player "Assassination Contracts Finished as Client:<-:<flag.p:Assassination Contracts Finished as Client[1]>"
    - ^flag player "Assassination Contracts Finished as Client:<-:<flag.p:Assassination Contracts Finished as Client[1]>"

"Assassination Handler Agent Contract Ongoing":
    type: task

    script:
    # Display random ongoing contract message
    - ^random 8
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || Someone><white>'s heart still beats. That is a problem. Fix it."
    - ^chat "<yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || Someone> <white>still lives. You should remedy that."
    - ^chat "<white>We can help you <red>track <white>down <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || anyone> <white>if you pay our fee of <yellow><cons:Assassination Handler Tracking Fee> <white><player.money.currency>."
    - ^chat "<white>Are you unable to find <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || anyone><white>? Then perhaps we can help you <red>track <white>them down."
    - ^chat "<white>We hope you are not here to <red>cancel <white>your contract, given that we can help you <red>track <white>down <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || your target>."
    - ^chat "<white>Unable to <red>track <white>down <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || your target><white>? Our death magic can aid you."
    - ^chat "<white>You must find and eliminate <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || someone><white>. Hopefully the task is not so difficult for you that you have come here to <red>cancel <white>your contract."
    - ^chat "<white>If you've come here to <red>cancel <white>your contract, you will not get a single <player.money.currency.singular> out of the bounty's <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[2] || 0><white>."

"Assassination Handler Agent Cannot Take Contract":
    type: task

    script:
    # Display random message when the player already has a contract but tries to take a new one
    - ^random 3
    - ^chat "<white>You are already working for us. We cannot let you take a new contract until you finish or <red>cancel <white>the one you already have."
    - ^chat "<white>Once you finish your current contract we may discuss your further employment."
    - ^chat "<white>Not until you finish the one you already have."

"Assassination Handler Agent Can Take Contract":
    type: task

    script:
    # Clear variable flags for valid contract counting loop
    - ^flag player "Assassination Iterator:0"
    - ^runtask "script:Assassination Handler Agent Count Valid Contracts Loop" instantly

"Assassination Handler Agent Cancel Contract":
    type: task

    script:
    # Cancel Kill Listener for player
    - ^listen kill "id:Assassination of <flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1]> Listener" cancel
    # Display random message when the player cancels a contract
    - ^random 5
    - ^chat "<white>Go back to building houses if you are too unskilled to be an assassin."
    - ^chat "<white>We are sorry to hear you are completely inept. Come back if that ever stops being the case."
    - ^chat "<white>We have cancelled your contract. Return once you are less incompetent."
    - ^chat "<white>Even children are better at killing people than you are."
    - ^chat "<white>Refrain from wasting our time in the future."
    # Let the player know the contract has been cancelled
    - ^narrate "<red>You are no longer contracted to kill <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1] || no one> <red>."
    # Remove the player from the list of agents for this contract
    - ^flag global "Assassination Contract <flag.p:Assassination Current Contract> Agents:<-:<player.name>"
    # Clear current contract now that it is cancelled
    - ^flag player "Assassination Current Contract:!>"

"Assassination Handler Agent Count Valid Contracts Loop":
    type: task

    script:
    # Increase value of iterator by 1 every time the loop runs
    - ^flag player "Assassination Iterator:+"
    # The loop continues until the iterator has the same value as the maximum number of contracts the assassination handler can have
    # There are 3 possibilities here
    # 1) While the loop is ongoing, if the current target is valid (i.e. the contract is not empty and the player is not a target in it and the player did not place it), add it to the list of contracts to display for this player
    # 2) While the loop is ongoing, if the current contract is invalid (i.e. the contract is empty or the player is a target in it or the player is the one who placed it), ignore it and continue the loop
    # 3) Else, try to continue loop
    # 4) If the loop is over, display the valid contracts
    - ^if "<flag.p:Assassination Iterator>" <= "<cons:Assassination Handler Contract Limit>"
      && "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>.size || 0>" > 0
      && "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>" !== "<player.name>"
      && "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[3]>" !== "<player.name>"
      runtask "script:Assassination Handler Agent Add Displayed Contract" instantly
      else if "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[3]>" == "<player.name>"
      runtask "script:Assassination Handler Agent Add Placed Contract Mention" instantly
      else if "<flag.p:Assassination Iterator>" <= "<cons:Assassination Handler Contract Limit>"
      runtask "script:Assassination Handler Agent Count Valid Contracts Loop" instantly
      else runtask "script:Assassination Handler Agent Count Valid Contracts" instantly

"Assassination Handler Agent Add Displayed Contract":
    type: task

    script:
    - ^flag player "Assassination Displayed Contracts:->:<flag.p:Assassination Iterator.asint>"
    - ^runtask "script:Assassination Handler Agent Count Valid Contracts Loop" instantly

"Assassination Handler Agent Add Placed Contract Mention":
    type: task

    script:
    - ^flag player "Assassination Placed Contracts:->:<flag.p:Assassination Iterator.asint>"
    - ^runtask "script:Assassination Handler Agent Count Valid Contracts Loop" instantly

"Assassination Handler Agent Count Valid Contracts":
    type: task

    script:
    # There are 6 possibilities here
    # 1) If there are no contracts to display for this player, and the player has not placed any contracts, let him/her know
    # 2) If there are no contracts to display for this player, but the player has placed a single contract, let him/her know that others may take it
    # 3) If there are no contracts to display for this player, but the player has placed more than a contract, let him/her know that others may take them
    # 4) If there is a single contract to display for this player, but the player has placed at least one contract, let him/her know that he/she can only take the contract he/she has not placed
    # 5) If there are more contracts to display for this player, but the player has placed at least one contract, let him/her know that he/she can only take the contracts he/she has not placed
    # 6) If the player has not placed any contracts, simply list the contracts available
    - ^if "<flag.p:Assassination Displayed Contracts.size || 0>" < 1
      && "<flag.p:Assassination Placed Contracts.size || 0>" < 1
      chat "<white>Our guild has no contracts available for you at this time."
      else if "<flag.p:Assassination Displayed Contracts.size || 0>" < 1
      && "<flag.p:Assassination Placed Contracts.size || 0>" == 1
      chat "<white>We have no contracts for you right now, though others may take the contract you have placed."
      else if "<flag.p:Assassination Displayed Contracts.size || 0>" < 1
      && "<flag.p:Assassination Placed Contracts.size || 0>" > 1
      chat "<white>There are no contracts you can take at the moment, but others can take the <flag.p:Assassination Placed Contracts.size || 0> contracts you have placed."
      else if "<flag.p:Assassination Displayed Contracts.size || 0>" == 1
      && "<flag.p:Assassination Placed Contracts.size || 0>" > 0
      runtask "script:Assassination Handler Agent Contracts Available 1" instantly
      else if "<flag.p:Assassination Displayed Contracts.size || 0>" > 1
      && "<flag.p:Assassination Placed Contracts.size || 0>" > 0
      runtask "script:Assassination Handler Agent Contracts Available 2" instantly
      else if "<flag.p:Assassination Displayed Contracts.size || 0>" == 1
      runtask "script:Assassination Handler Agent Contracts Available 3" instantly
      else runtask "script:Assassination Handler Agent Contracts Available 4" instantly
    - ^flag player "Assassination Placed Contracts:!"

"Assassination Handler Agent Contracts Available 1":
    type: task

    script:
    - ^zap "step:Take contract target" "script:Assassination Handler Conversation"
    - ^chat "<white>You may not take a contract you have placed yourself, so we only have one contract available for you. If you want it, tell me the name of its target."
    - runtask "script:Assassination Handler Agent Display Contract Loop" instantly

"Assassination Handler Agent Contracts Available 2":
    type: task

    script:
    - ^zap "step:Take contract target" "script:Assassination Handler Conversation"
    - ^chat "<white>You cannot take a contract placed by yourself, but here are all the ones placed by others that you can take. Choose one of the targets."
    - runtask "script:Assassination Handler Agent Display Contract Loop" instantly

"Assassination Handler Agent Contracts Available 3":
    type: task

    script:
    - ^zap "step:Take contract target" "script:Assassination Handler Conversation"
    - ^chat "<white>This is the only contract we have available at this time. If you want to take it, tell me the name of its target."
    - runtask "script:Assassination Handler Agent Display Contract Loop" instantly

"Assassination Handler Agent Contracts Available 4":
    type: task

    script:
    - ^zap "step:Take contract target" "script:Assassination Handler Conversation"
    - ^chat "<white>You wish to work for us. So be it. Here are the contracts we have available. Choose one of the targets."
    - runtask "script:Assassination Handler Agent Display Contract Loop" instantly

"Assassination Handler Agent Display Contract Loop":
    type: task
    
    script:
    - ^if "<flag.p:Assassination Displayed Contracts.size || 0>" > 0
      runtask "script:Assassination Handler Agent Display Contract"
      else runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Agent Get Assassination Action":
    type: procedure

    script:
    # Choose a random name for each contract available to the player
    - ^random 67
    - ^determine "Annihilate <yellow><flag.p:Assassination Target>"
    - ^determine "Assassinate <yellow><flag.p:Assassination Target>"
    - ^determine "Behead <yellow><flag.p:Assassination Target>"
    - ^determine "Bury <yellow><flag.p:Assassination Target>"
    - ^determine "Butcher <yellow><flag.p:Assassination Target>"
    - ^determine "Decapitate <yellow><flag.p:Assassination Target>"
    - ^determine "Destroy <yellow><flag.p:Assassination Target>"
    - ^determine "Disembowel <yellow><flag.p:Assassination Target>"
    - ^determine "Dismember <yellow><flag.p:Assassination Target>"
    - ^determine "Dispatch <yellow><flag.p:Assassination Target>"
    - ^determine "Eliminate <yellow><flag.p:Assassination Target>"
    - ^determine "Eradicate <yellow><flag.p:Assassination Target>"
    - ^determine "Eviscerate <yellow><flag.p:Assassination Target>"
    - ^determine "Execute <yellow><flag.p:Assassination Target>"
    - ^determine "Exterminate <yellow><flag.p:Assassination Target>"
    - ^determine "Kill <yellow><flag.p:Assassination Target>"
    - ^determine "Liquidate <yellow><flag.p:Assassination Target>"
    - ^determine "Massacre <yellow><flag.p:Assassination Target>"
    - ^determine "Murder <yellow><flag.p:Assassination Target>"
    - ^determine "Obliterate <yellow><flag.p:Assassination Target>"
    - ^determine "Slaughter <yellow><flag.p:Assassination Target>"
    - ^determine "Slay <yellow><flag.p:Assassination Target>"
    - ^determine "Snuff <yellow><flag.p:Assassination Target>"
    - ^determine "Waste <yellow><flag.p:Assassination Target>"
    - ^determine "Whack <yellow><flag.p:Assassination Target>"
    - ^determine "Bump off <yellow><flag.p:Assassination Target>"
    - ^determine "Cut down <yellow><flag.p:Assassination Target>"
    - ^determine "Dispose of <yellow><flag.p:Assassination Target>"
    - ^determine "Do in <yellow><flag.p:Assassination Target>"
    - ^determine "Extirpate the tumor that is <yellow><flag.p:Assassination Target>"
    - ^determine "Get rid of <yellow><flag.p:Assassination Target>"
    - ^determine "Make ribbons out of <yellow><flag.p:Assassination Target>"
    - ^determine "Peel the flesh off <yellow><flag.p:Assassination Target>"
    - ^determine "Take out <yellow><flag.p:Assassination Target>"
    - ^determine "Wipe out <yellow><flag.p:Assassination Target>"
    - ^determine "Arrange a meeting between <yellow><flag.p:Assassination Target> <red>and death"
    - ^determine "Bring <yellow><flag.p:Assassination Target><red>'s head on a plate"
    - ^determine "Conclude <yellow><flag.p:Assassination Target><red>'s existence"
    - ^determine "Chop <yellow><flag.p:Assassination Target> <red>into little pieces"
    - ^determine "Cut <yellow><flag.p:Assassination Target> <red>from head to toe"
    - ^determine "Extinguish <yellow><flag.p:Assassination Target><red>'s life"
    - ^determine "Feed <yellow><flag.p:Assassination Target> <red>to the worms"
    - ^determine "Flay <yellow><flag.p:Assassination Target> <red>alive"
    - ^determine "Force <yellow><flag.p:Assassination Target> <red>to say their last words"
    - ^determine "Gut <yellow><flag.p:Assassination Target> <red>like a pig"
    - ^determine "Harvest <yellow><flag.p:Assassination Target><red>'s vital organs"
    - ^determine "Help <yellow><flag.p:Assassination Target> <red>find out if there is life after death"
    - ^determine "Inhume <yellow><flag.p:Assassination Target> <red>in the cold ground"
    - ^determine "Inter <yellow><flag.p:Assassination Target> <red>in the nearest cemetery"
    - ^determine "Introduce <yellow><flag.p:Assassination Target> <red>to their death"
    - ^determine "Leave <yellow><flag.p:Assassination Target> <red>to die in a pool of blood"
    - ^determine "Make <yellow><flag.p:Assassination Target> <red>meet an untimely end"
    - ^determine "Make <yellow><flag.p:Assassination Target> <red>say farewell to this world"
    - ^determine "Place <yellow><flag.p:Assassination Target> <red>inside a coffin"
    - ^determine "Put <yellow><flag.p:Assassination Target> <red>six feet underground"
    - ^determine "Put <yellow><flag.p:Assassination Target> <red>to death"
    - ^determine "Qualify <yellow><flag.p:Assassination Target> <red>for a tombstone"
    - ^determine "Remove <yellow><flag.p:Assassination Target><red>'s brain and preserve it for science"
    - ^determine "Remove <yellow><flag.p:Assassination Target><red>'s entrails"
    - ^determine "Rip out <yellow><flag.p:Assassination Target><red>'s beating heart"
    - ^determine "Send <yellow><flag.p:Assassination Target> <red>to meet their maker"
    - ^determine "Send <yellow><flag.p:Assassination Target> <red>to the morgue"
    - ^determine "Separate <yellow><flag.p:Assassination Target><red>'s head from their body"
    - ^determine "Sever <yellow><flag.p:Assassination Target><red>'s head"
    - ^determine "Stab <yellow><flag.p:Assassination Target> <red>in the heart"
    - ^determine "Slit <yellow><flag.p:Assassination Target><red>'s throat"
    - ^determine "Tear <yellow><flag.p:Assassination Target> <red>into tiny shreds"

"Assassination Handler Agent Display Contract":
    type: task
    speed: 4

    script:
    # Temporarily save the target from the current contract in the Assassination Target flag
    - ^flag player "Assassination Target:<flag.g:Assassination Contract <flag.p:Assassination Displayed Contracts[1]>[1]>"
    # Display a name for each contract available to the player
    - narrate "<red>- <proc:Assassination Handler Agent Get Assassination Action> <red>for <yellow><flag.g:Assassination Contract <flag.p:Assassination Displayed Contracts[1]>[2]> <red><player.money.currency>"
    - ^flag player "Assassination Displayed Contracts:<-:<flag.p:Assassination Displayed Contracts[1]>"
    # Display the next contract on the list
    - runtask "script:Assassination Handler Agent Display Contract Loop" instantly

"Assassination Handler Agent Target Validate Loop":
    type: task

    script:
    # Increase value of iterator by 1 every time the loop runs
    - ^flag player "Assassination Iterator:+"
    # The loop continues until the iterator has the same value as the maximum number of contracts the assassination handler can have
    # There are 3 possibilities here
    # 1) While the loop is ongoing, if the player chose himself/herself as the target and the current contract contains him/her as the target, refuse to let the player take the contract
    # 2) While the loop is ongoing, if the player chose the target of a contract which he/placed, do not let the player take the contract
    # 3) While the loop is ongoing, if the target chosen by the player is found in a contract, the player is not the target
    # 4) While the loop is ongoing, move to the next contract
    - ^if "<player.name>" == "<flag.p:Assassination Target>"
      && "<player.name>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      chat "<white>And how would you complete the contract placed on you? By committing suicide? No, we will not give it to you."
      else if "<flag.p:Assassination Target>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      && "<player.name>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[3]>"
      chat "<white>You may not take a contract you have placed yourself."
      else if "<flag.p:Assassination Iterator>" <= "<cons:Assassination Handler Contract Limit>"
      && "<flag.p:Assassination Target>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      runtask "script:Assassination Handler Agent Target Valid" instantly
      else if "<flag.p:Assassination Iterator>" <= "<cons:Assassination Handler Contract Limit>"
      runtask "script:Assassination Handler Agent Target Validate Loop" instantly
      else chat "<white>There is no such contract."

"Assassination Handler Agent Target Valid":
    type: task

    script:
    # Zap back to the "Greeting" step now that a valid target has been chosen
    - ^zap "step:Greeting" "script:Assassination Handler Conversation"
    # Add the player to the agents for this contract
    - ^flag global "Assassination Contract <flag.p:Assassination Iterator.asint> Agents:->:<player.name>"
    # Set this contract as the player's current contract
    - ^flag player "Assassination Current Contract:<flag.p:Assassination Iterator.asint>"
    # Create a kill listener for this player with the chosen target
    - ^listen kill "id:Assassination of <flag.p:Assassination Target> Listener" type:player "name:<flag.p:Assassination Target>" "script:Assassination Handler Agent Killed Target"
    # Inform the player that he/she has been given the contract
    - runtask "script:Assassination Handler Agent Give Contract" instantly

"Assassination Handler Agent Give Contract":
    type: task

    script:
    # Display random message for giving a contract to the player
    - random 2
    - chat "<white>The contract is yours. Kill <yellow><flag.p:Assassination Target> <white>for us and you will be rewarded. And we can help you <red>track <white>them down if you like."
    - chat "<white>Very well. I am entrusting you with <yellow><flag.p:Assassination Target><white>'s death. Strike swiftly, and remember that we can help you <red>track <white>down any target."
    - narrate "<red>You have taken a contract to kill <yellow><flag.p:Assassination Target || no one><red>."
    # Delete temporary contract flags
    - runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Agent Killed Target":
    type: task

    script:
    # Add this contract to the player's finished contracts
    - ^flag player "Assassination Contracts Finished as Agent:->:<flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1]>"
    - ^flag player "Assassination Contracts Finished as Agent:->:<flag.g:Assassination Contract <flag.p:Assassination Current Contract>[2]>"
    # Remove the player from the list of agents for this contract
    - ^flag global "Assassination Contract <flag.p:Assassination Current Contract> Agents:<-:<player.name>"
    # Use a temporary global flag to store the number of this contract for 2 commands, because the player argument below changes the player that a flag.p would refer to
    - ^flag global "Assassination Contract Cleared:<flag.p:Assassination Current Contract>"
    # Add this contract to the contract client's finished contracts
    # Use ^ in the player argument tags to make the replaceable tags get loaded early enough - i.e. in Denizen's buildArgs() - to work
    - ^flag "player:<^flag.g:Assassination Contract <^flag.g:Assassination Contract Cleared>[3]>" "Assassination Contracts Finished as Client:->:<flag.g:Assassination Contract <flag.g:Assassination Contract Cleared>[1]>"
    - ^flag "player:<^flag.g:Assassination Contract <^flag.g:Assassination Contract Cleared>[3]>" "Assassination Contracts Finished as Client:->:<flag.g:Assassination Contract <flag.g:Assassination Contract Cleared>[2]>"
    # Get rid of the temporary global flag
    - ^flag global "Assassination Contract Cleared:!"
    # Announce contract completion to all players
    - ^announce "<red>The assassination contract on <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1]> <red>has been completed!"
    # Let this player know that he/she can return for the reward
    - ^narrate "<red>Return to an assassination handler to receive your reward of <yellow><flag.g:Assassination Contract <flag.p:Assassination Current Contract>[2]> <red><player.money.currency>."
    # Run the contract clearing loops to:
    # 1) turn this contract into a failed one for everyone remaining on its list of agents
    # 2) remove it from the list of active contracts
    - ^runtask "script:Assassination Handler Agent Clear Contract Loop" instantly

"Assassination Handler Agent Clear Contract Loop":
    type: task

    script:
    # Take the first player on the list of agents for this contract and cancel his/her Kill Listener
    # Use ^ in the player argument tags to make the replaceable tags get loaded early enough - i.e. in Denizen's buildArgs() - to work
    - ^listen kill "player:<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0> Agents[1]>" "id:Assassination of <flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1]> Listener" cancel
    # Add the contract's target and bounty to his/her list of failed contracts
    - ^flag "player:<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0> Agents[1]>" "Assassination Contracts Failed:->:<flag.g:Assassination Contract <flag.p:Assassination Current Contract>[1]>"
    - ^flag "player:<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0> Agents[1]>" "Assassination Contracts Failed:->:<flag.g:Assassination Contract <flag.p:Assassination Current Contract>[2]>"
    # Also remove the current cotract for this player
    - ^flag "player:<^flag.g:Assassination Contract <^flag.p:Assassination Current Contract || 0> Agents[1]>" "Assassination Current Contract:!>"
    # Now remove this player from the list of agents for this contract
    - ^flag global "Assassination Contract <flag.p:Assassination Current Contract> Agents:<-:<flag.g:Assassination Contract <flag.p:Assassination Current Contract> Agents[1]>"
    # Check if there is anyone left on the list of agents for this contract
    # If yes, restart this loop
    # If not, clear the contract
    - ^if "<flag.g:Assassination Contract <flag.p:Assassination Current Contract> Agents.size || 0>" > 0
      runtask "script:Assassination Handler Agent Clear Contract Loop" instantly
      else flag global "Assassination Contract <flag.p:Assassination Current Contract>:!"

"Assassination Handler Client Target Is Handler":
    type: task

    script:
    # Display random message when the player gives the assassination handler's name as the target
    - ^random 4
    - ^chat "<white>Your weak attempts at humor do not amuse us."
    - ^chat "<white>Or perhaps we should place a contract on you, with a big fat bounty."
    - ^chat "<white>Do not take us lightly or you will regret it."
    - ^chat "<white>Take your stupid jokes elsewhere."

"Assassination Handler Client Target Is Inexistent":
    type: task

    script:
    # Display random message when the player chooses a target that is not a real player
    - ^random 6
    - ^chat "<white>Our guild does not believe someone by the name of <yellow><flag.p:Assassination Target> <white>has ever come to this land. Choose someone else."
    - ^chat "<white>We have never heard of this <yellow><flag.p:Assassination Target><white>. Try again."
    - ^chat "<white>Are you sure this <yellow><flag.p:Assassination Target> <white>actually exists? We do not think so."
    - ^chat "<white>No one by that name exists."
    - ^chat "<white>There is no such person."
    - ^chat "<white>There is no one with that name."

"Assassination Handler Client Target Validate Loop":
    type: task

    script:
    # Increase value of iterator by 1 every time the loop runs
    - ^flag player "Assassination Iterator:+"
    # The loop continues until the iterator has the same value as the maximum number of contracts the assassination handler can have
    # There are 5 possibilities here
    # 1) If the loop has ended without finding a spare contract slot, let the player know there is no room for new contracts
    # 2) While the loop is ongoing, if the target chosen by the player is found in a contract that already exists, ask the player if he/she wants to increase the bounty on the target
    # 3) While the loop is ongoing, if the player chose himself/herself as the target and the current contract slot is empty, create a new contract with special dialogue in that slot
    # 4) While the loop is ongoing, if the player chose someone else as a target and the current contract slot is empty, create a new contract with regular dialogue in that slot
    # 5) else move to the next contract slot
    - ^if "<flag.p:Assassination Iterator>" > "<cons:Assassination Handler Contract Limit>"
      chat "<white>We have too many contracts already, so you cannot place a contract on <yellow><flag.p:Assassination Target><white>. However, if there are others whom you want dead, tell us their names. Perhaps we have contracts on them and you can add to their bounties."
      else if "<flag.p:Assassination Target>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      runtask "script:Assassination Handler Client Target Already Exists" instantly
      else if "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>.size || 0>" < 1 && "<flag.p:Assassination Target>" == "<player.name>"
      runtask "script:Assassination Handler Client Target Is Self" instantly
      else if "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>.size || 0>" < 1
      runtask "script:Assassination Handler Client Target Valid" instantly
      else runtask "script:Assassination Handler Client Target Validate Loop" instantly

"Assassination Handler Client Target Already Exists":
    type: task

    script:
    # Zap to the "Add contract bounty" step and let the player decide how much money to add to the bounty
    - ^zap "step:Add contract bounty" "script:Assassination Handler Conversation"
    # There are 2 possibilities here
    # 1) If the player chose himself/herself as the target, ask if he/she wants to increase the bounty on himself/herself using special dialogue
    # 2) Else, if the player chose someone else as the target, ask if he/she wants to increase the bounty on the target using regular dialogue
    - ^if "<flag.p:Assassination Target>" == "<player.name>"
       chat "<white>There already is a bounty of <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[2] || 0> <white><player.money.currency> on your head. What additional sum of <player.money.currency> do you want your slayer to get?"
       else chat "<white>There is already a bounty of <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[2] || 0> <white><player.money.currency> on <yellow><yellow><flag.p:Assassination Target><white>'s head. What sum of <player.money.currency> do you want to add to it?"

"Assassination Handler Client Target Is Self":
    type: task

    script:
    # Zap to the "Place contract fee" and let the player decide if he/she wants to pay the fee
    - ^zap "step:Place contract fee" "script:Assassination Handler Conversation"
    # Display random message when the player gives his/her own name as the target
    - ^random 2
    - ^chat "<white>So you wish to place a contract on your own life. It is all the same for us. You must still pay our guild's fee of <yellow><cons:Assassination Handler Contract Fee> <white><player.money.currency>. Will you pay it?"
    - ^chat "<white>A contract on yourself? Perhaps you have philosophical reasons for desiring death or you merely seek a challenge. We do not care. Will you pay our guild's fee of <yellow><cons:Assassination Handler Contract Fee> <white><player.money.currency> for placing the contract?"

"Assassination Handler Client Target Valid":
    type: task

    script:
    # Zap to the "Place contract fee" step and let the player decide if he/she wants to pay the fee
    - ^zap "step:Place contract fee" "script:Assassination Handler Conversation"
    # Display random message when the player gives a valid name (an existing online or offline player) as the target
    - ^random 2
    - ^chat "<white>Before we can proceed, you need to pay our guild's fee of <yellow><cons:Assassination Handler Contract Fee> <white><player.money.currency>. Afterwards you may put a bounty on your foe. Do you wish to pay the fee?"
    - ^chat "<white>First you must pay the <yellow><cons:Assassination Handler Contract Fee> <white><player.money.currency> fee we charge for our service of intermediation. Then you can place a bounty on <yellow><flag.p:Assassination Target><white>'s head. Will you pay the fee?"

"Assassination Handler Client Create Contract Loop":
    type: task

    script:
    # Increase value of iterator by 1 every time the loop runs
    - ^flag player "Assassination Iterator:+"
    # There are 4 possibilities here
    # 1) While the loop is ongoing, if the current contract slot is empty, create the new contract in it
    # 2) While the loop is ongoing, move to the next contract slot
    # 3) While the loop is ongoing, if a contract on this target already exists, mention that to the player and give him/her a refund
    # 4) If the loop is over, which means no free contract slots were found, mention that to the player and give him/her a refund
    - ^if "<flag.p:Assassination Iterator>" <= "<cons:Assassination Handler Contract Limit>"
      && "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>.size || 0>" < 1
      runtask "script:Assassination Handler Client Create Contract" instantly
      else if "<flag.p:Assassination Target>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      runtask "script:Assassination Handler Client Contract Already Exists" instantly
      else if "<flag.p:Assassination Iterator>" <= "<cons:Assassination Handler Contract Limit>"
      runtask "script:Assassination Handler Client Create Contract Loop" instantly
      else runtask "script:Assassination Handler Client Contracts Full" instantly

"Assassination Handler Client Create Contract":
    type: task

    script:
    # Creating a new contract in the current empty contract slot
    # Add the name of the target to the first position of the flag list
    - ^flag global "Assassination Contract <flag.p:Assassination Iterator.asint>[1]:<flag.p:Assassination Target>"
    # Add the bounty to the second position of the flag list
    - ^flag global "Assassination Contract <flag.p:Assassination Iterator.asint>[2]:<flag.p:Assassination Bounty>"
    # Add the name of the client to the third position of the flag list
    - ^flag global "Assassination Contract <flag.p:Assassination Iterator.asint>[3]:<player.name>"
    # Announce the creation of the new contract to all players
    - ^announce "<red>Assassination contract placed on <yellow><flag.p:Assassination Target> <red>for <yellow><flag.p:Assassination Bounty> <red><player.money.currency>!"
    # There are 2 possibilities here
    # 1) If the player put a contract on himself/herself, let him/her know that the contract has been created using special dialogue
    # 2) If the player put a contract on someone else, let him/her know that the contract has been created using regular dialogue
    - ^if "<flag.p:Assassination Target>" == "<player.name>"
      chat "<white>I have created the contract on your life. Whoever kills you will get <flag.p:Assassination Bounty> <player.money.currency> from us. We would let you know once the deed is done, but we are sure you will be able to tell by yourself."
      else chat "<white>I have created the contract. The agent of death who slays <yellow><flag.p:Assassination Target><white> shall receive your bounty of <yellow><flag.p:Assassination Bounty> <white><player.money.currency>. We will let you know once the deed is done."
    # Delete temporary contract flags
    - runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Client No Bounty Increase":
    type: task

    script:
    # Zap to the "Greeting" step because the player does not want to add to the target's bounty
    - ^zap "step:Greeting" "script:Assassination Handler Conversation"
    - ^chat "<white>So you do not wish to add any <player.money.currency> to <yellow><flag.p:Assassination Target><white>'s bounty. Very well."
    # Delete temporary contract flags
    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Client Try Bounty Increase":
    type: task

    script:
    # Zap to the "Greeting" step regardless of whether adding to the bounty works or not
    - ^zap "step:Greeting" "script:Assassination Handler Conversation"
    # There are 2 possibilities here
    # 1) If the player's target is no longer the target in the contract (because maybe someone has finished it in the meantime), cancel adding to the bounty
    # 2) Else, add to the target's bounty, but let the player know that he/she has not become the client of the contract
    - ^if "<flag.p:Assassination Target>" !== "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1] || 0>"
      runtask "script:Assassination Handler Client Bounty Increase Failed" instantly
      else runtask "script:Assassination Handler Client Bounty Increase Succeeded" instantly

"Assassination Handler Client Bounty Increase Failed":
    type: task

    script:
    - ^chat "<white>It seems there is no longer a contract on <yellow><flag.p:Assassination Target><white>. Keep your money."
    # Delete temporary contract flags
    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Client Bounty Increase Succeeded":
    type: task

    script:
    # Add the money offered by the player to the contract's bounty
    - ^flag global "Assassination Contract <flag.p:Assassination Iterator.asint>[2]:+:<flag.p:Assassination Bounty>"
    - ^flag global "Assassination Contract <flag.p:Assassination Iterator.asint>[2]:<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>.asint[2]>"
    # Take the bounty from the player
    - ^take money "qty:<flag.p:Assassination Bounty>"
    # There are 4 possibilities here
    # 1) If the player originally created this contract, and he/she is the target, mention that the player is adding bounty to his/her old contract on himself/herself
    # 2) Else, if the player is the target of the contract, mention that the player is adding bounty to himself/herself
    # 3) Else, if the player originally created this contract, mention that fact
    # 4) Else, let the player know that he/she is not the creator of the contract and will not be informed when it is finished
    - ^if "<player.name>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[3]>" && "<player.name>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      chat "<white>You have added to your former bounty on <yellow>yourself<white> and made it <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[2]> <white><player.money.currency>. You must surely have a death wish."
      else if "<player.name>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]>"
      chat "<white>You have contributed to the bounty on <yellow>your life <white> and made it <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[2]> <white><player.money.currency>. Trying to quicken your death, are you?"
      else if "<player.name>" == "<flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[3]>"
      chat "<white>You have added to your former bounty on <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]><white> and made it <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[2]> <white><player.money.currency>."
      else chat "<white>You have added to the bounty on <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[1]><white>'s head and made it <yellow><flag.g:Assassination Contract <flag.p:Assassination Iterator.asint>[2]> <white><player.money.currency>. However, be advised that because you are not the original client of the contract, we will not let you know when it is finished."
    # Let all players know that the bounty on this target has been increased, but only if the added bounty is at least larger than the handler's fee (to avoid spam)
    - ^if "<flag.p:Assassination Bounty>" >= "<cons:Assassination Handler Contract Fee>"
      announce "<red>The bounty on <yellow><flag.p:Assassination Target> <red>has been increased by <yellow><flag.p:Assassination Bounty.asint> <red><player.money.currency>!"
    # Delete temporary contract flags
    - ^runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Client Give Refund":
    type: task

    script:
    # Set the refund to the handler's fee
    - ^flag player "Assassination Refund:<cons:Assassination Handler Contract Fee>"
    # Then add the bounty to the refund
    - ^flag player "Assassination Refund:+:<flag.p:Assassination Bounty>"
    # Give back the money
    - ^give money "qty:<flag.p:Assassination Refund.asint>"
    - ^narrate "<red>You have received a refund of <yellow><flag.p:Assassination Refund.asint> <player.money.currency>."

"Assassination Handler Client Contract Already Exists":
    type: task

    script:
    # Give refund to player
    - runtask "script:Assassination Handler Client Give Refund" instantly
    # Explain what has happened
    - ^chat "<white>Another contract has already been placed on <yellow><flag.p:Assassination Target><red>'s life, and we cannot accept more than one contract on the same target."
    # Delete temporary contract flags
    - runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Client Contracts Full":
    type: task

    script:
    # Give refund to player
    - runtask "script:Assassination Handler Client Give Refund" instantly
    # Explain what has happened
    - ^chat "<white>I have just learned through scrying magic that, while we were discussing your placement of a new contract, our guild reached the maximum number of contracts we allow at once. Return in the future and we may have room for yours."
    # Delete temporary contract flags
    - runtask "script:Assassination Handler Delete Temporary Contract Flags" instantly

"Assassination Handler Delete Temporary Contract Flags":
    type: task

    script:
    # Deleting temporary value-storing flags because we no longer need them
    - ^flag player "Assassination Iterator:!"
    - ^flag player "Assassination Target:!"
    - ^flag player "Assassination Bounty:!"
    - ^flag player "Assassination Refund:!"
    - ^flag player "Assassination Displayed Contracts:!"
    - ^flag player "Assassination Placed Contracts:!"

"Assassination Handler Delete Temporary Tracking Flags":
    type: task

    script:
    # Deleting temporary value-storing tracking flags because we no longer need them
    - ^flag player "Assassination Target Location:!"
    - ^flag player "Assassination Target Distance:!"
    - ^flag player "Assassination Target Additional Info:!"
    - ^flag player "Assassination Target Skylight:!"
    - ^flag player "Assassination Target Light:!"
    - ^flag player "Assassination Target Y:!"
    - ^flag player "Assassination Target Holding:!"
    - ^flag player "Assassination Target World:!"




Comments
2013-02-26 17:42:00 - hevydani:

I cannot get this script to work. Using CB 1.4.7, citizens 2.0.7, denizens 0.7.6. Upon left-click, nothing, upon right-clicking the NPC just says "I have nothing else for you right now". Here is my assignment.yml - http://pastebin.com/XmDSHMPk I'm creating the NPC using; /npc create Sephillion --trait denizen Any help would be appreciated
2013-02-26 17:54:37 - hevydani:

I cannot get this script to work. Using CB 1.4.7, citizens 2.0.7, denizens 0.7.6. Upon left-click, nothing, upon right-clicking the NPC just says "I have nothing else for you right now". Here is my assignment.yml - http://pastebin.com/XmDSHMPk I'm creating the NPC using; /npc create Sephillion --trait denizen Any help would be appreciated
2013-02-26 17:56:22 - hevydani:

Sorry about the double post, it posted again when I refreshed the page. I've now updated to denizen 0.8 and the latest citizens build. Still not working, now the NPC does nothing atall, doesn't wander, respond to left or right clicks, nothing.
2013-02-26 18:26:58 - hevydani:

Ok now I finally have him registered with that assignment, but typing "take" or "place", does nothing.
2013-02-26 19:00:07 - hevydani:

http://pastebin.com/iH0nTDva
2013-03-01 00:23:29 - davidcernat:

hevydani, did you notice this script is for Denizen 0.88?
2013-03-01 00:55:45 - davidcernat:

That means you should make sure other, basic scripts for 0.88 work for you. If they don't, that means you're having problems with scripts in general. Anyway, try deleting your Denizen\config.yml and see if that helps.
2013-04-12 10:08:58 - Harrygo:

Your dialogue for the contract "on yourself" is just awsome ! "Back from the dead, Harrygo ? Maybe you should not place contracts on yourself in the future." XD
2013-04-24 02:08:15 - danton1983:

Can someone make it so the bountied player has to pay off their bounty?
2013-08-09 08:48:31 - superpercy1990:

Hey davidcernat or anybody else who can help me. I am trying to get the script to work. I get to the stage where I input a name to be killed then nothing happens. Hope someone can help. Thanks Percy
2013-08-09 09:40:07 - superpercy1990:

Hey davidcernat or anybody else who can help me. I am trying to get the script to work. I get to the stage where I input a name to be killed then nothing happens. Hope someone can help. Thanks Percy
2013-08-09 10:24:07 - superpercy1990:

Hey davidcernat or anybody else who can help me. I am trying to get the script to work. I get to the stage where I input a name to be killed then nothing happens. Hope someone can help. Thanks Percy
2013-08-09 12:23:59 - superpercy1990:

Hey davidcernat or anybody else who can help me. I am trying to get the script to work. I get to the stage where I input a name to be killed then nothing happens. Hope someone can help. Thanks Percy