SamuZai
Bent Shaft Studios
Bent Shaft Studios

patreon


High Level Dialogue System Design Showcase!

Greetings! This is Gabriel Plourde here, making my first Patreon post for Sucker Punch. I thought I’d go into detail on the high-level design and development of some of the systems and core mechanics. So if you see a post from me, you can expect just that. Pyro will still be here, don’t you worry! :D

I’m going to focus on a single system for this post: the Dialogue System.

Core Design Philosophy:

- A scale-able, open-ended dialogue system that can be used to create unique and theoretically infinite conversations.

Systems Design:

Staying at a high-level overview, I’ll be excluding actual code and instead describing the systems without getting too technical.

We start with a data structure made up of multiple arrays of data for NPC dialogue, player dialogue, and unique actions called during dialogue. Visualized, this would look like various 2D tables:

-NPC dialogue data

each data element contains a single phrase/sentence to be said to the player at that point of the conversation.

-Player Dialogue Data

each element contains a single phrase/sentence used for the player’s choice at that point of the conversation.

-Event Functions Dialogue Data

each element contains functions to be called at that point of the conversation.


There are other elements to this system to control when the player can reply, if functions can be called, and more, but we will be ignoring those additions for this discussion.

Traversing through data elements:

When dialogue starts, we begin all arrays at 0,0. So, the NPC will greet the player with the dialogue populated inside the element of the NPC dialogue data located at column 0, row 0. As the player progresses through the dialogue phrase by phrase, we go down the NPC dialogue data row of elements until they’ve been exhausted.

At this point, the player can potentially reply to the NPC if we designed this conversation with that functionality in mind. If the player can reply, the choices available to the player are populated in the Player dialogue data column with the same index as the current column index used for the NPC dialogue data. So, in this example we would be using the player choices under column 0.

Depending on the player’s decision, the dialogue now branches to a different column and starts from the top again. This uses a formula that can traverse dynamically sized data structures, allowing for theoretically infinite conversations.

Formula:

New Column Index = I,

Current Column Index = J = 0 (in our example),

Previous Column Index = K,

Player Decision = P. P>0, P<4,

Possible Player Decisions = Q = 3,

Fibonacci adder = F. F>0

I = P + F

where F = K*Q

Following this example:

if the player chooses choice 1 we get:

F=0*3 =0

I =1+0=1

if the player chooses choice 2 we get:

F=0*3 =0

I =2+0=2

if the player chooses choice 3 we get:

F=0*3 =0

I =3+0=3

As a more complicated example just to show how we traverse in the middle of the dialogue data set, lets assume the current column index is 5 instead of 0. Let’s also assume the player decision is 2. So:

F=5*3=15

I =2+15=17

So in this example we would now be traversing to column 17.

Wow, you made it this far. Congrats on your attention span! This process repeats until the dialogue data is fully traversed. Throughout the entire process, our event functions dialogue data can have corresponding events be called at that same point in the conversation. This means any events with the same column and row indexes will be called.

Some examples of events we can use during conversations are:

-calling audio to be played

-switch to a different level or cinematic

-earn money or rewards

-change character visuals or variables

-switching to a different dialogue tree (includes randomization!)

-and much more!

And that’s about it! This describes a single dialogue container. So any dialogue in the game can be populated using this system. This system was also designed with Unity inspector variables support and such so that it can be populated with data without getting into the code. So it can be utilized directly by our writer PyroToaster!

If you are looking for code examples of a more in depth understanding, feel free to message me.

Thank you!

-Gabriel Plourde



High Level Dialogue System Design Showcase!

More Creators