Paste #39621: Repeatable Quest

Date: 2017/02/05 20:41:40 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Kill the skeletons
# Citizens 2 (build #1045)
# Denizen 0.9.3 (build #1417)
#
# This will ask the player to kill a few skeletons and will reward them for doing so.
#
# It uses the "listen" command to determine whether the player has killed
# any skeletons, but unfortunately doesn't allow control over WHERE the skeletons have been killed.
#
# The quest repeat timeout constant value below will control how often the 
# player can repeat the quest. It's on 24 hours currently.
#
# NOTE: This requires an economy to deal with 'money' as a method of reward.
#
# @author mythanical
# @script version 1.0.3
# @last-updated 12 January 2014
# @irc EsperNet IRC Network #denizen-dev
# @Minecraft Server - minecraft.geek.nz
# @Donate Bitcoin: 1Fzacc2gZ5NGRMXg5jWP6NcUkWei34xjzt
# @Donate Litecoin: LhsaGa1QzmVLjMYwg4ZPTVnmSgnBDGc75U

Jack:
  type: assignment

  default constants:

    # Number of skeletons that must be killed for quest to be completed
    skeletonsQty: 10
    # The reward (money) for killing the skeletons
    RewardAmount: 1000
    # The time in between each repeat of the quest (currently set at 24 hours)
    Quest Repeat Timeout: 1200
    # Reset all quest progress (this is in case quest gets stuck or if the 'kill listener' stops 'listening'
    Quest Reset Timeout: 4800
    # Name of your town, used in some dialog options.
    Townname: 'Noxville'

  interact scripts:
  - 10 Killing the skeletons

  actions:
    on assignment:
    - trigger name:chat toggle:true
    - trigger name:click toggle:true
    - trigger name:proximity toggle:true

"Killing the skeletons":
  type: interact

  steps:
    1:

      click trigger:
        script:
        # On clicking, run a slightly different script to check requirements before starting quest.
        - run "skeletonkiller Quest Requirement"

    2:
      chat trigger:
        'Start Questline':
          Trigger: /Yes/, I will help you.
          script:
          # If the player answer 'yes', this will set the quest flag to started and also start 'listening' for the player
          # killing skeletons and once the player killed the number of skeletons specified at the top of the script, it will run
          # the 'skeletonkiller Quest Completed' script.
          - engage
          - flag <player> skeletonkiller:Started "duration:<npc.constant[Quest Reset Timeout]>"
          - listen kill "id:skeletonkiller Listener" type:entity qty:<npc.constant[skeletonsQty]> target:skeleton "script:skeletonkiller Quest Completed"
          - narrate "<red>Jack: <yellow>Thank you so much! come back to me once you've killed <npc.constant[skeletonsQty]> skeletons."
          - narrate "<red>Exterminate 10 skeletons - Quest Started"
          - disengage

        'Deny Questline':
          Trigger: /No/, I have better things to do.
          script:
          # If the player says 'no', then display one of the following 3 messages and put them back at Step 1 for 'Killing
          # the skeletons' script.
          - random {
            - narrate "<red>Jack: <yellow>Just leave me then. You little bitch."
            - narrate "<red>Jack: <yellow>I bet your glad my dog is dead. You dick head."
            - narrate "<red>Jack: <yellow>You heartless little piece of shit. Fuck off." }
          - zap step:1

      proximity trigger:
        exit:
          script:
          # If they exit the proximity trigger for the NPC, put them back at Step 1 so they get presented with the
          # relevant options when they come back later.
          - zap step:1

      click trigger:
        script:
        # This is simply to present the options again if the player accidentally clicks the NPC, rather than type a response.
        - run "skeletonkiller Quest Requirement"

"skeletonkiller Check Requirements":
  type: task

  script:
  # The following options exist here
  # 1) If the player is holding a sword in their hand, the NPC will run the 'Deny Interaction' script until the player put
  #  their weapon away.
  # 2) The next if statement checks to see if the quest has been flagged as 'Started', if so tell them to come back when all the skeletons
  #  have been killed.
  # 3) Otherwise if the flag is set to 'ClaimReward', tell the player to come get the reward.
  # 4) Lastly, if none of the 'if' statements are met, simply present them with the general chat dialog.
  - if 0 contains <player.item_in_hand.id> run
    else if <player.flag[skeletonkiller]> == Started narrate "<red>Jack: <yellow> Hey <player.name><yellow>, please come back to me when you've killed all <npc.constant[skeletonsQty]><yellow> skeletons!"
    else if <player.flag[skeletonkiller]> == Claimed chat "<yellow>Thanks for your help <player.name>. It really means alot. please come back later to help me again. We will exterminate all the skeletons in this world."
    else run "skeletonkiller General Chat"

"skeletonkiller Quest Requirement":
  type: task

  script:
  # This part is for when the player clicks the NPC. The options that exist are the same as the
  # check requirements above except this time if the skeletonkiller flag is on 'ClaimReward', it will run the 'skeletonkiller Quest
  # Completed Reward' script further below.
  - if 0 contains <player.item_in_hand.id> run 
    else if <player.flag[skeletonkiller]> == Started narrate "<red>Jack: <yellow> Hey <player.name><yellow>, please come back to me when you've killed all <npc.constant[skeletonsQty]><yellow> skeletons!"
    else if <player.flag[skeletonkiller]> == Claimed chat "<yellow>I thank you for your help <player.name><yellow>, please come back in <red><player.flag[skeletonkiller].expiration.formatted><yellow> to help me again."
    else if <player.flag[skeletonkiller]> == ClaimReward run "skeletonkiller Quest Completed Reward"
    else run "skeletonkiller Present Quest"

"skeletonkiller Present Quest":
  type: task

  script:
  # This part presents the player with the quest, giving them some details via random dialog options
  # and then asks them to answer 'yes' or 'no' before 'zapping' them to Step 2 in the script 'Killing the skeletons'
  # where it's waiting for the player to type something.
  - random {
    - narrate "<red>Jack: <yellow>Hey Man. I was out with my dog and we got ambushed by a bunch of skeletons. They killed my dog. His name was Fluffy. Avenge him. Please. Will you do that for me?"
    - narrate "<red>Jack: <yellow>Hey dude like my dog got killed by a bunch of skeletons can you kill some for me?"
    - narrate "<red>Jack: <yellow>Hey. I need you to do me a favor those stupid skeletons killed fluffy. They shot him right through the head. Dont let him die in vain. Kill some for me."
    - narrate "<red>Jack: <yellow>Skeletons killed my only friend. He was only trying to protect me. Will you help me banish some skeletons to the nether?"
    - narrate "<red>Jack: <yellow>My only friends name was fluffy. He was my dog. Skeletons shot him and I couldnt heal him fast enough. Kill a bunch of them for me." }
  - random {
    - narrate "<red>Jack: <yellow>I will pay you <gold><npc.constant[RewardAmount]><yellow> <player.money.currency>dollars if you kill <red><npc.constant[skeletonsQty]><yellow> skeletons for me."
    - narrate "<red>Jack: <yellow>I can give you <gold><npc.constant[RewardAmount]><yellow> <player.money.currency>dollars for killing <red><npc.constant[skeletonsQty]><yellow> skeletons. will you do it?"
    - narrate "<red>Jack: <yellow>If you kill <red><npc.constant[skeletonsQty]><yellow> skeletons I will give you <gold><npc.constant[RewardAmount]><yellow> <player.money.currency>dollars. Are you going to help me or not?" }
  - narrate "<red>Say<&co>"
  - ^narrate "  <blue>Yes<blue> <gray>or<red> No"
  - ^zap "s@Killing the skeletons" step:2

"skeletonkiller Quest Completed":
  type: task

  script:
  # When the 'listen' command detects the necessary quantity of skeletons killed, it will run this scripts and also
  # update the flag to 'ClaimReward' which the NPC will check to decide if the user should be rewarded.
  - narrate "<red>Exterminate skeletons - Quest Completed."
  - ^flag <player> skeletonkiller:ClaimReward

"skeletonkiller Quest Completed Reward":
  type: task

  script:
  # This is the part where the flag expiry duration is determined from the constant value you set at the top of the script. After that
  # time, the flag expires and the quest can be done again. In this section the player is also rewarded (money) by the quantity specified
  # above.
  - ^flag <player> skeletonkiller:Claimed "duration:<npc.constant[Quest Repeat Timeout]>"
  - random {
    - narrate "<red>Jack: <yellow>Haha good job <player.name> you got those skeletons good! You can come back and kill some more of those bastards later."
    - narrate "<red>Jack: <yellow>You did good <player.name>, that will teach those damn skeletons! You can come back and help me again some other time."
    - narrate "<red>Jack: <yellow>Holy shit you did it <player.name> but remember they respawn so come back later and you can help me again. }
  - ^give money qty:<npc.constant[RewardAmount]>
  - ^narrate "<red>Jack pays you <red><npc.constant[RewardAmount]><red><player.money.currency> dollars."