Dialog SystemForum Home > Construct 2 General > How do I....?
|Post Reply||Page 123>|
Topic: Dialog System
Posted: 03 Jan 2012 at 7:11pm
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.
Edited by kabuto202 - 03 Jan 2012 at 7:17pm
|Post Options Quote Reply Posted: 03 Jan 2012 at 7:35pm|
There is a Dialog plugin have you looked into that yet?
|Post Options Quote Reply Posted: 03 Jan 2012 at 7:42pm|
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?
Edited by kabuto202 - 03 Jan 2012 at 7:43pm
|Post Options Quote Reply Posted: 03 Jan 2012 at 7:57pm|
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.
Edited by Kyatric - 03 Jan 2012 at 7:59pm
|Post Options Quote Reply Posted: 03 Jan 2012 at 8:07pm|
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.
Edited by kabuto202 - 03 Jan 2012 at 8:10pm
|Post Options Quote Reply Posted: 03 Jan 2012 at 8:13pm|
It's likely that in a few hours the example will be posted, Yann is pretty active on the forum.
|Post Options Quote Reply Posted: 04 Jan 2012 at 12:03am|
Well my ears are ringing :D
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 :
And your possible answer
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
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?"
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 :
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 :D
Edited by Yann - 04 Jan 2012 at 12:11am
|Post Options Quote Reply Posted: 04 Jan 2012 at 2:10am|
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()
Edited by kabuto202 - 04 Jan 2012 at 2:18am
|Post Options Quote Reply Posted: 04 Jan 2012 at 2:22am|
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
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 :
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.
Edited by Yann - 07 Aug 2012 at 8:50pm
|Post Options Quote Reply Posted: 04 Jan 2012 at 2:37am|
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.
Edited by kabuto202 - 04 Jan 2012 at 2:39am
|Post Reply||Page 123>|
|Forum Jump||Forum Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum