What’s in a Dialogue Tree?
Since finishing Fluster I’ve had some time to think about different game ideas. One discussion with my friend Eddie started me thinking about dialogue trees. For his upcoming game Psychedelic Farmer he needs to create dialogues between the different characters and would also like the dialogue to be different depending on the items the player is carrying. I haven’t found the solution to this problem yet but I have started thinking about it, I thought I’d share my thoughts and get some feedback from you guys.
I approached this problem thinking about a dialogue as a tree. Each node in the tree should represent one statement in the dialogue. When there is more than one response possible then that should represent a choice for the player. Here’s how it might look:
Dialogue as a Tree
<dialogue>
<statement text="Welcome to my store." />
<statement text="Hey there, what can I do for you?">
<response text="I'd like to buy something." />
<response text="I'd like to sell something." />
</statement>
</dialogue>
There are a couple of problems with that, I think. First off it doesn’t really
meet all of the Eddie’s requirements so we’ll need to extend it. Worse, it
isn’t clear how this will drive the game, somehow we need to alert the game
when a given node is reached. To that end I’ve added ID’s to important nodes. Presumably the dialogue engine can trigger an onNode event when the player selects an important node (e.g. he selects the “Buy stuff” option).
Dialogue Tree with IDs on Important Nodes
<dialogue>
<statement text="Welcome to my store." />
<statement text="Hey there, what can I do for you?">
<response text="I'd like to buy something." />
<statement text="What would you like to buy?">
<response id="buy-weapon" text="I'd like to buy a weapon." />
<response id="buy-item" text="I'd like to buy an item." />
</statement>
<response id="sell-something" text="I'd like to sell something." />
</statement>
</dialogue>
Now, what about having multiple dialogues in a file? And what about having dialogues be context sensitive? My first sense for this problem is to create a mechanism to index into the XML for the desired attributes. For instance, you might want to find the dialogue between Eddie and the store keeper:
Dialogue Trees with Character Indexing
<dialogues>
<characters>
<character name="Alex" description="Swash buckling pirate-ninja!" />
<character name="Eddie" description="Possibly drug using farmer." />
<character name="Bob" description="Bob of Bob's Dry Goods fame." />
</characters>
<dialogue primary="Bob" secondary="Eddie">
<statement text="Welcome to my store." />
<statement text="Hey there, what can I do for you?">
<response text="I'd like to buy something." />
<statement text="What would you like to buy?">
<response id="buy-weapon" text="I'd like to buy a weapon." />
<response id="buy-item" text="I'd like to buy an item." />
</statement>
<response id="sell-something" text="I'd like to sell something." />
</statement>
</dialogue>
<dialogue primary="Alex" secondary="Eddie">
<statement text="Nice pineapple, I'm going to take it!" />
</dialogue>
</dialogues>
I’ve declared a list of characters at the top and then added primary and secondary attributes to each dialogue. The primary attribute designates the person being spoken to, e.g. Bob the store owner, while the secondary attribute designates the listener — usually the player. Naturally, I would extend this idea to work for items, too. Perhaps a reasonable constraint would be to have an optional single item as an index for a dialogue which would make it easy/fast to grab the right dialogue tree given two characters and an item.
So this is where I am right now. So far I think this could work for some cases, such as an exchange between the main character and some NPC. Still it’s clear it won’t work if we try to have a conversation between more than two characters. For instance, if a member of your party wants to interject some advice mid-conversation. With all of that said, how do you manage the dialogue tree in your game?
If you have any ideas and would like to hack around this problem with me, feel free to edit my gist on the subject.
comments
-
Craig Stern
-
Gornova
-
twood
-
Rob
-
aschearer







