NPCS: conversations

Started by
6 comments, last by graveyard filla 19 years, 5 months ago
im creating a text adventure. ive got a lot done, the parser, the game class, the room class, the commands, the player class, the items, etc. i want to add characters. i want to do a talk <character> command, and a say <choice> command. if there is a character in a room, you can say talk man and it would do something like this Man Says: "Hello. what do you need?" 1)what is your name? 2)do you have money? 3)where is the princess? 4)nothing, thanks and you can go: say 3 to ask where the princess, where upon he would say Man Says: "Wouldn't you like to know? Whats in it for me?" 1) money 2) sexual favors 3) nothing. anyway, i want to make a flexable interface for conversations with charaters, where there can be a tree of conversational flow, with any number of responses available. what type of data structure can/should i use for conversations like this? any ideas? and how would i implement something like the character giving the player an item once they reach a specific node of the conversation? if you guys could just give some ideas or insight, that would be awesome, thanks! -scott
---------Coming soon! Microcosm II.
Advertisement
any remote ideas?
---------Coming soon! Microcosm II.
The way I'm dealing with conversations is by using a simple event handling system with each 'event' being made up of one or more triggers, which if all true, result in one or more responses. Quite often the triggers are pretty simple such as a check to see if the player has killed a certain monster or talked to a certain NPC, with the response being for example an additional dialogue option or a change to the player's inventory.

The great thing about this is that as much of the game is arranged around this event handling system (not just the dialogue system) it is really easy to have dialogue impacting other aspects of the game (for instance it would be possible for the player to kill characters or destroy buildings just by selecting a certain dialogue option - select 'Say Abracadabra' and boom, there goes the neighbourhood).

Finally this system gives you all kinds of flexibility with dialogues - tree conversations are possible with one event activating another (sort of if dialogue option 1 is selected then turn on event Z) while it is possible to have completely free flow dialogues (if a player knows about something then an event adds another dialogue option to the list of those available). And then all sorts of combinations of the two are possible (if a bit tricky to manage).

Hope this all makes some kind of sense and is helpful,

Jon.
Jon.
_______________________________________
Legends from the Lost Realms
the only problem is that the engine that i have to used is based off a simple api that is given to me in the course java file. this is an intro java class for cs majors, and because its an intro course ( i happen to have a little more experience ) the api is simple and limited. it seems as though the engine is completely command based, so i have to keep it that way. i was thinking about having a list of topics that the player could as the character, and then the character would respond, and then it could reveal any number of more topics the chracter could ask about, and or change the inventory of the player. that way, if a player wants to access any part of the conversation, they wont have to go through a tree, and that way, they can get the information in any way that they want without missing a piece of the conversation, sounds good ?
---------Coming soon! Microcosm II.
I have three classes: Conversation, PlayerNode and NPCNode.
PlayerNode has the name/pointer to an "availability" function to check if the player has this option available (eg. has a certain item). NPCNode has an "event" function which is called when the NPC "says" some special node.

PlayerNode has a pointer to a NPCNode (what will the NPC say to this reply). NPCNode has a list of possible PlayerNodes (replies).

The Conversation class just stores and handles all the PlayerNodes and NPCNodes and controls the flow of the conversation.

That's a rough description of how my system works.. I recommend storing the conversations for example in XML and then scripting all the events.

Here's a mockup of a conversation file from my game vaino_dialog.xml. The syntax is now a bit different but you get the idea.
Ad: Ancamnia
i strongly recommend reading through this thread. i have a character dialogue system that is very similar to the one you describe (im given choices, which can branch out to other choices, etc.). in the thread, its explained to me how to set it up and i probably posted working code when i got it working.

i later converted it to work with and be scriptable through Lua. i recommend you start looking into scripting languages soon. if you have any more questions just ask! good luck!
FTA, my 2D futuristic action MMORPG
Quote:Original post by graveyard filla
i strongly recommend reading through this thread. i have a character dialogue system that is very similar to the one you describe (im given choices, which can branch out to other choices, etc.). in the thread, its explained to me how to set it up and i probably posted working code when i got it working.

i later converted it to work with and be scriptable through Lua. i recommend you start looking into scripting languages soon. if you have any more questions just ask! good luck!


Yes, that's a good thread. It also helped me a lot :) And scriptability is a must! I liked the combination of XML and Lua (works for me atleast).

And how's your game coming along? Seemed interesting..
Ad: Ancamnia
coming along, slowly but surely... going through debugging hell right now [smile]. trying to figure out bugs in a client/server environment is quite "interesting" to say the least [grin].
FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement