I’m wondering how you guys would create a system that handle chats and npc behavior in a game where your actions, choices and appearance affects them. For example, how would you create such a system for a game like Skyrim ?
It seems like a huge pain to manage a global context where each npc would find the relevant information to react from, and at the same time expose their possible reactions to non developers guys.
Any example of implementation, ideas, proposition, etc are welcome
We’re using a global context for a system like this. It’s not that a big of a pain, to be honest. Tips for that:
Make it easy for designers to create the save triggers and values that’s going to be used, and to apply them where they’re used.
Plan ahead - make it really easy to figure out where each save trigger is used, so you’re able to delete unused ones. We didn’t do that, and it’s a major pain.
Make a system where you can rename all of the data (saved triggers and values). Reference them by generated unique IDs that stay constant, not their names. We didn’t do that, and it’s a major pain.
So you’re using a big global dictionary that stores each key value pair that are updated by the triggers ? If so, do you handle restrictive access to the stored information (some npc that can access to the up to date info and some who don’t) ?
How do you expose the possible behaviors to the designer ? Do you use a simple xml/json descriptive file using the keys stored in the dictionary ?
If you’re using a system where information is not instantaneously available to all relevant actors, then using a big global dictionary (AKA a “save file”) is not going to be viable, no.
Truth be told, the only game I know of to date where information about the player’s action flows from actor to actor in order to let some actors only know about outdated information is Dwarf Fortress. I’m pretty sure games like Skyrim save one trigger for “the player has done this thing” and another for “this group of NPCs knows that the player has done this thing” if those two are seperate. You know how the entire village knows if you killed a single chicken, as long as one villager saw you? That’s the result of that.
The data (both the save data and things like a conversation) is saved in a ScriptableObject, and exposed to the designers through custom Editor Windows that we wrote.
Love/Hate maintains separate action memories (deeds) for each NPC, and they can share memories when they run into each other (gossip).
It offers integration with the Dialogue System for Unity, which has its own data model for recording other world info such as player quest states, weather, time of day, etc. The Dialogue System also has a save system that can load and save this data, including Love/Hate’s data. Dialogue trees can branch based on the current values of these data, and each dialogue node can control things like playing facial and body language animations.
I don’t intend this as a product plug, but just to describe one solution that’s worked well for a lot of games. The documentation’s free to read, and you might find some of the ideas useful in your own implementation.
Exposing the internal data to a simple Lua scripting system has proven to be a useful way to provide some pretty powerful and flexible data control to designers. There are a few good, free Lua implementations that run well in Unity.
Also, it was helpful to keep the Love/Hate stuff separate from the Dialogue System stuff, with only a narrowly-defined connection between them. The more you can keep each module separate and decoupled, the easier it’ll be to implement and test the individually and avoid side effects.
Thanks a lot TonyLi for those links. I’m usually not against buying plugins in Unity but I do want to work on this subject and try to implement my own solution As you said, reading the documentation of Dialog System for Unity and Love/Hate will probably give me ideas and valuable information though !
I’m not sure about the Lua part. Will designer be able to use it ? I was thinking that using a descriptive language as xml or json would be easier. Do you have any experience to share about that ?
Lua’s used a lot around the industry as a scripting language for games. It’s supposed to be easier to write than traditional enterprise languages (Java, C#, etc.), while still having the power to express yourself.
It’s healthy for your designers to learn a bit of scripting anyway, so if you think they’re ready to write an if-statement or two, but don’t want to throw them in the deep end of polymorphism, that’s the way to go.
XML and JSON isn’t languages, they’re data formats. If you create a way for designers to create a conversation system writing JSON data, you’ve simply made a DSL for conversation systems. Which might be appropriate, but be aware that that’s what you’ve done, and that maintaining languages is a bunch of work.
It can be helpful to write a simplified front-end for basic Lua, or for basic XML/JSON. For example, the Dialogue System provides optional drop-down “wizards” for when writers don’t want to type Lua code manually:
Some designers love the flexibility and control they get with Lua; others are perfectly content with the drop-downs, which cover all the standard things most writers will ever need to do. I definitely agree with @Baste that (1) if you’re going to provide a simple scripting language, Lua is the way to go because it’s so common, and (2) don’t make writers work directly with a data format like XML or JSON; provide some kind of interface. It’s probably even more frustrating for writers to have to fiddle with XML or JSON than it would be to work with Lua.
Speaking of data formats, why not Twee instead of XML or JSON? Twee is another simple text-based format, and your writers could use the node-based Twine editor and even test their conversations by playing them in Twine.
Whatever under-the-hood format you choose, I suggest giving your writers a GUI-based front-end. I suggested Twine because it’s already written and tested, it’s free, it’s documented, and many people are already familiar with how it works. (Why re-invent the wheel, right?) But you could always write your own editor in Unity if you want.
There’s also Excel. A lot of developers still write their dialogue in Excel, although managing large, interconnected conversations can become a chore.
Well, I’ll go for Lua if I can expect designers to accept that ! I already worked with it in C++ but always did it for developers.
I really hate building GUI front-end, they usually are the main reason I consider buying a plugin… Twine looks interesting, thank you !
I’m using Excel already, but only to easily store the texts in multiple languages.