! Interaction code for an incredibly simple NPC which can respond
! to "hello", ask how the PC is and understand the answer.


! Define your emotional states to start with - these
! represent the range of how your character can feel.

EmotionalStates {
       passive
       suspicious
       angry
}

! Talk routers pick keywords from a PC and route
! to a conversation thread.

TalkRouter {
       Words "sorry"
       Or "apologise"
       Or "apologize"
       Or "forgive me"
       SetThread sorrythread
}

       ! Conversation threads change according to how the NPC is feeling. Threads
       ! can change the NPC's emotional state, as well as speaking and making
       ! actions.

       Thread sorrythread "sorry" {

               passive suspicious [
                       Speech "You have nothing to be sorry about!"
                       Action "looks puzzled."
               ]

               angry [
                       Speech "Ok, I'll forgive you, please try not to do it again."
                       SetEmotion passive
               ]
       }

TalkRouter {
       Words "fuck off"
       Or "piss off"
       Or "kiss my"
       SetThread nasty
}

       Thread nasty "Nasty" {

               passive suspicious [
                       Speech "There's no need for that kind of language."
                       SetEmotion angry
               ]

               angry [ 1
                       Speech "I don't speak to coarse oafs. Either wash your dirty mouth out or apologise."
               ]
       }


TalkRouter {
       Words "hello"
       Or "hi"

       SetThread hello
}


       Thread hello "Hello Thread" {

               passive suspicious [ 2
                       Speech "Hi, how are you doing?"
                       Action "smiles at you."
                       SetContext howareyou
               ]

               angry [
                       Speech "Go away."
                       SetThread imeanit_goaway
               ]
       }

               Thread imeanit_goaway {

                       angry [ 2
                               Speech "I mean it - apologise or get lost."
                       ]
               }

               ! Contexts are always checked before routers, so if a thread sets
               ! a context to be active, you can check for a response to NPC questions
               ! as well as keep the thread up with what the PC is talking about.

               Context howareyou {

                       [
                               Words "not" "bad"
                               Or "good"
                               Or "well"
                               Or "sound"
                               Or "happy"
                               Or "great"
                               Or "excellent"

                               SetThread goodtohear
                       ]

                       [
                               Words "bad"
                               Or "awful"
                               Or "terrible"
                               Or "not" "good"
                               Or "crap"

                               SetThread sorryaboutthat

                       ]
               }

                       Thread goodtohear "That's good to hear" {

                               passive suspicious [
                                       Speech "That's good to hear!"
                               ]
                       }

                       Thread sorryaboutthat {

                               passive suspicious [
                                       Speech "I'm sorry to hear that."
                               ]
                       }