Branching Dialogue using JSON

15

Index

Features on these Courses

Attached Files

The following files have been attached to this tutorial:

.c3p

branching-dialogue.c3p

Download now 170.7 KB

Stats

8,539 visits, 19,346 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 7 Apr, 2020. Last updated 21 Apr, 2022

The first thing you’ll notice is that the NPC system is substantially larger in this project. That’s because this was born out of a need to refactor my own NPC code used in my main game file. I could have taken it out, but I’ve left it there as an example of using families etc.

The basics of the NPC mechanics were designed a LONG time ago, and quite frankly were pretty messy. They worked, but there was a lot of event repetition and the whole thing was bulkier than it needed to be. It was fine for showing how each NPC worked as in this tutorial but not great for a big game. So if you’re looking to polish your skills refactoring and using families, why not try taking the NPC events from the original tutorial, and tidying them up to something more like what’s included in this tutorial.

Anyway, tangents aside, let’s get back to the project at hand.

The project uses a lot of the same JSON functionality as the previous project. So, you’ve still got the CurScene, CurDialogue and GameState global variables, but there are some extra ones needed for this project:

  • InteractionID – This stores the ID number of the NPC being talked to, helps with picking
  • Question – a Boolean which tells the game whether or not a question is being displayed
  • ChosenAnswer – This stores the ID number of the answer currently selected by the player
  • CurLine – Simply used for debugging, this shows the current line of text being pulled from the JSON file

In terms of events a lot of what we’ll be using expands upon the events in the previous project. There will be a few more functions, and some changes to existing ones, but we’ll cover that as we go along.

The JSON file has changed a little in structure, adding some different strings for the type key to allow the system to perform End checks. By having “end” as a type in the JSON, we no longer need the GetNumLines function, because any time the type reads as “end” the EndDialogue function will be called.

  • 10 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Hi!

    I started an open source Game Dialogue Maker project (still very much in alpha) based on this very tutorial. The idea is to offer a node-based system of planning branching dialogue and then you can export it to a JSON file that you can drop to your c3p project here. Everything is in JavaScript and HTML. You can check it out here (and contributors are very welcome):

    github.com/AnttiPerala/GameDialogueMaker

    I don't understand some things in the example JSON perfectly yet. For example the very first object that sets nextscene to 3. If I leave it out from the output of Game Dialogue Maker then it breaks so it seems necessary. But why is it setting nextscene to 3? Can you Laura_D expand on that part?

  • Hi Laura_D,

    To activate a function, a "Z" press is needed, is there a way to have the function activate simultaneously with a dialogue line?

    RESOLVED EDIT

    For people interested, you can make a new type "lineFunction" and call a line and a function at the same time.

  • Great tutorial, thanks!

  • Hey, thank you for tutorial, i use Construct 2 and Construct 3!

  • Hi, Laura_D I have a major issue I've been trying to solve. I haven't been able to figure it out. If you could help me out that'd mean a ton.

    construct.net/en/forum/construct-3/how-do-i-8/change-variable-per-copy-169181

  • Load more comments (5 replies)