Dialogue system

Hi everybody, my first post here.

I’m interested in creating a sort of point’n click adventure game. I decided to give a try at GD instead of other more focused engines out there because i like a lot the event paradigm, and because of the html5 deploy, which i think is, as of now, the ultimate platform.

One thing that bothers me is how can i manage conversations between charachters, and how to make them change over time in the game.
Hints? Did anyone already faced this?

thanks in advance

I have just done dialog in sprites that appear on timers. For an example of how this looks like go to this game gamejolt.com/games/strategy-sim/ … eta/27376/ and then go on tutorial.

Those text boxes are just sprites that I drew in GIMP that are appearing on timers. Something like that should work just fine?

thank you for repling Mats.

Your solution is not what I intended. I’d prefer using a Textbox for such a task (less sprites around) giving timed istructions like

txt Do =“Something” to the text of MyTextbox

Anyway, my need is a methodto manage many dialogs between charachters at different stages in the game. So that the first time you talk to a guy he replies something. The second time he says something else. And if you talk to him after something has happened (i.e you find an object, you visited a place, you solved a puzzle, etc…) he says something different too. Also I’d like to know how to make branches in dialogs, that is having multiple choice to reply to a question, that lead to different patterns in the conversation.
I know that it can be done with variables-checking, but i fear that would be a huge effort even for short dialogs.

Other adventures-dedicated softwares often have dialog-editors, looking like diagrams. How could I replicate such a feature in GD?
I thought I could use several external event (one for each charachter?).

Did anyone already made something similar?

It really won’t. It’s literally a case of incrementing and checking just ONE number. Really fast and simple. :wink: You can also use this variable to create your branches.

Also, you can do it with text objects, but I don’t see what advantage this has over using sprites? You won’t have too many sprites around, as they are only created when they are required and destroyed once they are finished with. However, I have implemented a message box system in my roguelike I’m working on and when I get home later tonight I can show you how I did that so you can see another method.

Yes you can.

thanks Mats, I just love seeing examples!

Regarding variables. Ok i see what you mean. I should assing a variable to a charachter and do conversations relative to its value. Whenever a change happens (i.e. i found a machete) i just change the variable value to have the proper action “txt Do =“Be careful with that knife””.

Regarding sprites, as far as I have learnt, each one has to have an image on disk. If so, it would mean creating tons of images to display the many text balloons required even for a short adventure game. This is why i would prefer storing text in actions “txt Do”.

Actually, my “joke game” I posted on Kongregate some time ago has dialogs and since I have project files… dl.dropboxusercontent.com/u/210 … ources.rar

The scene you want to look at is “Intro” I believe. There’s complete letter-by-letter message system, although a bit complicated.

Hey Darkhog, you rock! :slight_smile:

Thank you for helping too.
I see in your example that you put the actual text to be shown into scene “Intro” variables as structures. Fine.
How can I have something like that but using an external file? XML?

Probably you could reuse lot of my code, you just need to populate structures with data from XML. I’m afraid I can’t help you with that as I never really needed it, but other people will!

Looks like i found a bottleneck for html5 distribution: how can I load values from an external file?

I think on HTML5 you can’t.

@4ian, maybe you could add ability to load values from json or csv over http when using html5 platform?

It’s already possible using the function to do an HTTP request :slight_smile:
Then use the action to convert the variable containing the raw JSON returned by the server to a structure variable.

Ok, so it IS possible! Nice.
Where can I find documentation to learn how to do these operations?

Added an article about it on the wiki: wiki.compilgames.net/doku.php/en … s/jsonfile :slight_smile:

Let me know if something is not clear.

Wow 4ian, very kind and , i must say, very responsive of you. ( this also makes GD gain points )

ok, I’m now entered in the world of json (didn’t know much about it before). I can write and validate a structured json file, and I managed to load it into a variable (oh, can this variable be a global one?)
what is not clear to me is the syntax needed to access nested values, i.e the third value in an array inside an object which is inside another object at root level

thanks in advance

Here is an example oj json that I made to test my dialog system:

{ "People" : { "Albert" : { "dialogs" : { "1" : [ 5, "Hello", "You're new here, aren't you?", "So maybe...", "You gotta pay something", "Don't you think it's due?" ] }, "items" : { "3" : [ "Old book" ] } }, "Bertrand" : { "dialogs" : { "1" : [ 4, "Hello", "You're new here, aren't you?", "You gotta pay something to Albert", "You know this, right?" ], "2" : [ "3", "I just found this beautiful piece of art", "Some fool tossed it in the garbage", "I feel so generous that I'll give it to you" ] }, "items" : { "2" : [ "Rusty piece of something" ], "4" : [ "Used napkin" ], "5" : [ "Clean napkin" ] } } }, "Places" : { "Church" : null, "Square" : null, "etc..." : null } }

So how do I access to - let’s say - the string “I just found this beautiful piece of art”?
It is in an array inside an object (dialogs) inside an object (Bertrand) inside an object (People) in the root

I tried VariableString(jsonraw.People.Bertrand.dialogs.2[1]) but didn’t have luck.
I’m pretty sure the syntax is wrong, I’m totally new at javascript :blush:

First you must NOT access jsonraw, but the variable were you saved the result of the second action (the second action transform the content of jsonraw into a structure variable, called “result” for example ).

Then you do

VariableString(result.People.Bertrand.dialogs.2["1"]) 

(quotes are important)

I always thought that the way multimedia fusion handled it (with the ini files extension) was by far the nicest design approach.

Ini files (ini file interpreter automatism?) are great not only for dialogue from external text files. They can also be used to read and store other types of gameplay data.
i’m attaching a tutorial here to illustrate why they make things much easier/simpler :slight_smile:
In-Game Dialogue Tutorial.pdf (913 KB)

The issue is that HTML5 games are not able to read any local file. INI or whatever :slight_smile: (I’m quite sure that HTML5 games produced by multimedia fusion are not able to read INI files! :slight_smile: ). It is a browser restriction and developers can do nothing to overcome it!
You have to use requests such as demonstrated in the wiki article, and it only works when the game is on a server. (Because request to local files are also forbidden by browsers).

Note that native games do not suffer from this browser restriction, so that I created actions to read/write from/to XML files. (Because XML and json files are waaaay more powerful that these old so 90’s INI files).

The nice thing about ini files is that they are very easy to understand and use. They do not require you to write as much and learn as much.
And ultimatelly- their ini system has an already made syntax interpretter that is very easy to use and powerful enough to do a number of different jobs. It is easy to understand by anyone.

With construct2 and gamedevelop, one has to make their own interpretter and it is waaaaaaay more complicated and involved to do so. How many of our users actually know how to deal with xml/json in gd?

The issue is not wether they can be online or not. The issue is in the actual use of json files and so on. I wish gamedevelop had something as easy and as nice as the ini files- in terms of workflow…but without the limitation of needing to be local.

Thank you again fo directions 4ian. I managed to make it work.
Now, i’m figuring out how to do this whole thing :slight_smile: - Next step will be making a micro-game with all of the pieces I need for the complete one. Once I’ll be able to wrap it up together, I’ll be ready for the Big Job.

Regarding .ini vs json/xml
I really enjoyed learning json, and found it a very clever and easy way to store data (see jsoneditoronline.org/). Also it is way more powerful than .ini.
Dealing with json shouldn’t be too hard the moment you know how to use variables. As you see in my dialogue example, it’s just the matter of changing a number to get to a specific dialog, and then increasing a variable number to get the sentences in the order stored in an array