# Dialogue trees and quest systems?

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

## Recommended Posts

Does anyone have a good method for organizing dialogue in a game, where the dialogue is pulled from a set depending on what quest you have available at the NPC, as well as the attitude towards the player? Also for multiple NPC's belonging to the same quest? For example: (click on NPC)NPC1:Hello, nice to meet you (click continue)NPC1: Have you seen my lost Dog? (click 'I hate dogs')NPC1: how rude, goodbye (click on NPC1)NPC1: What do you want? (click 'help find dog')NPC1: The last time I saw him, he was playing up north. bring him to NPC2. [start quest, add quest to players active quests, spawn dog] (find dog, click on NPC2) NPC2: Hello, good to meet you, my name is NPC2. (click give dog to NPC2) NPC2: Why isn't that the missing dog!? [give player reward, and change NPC1 and 2 to offer the respective next quests] Any good ideas on how to tie the different dialogue options, along with responses, and the quest system? I have something that works, but is not pretty to work with....

##### Share on other sites
Consider something like the Blender node graph for describing dialogue and quest trees: http://www.geneome.net/blender/writtentutorials/images/title.png (from Google)

It is essentially a directed graph. This might not be the best solution, but something like this may be what you want: http://imgur.com/6SUOc.png

The basic idea is that you've got some array of flags that you can set for the player, that represent the state. Then you have a number of possible conversation starters with corresponding flags as a condition: if the player doesn't have any flags, they get an introduction. If they've got the Introduction flag, they get the quest. Then, each dialog has the ability to execute some actions, which may be things like:

SAY: The last time I saw him, he was playing up north. If you find him, bring him to NPC #2.
SETFLAG: DogQuest
SPAWN: Dog

It's just an idea. The purpose of the graph is to allow you to easily describe the sequence.

##### Share on other sites
Aye, as described above I would form a kind of graph based system. Given the example domain, the 'dialog system' would have an associated 'parameter' table. Where certain options can cause the system to provide responses. The parameters would be assigned at the time when the dialog tree is defined, for example (in the form of XML, and it's off the top of my head and on the spot, so only intended illustratively):

<DialogTree name="NPC1" >    <Dialog operator="default" >        <Message text="Hello, nice to meet you" />        </Exit>    </Dialog>    <Dialog operator="equality" param="12" value="0">        <Message text="Hello, nice to meet you" />        <Option text="continue" >           <Dialog text="Have you seen my lost dog?">           <Option text="I don't like dogs" >               <Message text="How rude, goodbye!" />               <Exit/>           </Option>           <Option text="Help find dog">              <Param operator="set" param="12" value="1"/>           </Option>        </Option>    </Dialog></DialogTree>

Code wise, I would structure it similar to.

struct DialogTree
{
int baseDialog;
int nDialogs;
};

The dialog definition file would contain a flat table of these along with an array of dialog parameters...

int[ number_of_dialog_parameters ];
DialogTree[ number_of_dialog_trees ];

The DialogTree structures 'baseDialog' parameter indexes into another table of the following structure:

enum kDialogOperator{    kDialogOperator_Default,    kDialogOperator_Equal,    kDialogOperator_NotEqual,    kDialogOperator_LessThan,    kDialogOperator_MoreThan,};struct DialogEntry{    kDialogOperator     operator;    int                 parameterIndex;    int                 parameterValue;    int                 baseRule;    int                 nRules;};

With the baseRule and nRules parameter indexing into yet another table of DialogRule objects, which are formatted similar to the DialogEntry. The index basically specifies the first index within the table associated with the object and the number of items starting at that index.

The above would allow a relatively strong and extensible dialog system I think, though I'm sure there are many thing's I've not thought of.

n!

##### Share on other sites
As ever I like to refer to the PDF describing SimDialog. It doesn't handle all the problem written in the OP, but it deals fine with "the attitude towards the player" and the like.

[Edited by - haegarr on December 3, 2009 12:59:29 PM]

##### Share on other sites
Awesome, thanks! That will give me some stuff to try- I'm storing it in XML right now, so the structure is somewhat similar, but that will help me get it working the way it needs to.

Thanks!

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632983
• Total Posts
3009706
• ### Who's Online (See full list)

There are no registered users currently online

×