In previous GearHead games, dialogue trees had to be constructed manually. Each NPC could have an assigned dialogue tree, and random plots could override this with their own dialogue tree. This worked well but was labor intensive and somewhat inflexible.
GearHead Caramel does things a bit differently. When a conversation starts, a list of all the things this NPC could possibly say is generated. These get linked together into a dialogue using a process similar to a context-free grammar (it’s almost context-free; context-lite maybe?). For instance, a “Hello” node might link to an “Info” node or an “Open Shop” node. A “Mission Offer” node might link to “Accept Mission” and “Reject Mission” nodes. It’s also possible for a conversation node to come with pre-attached replies, for situations that don’t match any of the standard contexts.
These conversation nodes can come from a variety of sources. An NPC might have nodes directly assigned to it, such as a shopkeeper’s “Open Shop” node. A random plot might assign new dialogue nodes to an NPC, such as the “Mission Offer”, “Accept Mission”, and “Reject Mission” nodes that the mission-giver needs. It’s even possible for an NPC to receive dialogue nodes from a generic source, such as requests for information that you can ask to anyone living in a certain area or belonging to a particular faction.
Once the dialogue has been built, the last step is to construct the text. GearHead Caramel uses a token expansion system to procedurally generate a lot of the text used in the game. For instance, instead of assigning the NPC the dialogue “Hello. Nice to meet you!”, I can instead assign the tokens “[HELLO] [NICE_TO_MEET_YOU]”. The dialogue processor will check the grammar dictionary and replace tokens with appropriate text, recursing until no valid tokens remain. There are two main advantages of doing things this way: first, dialogue lines will be subtly different each time they’re seen, helping the world seem a little bit more alive. Second, this technique allows dialogue to be tailored for different personality traits and other character attributes. The grammar dictionary has multiple options for each token, sorted by tags. This helps characters to speak with a consistent voice, even though I don’t know who is going to be speaking a line when I write it.
The token expansion system is also used for the PC’s dialogue, so different player characters should sound different.