Paste #5956: PeaceKeeper

Date: 2014/06/29 03:48:05 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"PeaceKeeper":

    type: assignment

    default constants:
        # Name of the Town used for NPC text option.
        town: Fryllnas

        # List of all weapon ID numbers used in the script for guard recognition
        weapons: 267|268|272|276|283|271|275|258|279|286|261

    interact scripts:
    - 10 Peace Keeper

    actions:
        on assignment:
        # These are the basic triggers used in most NPC's.
        - trigger name:chat toggle:true
        - trigger name:click toggle:true
        - trigger name:proximity state:true range:7
        # Make the NPC warn the player who push him.
        on push:
        - run "script:warningPush"


"Peace Keeper":

    type: interact

    steps:
    # This step is a Jumping off point for ways the NPC interacts with you. By placing different types of triggers
    # inside of the steps it can be a way to make One character more varried.
        '1':
            proximity trigger:
                entry:
                    script:
                    # When a player enters the Proximity Range it will fire a script located lower down.
                    - run "script:welcomeCheck"
            click trigger:
                script:
                - random 4
                - chat "Bonjour <player.name>."
                - chat "Hello."
                - chat "Est-ce que tout va bien ?"
                - chat "<player.name> puis-je vous aider ?"

#
#
# This is the start of the task script section for the weapons check.
#
#
"welcomeCheck":
    type: task
    script:
    # In this section the NPC uses the constant list of weapons to identify if a player is armed and then runs another set of scripts containing a warning.
    - if <cons:weapons> contains <player.item_in_hand.id> run "script:warning"
        else run "script:welcome"

#
# Here is the welcome that you would recieve if you do not have a weapon when approaching the NPC.
#
"welcome":
    type: task
    script:
    - random 5
    - chat "Bienvenue a <cons:town> <player.name>."
    - chat "<cons:town> vous souhaite la bienvenue <player.name>."
    - chat "<cons:town> est un endroit paisible, gardez le ainsi s'il vous plait."
    - chat "<player.name> appreciez vous <cons:town> ?"
    - chat "Bienvenue <player.name>."

#
# This is the alternate welcome you recieve if you put away a weapon that was held when approached
#
"thank":
    type: task
    script:
    - random 3
    - chat "Merci et bienvenue a <cons:town>."
    - chat "<cons:town> Vous remercie pour votre respect."
    - chat "J'apprecie votre honneur <player.name>."

#
# This script is the start of the warning you get for having a weapon.
#
"warning":
    type: task
    script:
    - chat "Soyez averti<player.name>, <cons:town> n'autorise pas le port d'arme dans les rues."
    - wait 1
    - chat "Vous avez cinq secondes pour la ranger."
    - run "script:5"

"5":
    type: task
    script:
    - wait 1
    - if <cons:weapons> contains <player.item_in_hand.id> run "script:4"
        else run "script:thank"

"4":
    type: task
    script:
    - wait 1
    - if <cons:weapons> contains <player.item_in_hand.id> run "script:3"
        else run "script:thank"

"3":
    type: task
    script:
    - wait 1
    - if <cons:weapons> contains <player.item_in_hand.id> run "script:2"
        else run "script:thank"

"2":
    type: task
    script:
    - wait 1
    - if <cons:weapons> contains <player.item_in_hand.id> run "script:1"
        else run "script:thank"

"1":
    type: task
    script:
    - wait 1
    - if <cons:weapons> contains <player.item_in_hand.id> run "script:0"
        else run "script:thank"

"0":
    type: task
    script:
      - run "Player_Raise_Debt" "def:20"
      - random 3
      - chat "Tu es redevable de <proc:Player_Get_Debt> envers <cons:town>."
      - chat "Ta dette pour cette ville augmente de 20 or !"
      - chat "20 or en plus pour les caisses de la ville."

"Player_Raise_Debt":
    type: task
    script:
    - define "max" 200
    - define "min" 0
    - run "Add_Limited_Player" "def:Debt_<cons:town>|%1%|%min%|%max%"

"Player_Set_Debt":
    type: task
    script:
    - flag player "Debt_<cons:town>:%1%"

"Player_Get_Debt":
    type: procedure
    script:
    - ^if <player.flag[Debt_<cons:town>]> == null flag player "Debt_<cons:town>:0"
    - determine <player.flag[Debt_<cons:town>]>
"Add_Limited_Player":    
    type: task
    context: value
    script:
    - ^if <player.flag[%1%]> == null flag player "%1%:%2%"
        else flag player "%1%:+:%2%"
    # clip value
    - ^if <player.flag[%1%]> > %4% flag player "%1%:%4%"
       else if <player.flag[%1%]> < %3% flag player "%1%:%3%"