Dialog System

0 favourites
From the Asset Store
Template for a generic save / load system, fully documented in comments and video
  • 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.

  • There is a Dialog plugin have you looked into that yet?

  • 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?

  • 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.

  • 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.

  • It's likely that in a few hours the example will be posted, Yann is pretty active on the forum.

  • Well my ears are ringing

    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 :

    ID_DIALOG [range or charisma, range of sensibility, range of coldness] "actual dialog" ID_ANSWER[/code:1qwst2bf]
    example :[code:1qwst2bf]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:1qwst2bf](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:1qwst2bf]ID_ANSWER [tonality] [charisma,sensibility,coldness] "actual answer" ID_DIALOG[/code:1qwst2bf]
    example:[code:1qwst2bf]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:1qwst2bf](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 :
    [url=https://app.box.com/s/qpdy973ve55vcpeese7fbn2bsxwmrdue]capx[/url]
    
    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
  • 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()

  • 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

    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

    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 :

    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

    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.

  • 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.

  • tokenat(string,index,newline) works like a charm.

    Also I didn't manage to successfully import stuff by previewing

    So for testing I do a

    on start of layout
       -> set [variable you want to import your .txt to]  to  [and I past the big .txt]

    You just have to remember that if you use external files, you will have a little lag between the ajax call and the answer.

    You usually have to stop thing while waiting for the answer. As I launched the writting once I was sure I had received something in my example capx.

  • Alright, everything seems to work fine. Thanks a bunch!

  • hope we'll see some stuff soon

  • Those are some damn good pancakes, Yann!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • these days I like them with apple sauce... god damn sweet but not too sweet like Jam... if you know what I mean

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)