NPCS

Warejax101
10 Jul 2017, 00:37

How can I make a Proper NPC with Ask-Tell? When I test my game and select " Speak to " It just says " Jaxon has nothing to say ". Any way around this?


hegemonkhan
10 Jul 2017, 02:27

the 'ask/Ask' Functions' descriptions are a bit misleading, they're actually 'yes/no' type of questions, and not as/for open-ended generalized normal questions and responses.

an example:

'ask' produces a popup window for its menu

'Ask' produces an in-line (as clickable hyperlinks within the left side's big text box) menu

ask ("Are you male?") {
  // quest automatically (hidden from you) sets your input to the built-in 'result' String Variable: result = YOUR_SELECTED_INPUT
  // and for these 'ask/Ask' Functions, your input of 'yes' is actually an input of 'true' and your input of 'no' is actually an input of 'false', which are BOOLEANS, which can be checked directly by the 'if' Script/Function block below
  if (result) { // if (result = true) // if (TRUE)
    player.sex = "male"
  } else { // if (result = false) // or: if (not result) // or: if (not result = true) // if (FALSE)
    player.sex = "female"
  }
}

I'm not familiar with the built-in 'tell' Function... I don't use the GUI/Editor much and haven't yet learned all of the built-in stuff.


I believe, there's the built-in 'talk' and/or 'speak' (or they're the same Verb/Command: alternative names) Functions, for doing normal dialogue/conversation (open-ended generalized normal questions and responses).


you can always create your own Verb/Command too, especially if you want to be safe, and not accidentally over-ride the useful built-in Functions and their underneath handling.

for example of doing/using a Verb:

the 'switch' and 'if' Functions are exactly the same functionally, just a different style/look to them, which ever you prefer and/or works better for you and/or your design

// ----------------------------------------------------------------------

// using the 'switch' Function:

<object name="npc_1_object">
  <attr name="alias" type="string">The King</attr>
  <attr name="dialogue_list" type="simplestringlist">princess;dragon;sword;wizard</attr>
  <attr name="dialogue" type="script">
    show menu ("Ask the King about?", dialogue_list, false ) {
      // just like the 'ask/Ask' Functions, the 'show menu / ShowMenu' Functions do the same thing with your input: result = YOUR_SELECTED_INPUT
      switch (result) {
        case ("princess") {
          msg ("Help me! Rescue my beloved princess from the dragon who kidnapped her, and she and my kingdom/crown are yours!")
        }
        case ("dragon") {
          msg ("The dragon has kidnapped my beloved princess, please kill it and rescue her, but you'll need the dragon slayer sword, as its scales are otherwise impenetrable")
        }
        case ("sword") {
          msg ("The dragon slaying sword is held by an evil wizard in his dark tower")
        }
        case ("wizard") {
          msg ("He's an evil wizard, who uses dark magic, who has killed many heroes")
        }
        default {
          msg ("wrong input, try again") // actually this won't ever be used unless youdon't match up the list's items and your 'if Function's conditions, as the 'show menu / ShowMenu' Functions have choices that you are forced to select
        }
      }
    }
  </attr>
</object>

// ------------------

// or, using the 'if' Function:

<object name="npc_1_object">
  <attr name="alias" type="string">The King</attr>
  <attr name="dialogue_list" type="simplestringlist">princess;dragon;sword;wizard</attr>
  <attr name="dialogue" type="script">
    show menu ("Ask the King about?", dialogue_list, false ) {
      // just like the 'ask/Ask' Functions, the 'show menu / ShowMenu' Functions do the same thing with your input: result = YOUR_SELECTED_INPUT
      if (result = "princess") {
        msg ("Help me! Rescue my beloved princess from the dragon who kidnapped her, and she and my kingdom/crown are yours!")
      } else if (result = "dragon") {
        msg ("The dragon has kidnapped my beloved princess, please kill it and rescue her, but you'll need the dragon slayer sword, as its scales are otherwise impenetrable")
      } else if (result = "sword") {
        msg ("The dragon slaying sword is held by an evil wizard in his dark tower")
      } else if (result = "wizard") {
        msg ("He's an evil wizard, who uses dark magic, who has killed many heroes")
      } else {
        msg ("wrong input, try again") // actually this won't ever be used unless youdon't match up the list's items and your 'if Function's conditions, as the 'show menu / ShowMenu' Functions have choices that you are forced to select
      }
    }
  </attr>
</object>

// -------------------------------------------------------------------------------

<verb>
  <property>dialogue</property>
  <pattern>dialogue</pattern>
  <defaultexpression>You can't have dialogue with that!</defaultexpression>
</verb>

ask if you got any questions and/or need help


hegemonkhan
10 Jul 2017, 03:27

there's lots of guides on conversation/dialogue/npcs, just search/navigate the site for them, such as here:

http://textadventures.co.uk/forum/samples

and also the quest doc site too:

http://docs.textadventures.co.uk/quest/

http://docs.textadventures.co.uk/quest/#Tutorial

http://docs.textadventures.co.uk/quest/#Howto

http://docs.textadventures.co.uk/quest/conversations.html

http://docs.textadventures.co.uk/quest/ask_about.html

etc etc etc


ask fi you still need help with this stuff and/or if you got any questions about whatever


Richard Headkid
10 Jul 2017, 03:32

In the GUI, you can select the NPC from the object tree, then select the VERBS tab. Click +Add. As soon as you type "speak" it should auto-fill "speak to; speak; talk to; talk". Then, just enter your script.

After this, speak should work when clicking it with no further steps.


The Pixie
10 Jul 2017, 09:53

There is a guide to using ask/tell here:
http://docs.textadventures.co.uk/quest/ask_about.html

Note that you have to turn it on first on the Features tab of the game object.


Warejax101
11 Jul 2017, 01:27

Thanks for your help guys, but I still need to make something clear. I am not using the coding thingy of Quest, and I have The Option Turned on, Made a topic, etc. But when I try to speak to it, it just says " He says nothing. "


Richard Headkid
11 Jul 2017, 01:35

SPEAK, ASK, and TELL each need their own topics set up.

You have to set up a 'speak' VERB for the character.

You can't set up the topic for SPEAK/TALK until you've created a verb. Once you've created the 'speak' VERB, you'll have to create a script for it.

In the GUI, you can select the NPC from the object tree, then select the VERBS tab. Click +Add. As soon as you type "speak" it should auto-fill "speak to; speak; talk to; talk". Then, just enter your script.

(The script can call upon the ASK topics and replies, but it's a little complicated to set it up. I have the code, though, if you'd like it.)


hegemonkhan
11 Jul 2017, 02:18
simple example:

create a new text adventure game

left side's "tree of stuff" -> 'room' Room Object (click on it so it is highlighted) -> 'Objects' Tab (on right side, up top) -> Add -> Name: npc

left side's "tree of stuff" -> 'npc' Object (click on it so it is highlighted) -> 'Attributes' Tab (on right side, up top) -> Attributes box (NOT the Inherited Attributes box and NOT the status attributes box) -> Add -> (see below)

(Object Name: npc)
Attribute Name: topics
Attribute Type: stringlist
Attribute Value: (see below)

Add -> Item Name: princess
Add -> Item Name: dragon

left side's "tree of stuff" -> 'npc' Object (click on it so it is highlighted) -> 'Verbs' Tab (on right side, up top) -> Add -> Name: dialogue -> (see below)

add new script -> 'output' section category -> 'show a menu' Script -> (see below)

menu prompt box: Ask about?
menu list box: npc.topics
menu cancel'able option: false (unchecked)

add new script -> 'scripts' section/category -> 'if' Script -> if [EXPRESSION] result = "princess"
-> then, -> add new script -> 'output' section/category -> 'print a message' Script -> print [MESSAGE] The princess has kidnapped by the dragon!
else if -> [EXPRESSION] result = "dragon"
-> then, -> add new script -> 'output' section/category -> 'print a message' Script -> print [MESSAGE] The dragon can only be pierced (killed) by the dragon slayer sword.