I've always avoided conversations in my games, mainly because I see them as potential minefields in terms of being littered with commands that aren't understood.
I know of TP's ConvoLib but have never looked into it because as I say I tend to avoid the need, but is there a 'proper' and correct way to handle NPC conversations?
I'm guessing the two most widely used verbs are ask and say but what's the correct way to handle and accommodate everything that comes after this? Custom commands?
Ideally I would like mine to respond to the relevant questions, but to give logical responses to the incorrect ones.
Any tips, advice or even whole scripts that do this would be appreciated.
What I do is in the NPC description I give all the commands that pertain to that NPC. I have a "Chat/Compliment System" where all possible conversations will be put into a ShowMenu result/response. I think keeping it all together is the easier way.
You can't take everything into consideration unfortunately as it would require an insane amount of time on just that one character but if you make a small list of things the NPC could talk about in the ShowMenu and then have the player decide little variations, it might be nicer to program and easy for you to keep track of.
Hope that helps!
Anonynn.
I always have the NPC have a list of random generic responses to a talk to script like "That's great, pal, but what specific things would you like to tell me?"
Then I have a bunch of topics that can be asked about or responded to.
I avoid menus because it feels too guided.
If the menu system hides things the player must get from someone else, there should not be a problem...
IE: player talks to NPC#1 who responds with "Don't bother me."
Player talks to NPC#2 who comments that #3 knows a secret
Player talks to NPC#3 who tells you to ask #1 about his sword
Player talks to NPC#1 again, (and if there is a menu, sword is added)... "OH, this old thing? I got it fro NPC #2's brother makes them
Back to #2 to ask about his brother...
and so on...
BUT #1 will not say anything until the chain is followed.
(no shortcuts to ask #2 about his brother...)
Multiple choice menu systems are the way to go. I have never come across chat in a TA that wasn't extremely frustrating.
dialogue/conversation coding is extremely complex (well if you want it to be advanced in your game design)... you got to be a really good programmer to craft a very well designed coding structure/system for handling a complex/advanced dialogue/conversation game feature, as we're "talking" (lol, pun) about human language, and interaction of human language is a very complex thing, as it is very very very dynamic. Just think of conversation with a friend, of all the instricasisies of it, which we do so naturally and take for granted, of how we so easily handle going off in different directions and/or how we so easily are able to respond to whatever questions, well... this is a nightmare in trying to code it... especially to code it well...
Thus... look into (or just use) Pixie's and/or Jay's (see/play/use his 'Spondre' game and/or its source/game code which he wonderfully made public).
Also, just research how it is done, play games, see how they do it... such as the TES games (skyrim and etc)... build up a knowledge base of the different designs already thought of and used by professional game makers/coders... though learning the coding itself... is another matter... lol
My usual method would be to just set the NPC as an object, and then create a list of custom command patterns in the 'room', such as ask about old manor; ask about manor; ask about big house
But that's just the usual hacky me.
But if I do go with that, how would I set a default response for any unrelated 'asks' so that the NPC can say things like, "I have no idea what you're talking about."
I can't use ask #text#
because that would mean anything that followed 'ask' would get that response, wouldn't it?
see here:
http://docs.textadventures.co.uk/quest/elements/command.html
there's also the 'unresolved' String Attribute, which is like a 'default' response, except it activates if your Object_name input (using the '#objectXXX#' and 'objectXXX' Parameters, not the '#textXXX#' and 'textXXX' Parameters) is not found within the room you're in.
<command name="ask_about_command">
<pattern>ask about #text#</pattern>
<script>
if (text = "old_manor" or text = "manor" or text = "big house") {
msg ("blah")
} else if (text = "cat") {
msg ("blah2")
} else {
msg ("I have no idea what you're talking about.")
}
</script>
</command>
or, if you'd rather use the 'switch-case' instead of 'ifs':
<command name="ask_about_command">
<pattern>ask about #text#</pattern>
<script>
switch (text) {
case ("old_manor" or "manor" or "big house") {
msg ("blah")
}
case ("cat") {
msg ("blah2")
}
default {
msg ("I have no idea what you're talking about.")
}
}
</script>
</command>
or, example of using the 'unresolved' :
<command name="ask_about_command">
<pattern>ask about #object#</pattern>
<unresolved>Sorry, but that Object is not found in the same room as you</unresolved>
<script>
if (object = old_manor or object = manor or object = big house) {
msg ("blah")
} else if (object = cat) {
msg ("blah2")
} else {
msg ("I have no idea what you're talking about.")
}
</script>
</command>
or, if you'd rather use the 'switch-case' instead of 'ifs':
<command name="ask_about_command">
<pattern>ask about #object#</pattern>
<unresolved>Sorry, but that Object is not found in the same room as you</unresolved>
<script>
switch (object) {
case (old_manor or manor or big house) {
msg ("blah")
}
case (cat) {
msg ("blah2")
}
default {
msg ("I have no idea what you're talking about.")
}
}
</script>
</command>
Thanks a lot. The first one you posted is very me and the one I shall be using :)
There is already a system built into handle, for example, ASK MARY ABOUT MANOR. This will run a script set up on the NPC if the topic is not recognised.
If you want to use ASK, I would start from that. Add ASK ABOUT MANOR, and have that check what NPC was present, and then use the above system to handle it (the DoAskTell
function specifically).
I would also have a TOPICS command the player can use to get a list of topics available, and have that update as the game progresses.
Thanks, TP. Not sure if by TOPICS you mean some kind of list to pick from, but I don't like to use that kind of system as I think it breaks the immersion.
Any conversations I use will be very simple and brief - probably not even vital to the game - so I think hege's command pattern will probably suffice.
You could try programing your NPC with a chatbot function. If you feel ambitious you could even give it the ability to learn. There's a number of chatbot tutorials on the net, and it's not that hard to do.