Dialog templates: Localize and customize your NPC dialog

Localization and customization is a big deal…

Of all of the feedback I’ve received during GDC when talking about Interrogative, one of the most received was that of being able to localize the dialog generated. That’s a valid concern: Games these days launch in multiple countries at once, or with localized versions following very closely behind the primary-language version. The amount of effort for such a task is actually pretty big, unless you’re working on an online game with massive amounts of text that needs to be converted, in which case the task is absolutely monumental. I could forgive people for looking at tech that generated dialog with localizing near the top of their list of features they would need to assure them that this tech was for them.

Fortunately, Interrogative has a solution. And it goes hand in hand with being able to do a ton of other cool things with dialog…

Dialog templates: For customization of your dialog.

Interrogative will ship with sample implementations of dialog, but let’s face it: I’m not a great writer. You’re not going to want to accept the dialog that my tool spits out as a default, especially if your dialog requires a style that is not contemporary. If your game takes place in the Middle Ages, you’ll want to change your dialog to suit that speaking style. Same goes for games set in certain areas of the world where the grammar is slightly different than standard American English (pretty much everywhere, since American English has no real standard itself!). So once you get the tool, you’ll want to customize how the dialog is churned out.

At first, and I did this to quickly implement other functionality while I tried to figure out this little Gordian Knot of a problem, I hard-coded how the data pulled from the database was input into the dialog and spit out as a sentence (or two, or three). The upside was that I had full programmatic control of the text, but the downside was that if you wanted to customize it, you either had to modify source code or make a system to roll your own calls to get the data and assemble it into dialog. The latter gives the user power, but at the same time limits the ability to customize dialog to those with programming skill- and this tool needs to be usable by writers. So a third was was to use a kind of dialog template that was generic enough that a writer could create a sentence for a particular purpose, mark it up with where variables needed to be, and it would get filled in mad-libs-style.

The benefit of this is two-fold: First, the writer gets to do most, if not all, of the customization work. And second, when the writer needs to pull some information into the template that isn’t supported out of the box, the templates are based on functions linked to the markup, and so extending the functionality means adding an additional marker and having a programmer create that function which will access the data for you. So you can take one of the one-sentence templates and turn it into a two-paragraph exposition template if you need to, or you can customize the callbacks for the markers to do extra processing for information that needs to be generated on the fly, but is not inside the database (such as for single-player games where you want to calculate stats at a specific point in time, or for online games where you need to look at data that exists both in your database and in your scene object tags). It’s very flexible that way.

Here’s a good example of what a template could look like:

“You [smurf] like a [smurf].” (You can’t possibly not get the reference!)

Simple, and the markers for “smurf” and “smurf” get replaced with whatever you need to fill into that. NPC names, the subject of conversation, verb conjugation, stat calculations, or even flavor-text that reflects the state of your AI (NOTE: That feature is currently waiting for the completion of this feature, so that will be supported out of the box).  If you like, you can even do something like:

“NPC tells you a joke: [joke].”

And replace [joke] with a function that randomly picks a set of predefined jokes. It’s all up to you is what I’m saying here. But Interrogative’s power doesn’t end there…

Dialog templates: For localization of your dialog.

So, you made all this fantastic dialog in Interrogative, and then one of your writers says “That’s awesome! But…what about when we ship in French?”. Don’t fret- dialog templates are, as you see, simple strings with markup that can be replaced with other simple strings with markup, allowing you to replace the words with those in another language, and place the markers where they need to be in that language’s grammar.

So in one table, you could have:

“You [smurf] like a [smurf].” (English)

And in another:

“Usted [smurf] como [smurf].” (Spanish)

Or:

“[smurf] bat bezalako [smurf].” (Basque)

The grammar for Spanish and English are similar here, but Basque is not. Actually, you’ll need a marker and function for “bezalako” to conjugate that, if Google Translate is correct- and not knowing jack about Basque, I’ll take Google’s word for it. And while we’re talking about conjugating stuff…let’s talk about conjugating stuff quickly.

I like Dictionary types. Specifically, Dictionaries that allow you to quickly look up a word (with close to O(1) performance) and return a value, like a conjugated version of it. Once those words are in, your writers have much less work to do outside of customizing the dialog templates, which will then go on to create orders of magnitude more dialog than was created by the writers.

The dialog templates and markup in Interrogative are force multipliers for your writing team.

So, where’s the demo?

I’m working on it. Got an AWS instance all set up and everything so that I can throw a Unity web-player up on this site and let you play with features as they get developed. I also have a number of demos in mind to show off some things that can be done with the PAI, conversation system, and also with those features in conjunction with gameplay techniques. Actually, I was hoping to have had it up already, but jobs are busy things, and my brain was still a bit fried from GDC, and now we’re here.

But yeah, it’s coming very soon, and all of the dialog in it will be run through these templates (which look exactly like the dialog it was spitting out when I hard-coded it, but I can fine-tune it now and it lets me see where I can make the dialog more flexible using markers and functions).

Next blog: Probably more on Opinions, since I had gotten some of that to work in the airport waiting for my flight from GDC back home, or maybe on some new things I was thinking of that you could do with the semantic data to make your NPC think (and talk) just a little bit more deeply. We’ll see!

Leave a Reply