• Advertisement

Archived

This topic is now archived and is closed to further replies.

Implementing NPC Conversation Tree

This topic is 5268 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there some pseudo code/tutorials or algos for implementing some kind of conversation tree for my non-player chars? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Maybe the way Morrowind / Exile did it:

- Keep a list of all words npc reacts to, and to each word or expression tie a sentence or series of sentences.
- Also keep a list of words the player can say to the NPC (all of these should be in the above list too). Whenever the player discovers he can say something else, add that word to this list.
- Whenever the player says a word to the NPC, print out the sentence the NPC has to say, and underline/mark in that sentence the words to which the NPC can further react.

Then, you might be able to implement additional stuff, like for instance conditions for saying some things (that is, to a word attach a list of possible sentences, each sentence being tied to a certain condition. The first sentence whose condition is met is used. )

ToohrVyk

Share this post


Link to post
Share on other sites
if I can add to the question...

Yeah I''ve been kinda curious about this myself.

Have anyone played Fallout 1&2, Planescape Torment, Baldurs Gate 1&2, Arcanum? *if you said "no", go away *

The conversation trees there are really exceptional! Sometimes I think they were a little to advanced, at least for the designers *heh* Ever got cought in a loop where you could say A, say B, say A, say B, over and over again? And also receive exp or gold each time you said B? heh Ever talked to a npc, then taken some intelligence booster and talked again to the same npc revealing completely new options? Or intelligence non-booster? (Fallout: "gargh!")

What you can say usually depends on your intelligence and previous knowledge and quests. And depending on the game: your class, race, gender, mage/tech-alignment, good/evil-alignment, etc.

How do one implement such a conversation tree? Based on _so_ many properties?? And even worse: how do you controll it?

The way morrowind did it reminds me of old school games. Keywords, ask around for those and get more keywords. *yeey*

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites
quote:
Original post by ToohrVyk
Maybe the way Morrowind / Exile did it:

- Keep a list of all words npc reacts to, and to each word or expression tie a sentence or series of sentences.
- Also keep a list of words the player can say to the NPC (all of these should be in the above list too). Whenever the player discovers he can say something else, add that word to this list.
- Whenever the player says a word to the NPC, print out the sentence the NPC has to say, and underline/mark in that sentence the words to which the NPC can further react.



Thanks This sounds good - do you have any terms of reference for this as I am implementing it for a uni project.

--------------------------------------------------------------

How come my sister has 3 brothers and I''''ve only got 2?

Share this post


Link to post
Share on other sites
quote:
How do one implement such a conversation tree? Based on _so_ many properties?? And even worse: how do you controll it?



Having played most of the games you mention, I would figure that the conversations are formed in three parts:

* The basic conversations that should be available to any player no matter alignment, stats, etc.

* Quest based conversations.

* Stat based conversations.


Triggering of these options would probably be handled through a simple conversational scripting engine, so each option on the conversation tree has a few special characters at the beginning of the option so the engine can detemrine if they should be displayed. Then it''s simply a case of the designers testing the conversations to make sure you don''t get the A, B, get gold, A, B, get gold loops.

I think in reality, the simplest methods for such things work best. There''s really no need for some extremely advanced conversation engine for most games. Unless you want some kind of realistic emotional response that is engineered from player options, then fixed options through simple stat controlled trees should provide the felxibilty needed.

Share this post


Link to post
Share on other sites
Yes I guess you''re right. I think the designer would need some kind of visual representation of the dialogs, like trees. Don''t know if anyone has such game specific tools? Haven''t tried the Fallout 2 editor yet, but I really should I guess

One thing, the basic conversation tree. I know in fallout that even that tree (if it really is devided in 3 like you said) is based on intelligence. I remember a situation that was kinda:
int 7 : "Where can I find a water chip?"
int 2 : "ugh... water! chip..?"

Stuff like that really amazed me when I was playing the game

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites

struct Command
{
Dialog * resultdialog;
QuestRequirements qreqs;
StatRequirements sreqs;
};

struct Dialog
{
vector<Command *> commands;
};


Make all of that template based, with some policy pattern for the requirements for example, and you''re done, I guess...

Share this post


Link to post
Share on other sites

  • Advertisement