Dialogue best practices - and where to store text

Get help using Construct 2

Post » Thu Mar 21, 2013 11:47 pm

Hi dudes, I've been trying to find as much as I can about the different way people use Construct 2 to show dialogue between characters & NPCs, and have searched this forum many times to get many different ways of doing it - from loading via text file, or long and cumbersome amounts of events within Construct itself.

An example like this one http://www.scirra.com/forum/topic61701.html by Miu3 seems common, especially with those few people I've seen who want to create interactive story books. The dialogue is stored in instance variables on the character objects, and events track which scene you're in. Which is absolutely fine, but the amount of dialogue that needs to go within Construct 2 could end up becoming immense, and get completely out of control. And what if you want to change something? The idea of going through potentially hundreds of events, actions and instance variables and changing them makes me worry that I have to get this right first time!

Then of course there's Aluriak/Yann's example here http://www.scirra.com/forum/npc-dialog_topic48355_post303797.html, where the dialogue is stored in one big splat at the top of the event sheet. Which is also fine, but imagine if the text was a 100 times bigger, and there's many more characters to talk to. Again it'd become a nightmare.

Would it be better if the text was stored externally in another file> This is how I've always imagined it should be, although splitting it away from the logic might make it even more confusing.

There's so many options and I want to know which way is best practice, and most advised. How do you all handle this in your games? onion2013-03-22 00:06:50
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Fri Mar 22, 2013 12:07 am

Never did a dialogue system myself ... but I recommend arrays , it's easy to split each line with them

Edit :

Here , I made you an example to show how epic I am

The main code is in 5 events , you can easily change all the rest of the events to fit you Whiteclaws2013-03-22 01:49:02
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Fri Mar 22, 2013 8:23 am

Thanks for taking the time to create that example Whiteclaws, I really appreciate it!

I agree it's probably better to use arrays than instance variables. However it doesn't seem a very elegant solution, especially as it requires an action for every piece of spoken dialogue. Also you have to keep track of each NPC's number (which corresponds to the index in the array), which can get a bit tricky when you have many.

The biggest problem with your solution however is that it won't work if an NPC needs to say more than 1 thing ever. Where would the second piece of dialogue go in the array?

I think Aluriak/Yann's example here http://www.scirra.com/forum/npc-dialog_topic48355_post303797.html might be a more flexible solution than this, although I'm still interested in seeing more examples.
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Fri Mar 22, 2013 6:39 pm

The best solution to what you want to do is JSON/Array

Here you would write out the JSON file manually or use some kind of tool. Here you write in a format(please forgive me for my JSON parsing is in error, just use as theory)

Mayor{
image: mayorspresheet,
speeches{
    hello{
      emotion: "smile",
      dialog: "Good day, your new around here; Our litte town...bleah"
    }
    abouttown{
      emotion: "excited"
      dialog: "oh my yes, our town has been prosperous for years..."
    }
}
}

somevillain{
image: "crucifix"
speach{
    firstmeeting{
      emotion: "curiousgrin"
      dialog: "And who are you to intrude upon my work?"
    }
    mwahaha{
       emotion: "evillaugh"
       dialog: "mwa ha ha ha "
    }
}
}


Now of course this is not accurate to how you will use it.
emotion refers to animation set in the sprite sheet.
names refer to the manual sprite name
dialog names you have to figure a way to trigger them.

When you import the JSON into the array. you will end up with 3 dimensional layer that you will need to create an in game event engine to handle

DimensionX, this is the NPC's name.

Function.Call("Dialog.Talk", NPC.name, NPC.dialog)
----
Function Talk
setimagesideright(NPCArray[Function.Param(0), Function.Param(1), 0)
setdialog(NPCArray[Function.Param(0), Function.Param(1), 1)
-----

Of course this is all simple design. You can also create JSON scripts to handle long conversations going back and forth. This would also be written to a different JSON and array.

ConvoFile.json
wakeupchrono{
1{"mom", "wakeup1", "right"}
2{"chrono, "grumble", "left"}
3{"mom", "lazyson", "right"}
4{"chrono, "grumble", "left"}
   ...............
}
chronolucafirst{
similar as above :P
}


anyways. this is probably the best way to handle it in my opinion. It's probably the most long term solution for LARGE games with more complex dialog and even include tree options into the speech.

    firstmeeting{
      emotion: "curiousgrin"
      dialog: "And who are you to intrude upon my work?"
      options{
        1{ reply: "i'm askign the question", "shepard", "pissedoff", "Shut up before I shoot."}
        2{ reply: "I'm shepard, and you are"....
        3{ reply: "[Shoot]", ....}
      }
    }

anyways. i've written enough and probably made it a large incoherent mess :P good luck.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Wed Mar 27, 2013 12:29 pm

@jayderyu you're awesome! Thanks for the brilliant example. I'm going to have to take some time to absorb this and work it into my game! I'll keep you posted with progress :-)
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Wed Mar 27, 2013 4:59 pm

As a follow up after playing around with some C2 JSON creation strings and array importer. I would mandatorally suggest making the conversation tools with C2.

C2 has it's requirements as to what the JSON looked like. I tried implementing the above dialog structure for quick test and it didn't work so easily. Unfortunatly it seems C2 can't just do a raw JSON import :(

Here is what you need to consider if you do it by hand.
The over structure must be encapsulated by
{""C2Array": true, ""size"" : [x,y,z], ""data"": { your stuff } }

All objects names must be in "" "" two set's of qoutes each
You can't alternate with " ' ', ' ' "   C2 doesn't interpret ' :(
the C2 wrapper of the object require the above

it's actually a massive pain.

So you really are better writing some kind of tool that will fill the array in the tool. Then you can export the array as a JSON string. Then that should work :\

unfortunally for all the webstandards that C2 dos use. the JSON seems to not be one of them.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Wed Mar 27, 2013 5:47 pm

Hello all, I am also slowly moving forward to the point I need something similar.

How do people feel about using XML? That should also be a fairly customizable solution.
B
19
S
4
G
4
Posts: 70
Reputation: 3,896

Post » Wed Mar 27, 2013 6:06 pm

I don't think anyone is particullaly fond of one format over the other. Whom ever get's a working spritesheet and toolset I think would be the key :P
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Mar 28, 2013 5:59 pm

I don't have a practical suggestion to dialogue implementation because I'm looking for one too. However if you somehow want to sort it out with spreadsheet format, rexrainbow's csv plugin will get anything spreadsheet related sorted for you.

I'm thinking about some form of tree structure myself, but cocoonjs can't export xml which I eventually want to use.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Mar 28, 2013 7:08 pm

You could also use the dictionary object and store everything as keys.

Set key npcname & conversationname & paragraph to "Hello."

I haven't tried it though, so it might actually be cumbersome in practice, but in theory it seems like a good idea, as that way you could store it all and not have to worry about the grid of an array, and could retrieve whatever you wanted with a few variables (it would probably make branching dialogue easier as well).
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests