Silverdale -Advanced Scripts samples of DockHand and Castle Xee Adam

Discussion in 'Ink NPC Dialogue Composition' started by Xee, Mar 23, 2023.

  1. Xee

    Xee Bug Hunter

    Messages:
    2,203
    Likes Received:
    2,994
    Trophy Points:
    153
    Below is my Silverdale Dock hand script. it contains saved local to player variables as well counters for anger level of the npc, random shuffled outcomes in sentences, counter assigned greeting that changes based on number. I am not done with this as I want to add emotes and the likes as well will be changing the counter for not talking to player from X chats to perhaps days or weeks using some of the options Chris has exposed. will be also soon adding virtue checks so that paths will be different based on virtue. but for now the working version:

    Code:
    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    VAR currentScene = "Silverdale Docks"
    VAR playerName = "NONE"
    VAR playerNameKnown = "NO"
    VAR visits = 0
    ~loadVariable("playerNameKnown")
    ~loadVariable("visits")
    ->MainStitch
    
    = MainStitch
    
    
    Welcome to {currentScene}, {isNameKnown(): {playerName}|Outlander}.
    {isNameKnown():
        ->MeetMir
    -else: ->EnterName
    }
    
    -(EnterName)
        What is your name?
        +[My name is {playerName}]
        ~playerNameKnown = "YES"
        ~SaveData("playerNameKnown")
        ->MeetMir
    
    -(MeetMir)
        {
            - not (visits == 5 or visits >= 10): -> dock
            - visits == 5: -> refuse_to_talk
            - visits >= 10: -> reset_visits
        }
    
    = dock
    Mir: "Hello there, {visited_n_times(visits)}, {~"My name is Mir but you may already know that" | "I'm Mir plesure to meet you" | "Hmmmm" | "What do you want?"} I'm the lead dock hand here at Silverdale docks. {~" I've moved a lot of stuff in my time - crates, kegs, bodies, coffins, ancient artifacts, furs, and all sorts of creatures." | "This is my Turff," | "Don't let the Captian see you down here talking to me," | "All in a days work," | "Is it lunch yet?" } What brings you here ?"
    + "I'm just passing through."
        Mir: "Ah, I see. Well, enjoy your stay in Silverdale. The market is quite an interesting place."
        -> increase_visits
    + "I'm here for the market."
        Mir: "The market is amazing! They sell all kinds of magical weapons and armor. You should definitely check it out."
        -> increase_visits
    + "I'm interested in your stories."
        -> stories
    + "I'm looking for work."
        Mir: "We could always use more hands at the docks. See the supervisor if you're interested in joining us."
        -> increase_visits
    
    = refuse_to_talk
    Mir: "I've had enough of your interruptions! Leave me alone for a while!"
    -> increase_visits
    
    = reset_visits
    Mir: "Alright, I've got time to talk now. Let's start over."
    ~visits = 0
    ~SaveData("visits")
    -> dock
    
    = increase_visits
    ~visits++
    ~SaveData("visits")
    -> END
    
    = stories
    {
        - visits < 5:
            Mir: "Alright, I'll tell you a story, but I don't have much time for chatting."
            -> story_selection
        - else:
            Mir: "I've already wasted too much time talking! Don't you have anything better to do?"
            -> increase_visits
    }
    
    = story_selection
    * "Tell me about moving a body."
        Mir: "There was this one time I had to move a body. The stench was unbearable! But we dock hands have to do our job, no matter what."
        -> increase_visits
    * "Tell me about moving an ancient artifact."
        Mir: "I once moved an ancient artifact that was said to have mysterious powers. I didn't stick around to find out if it was true."
        -> increase_visits
    * "Tell me about moving a dangerous creature."
        Mir: "I had to move a dangerous creature once. It had sharp claws and poisonous fangs. I was lucky to get out of that one unscathed."
        -> increase_visits
    * "Nevermind."
        Mir: "Alright, suit yourself. Let me know if you need anything else."
    
    ->END
    
    == function visited_n_times(n) ===
    {
        - n == 0: "stranger"
        - n == 1: "friend"
        - n == 2: "curious one"
        - n >= 3: "Pest!"
        }
    ===function isNameKnown===
    ~return playerNameKnown == "YES"
    
    ====function LoadData(varName)===
    //loading {varName}        //uncomment for testing in editor
    ~loadVariable(varName) //comment for testing in editor
    
    ====function SaveData(varName)===
    //saving {varName}         //uncomment for testing in editor
    ~saveVariable(varName) //comment for testing in editor
     
    Last edited: Apr 1, 2023
    Tahru, Sean Silverfoot, Anpu and 2 others like this.
  2. Xee

    Xee Bug Hunter

    Messages:
    2,203
    Likes Received:
    2,994
    Trophy Points:
    153
    If you want even more complex this one takes the above further it tracks how many times you talk to it with multi options for choices and multi branch. It also knows its master vs player offering a different path option.
    I am going to be expanding it further with counter quests so that after so many visits it will interrupt the script for an important event timer. That will be coming soon. We will add in emotes to the conversations once they get that working again.
    if you want to see anything specific let me know. I plan to see how advanced I can make these. I still am saving alot of space for later linking npc's together so they can pass along information.

    Code:
    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    VAR currentScene = "Silverdale Docks"
    VAR playerName = "NONE"
    VAR playerNameKnown = "NO"
    VAR visits = 0
    ~loadVariable("playerNameKnown")
    ~loadVariable("visits")
    ~visits++
    ~visits = visits % 11
    ~SaveData("visits")
    
    ->checkPlayerName
    
    = checkPlayerName
    {
      - playerName == "Xee":
        -> GreetMaster
      - else:
        {isNameKnown(): Greetings, {playerName}.|Greetings, Outlander.}
        {isNameKnown():
          ->MeetServant
        -else:
          ->EnterName
        }
    }
    
    
    = GreetMaster
    {~-> GreetMaster1 | -> GreetMaster2 | -> GreetMaster3 |-> GreetMaster4 }
    
    -(GreetMaster1) "Greetings, Master Xee! Everything is awesome today!" -> END
    -(GreetMaster2) "Ah, Lord Xee! The castle is as you wish" -> END
    -(GreetMaster3) "Master, welcome back! The day is splendid, and all is well!" -> END
    -(GreetMaster4) "Lord Xee, today is a day full of merriment and good fortune!" -> END
    
    = EnterName
    What is your name?
    +[My name is {playerName}]<{playerName}>
    ~playerNameKnown = "YES"
    ~SaveData("playerNameKnown")
    ~SaveData("playerName")
    -> MeetServant
    
    = MeetServant
    {visited_n_times(visits)}, {~"I am at your service" | "I'm a servant of Lord Xee, pleasure to meet you" | "Hello!" | "What brings you here?" | "How may I assist you?" | "Is there anything I can help you with?"}. {~"This is a place of great power," | "The Lord won't be happy if he sees you wandering without purpose," | "You need to state your business," | "This isn't a place for idle chitchat." | "Please, do not waste Lord Xee's time."} What can I do for you?"
    
      + "I'm here to learn more about the Lord of the Castle."
        -> learn_about_lord_xee
      + "I'm interested in the magic mirror discovered in Silvedale."
        -> magic_mirror
      + "I've heard about a mysterious book Lord Xee is looking for."
        -> mysterious_book
      + "I'm just passing through, thank you."
        -> END
      + "Never mind, I'll check back later."
        -> END
      + "I'm here to see Lord Xee."
        -> Toobuzy
     
    = learn_about_lord_xee
    {~ -> learn_about_lord_xee1 |-> learn_about_lord_xee2 | -> learn_about_lord_xee3 }
    
    -(learn_about_lord_xee1)  "Lord Xee is a powerful and enigmatic figure, known to dabble in death magic. While many fear his abilities, few understand his true motivations. Some say he uses his knowledge of the arcane to maintain order and protect his people, while others believe he pursues his own, darker agenda."
      + "I'm here to learn more about the Lord of the Castle."
        -> learn_about_lord_xee
      + "I'm interested in the magic mirror discovered in Silvedale."
        -> magic_mirror
      + "I've heard about a mysterious book Lord Xee is looking for."
        -> mysterious_book
      + "Never mind, I'll check back later."
      -> END
     
    -(learn_about_lord_xee2)  "Lord Xee is a master of the arcane arts, with a particular interest in the balance between life and death. His vast knowledge and understanding of magic has allowed him to achieve incredible feats, both in the name of good and for his own purposes. It is said that he holds a great deal of power and influence over the realm, but his true intentions remain shrouded in mystery."
      + "I'm interested in the magic mirror discovered in Silvedale."
      -> magic_mirror
      + "I've heard about a mysterious book Lord Xee is looking for."
      -> mysterious_book
      + "I'm here to see Lord Xee."
      -> Toobuzy
     
    -(learn_about_lord_xee3)  "The enigmatic Lord Xee is a figure of great power and influence, commanding respect and fear from those who know of him. As a practitioner of death magic, his prowess is unmatched, and his knowledge of the arcane is unrivaled. Some claim he seeks to protect his people, while others whisper that he harbors a darker, more sinister agenda."
    
    +"Interesting. Tell me more about the magic mirror."
    -> magic_mirror
    +"I've heard about a mysterious book Lord Xee is looking for."
    -> mysterious_book
    +"Thank you for the information. I must take my leave now."
    -> farwell
    
    = farwell
     "Farewell, {playerName}. I hope your visit to the castle has been enlightening." -> END
    
    = magic_mirror
     "Ah, the magic mirror found in Silvedale. It is said to possess the ability to transport those who gaze into it to other dimensions. Lord Xee showed great interest in the mirror, as if he knew it was hidden there. Some speculate he may be searching for something or someone beyond our world."
    
    +"I want to learn more about Lord Xee."
    -> learn_about_lord_xee
    +"Tell me about the mysterious book Lord Xee is looking for."
    -> mysterious_book
    +"Thank you for the information. I must take my leave now."  "Farewell, {playerName}. I hope your visit to the castle has been enlightening." -> END
    
    = mysterious_book
     "Rumors have been circulating about a mysterious book that Lord Xee has. This ancient tome is said to contain powerful secrets, perhaps even the key to unlocking the true potential of the magic mirror. It is whispered that the book is hidden in a place where few dare to tread, guarded by creatures from beyond our realm. Lord Xee's search for the book seems relentless, and some wonder what he plans to do once he possesses it."
    
    +"I want to learn more about Lord Xee."
    -> learn_about_lord_xee
    +"Tell me about the magic mirror discovered in Silvedale."
    -> magic_mirror
    +"Thank you for the information. I must take my leave now."
    -> farwell
    
    === Toobuzy ===
     "Xee is very busy right now, come back later"
    ->END
    == function visited_n_times(n) ===
    {
        - n == 0: "stranger"
        - n == 1: "friend"
        - n == 2: "curious one"
        - n >= 3 and n < 10: "frequent guest"
        - n >= 10: "regular"
    }
    ===function isNameKnown===
    ~return playerNameKnown == "YES"
    ====function LoadData(varName)===
    //loading {varName} //uncomment for testing in editor
    ~loadVariable(varName) //comment for testing in editor
    ====function SaveData(varName)===
    //saving {varName} //uncomment for testing in editor
    ~saveVariable(varName) //comment for testing in editor
    
     
  3. Xee

    Xee Bug Hunter

    Messages:
    2,203
    Likes Received:
    2,994
    Trophy Points:
    153
    Currently there is a bug with NPC's looks like with Testing with Dev that there are issues with npc's using variable not working for others short of the person that made it. so not sure what that means exactly short of its on @DavidDC list to look at abit later. I will probably make a ticket as well just to make sure its in the system. will update once we know its working thanks.

    **update looks like they found the bug with variables there will be a future patch to fix so npc's will work for other players once patched. woot woot.
     
    Last edited: Apr 4, 2023
    Anpu and Tahru like this.