Writing Game Dialogue

A lot of you know I'm a multiclassed programmer/writer. Before I drafted four novels and got an agent, I had a Computer Science degree, scripted for Planescape: Torment, and completed a few dozen Project Euler problems (until they got too hard). Unfortunately, since I've been more focused on writing, my levels in programming have gone largely unused.

Until now. It turns out game dialogue is the perfect job for my class combination. It's nowhere near as complicated as writing a program to solve Sudoku, but it's got all the puzzle-solving aspects of programming that I love.

And it's not as hard as it sounds. Here, I'll show you.

Typical dialogue in a novel goes something like this (excerpt from Post-Apoc Ninjas):

     "Tell me who you really are," the Marshal said.
     Here we go. The Marshal had already guessed much. Kai would have to be careful. "As I said, I grew up among mercenaries in Rivaday, though the mercenaries themselves were from all over."
     "Ah, so the story changes. How much did my grandson pay you, then?"
     "Pay me?"
     "In reward. Surely a mercenary would not rescue the Lord of Gintzu and take nothing in return."
     Kai hesitated. Marshal Aryenu was much sharper than his appearance made it seem. It felt very much like talking to Domino. Better to turn the questions on him. "How much of what Lord Domino told me was true?"
     "Your reward, mercenary?"
     Both sharper and more stubborn than his grandson. "Two thousand."

     "A lie. The boy doesn't pay anyone he doesn't have to."

Game dialogue is not so different from this, at least for a game like Torment. Prose-wise, there are only a few changes:
  • Dialogue tags ("the Marshal said") are rarely necessary, since the character speaking is usually indicated on the game screen.
  • The Player Character's thoughts (in this example, our PC is Kai) are not tied to the PC's lines, if they're included at all; sometimes all information is conveyed through dialogue or item description instead.
  • PC lines are typically very brief. (In some games, you don't even get a line, just a motive or emotion that the game designers interpret for you).
  • Any description is written in present tense and second person (though I suppose it doesn't have to be).
So a more Tormenty version would look like this (speaker tags added for clarity):

Marshal: "Tell me who you really are."
PC: "As I said, I grew up among mercenaries in Rivaday."
Marshal: "Ah, so the story changes. How much did my grandson pay you, then?"
PC: "Pay me?"
Marshal: "In reward. Surely a mercenary would not rescue the Lord of Gintzu and take nothing in return." He examines you carefully. Suddenly, he seems much sharper than his appearance first suggested.
PC: "How much of what Lord Domino told me was true?"
Marshal: "Your reward, mercenary?"
PC: "Two thousand."
 
Marshal: "A lie. The boy doesn't pay anyone he doesn't have to."

Those differences are primarily cosmetic. The real difference, and the most fun, is that game dialogues allow the player to choose what they say.

Marshal: "Tell me who you really are."

1)
[Lie] "As I said, I grew up among mercenaries in Rivaday." 
2) "I'm a ninja."
3) "How much of what Lord Domino told me was true?"
4) Attack the Marshal.

Each one of those choices goes to a different branch of dialogue (or exits dialogue and starts combat, in the case of the last one). It's pretty much exactly like a Choose Your Own Adventure novel combined with a combat mini-game.

But a game should be better than that, no? We can respond, not just to what the player chooses to say, but to their other choices as well -- things they've done in the past, how they've customized their character, who they choose to travel with, etc. We call this reactivity.

Marshal: "Tell me who you really are."

1)
[Lie] "As I said, I grew up among mercenaries in Rivaday." 
2) "I'm a ninja."
3) "How much of what Lord Domino told me was true?"
4) Attack him.
5) (If the PC betrayed his clan) "I'm a ninja, and a fugitive from my clan."
6) (If the PC killed the guards outside the keep) "I'm the guy who killed your guards."  
7) (If the player took the Read Minds ability) Try to read his mind.

And then each of those responses might have reactivity as well. The lie in (1) might succeed if you have a high deception skill, for example. What you learn from (7) might change depending on your level in the ability.

What you end up with is a branching, interlinking dialogue tree, hopefully one that is every bit as interesting for the player to navigate as combat or exploration.


It might seem overwhelming, but really such a thing evolves gradually as you write each line and think about what the player might want to say in reply. In fact, it's difficult NOT to write a huge, unwieldy conversation tree. For me, that's half the fun: trying to figure out how to guide the player to all the information I want them to get, without forcing them.

Here, if you want to play with a free, online example, try this online game where you play a dragon. But, um, don't blame me for any productivity loss.