Monday, 21 June 2021

#24 Dialog Systems & Ocularis

 Today we're going to talk about dialog systems, their integration in quest systems, and how I implemented such a thing.

Dialog Systems

Let's hear what Chris Bateman has to say about dialog systems (or engines):

"A dialogue engine is the means by which a game speaks. This software mediates the delivery of all dialogue (and monologue) inside the game"

Consequently we may understand them as a component of the medium computer game, being in particular responsible for the channel of perception that is "speech" or "conversation".

So we usually have the possibility here to deploy speech lines, e.g. a sentence being displayed as a subtitle, heard out loud or seen as a (possibly synchronized) lip animation. Lines are usually not unconnected from each other but tied together into forms like trees, graphs, hubs and so on.

Many dialog system allow choices, in which the player is given with the possibility to steer the dialog flow. Oftentimes a list of written options is presented which can be scrolled and selected. There are special variants like timed choices, optional choices (on which lines follow that lead back to the same decision node), choices that lead to special mechanics (e.g. a boxing minigame) and so on.

Furthermore, additionally, moreover, especially nowadays many dialog engines tend to lean towards a more cinematographic style. Dialog partners/actors are positioned, there are fadings, blends and NPCs may walk around in the shot.

In general - the gaps between cinematic, in-game animated sequence, dialog scene and gameplay tend to blur more and more. This is for example visible when tracing CD Projekt RED's games. While Witcher 1 had that classic distinction quite rigorous and didn't make much use of cinematography, already Witcher 2 very explicitely employed cinematographic principles to tell certain things. In The Witcher 3 cutscenes and dialog scenes became almost indistinguishable because of the possibilities that were added to the dialogsystem. In Cyberpunk 2077, dialogs and cinematic sequences aren't separated from gameplay but flow flawless into each other.

Here is an example (Cyberpunk 2077 main quest spoilers), where the gameplay literally is the scene. Dialogs and choices dynamically pop up when moving around the space. The space is set up in such a way that the player is automatically drawn to look at certain things the right way.

The last point I'll consider here is the means of activation - when does a line (text or choice) fire? As Bateman puts it, "event-driven engines are by far the most common form of dialogue engines". So basically all those systems in which batches of lines are played to the player (haha) when some event in the game world is happening, say, a weather change or the player enters a certain area. this is the type I'll be implementing below.
Bateman distinguishes two more dialogue engine types: Topic driven engines are those in which the next lines is determined by the current context - which actions have been done, what items are in the inventory. It is less about when lines are played but which.
Dialogue trees, or maybe rather branching dialogues, are dialogue systems which allow for different subsequent lines depending on a choice made.

When you look at it, these three aren't actually completely distinct (in the sense of you can't have them at the same time) but rather different features a dialog system might have.

But now let's see, how an implementation might work.

Further Reading / Inspiration

  • Chris Bateman: Game Writing. Narrative Skills for Videogames. - Dialogue Engines

    In general, I can only recommend reading this.

Dialog System in Ocularis

Ocularis (very secret project) is basically an Action-Adventure-RPG - the avatar Leonora has fighting abilities, but she also talks a lot to herself and the ones she finds in the world. The world is constructed as a space of progression, and depending on that space-progression both fighting and dialogue-events are delivered. So this is how quests are in Ocularis.

And this is how the dialog engine works:

Overview of Ocularis' dialogue engine.

In every level an overall UI for dialogs is instantiated and communicated to all scenes. A scene object in Ocularis consists of 

  • a scene trigger (usually a box that the player may run into), 
  • scene content (text and choice lines), 
  • scene logic, which is responsible for blending in/out the dialogue UI, setting texts in it, adding/removing choice options and forwarding to the next line. And also dialogue-relevant player input is managed such as scrolling through choice options and selecting them is handled.

Here you'll see some in-engine (Unreal) screenshots of all that with explanations.

Example of scene trigger boxes in the level.

Screenshot of the line data structure.

Example of a scene content definitions with various text lines and a choice line.

Overview of scene logic.

The scene logic is event based: Every red node on the left is the entry point for a certain event. In the middle the scene start section is placed which  is activated e.g. by player overlap with the scene trigger box. The NextLine event is fired to calculate and deliver the next line. Text lines automatically call NextLine again, choice lines have to wait for player input, which is catched in the logic on the top left.

Dialog UI creation and propagation to scene objects in level.

A Quest Jam

Alright, this was fun. But I realized. This wasn't a quest design I wrote down - but this is what I want to commit to. So here is a short quest jam.

Scenario: Two friends meet in a café. Karla and Hannah. Karla is a notorious fast talker and always feels like there is not enough time. Hannah, our avatar, has light depressions, has just lost her job and wants to reveal that to Karla but won't feel in the right situation for that, which'll later cause tension between the two.

The level should contain the café and its surrounding and be entered upon about 9am. It should feel too open, the café has many glassy walls and little separation to other tables and guests. The player is funneled over the busy street, past a beggar who is pleading for money (representing Hannah's fear). Getting to the entrance she isn't greeted instantly, but has to call twice for someone. She's then guided to the unpleasant place and has to wait there some time, overhearing a conversation of a very successful man.

Finally, Karla arrives. She is in a rather pragmatic busy mood and starts talking long and much about her own life. The player at several times gets the choice to try bringing up her own issues, but Karla misinterprets that or quickly diverts in another direction. The noises are increasingly loud to Hannah, at some time she falls silent. At last Karla notices, but suddenly a fire alarm starts, chaos breaks out and everyone leaves the building. In the mess the friends loose each other. The player is directed to a silent place in a dirty side lane where Hannah sits down.

In a monolog with herself the player can express how he would talk to himself in Hannah's skin.

Ideas for Feedback

  • What is the meaning of life?
  • What kind of dialog system might fully evade the descriptions I gave?
  • What might be building bricks, toys to play around and construct quests with for brainstorm/ quest jam sessions?

Conclusion

What a long post. I'm wondering why I write so much about things already known or done. I mean, it surely isn't for potential readers alone. Maybe classic need for any self-expression? Maybe the strive to achieve something? I feel there's like a huge amount of ideas, concepts, text, music, images and so on in my head that just want to be put out into the world, simply because it would be kind of... stressful(?) to let them stay inside. Maybe this is about freeing my mind from the necessity of needing to let those things endure inside.

Well, on the other hand, of course, I enjoy documenting things for other people and myself to build upon that, to synthesize the knowledge and energy of people.

Those reflections are a nice closing.

Until next time, have a good time!


No comments:

Post a Comment