Paste #38: dTravelers 1.0

Date: 2013/10/19 20:36:51 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# dTravelers: NPCs to help you travel around the world!
# 
# To create a dTraveler:
# /npc create [Name]                        ## [Name] is the name of the NPC
# /npc assign --set dtraveler_assign        ## All literal
# /dtraveler name [NameOfTravelLocation]    ## [NameOfTravelLocation] is what you want to call this location
#                                           ## Remember not to give two NPC's the same name!
# Player interaction:
# Click on a traveler to unlock it.
# You can speak the name of any travel location to a traveler to go there.
# You can also say 'list' to a traveler to see what locations you've unlocked.
# 
# Commands:
# /dtraveler name [NameOfTravelLocation] ## Sets the name of an NPC's travel location
# 
# Permissions:
# denizen.scripts.dtravelers - Admin control of the dtravelers
# 
# Other:
# Author: mcmonkey4eva
# EMail: mcmonkey4eva@hotmail.com
# Website: http://mcmonkey4eva.dyndns.org/mcserver
# Version: Denizen 0.9.2

dtraveler_world_commands:
    type: world
    events:
        on dtraveler command:
        - DETERMINE passively fulfilled
        - IF <player> == "null" {
          - QUEUE clear
          }
        - IF <player.has_permission[denizen.scripts.dtravelers]> != "true" {
          - NARRATE format:dtraveler_format_warning "You do not have permission to use this command."
          - QUEUE clear
          }
        - IF <player.selected_npc> == "null" {
          - NARRATE format:dtraveler_format_warning "You must have an NPC selected."
          - QUEUE clear
          }
        - IF <context.args.size> == 2 && <context.args.get[1]> == "name" {
          - FLAG entity:<player.selected_npc> dtraveler_name:<context.args.get[2]>
          - NARRATE format:dtraveler_format_valid "<player.selected_npc.name><&2>'s location name set to <context.args.get[2]><&2>."
          - QUEUE clear
          }
        - NARRATE format:dtraveler_format_warning "Incorrect command arguments..."
        - NARRATE "<&c>/dtraveler name [NameOfTravelLocation]"

dtraveler_assign:
    type: assignment
    actions:
        on assignment:
        - TRIGGER name:click state:true
        - TRIGGER name:chat state:true
    interact scripts:
    - 10 dtraveler_interact_main

dtraveler_interact_main:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - IF <player.flag[dtraveler_named_<npc.flag[dtraveler_name]>]> != "true" {
                  - FLAG player dtraveler_named_<npc.flag[dtraveler_name]>:true
                  - FLAG player dtraveler_list:->:<npc.flag[dtraveler_name]>
                  - FLAG player dtraveler_locat:->:<npc.location.add[1,0,1]>
                  - IF <player.flag[dtraveler_list_text]> == "null" {
                    - FLAG player "dtraveler_list_text:<npc.flag[dtraveler_name]>"
                    }
                    else {
                    - FLAG player "dtraveler_list_text:<player.flag[dtraveler_list_text]>, <npc.flag[dtraveler_name]>"
                    }
                  - NARRATE format:dtraveler_format_valid "You've found a new travel location!"
                  - PLAYSOUND <player.location> level_up
                  }
                - CHAT "<&2>Hello there, <player.name>!"
                - WAIT 1
                - CHAT "<&2>I'm <&b><npc.name.nickname><&2>, the official travel master of <&b><npc.flag[dtraveler_name]><&2>!"
                - WAIT 2
                - CHAT "<&2>My job is to take you places you've been before. Simply name the place and I'll get you there."
                - ^FLAG player dtraveler_hasresponded:false
                - RUN dtraveler_task_hello delay:10s
            chat trigger:
                1:
                    trigger: "I need to see a /list/ of what places I've unlocked..."
                    script:
                    - ^FLAG player dtraveler_hasresponded:true
                    - CHAT "<&2>If I've heard right, you've been to the following locations<&co>"
                    - NARRATE "<player.flag[dtraveler_list_text]>"
                    - WAIT 2
                    - CHAT "<&2>So... which one would you like to go to?"
                2:
                    trigger: "/REGEX:.+/"
                    script:
                    - ^FLAG player dtraveler_hasresponded:true
                    - WAIT 1
                    - ^FLAG player dtravel_success:false
                    - ^IF <player.chat_history> contrains <npc.flag[dtraveler_name]> {
                      - ^CHAT "<&2>We're already there!"
                      - ^QUEUE clear
                      }
                    - ^REPEAT <player.flag[dtraveler_list].aslist.size> {
                      - ^IF <player.chat_history> contains <player.flag[dtraveler_list].aslist.get[%value%]> {
                        - ^CHAT "<&2>To <player.flag[dtraveler_list].aslist.get[%value%]>? Alright then..."
                        - ^FLAG player dtraveler_target:<player.flag[dtraveler_locat].aslist.get[%value%]>
                        - ^RUN dtraveler_task_travel
                        - ^FLAG player dtravel_success:true
                        }
                      }
                    - ^IF <player.flag[dtravel_success]> != "true" {
                      - ^CHAT "<&2>You haven't unlocked such a location."
                      }
                    - WAIT 1
                    - IF <player.flag[dtravel_success]> != "true" {
                      - NARRATE format:dtraveler_format_valid "If you've forgotten where you've been, just say <&b>list<&2> to the travel master!"
                      }

dtraveler_task_hello:
    type: task
    script:
    - IF <player.flag[dtraveler_hasresponded]> == "true" {
      - QUEUE clear
      }
    - IF <player.location.distance[<npc.location>]> > 20 {
      - QUEUE clear
      }
    - NARRATE format:dtraveler_format_valid "If you've forgotten where you've been, just say <&b>list<&2> to the travel master!"

dtraveler_task_travel:
    type: task
    script:
    - NARRATE format:dtraveler_format_valid "Traveling..."
    - ^PLAYSOUND <player.location> portal_travel
    - ^PLAYEFFECT <player.location> large_explode
    - ^CAST blindness duration:5s
    - CAST confusion duration:8s
    - WAIT 1
    - TELEPORT <player> <player.flag[dtraveler_target]>
    - ^PLAYSOUND <player.location> portal_travel
    - PLAYEFFECT <player.location> large_explode

dtraveler_format_warning:
    type: format
    format: "<&7>[<&2>dTravelers<&7>]: <&c><text>"

dtraveler_format_valid:
    type: format
    format: "<&7>[<&2>dTravelers<&7>]: <&2><text>"