Paste #33305: Testing NPC Guide

Date: 2016/05/04 00:01:24 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# ===================================================
#
# Server Greeter Chat Format
#
# ===================================================

cChat:
  type: format
  format: "<aqua><npc.name><white><&co> <green><text>"

# ===================================================
#
# The Server Greeter Assignment
#
# ===================================================

ServerGreeter:
  type: assignment

  actions:
    on assignment:
    - trigger name:click state:true
    - trigger name:chat state:true
    - lookclose <npc> state:true range:5 realistic

  default constants:
    isNarrating: false
    sentWaitingMessage: false

  interact scripts:
  - 10 ServerGreeter_interact


# ===================================================
#
# The main server greeter interaction script  
#
# ===================================================

ServerGreeter_interact:
  type: interact
  steps:
    1:
      click trigger:
        script: 
        # If the player has already had the tutorial, we can say different things to them
        - if <player.flag[hadTutorial]> {
          - narrate ""
          - narrate format:cChat "Hello again <player.name>! Still UnAwakened, I see. Interesting it is, that you have not yet chosen the Aspect which best suits you."
          - wait 2
          - narrate ""
          - narrate format:cChat "Would you like the short tutorial and tour again? (<dark_green>Yes<&r> or <dark_red>No<&r>) - or for information, (<dark_gray>Aspects<&r>, <blue>Facet<&r>, or <dark_aqua>Attribute<&r>)"
          - narrate ""
        } else {
        # Otherwise, 
          - narrate ""
          - narrate format:cChat "Hello <player.name>! I am Kieliah, your guide to embracing the destiny that fate has seen fit to bestow upon you. You are now an UnAwakened - one who's soul has been torn from your body, and thrust into this new world. "
          - wait 2
          - narrate ""
          - narrate format:cChat "Would you like a short tutorial (and tour) about the server?"
          - narrate ""
          - narrate "<&r>-- You can say <dark_green>Yes<&r> for the tutorial, or <dark_red>No<&r> to just continue on to race selection. You can also say <dark_gray>Aspects<&r>, <blue>Facet<&r>, or <dark_aqua>Attribute<&r> for respective information"
          - narrate ""
        }

        # Send off to step 2 for chat responses, only if the player has interacted for step 1
        - zap 2

    2:
      chat trigger:
        1:
          trigger: /No/ thanks.
          script:
          - narrate ""
          - if <player.flag[hadTutorial]> {
            - random 4
            - narrate format:cChat "Well, you know where I stay, <player.name>!"
            - narrate format:cChat "Ok <player.name>. If you need a refresher, I will be here!"
            - narrate format:cChat "Ah, you UnAwakened. So indecisive."
            - narrate format:cChat ".... ok."
          } else {
            - random 4
            - narrate format:cChat "Alright. I will be here if you change your mind."
            - narrate format:cChat "Ok <player.name>. You can find me here if you change your mind."
            - narrate format:cChat "Ah well, here I shall wait for other newly UnAwakened..."
            - narrate format:cChat "DARN! I was hoping to get out and walk some! "
          }
          - narrate ""

          # Reset script to allow interaction once more
          - zap 1

        2:
          trigger: Why /yes/, I would like to know more about the server!
          script:

          # Start tutorial and tour - Create the 'phased' npc for the player, and remove the -real- npc
          - ^create witch "Kieliah" <npc.location> save:ServerGreeter_guide
          - ^adjust <server.list_online_players.exclude[<player>]> hide_entity:<entry[ServerGreeter_guide].created_npc>
          - ^adjust <player> hide_entity:<npc>

          # Check if the player is on a follow-up tour
          - if <player.flag[hadTutorial]> {
            - narrate format:cChat "Another tour, <player.name>? Excellent! I need the exercise, so follow me once more and I shall explain the server and its lore!"
          } else {
            - narrate format:cChat "Alright then, follow me and I will tell you a little about how the server works, as well as provide you with some lore and background on the worlds you now call home."
          }
          - narrate ""

          # Run the walking task, which will call specific steps in the dialog for narration
          - ^run ServerGreeter_path npc:<entry[ServerGreeter_guide].created_npc> def:<^npc>
          - ^run ServerGreeter_talk npc:<entry[ServerGreeter_guide].created_npc>

          # Set the script to step 3, to disallow this player from accessing it until after the tour
          - zap 3


# ===================================================
#
# The Server Greeter walking path
#
# ===================================================

ServerGreeter_path:
  type: task
  definitions: sGreeter
  script:
  # Start the walking. We want to be talking while walking, but we do not want to move 
  # from point to point until some text has been done. There are 7 stops before the 
  # Server Greeter returns to it's starting location.(the 8th 'stop')

  # -------------------------------------------------
  #
  # Wait for 2 seconds, allowing the narrate script
  # to start the story before we start moving
  #
  # -------------------------------------------------
  - wait 2

  # -------------------------------------------------
  #
  # Moving to the SpacePort window
  #
  # -------------------------------------------------

  # Walk to the midpoint of Start -> SpacePort waypoints, wait for player
  - ~walk <def[sGreeter].anchor[wpStart-SpacePort]> auto_range
  - ^inject ServerGreeter_narrate def:1

  # Walk to SpacePort waypoint, set flag that we are at "step 1", wait for player
  - ~walk <def[sGreeter].anchor[SpacePort]> auto_range
  - ^flag <npc> step:1
  - ^inject ServerGreeter_narrate def:1

  # wait until narration is complete before moving on
  - while <npc.flag[isNarrating]> {
    - wait 1
  }


  # -------------------------------------------------
  #
  # Moving from SpacePort to Parolit window
  #
  # -------------------------------------------------
  - ~walk <def[sGreeter].anchor[wpSpacePort-Parolit-1]> auto_range
  - ^inject ServerGreeter_narrate def:1
  - ~walk <def[sGreeter].anchor[wpSpacePort-Parolit-2]> auto_range
  - ^inject ServerGreeter_narrate def:1
  - ~walk <def[sGreeter].anchor[wpSpacePort-Parolit-3]> auto_range
  - ^inject ServerGreeter_narrate def:1
  - ~walk <def[sGreeter].anchor[Parolit]> auto_range
  - ^inject ServerGreeter_narrate def:1

  - ^flag <npc> step:2

  # wait until narration is complete before moving on
  - while <npc.flag[isNarrating]> {
    - wait 1
  }

  # -------------------------------------------------
  #
  # Return to the Start point, remove the fake NPC 
  # greeter and re-show the placeholder Greeter
  #
  # -------------------------------------------------

  # Return to Start
  - flag <npc> step:3
  - ~walk <def[sGreeter].anchor[Start]> auto_range
  - wait 3
  - remove <npc>
  - adjust <player> show_entity:<def[sGreeter]>

  # And allow the greeter to take this player on another tour
  - zap 1 script:s@ServerGreeter_interact


# ===================================================
#
# The Server Greeter Talking points  
#
# Narrate based on the step we are in. We do this for
# walking to a point, and then at the point, through
# the tour
# 
# ===================================================

ServerGreeter_talk:
  type: task
  script: 

  # -------------------------------------------------
  #
  # Welcome the player based on whether they have
  # done the intro or not, and begin tour. Walk to 
  # the SpacePort display window
  #
  # -------------------------------------------------
  # set the narrating flag to true so we stop at the SpacePort window
  - flag <npc> isNarrating:true

  # Start narration for server background
  - ~run ServerGreeter_narrate "def:2|This server is designed with entirely custom lore - that is the items, enemies, areas, system - virtually everything is customized."
  - ~run ServerGreeter_narrate "def:5|In doing so, it also pays homage to old 8-bit and 16-bit games like <dark_blue>Final Fantasy<white>, <gold>Phantasy Star<white>, <dark_green>Zelda<white>, <dark_red>Golvellius<white>, <light_purple>Zillion<white>, <green>and others"

  # -------------------------------------------------
  #
  # Tour is at SpacePort window. Explain relevance
  # of the SpacePort, and that there are connections
  # to many other areas for the player
  #
  # -------------------------------------------------

  # Wait until the NPC is at the SpacePort window before continuing narration  
  - while <npc.flag[step].is[LESS].than[1]> {
    - wait 1
  }

  # Talk about the SpacePort
  - ~run ServerGreeter_narrate "def:10|Through this window, you can see the SpacePort below us. It is here that you will access the main adventure world, server shops, purchase housing vouchers and store ownership deeds."

  # set the narrating flag to false so we leave the SpacePort window
  - flag <npc> isNarrating:false 

  # Start talking as we leave the window    
  - ~run ServerGreeter_narrate "def:3|The SpacePort is also the central point of access for the player shops, player housing, and the start of your adventure."

  # set the narrating flag back to true so we stop at the Parolit window
  - flag <npc> isNarrating:true

  # -------------------------------------------------
  #
  # Walking away from SpacePort window and onward to
  # the Parolit display window. 
  #
  # -------------------------------------------------

  - ~run ServerGreeter_narrate "def:7|The start of your adventure begins once you have completed attunement with the Aspect of your choice. We will get to that in a moment, as there is much more to explain to you about this world."

  # wait until the NPC is at the walk destination before moving onward  
  - while <npc.flag[step].is[LESS].than[2]> {
    - wait 1
  }



  # set the narrating flag to true
  - flag <npc> isNarrating:true

  # Talk about the SpacePort
  - look <npc> <npc.location.add[<location[2209,130,1555,30,-15,<npc.world.name>]>.direction.vector]>
  - ~run ServerGreeter_narrate "def:8|Look here - you see that railway? At the other end of that railway is Parolit."

  # set the narrating flag to false
  - flag <npc> isNarrating:false


# ===================================================
#
# The Server Greeter narrate section
#
#   Takes a time delay and text to narrate
# 
#   Validates player is close to greeter
#
#   Allows for delay without narration, narration
#     without delay, or neither (delay == 2 ticks)
#
# ===================================================

ServerGreeter_narrate:
  type: task
  definitions: delay|text

  # Set up default constants
  default constants:

    # Time that the NPC will wait for, in seconds
    npcWaitTime: 60

    # Distance that the NPC will check for the player
    npcMaxDistance: 4

  script:
    # Only display text if text was asked for
    - if <def[text].exists> {
      - narrate format:cChat %text%
      - narrate ""
    }

    # If a delay was passed, wait for that long. Otherwise, wait for 2 ticks by default
    - if <def[delay].exists> {
      - wait %delay%
    } else {
      - wait 2t
    }

    # Pauses the script for narration, and also checks for player in area before moving onward
    - ^while <npc.location.distance[<player.location>].is[OR_MORE].than[npcMaxDistance]> {
      - flag <player> waitedTooLong:++

      # If the player was away from the NPC for too long, reset.
      - if <player.flag[waitedTooLong].is[OR_MORE].than[npcWaitTime]> {
        # Clear flag, set tour Running to false
        - flag <player> waitedTooLong:!
        - flag <player> tourRunning:false
        - narrate ""
        - narrate format:cChat "Where have you gone, <player.name><&r>? I have waited long enough."
        - narrate ""
        - queue clear
      }

      # If we have sent a waiting message in the last 10 seconds, dont send one
      - if !<player.flag[sentWaitingMessage]> {
        # Otherwise set the sentWaitingMessage flag
        - flag <player> sentWaitingMessage:true duration:10s

        # and send a random waiting message
        - random 6
        - narrate format:cChat "Do try to keep up, <red><player.name><&r>!"
        - narrate format:cChat "Why are you making me wait around, <red><player.name><&r>?"
        - narrate format:cChat "I don't have all day <red><player.name><&r> - let's move it!"
        - narrate format:cChat "Do I look like Damor the Soothsayer to you? <red><player.name><&r>, get a move on!"
        - narrate format:cChat "I think Cloud spent less time in that tank than I am, right now, waiting for you <red><player.name><&r>!"
        - narrate format:cChat "... ... ... ... ... ... ... ... <red><player.name><&r>!!!! "

        - narrate ""
      }

      # Wait for the player to get in range again    
      - wait 1

    }

    # Remove the waitedTooLong flag (player got closer)
    - flag <player> waitedTooLong:!