Paste #22386: Talker

Date: 2015/11/08 04:34:59 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"Talker":
    type: assignment

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

    interact scripts:
    - 10 Talker_i


Talker_i:
    type: interact

    steps:
        First*:
            proximity trigger:
                Entry Radius: 5
                Exit Radius: 4
                Entry:
                    Script:
                    #The player enters on radius, so the NPC asks a question
                    - random {
                      - CHAT 'Hello <player.name> welome, how are you today?'
                      - CHAT 'Hello <player.name> welome, how do you feel?'
                      - CHAT 'Hi <player.name> welcome, I am having a great day how about you?'
                      - CHAT 'Hello <player.name> Hi, I am so fed up with this job!'
                    }
                    #The NPC waits for the answer, we set the flag to stop the movement and call the task to stop/move the NPC
                    - flag npc "AllowedToMove:0"
                    - ZAP 'SCRIPT:Talker_i' step:Second
                    - run Wait_on_place instantly


        Second:
            chat trigger:
                1:
                    Trigger: /fine/ thank you
                    script:
                    #If the player answers, the NPC says something and change the flag to keep moving
                    - CHAT "Nice to know"
                    - flag npc "AllowedToMove:1"
                    - cooldown 30s s:s@Talker_i
                    - ZAP 'SCRIPT:Talker_i' step:First

                2:
                    Trigger: very /good/ and you?
                    script:
                    - CHAT "Ohh Im great"
                    - flag npc "AllowedToMove:1"
                    - cooldown 30s s:s@Talker_i
                    - ZAP 'SCRIPT:Talker_i' step:First

                3:
                    Trigger: /ok/ i think?
                    script:
                    - random {
                      - CHAT "I am ok"
                      - CHAT "I fine thank you"
                      - CHAT "Don't ask"
                      - CHAT "<player.name>, I am good, have fun!"
                      - CHAT "<player.name>, I am ok"
                    }
                    - flag npc "AllowedToMove:1"
                    - cooldown 30s s:s@Talker_i
                    - ZAP 'SCRIPT:Talker_i' step:First

                #unexpected answer
                4:
                    Trigger: /REGEX:\w+/
                    script:
                    - random {
                      - CHAT "Sorry, I did not understand"
                      - CHAT "Sorry, I did not understand, ifeel so stupid."
                      - CHAT "<player.name> you make no sense"
                      - CHAT "<player.name>, Sorry, I did not understand, I am only a robot."
                      - CHAT "<player.name>, screw you."
                    }
                    - flag npc "AllowedToMove:1"
                    - cooldown 30s s:s@Talker_i
                    - ZAP 'SCRIPT:Talker_i' step:First

Wait_on_place:
  Type: Task
  Script:
  - flag npc "wait_xposwait:<npc.location.x>"
  - flag npc "wait_xposwait:++"
  - flag npc "wait_maxwaiting:0"
  - if <flag.n:AllowedToMove> == 0 run Wait_on_place_loop

Wait_on_place_loop:
  Type: Task
  Script:
  - walk "location:<flag.n:wait_xposwait>,<npc.location.y>,<npc.location.z>,Factions" "speed:0.00001"
  - flag npc "wait_maxwaiting:++"
  - if <flag.n:wait_maxwaiting> == 12 flag npc "AllowedToMove:1"
  - if <flag.n:AllowedToMove> == 0 run Wait_on_place_loop