Paste #6973: SpiderQuest

Date: 2014/07/16 07:46:03 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Kil the Spiders
# Citizens 2 (build #1045)
# Denizen 0.9.3 (build #1417)
#
# This will ask the player to kill a few bats and will reward them for doing so.
#
# It uses the "listen" command to determine whether the player has killed
# any bats, but unfortunately doesn't allow control over WHERE the bats 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.


"Araignees":
  type: assignment

  default constants:

    # Nombre d'araignees a tuer pour achever la quete
    SpiderQty: 16
    # La recompense monetaire pour avoir tue les araignees
    RewardAmount: 3000
    # Temps de delai avant repetition de la quete
    Quest Repeat Timeout: 86400
    # Reinitialise la quete au bout de 24h (this is in case quest gets stuck or if the 'kill listener' stops 'listening'
    Quest Reset Timeout: 86400
    # Nom de la ville, utilisee par plusieurs options de dialogue.
    Townname: 'Fryllnas'

  interact scripts:
  - 10 Killing the Spiders

  actions:
    on assignment:
    - trigger name:chat toggle:true
    - trigger name:click toggle:true
    - trigger name:proximity toggle:true
    - trigger name:damage toggle:true
    # Make the NPC so they can be killed by the player. They will respawn a few seconds later.
    - execute as_npc "npc sel <npc.id>"
    - execute as_npc "npc vulnerable"

"Killing the Spiders":
  type: interact

  steps:
    '1':
      proximity trigger:
        entry:
          script:
          # On player entering proximity range, run a script (located further down).
          - run "Spiderkiller Check Requirements"

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

      damage trigger:
        script:
        # When you hit the NPC, it will run the script called Spiderkiller Warning (further below).
        - run "Spiderkiller Warning"

    '2':
      chat trigger:
        'Start Questline':
          Trigger: /Oui/, ca m'interesse, quand commence-t-on?
          script:
          # If the player answer 'yes', this will set the quest flag to started and also start 'listening' for the player
          # killing spiders and once the player killed the number of spiders specified at the top of the script, it will run
          # the 'Spiderkiller Quest Completed' script.
          - engage
          - flag <player> SpiderKiller:Started "duration:<npc.constant[Quest Reset Timeout]>"
          - listen kill "id:Spiderkiller Listener" type:entity qty:<npc.constant[Spiderty]> target:spider "script:Spiderkiller Quest Completed"
          - chat "Parfait! Ne revenez me voir uniquement quand vous aurez tue <npc.constant[BatsQty]> araignees."
          - narrate "<red> La quete 'Les airaignees, tuez les toutes!' a commence"
          - disengage

        'Deny Questline':
          Trigger: /Non/, cela m'importe peu.
          script:
          # If the player says 'no', then display one of the following 3 messages and put them back at Step 1 for 'Killing
          # the Bats' script.
            - random 3
            - chat "Ah d'accord, ne venez pas pleurer quand l'une d'entre elle viendra pondre ses oeufs en vous..Je sens que vous serez un nid parfait pour leurs petits."
            - chat "Dommage. Revenez me voir si vous changez d'avis."
            - chat "Vous auriez pu avoir une belle somme en recompense de votre travail, revenez me voir si l'envie vous vient."
          - 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 "Spiderkiller Quest Requirement"

      damage trigger:
        script:
        - run "Spiderkiller Warning"

"Spiderkiller 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 bats
  #  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 267|268|272|276 contains <player.item_in_hand.id> run "Deny Interaction"
    else if <player.flag[SpiderKiller]> == Started chat "Bonjour <player.name>, revenez me voir quand vous aurez tue  <red><npc.constant[SpiderQty]><red> araignees!"
    else if <player.flag[SpiderKiller]> == ClaimReward chat "<player.name>, approchez!Et veuillez accepter ce modeste present, votre aide m'a ete precieuse!"
    else if <player.flag[SpiderKiller]> == Claimed chat "<player.name>, pensez a revenir de temps en temps pour m'aider, ce sera avec bon coeur que je vous recompenserai."
    else run "Spiderkiller General Chat"

"Spiderkiller General Chat":
  type: task

  script:
  # These are the general chats that come up when the player walks into proximity range.
    - random 7
    - chat "Et il a dit 'Elle mange des rats!'. Hahahaha.. oh, pardon. Je ne vous avais pas vu <player.name>."
    - chat "Qu'y a-t-il de mieux qu'une araignee? une araignee avec une epee plantee dans l'abdomen."
    - chat "Parfois je deteste mon travail, mais alors je me dit 'Non <npc.name> , tu aimes ce boulot' et je l'aime a nouveau."
    - chat "Rats, araignees, chats et autres nuisibles. Je les tue tous.. c'est genial! Je suis paye a chasser ma propre nourriture!"
    - chat "Le plus desagreable, c'est le sang de ces bestioles qui reste s'incruste dans les vetements. Je doit les laisser 3jours dans une eau savoneuse pour esperer les laver."
    - chat "Leurs mandibules me repugnent quand elles les font bouger, mais grillees au feu de bois c'est excellent!"
    - chat "Encore une journee a exterminer cette vermine..ou nuit, je ne sais plus, je n'y voit rien ici a vrai dire, vous le savez-vous?"

"Spiderkiller Warning":
  type: task

  script:
  # When you hit (damage) the NPC, they will respond with one of the following lines.
    - random 5
    - chat "<red>Oucch! Pourquoi faites-vous ça? Si je meurt, vous le regretterez!"
    - chat "<red>Aaarrggg! Ne me frappez plus ou je crie!"
    - chat "<red>Quo..Pourquoi me blessez-vous? Oh, Vous finirez par me le payer ."
    - chat "<red>Pitie, arretez cette violence! Je ne vous ai rien fait de mal, moi!"
    - chat "<red>Owwee! Arretez ou j'appelle les gardes..!" 

"Deny Interaction":
  type: task

  script:
  # If the player has a weapon, the NPC will say one of the following things.
    - random 5
    - chat " He, pourquoi vous venez me voir avec cette arme? Voyons, rengainez-la avant de tenter de me parler, je pourrais mal le prendre."
    - chat " C'est..c'est une epee? Pitie, ne me frappez pas! Vous pourriez le regretter."
    - chat " Je ne suis pas un de ces nuisibles, rangez-votre epee voyons!"
    - chat " Est-ce une politesse de pointer son arme sur la personne avec qui l'on parle d'ou vous venez?"
    - chat " Vous croyez qu'il est necessaire d'avoir une arme ici? Ou devons-nous nous engager dans une joute mortelle pour vous apprendre la courtoisie?" 

"Spiderkiller Quest Requirement":
  type: task

  script:
  - if 267|268|272|276 contains <player.item_in_hand.id> run "Deny Interaction"
    else if <player.flag[SpiderKiller]> == Started chat "Salutations <player.name>, s'il vous plait, revenez me voir quand vous aurez tue <<npc.constant[SpiderQty]> araignees!"
    else if <player.flag[SpiderKiller]> == Claimed chat "Merci de votre aide <player.name>, pensez a revenir me voir de temps en temps <player.flag[BatKiller].expiration.formatted> pour m'aider a nouveau."
    else if <player.flag[SpiderKiller]> == ClaimReward run "Spiderkiller Quest Completed Reward"
    else run "Spiderkiller Present Quest"

"Spiderkiller 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 Bats'
  # where it's waiting for the player to type something.
    - random 5
    - chat "Salut <player.name>! Pouvez-vous m'aider a exterminer ces maudites araignees?"
    - chat "Oh bonjour <player.name>, il y a pas mal d'airaignees par ici. Pourriez-vous en tuer quelques unes pour moi?"
    - chat "Les araignees... elles sont partout! Their squeaky high-pitched noises driving me nuts. Kill some for me?"
    - chat "Ces bestioles transmettent des maladies! Notre ville a besoin de les exterminer, pouvez-vous m'aider?"
    - chat "Vous entendez ces cliquetis, se sont de araignees, seriez-vous pret a partir a la chasse aux arthropodes avec votre epee?" 
    - random 3
    - chat "Je vous payerai <npc.constant[RewardAmount]> <player.money.currency> si vous tuez <red><npc.constant[BatsQty]><yellow> araignees pour moi."
    - chat "Ces <npc.constant[RewardAmount]> <player.money.currency> sonnent assez pour que vous alliez tuer <red><npc.constant[BatsQty]><yellow> araignees?"
    - chat "La recompense pour avoir tue <red><npc.constant[BatsQty]><yellow> araignees est de <npc.constant[RewardAmount]> <player.money.currency>. Interesse?"
  - narrate "<red>Say<&co>"
  - ^narrate "  <blue>Yes<blue> <gray>or<red> No"
  - ^zap "s@Killing the Spiders" step:2

"Spiderkiller Quest Completed":
  type: task

  script:
  # When the 'listen' command detects the necessary quantity of bats 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 Bats - Quest Completed. Return to <aqua><npc.name><red> to claim your reward."
  - ^flag <player> BatKiller:ClaimReward

"Spiderkiller 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.
    - random 3
    - chat "Haha, bon travail <player.name>, vous en avez terrasse un bon nombre! Vous pouvez revenir demain si vous le souhaitez."
    - chat "Bien joue <player.name>, c'est ce qui s'appelle exterminer! Vous pourrez revenir des demain pour m'aider a nouveau."
    - chat "Fantastique <player.name>, mais leurs petits sortiront demain. S'il vous plait, revenez demain et je vous payerai pour ce service."
  - ^flag <player> BatKiller:Claimed "duration:<npc.constant[Quest Repeat Timeout]>" 
  - ^give money qty:<npc.constant[RewardAmount]>
  - ^narrate "<white><npc.name> vous paie <gold><npc.constant[RewardAmount]><white> <player.money.currency>."