The heart of Derby Day is its conversation system. This is the engine on which everything else is built upon. I’m currently reworking this system for the third time and there has been countless iterations in between.

Dialog systems in games are notoriously difficult. On the outside they seem simple but there are always so many different cases that must be supported that it becomes impossible to code elegantly and efficiently. While coding Derby Day I feel like a pendulum between two opposites:

The conversation system must be able to cover all stories that I want to write.

I have to finish Derby Day. If a specific story line doesn’t fit in the conversation system I should hack it in.

Conversations are used to drive the game/story forwards. It is through conversations that the player achieves success or crumbles to game-over. Here are my constraints:

A conversation can be started from any location/state.

Characters will say different things depending on the location/state.

The player can call characters they’ve met to start a conversation.

Some conversations depend on past choices made by the player.

Some conversations will continue days after an action is made by the player.

Some conversations depend on race results, random chance, or other factors.

Some conversations can be unlocked through game events.

Here are some examples of conversations I want in the game:

Player can ask a gangster to kill another owner’s horse, that owner has a chance of catching the gangster. If this happens the corresponding owner then calls the player to threaten them.

Player’s daughter can start a conversation to tell the player that she found a wild horse that she wants to keep. The player can refuse this request but the daughter might still bring it to the stables and tell the trainer that you said it was okay. The trainer then calls the player to find out what’s going on.

Player’s jockey will call the player to say that he’s gained weight. The player can then fire the jockey, or tell them to try harder. If the jockey is told to try harder there’s a chance that they’ll overdose on cocaine.

One day I was feeling lost and frustrated. I tried to think of other games that had similar dialog systems and Stardew Valley came to mind. Players could walk around the world and start conversations with other characters who would reply depending on various factors like the current season, the time of day, how much they like you, and where they were currently located in the world. I wrote to Eric Barone, the man behind Stardew Valley to ask for advice. His reply:

For Stardew, I didn’t use any 3rd party tools. Most of the dialog is contained in xml files, where I associate each dialog message with a “key” that describes the conditions that trigger that specific message. So, for example, a key might dictate that a particular message comes up on Wednesdays in Winter, if the NPC is at 4 hearts. Within the dialog message, I have special characters that perform different functions. For example, a “#$b#” string denotes that the message should be broken into two separate windows at that point. It can get more complicated, like when an NPC asks you a question. But the bottom line is that I coded the dialog system myself from scratch, so I had complete control over these “special characters” and their behaviors. Your spouse getting “mad” about giving a gift to other players is just a check done in the code when you talk to your spouse. The system I created is actually pretty sloppy, and for my next game I’m going to try and do it in a cleaner way. But ultimately, it worked out. Hope that helps at all, and best of luck with your game. Horse racing game sounds cool

This helped immensely. Not because gave me the magic solution, but because he made me feel validated. There is no magic solution and it’s okay if I don’t feel great about how it all fits together. I can still code a great game like Stardew Valley. Thank you very much Eric!