Mass Effect: Dialogue

Game: Mass Effect, made by Bioware

Replicated Feature: The looks and behaviour of the dialogue system and dialogue wheel

More Information: [Blog Post]

Using the Sample:

This sample is composed of four projects.

First, the ZSquare.Dialogue project contains the 4 main classes used by the Dialogue System:

  • SpeechLine – represents a single line delivered by one character, or an event. This has a ID, a subtitle, optionally a sound file to be played when this line is played, and if the sound file is absent, a duration of the speech line
  • DialogueBranch – represents a series of SpeechLines that together compose a sequence of interactions between characters (excluding the Player Character). A branch leads the dialogue from one choice to the next. A branch also has a set of Precondition and Consequences. Normally, these would be analyzed by some other system of the game to determine if a certain branch can be chosen (for example, a certain amount of points in a skill), or to determine the outcome of a branch (for example, in a dialogue one branch might cause people to become hostile, and another would cause them to surrender). I represented these as Key-Value string pairs, and their analysis is not handled by this sample.
  • DialogueHub – represents a point in the dialogue where the Player can make a choice between replies. It can contain up to 6 choices, and can also hold up to 5 Investigation topics. When a hub has investigation topics, these are shown under a sub-choice called “Investigate”. Choosing an Investigation topic causes the corresponding branch to play, and then the dialogue returns to the hub from which the choice was made. Normal (non-Investigate) choices advance the dialogue to other hubs.
  • Dialogue – representa the whole dialogue, holding lists of SpeechLines, DialogueBranch and DialogueHubs. Because of the complex nature of the relation between these entities, each of them is referenced by an ID. So, a DialogueBranch holds a list of SpeechLine IDs, and a DialogueHub holds a list of DialogueBranch IDs.

The ZSquare.Dialogue.Pipeline project provides some Content Pipeline classes to allow loading of Dialogue objects in an XNA project.

The Editor project is just that. An visual editor to create a dialogue description file. For an example, you can use it to open the example.xml dialogue file inside the Content folder of the DialogueSystemSample project.

Which leads us to the main project of this sample, the DialogueSystemSample project. Some important classes encountered here are:

  • BranchPlayer – plays a DialogueBranch, playing the sound and making the subtitle available.
  • HubPlayer – handles filling and displaying the DialogueWheel, allowing the player to make choices in the dialogue.
  • DialogueWheel – displays and handles the input of the player in order to choose one of the presented options
  • DialoguePlayer – given a Dialogue object, it uses the above classes to handle the playing of the dialogue and interaction with the Player.

For illustrative purposes, I included an example dialogue (using text-to-speech for the voices).

The controls used in the sample are:

  • X – skip current speech line
  • Left Thumbstick – highlight a choice on the DialogueWheel
  • A – Activate the highlighted choice from the DialogueWheel

(Unlike Mass Effect, pressing X does not activate a choice, it only skips the current line).

Screenshots:

DialogueSystemSample 2009-04-05 23-30-49-31

DialogueSystemSample 2009-04-05 23-30-56-15

Download: DialogueSystemSample.zip

  • Pingback: Catalin’s XNA Experiments » Mass Effect Dialogue Sample

  • http://www.clarvalon.blogspot.com Clarvalon

    Very nice. The Mass Effect dialogue wheel is, as far as I’m concerned, the only real evolution of the dialogue tree common in the old point ‘n click adventures.

    P.S. I managed to get an unhandled exception in the Editor but I’m jiggered if I can recreate it.

  • http://www.catalinzima.com Catalin Zima

    About the exception… it’s entirely possible. The main point of the sample is the dialogue handling, as seen in the XNA project. The editor is just an extra bonus, which I did to avoid writing XML manually :)
    So yeah, if you encounter any exceptions… I’m sorry :)

    Thanks for the feedback

  • http://retroburngames.com Martin Caine

    Wow, very nice sample. I only wish one of our current games needed a dialogue system!

  • http://www.catalinzima.com Catalin Zima

    Maybe for your future games :)

  • http://spacialk.co.uk simonjohnroberts

    I really am going to look this over again.

    It’s like the third time I’ve been here.

    top work incidentally.

  • http://niklas-rother.de Niklas Rother

    Really cool!
    But you missed adding Keyboardsupport :)
    But i´ve done it for you: Simple replace DialogueWheel.HandleInput(GameTime) with this:
    if (!Visible)
    return;
    Vector2 leftThumbstick = input.CurrentGamePadStates[0].ThumbSticks.Left;
    if (leftThumbstick.Length() < 0.2f)
    {
    highlightedChoice = -1;
    }

    float angle = (float)Math.Atan2(-leftThumbstick.Y, leftThumbstick.X);
    angle += MathHelper.PiOver2;

    if (angle < 0)
    angle += MathHelper.TwoPi;

    highlightedChoice = (int)(angle / (MathHelper.Pi / 3));
    highlightedChoice = highlightedChoice % 6;

    if (input.LastKeyboardStates[0].IsKeyDown(Keys.NumPad9))
    highlightedChoice = 0;
    else if (input.LastKeyboardStates[0].IsKeyDown(Keys.NumPad6))
    highlightedChoice = 1;
    else if (input.LastKeyboardStates[0].IsKeyDown(Keys.NumPad3))
    highlightedChoice = 2;
    else if (input.LastKeyboardStates[0].IsKeyDown(Keys.NumPad1))
    highlightedChoice = 3;
    else if (input.LastKeyboardStates[0].IsKeyDown(Keys.NumPad4))
    highlightedChoice = 4;
    else if (input.LastKeyboardStates[0].IsKeyDown(Keys.NumPad7))
    highlightedChoice = 5;
    else
    highlightedChoice = -1;

    if (highlightedChoice == -1)
    return;

    if (entries[highlightedChoice] != null)
    if (input.IsDialogueChooseBranch(null))
    {
    ChosenBranchID = entries[highlightedChoice].BranchID;
    this.Visible = false;
    }
    Now you can select the entries with the numpad 😉

  • http://www.catalinzima.com Catalin Zima

    Cool, Thanks!

    I only ever played ME on the Xbox, so I only thought about controllers when implementing this sample. But yes, this would be of great help if you wanted to use it in a windows game.

  • Pingback: Gedanken zu Dialogen | Niklas Rother - XNA Computer & mehr

  • http://masseffect4indiegame.wordpress.com/ Hieronimus.le@hotmail.com

    HI! you are awesome, dude! i’ve been working on this thing for a few days with my own results for my own free indigame of mass effect. Im amazed, you created this first. Im looking on you code, but its probably better than mine, i have to ask, can i use some of your code? add it to my project or get inspiration from it? it will mean a lot to me

  • http://catalinzima.com Catalin ZZ

    Sure, use it freely!
    That’s why I shared it.

  • http://masseffect4indiegame.wordpress.com/ Hieronimus.le@hotmail.com

    thanks, i’ve been looking at it, and it has some interesting things. Your solution is more efficient, though i think mine is more reusable (for example, it can show more than 6 options, so it can work for other menus, or even for the tactic-pause). Thanks, again, i can take some ideas from it to make it more powerfull.