Dialog System

Get help using Construct 2

Post » Tue Jan 03, 2012 7:11 pm

So I'm kind of stumped to what might be the best approach here. I'm working on a dialog system a like to Alpha Protocol. Essentially multiple choices with varying effects. For simplicity's sake let's say the actual dialog is hidden until the player makes a choice based on a single word in the dialog box representing the tone of the response.

Now, since the game is going to include a lot of dialog I wan't to avoid making the 20+ actions for each dialog prompt required and I rather just use a cookie cutter system.

The cleanest method would be to use .txt file and simply parse out the dialog and various variables for each option. Unfortunately as far as I can Construct doesn't have that function and I doubt I'd be able to programmer a parser as I know next to nothing about them (I'm probably even using the the wrong term.)

Looking at some of the plugins I came across the associative list plugin, while it's certainly better then the first option that's still up to 6 keys/values per dialog option and once again very messy.

Right now the best looking approach to me is to store all the data in a 2D array. This would however concern me with loading times, since as far as I can tell there is no way change the "defualt" values of an array in Scirra outside runtime, and loading several thousand lines values at once could make for some mean loading times especially in a browser. The other option would be to make a separate array for each instance of player dialog and simply store the responses and their associated variables in those. While slightly more difficult to edit then the previous option, this would yield better loading times and make easier to access the actual data.

Anything I overlooked or suggestions for a better implementation? I'd like some feedback before I start cracking out a system that turns out to be bust and ineffective. kabuto2022012-01-03 19:17:46
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Tue Jan 03, 2012 7:35 pm

There is a Dialog plugin have you looked into that yet?
B
4
G
2
Posts: 20
Reputation: 1,357

Post » Tue Jan 03, 2012 7:42 pm

The only thing I found that's a "Dialog" plugin is this.
But, as far as I can tell it's purpose isn't remotely related to what I need. Could you link me to the plugin that you were talking about?kabuto2022012-01-03 19:43:36
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Tue Jan 03, 2012 7:57 pm

Extract from the how do I FAQ
Visual Novel/Dialogues example - LINK

It's not exactly a dialog system as you intend it, since it just stores and display some text lines, not really allowing for the user's input.

@Yann made an example opening a txt file and displaying lines out of it.
I'm sure he'll be glad to post it around.

For the loading time, I'm not sure hundreds of text lines will be an issue, not even sure a thousand would be.

In Space Jinx I implemented a hundred lines in actions and nothing is noticeable on the startup.
The longest thing to load/download at first is still the art of the game, not it's "binary" datas.

The dialog system you want to put in place can be tricky though. I guess for each sentence, you would have the string itself, X possible answers, a reference to the sentence the current string is an answer/following for.
I'd still stick for the array (even possibly 3D).

Or, once Yann has posted his file, the filling of an array from an external txt files.

You might also want to check the csv plugin, that might be of some help as far as serializing goes.
You might also consider the hash table plugin that provides ways to import/export keys and values if I'm correct.Kyatric2012-01-03 19:59:13
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Jan 03, 2012 8:07 pm

Thanks a bunch Kyatric. I guess the most logical course of action right now would be to put off creating the dialog system for a few weeks and see if Yann posts the file. If he doesn't I'll try to hack away at it using the 2D array. Though I should play around with the CSV plugin for a bit.

EDIT: And I just noticed all the grammatical errors in my main post, I should get some sleep.kabuto2022012-01-03 20:10:16
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Tue Jan 03, 2012 8:13 pm

It's likely that in a few hours the example will be posted, Yann is pretty active on the forum.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Jan 04, 2012 12:03 am

Well my ears are ringing :D

@kabu:
First, I don't think that importing external text from files is really your biggest problem.
I went to read the wikipedia page on Alpha Protocol. I think you'll have a lot of work to find a good reusable associative syntaxe.
With only 2min of thought, I think your character could have some parameters like "charisma, sensibility, coldness, etc" and each answer could add some point on these parameter and some dialog pieces could be locked or unlocked depending on these parameters.

You could have a list of interlocutor dialogs for the whole game with a syntaxe like :
[code]ID_DIALOG [range or charisma, range of sensibility, range of coldness] "actual dialog" ID_ANSWER[/code]
example :[code]120 [0-20,20-50,50-100] "Er.. What do you want?" 241
120 [0-30,60-80,0-5] "Don't look at me like that!" 242
120 [50-100,0-50,0-10] "I.. oh you are right" -1
120 [0-100,0-100,0-100] "yes?" 244[/code](note the 0-100 range for the 3 values makes it the default dialog and -1 would mean no possible answer)

And your possible answer
[code]ID_ANSWER [tonality] [charisma,sensibility,coldness] "actual answer" ID_DIALOG[/code]
example:[code]241 [gentle] [+1,+2,-2] "Oh don't worry, I just wanted to see if you were fine" 121
241 [cold] [-1,-3,+2] "Nothing" 122
241 [smart] [+2,-2,+1] "Do you have something to hide?" -1[/code](note -1 would mean end of dialog)

So following this example, if you are an insensible bastard, when you reach the moment of the game when you trigger the dialog with ID 120, you will be asked
"Er.. What do you want?"
Then you'll be able to choose either gentle, cold or smart tone, if you choose cold (as the insensible bastard you are) you'll trigger the answer
"Nothing" you will lose 1 point of charisma, 3 point of sensibility and earn 2 point of coldness.
And then trigger the dialog ID 122
etc

Basically if you do that the external file way, you'll have 2 file, one for dialog and one for answers, you'll load them on start of layout and fill a 2 dimensionnal Array
By parsing the whole string (like tokenat(dialog,index,newline))

for our example it would be
Dialog(120,0) = [0-20,20-50,50-100] "Er.. What do you want?" 241
Dialog(120,1) = [0-30,60-80,0-5] "Don't look at me like that!" 242
Dialog(120,2) = [50-100,0-50,0-10] "I.. oh you are right" -1
Dialog(120,3) = [0-100,0-100,0-100] "yes?"

And
Answer(241,0) = [gentle] [+1,+2,-2] "Oh don't worry, I just wanted to see if you were fine" 121
Answer(241,1) = [cold] [-1,-3,+2] "Nothing" 122
Answer(242,2) = [smart] [+2,-2,+1] "Do you have something to hide?" -1


After that it's just a matter of calling the dialog, parsing the first part of the string to see what match the parameters of your player (might have to be more exclusive than what I did) and then displaying the corresponding sentence.
And using the end of the string for possible answers. etc.

So for my test on string loading it's right here :
demo
text file
capx
But remember, it won't work on preview since js can only call stuff from the same domain, and on preview you are in localhost and the txt file is on dropbox.com.

That's all :DYann2012-01-04 00:11:14
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Jan 04, 2012 2:10 am

Your avatar essentially sums up my reaction to reading your post.

Thanks a bunch mate, I planning at hacking away at those aspects all by lone some up and here you have brought me a perfectly feasible system and a fully commented .capx file with everything I need to import a .txt! I have to admit I'm fairly speechless, all that's pretty much left for me is play around with some of the design elements and figure out how CSV works.

Edit: I actually just realized that I probably won't even need CSV, I could just parse them using tokenat()kabuto2022012-01-04 02:18:58
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Post » Wed Jan 04, 2012 2:22 am

If you're talking about the plugin I didn't try it
If you're talking about the format it's pretty straighforward

You draw a 2D array with coma (CSV = Coma Separated Values) and line breaks

In CSV the syntaxe I described would just look like

[code]ID;ChariRange;SentRange;ColdRange;Sentence;ID_ANSWER
120;0-20;20-50;50-100;Er.. What do you want?;241
120;0-30;60-80;0-5;Don't look at me like that!;242
120;50-100;0-50;0-10;I.. oh you are right;-1
120;0-100;0-100;0-100;yes?;244[/code]
As you noticed I used semicolons instead of comas. Because you could have comas in the sentences.
I don't know if you can configure custom separators in the plugin though.

Also you could build more complex but more usable Arrays breaking things up a bit more in a 3D Arrays. Like :

[code]Dialog(120,0,0) = "0-20"
Dialog(120,0,1) = "20-50"
Dialog(120,0,2) = "50-100"
Dialog(120,0,3) = "Er.. What do you want?"
Dialog(120,0,4) = 241
Dialog(120,1,0) = "0-30"
Dialog(120,1,1) = "60-80"
Dialog(120,1,2) = "0-5"
Dialog(120,1,3) = "Don't look at me like that!"
Dialog(120,1,4) = 242
Dialog(120,2,0) = "50-100"
Dialog(120,2,1) = "0-50"
Dialog(120,2,2) = "0-10"
Dialog(120,2,3) = "I.. oh you are right"
Dialog(120,2,4) = -1
Dialog(120,3,0) = "0-100"
Dialog(120,3,1) = "0-100"
Dialog(120,3,2) = "0-100"
Dialog(120,3,3) = "yes?"
Dialog(120,3,4) = 244[/code]
This way you can easily get the range parameter calling the third first Z indexes, or the sentence, or the id of the answer.
Can do the same for answers of course.Yann2012-08-07 20:50:31
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Jan 04, 2012 2:37 am

I was referring to the plugin. I was planning to use "|" as the seperator, but I have two questions. How would I go about accessing a local .txt? I tried using just "test.txt" and "localhost://test.txt" (Test "test.txt" file is located inside the project folder.)

How would I detect the line breaks with tokenat()? Or is there command in Construct that could detect those?

EDIT: Nevermind, I'll just use the plugin, it seems easy enough to work with.kabuto2022012-01-04 02:39:44
B
5
S
2
G
3
Posts: 36
Reputation: 1,622

Next

Return to How do I....?

Who is online

Users browsing this forum: michaelverdi and 21 guests