Hey everyone, Siilk here. Today I'd like to tell you a bit about my current task, implementation of the dialogue and multi-stage interactions in DNC. For an adventure game, dialogue trees are one of the core mechanics so making it potent and flexible is very important. Hence I avoided any kind of hard-coded dialogues and decided to go with dialogue processor approach, with tree-like data structure to hold the dialogue data a dedicated general-purpose processing code that would bring it to life.
I started with designing a data unit, a single dialogue node that will become building blocks for dialogue trees. To represent a single "step" of the dialogue, each node must have basic data fields(NPC speech to display etc) and also be linked to other nodes(child nodes for lower-level subtrees, back to parent node etc). So I decided to use GameMaker's object to build dialogue node from as it allowed me to use it's built-in rudimentary OOP support and add data fields to the object itself instead of creating data structure from an array or a list. This also gave me another unexpected advantage but I'll get back to that later.
In it's current current form, each dialogue node object contain prompt text(text that will be shown as player's choice for an option that will lead to this node), descriptive text that will be displayed when player will "enter" this node(NPC speech in reply to his choice etc), a couple of internal use fields to contain unique name of the whole dialogue and the node itself and a list of child elements(nodes this node will allow player to "move" to; this will represent dialogue options for this node). After some testing I also added a redirect field. This will be used to turn the node into a single-prompt redirect node that can be used to bring player back to a higher-level node. Such nodes can then be used to create a tree-like structure (a directed graph to be exact) that will represent a single dialogue with all possible choices and transitions between them.
After the basic data structure was more or less functional, I implemented the dialogue controller, an object that will act as a processor for dialogues. It's purpose is to draw the dialogue UI, process player input and change active dialogue node depending on player choice. Controller is still in it's infancy and so far lacks proper GUI(I use text output for debug purposes) but it already does the most important thing: brings dialogue data structure to life.
The biggest limitation this systems have so far is the lack of conditional changes to the dialogue graph. Ideally I would like to make conditions dynamically addable at runtime but so far it seems that it might be impossible to do in GameMaker. Another thing I would love to do with this is to implement a graphical dialogue editor that will allow us to create dialogues visually via custom-made GUI instead of writing the GML code to describe the graph structure. This is when nodes being GameMaker objects will come in handy as I will be able to draw them directly instead of creating the wrapper objects to represent each node on the screen.
There are of course other things like adding a field to store NPC emotion, dealing with multi-character dialogues etc but that's the distant future I guess. So far the most important thing is to add the actual GUI drawing subroutines.
Here are some work in progress style gifs of what dialogue UI looks like right now, as seen in DNC testing area.
Current testing text-only UI
Same stuff with debug overlay turned on(yeah, I'm a bit of a debug output junkie)