Dialogue Text for Adventure Game
by Joseph Rioux · in Game Design and Creative Issues · 08/11/2011 (9:55 pm) · 12 replies
Hi!
Trying to make an adventure game, and I want to a have text displayed for dialogue between characters. I was thinking of writing a class with all the text in the game stored in individual string variables that I can access whenever I need them. For example:
%speechLine[145] = "No, don't kill me! Kill the dog instead!";
%speechLine[146] = "But the dog is cute… and you're not.";
But something tells me that there's an easier and more efficient way. Any suggestions? Thanks!!
Trying to make an adventure game, and I want to a have text displayed for dialogue between characters. I was thinking of writing a class with all the text in the game stored in individual string variables that I can access whenever I need them. For example:
%speechLine[145] = "No, don't kill me! Kill the dog instead!";
%speechLine[146] = "But the dog is cute… and you're not.";
But something tells me that there's an easier and more efficient way. Any suggestions? Thanks!!
#2
Of course my example is so small - imagine something on a larger scale like some games out there.
Look into what J Olde Bijvank has answered - that's the better approach:
Have the text on some sort of database. You will need some data besides the text to know when and where to display each message (what conversation,between who, when in the game, when in a conversation, etc - really depends on your game).
Build a system to handle all that.
Ted Southard has blogged intensivelly about creating one such systems. Search his posts - you might find it interesting
09/30/2011 (8:10 am)
How Big is your game? If you will only have a couple of small conversations you could have that array of messages and handle it well - but if you will have a dozen different characters (player + NPCs) having conversations x times, each conversation with y lines it will get really hard to handle that way - so (example) player will talk to 20 NPCs, will have 10 conversations with each one of them, at 10 lines of text per conversation - that already 20*10*10 = 2000 lines of text to manage. - Plus having all that in memory at all times.Of course my example is so small - imagine something on a larger scale like some games out there.
Look into what J Olde Bijvank has answered - that's the better approach:
Have the text on some sort of database. You will need some data besides the text to know when and where to display each message (what conversation,between who, when in the game, when in a conversation, etc - really depends on your game).
Build a system to handle all that.
Ted Southard has blogged intensivelly about creating one such systems. Search his posts - you might find it interesting
#3
Also, if you're doing dialog trees, then there's several editors out there that allow you to efficiently create content in more visual ways, which is always helpful. Or if you have a budget for someone to help implement, I do contracting work ;)
There's many ways to skin this particular cat, and some of the places that I've found inspiration for earlier versions of my system included Toontown, Mass Effect, Fable II, etc. You can also go back to 80s games (there was a something (Adventure? Mystery?)-"Island" game by Lucas Arts that used dialog choices like Mass Effect, except without the cool GUI, 3D art, sci-fi, or...almost anything else). Hope that helps :)
Oh, and also, don't forget that Torque Script is string based, and so has handy functions for markup (or use GuiMLTextCtrl so you can use HTML- I use it and hooked the hyperlinks to in-game functions).
09/30/2011 (12:10 pm)
I agree with both Luis and J in that you'll need to find ways to manage both data and the interaction. I think that the way that you're doing it now, you're going to fill up memory pretty fast, and using something like xml/flat files (if it's a small amount of dialog), or SQLite (for lots of dialog or complex systems/tagging) would be better. That way, you access it when you need to, and leave it on disk when you don't.Also, if you're doing dialog trees, then there's several editors out there that allow you to efficiently create content in more visual ways, which is always helpful. Or if you have a budget for someone to help implement, I do contracting work ;)
There's many ways to skin this particular cat, and some of the places that I've found inspiration for earlier versions of my system included Toontown, Mass Effect, Fable II, etc. You can also go back to 80s games (there was a something (Adventure? Mystery?)-"Island" game by Lucas Arts that used dialog choices like Mass Effect, except without the cool GUI, 3D art, sci-fi, or...almost anything else). Hope that helps :)
Oh, and also, don't forget that Torque Script is string based, and so has handy functions for markup (or use GuiMLTextCtrl so you can use HTML- I use it and hooked the hyperlinks to in-game functions).
#4
10/03/2011 (3:14 pm)
Hey everybody! Glad I stumbled upon this post. I'm doing a lot of things that are on this topic. My biggest concern is the talk about memory. I implemented a system where I add the dialog to each NPC using the editor and the data is being held by that object specifically. Does this mean I'll have memory issues? I like being able to do it right in the editor but do I need to be reading it from a file instead?
#5
If you have a dynamical allocate/unallocate system for your NPC's it would save memory. You could even have your dialog text in the NPC object if you like.
Whether you need such a system or not really depends on the scale of your game. If the amount of data grows, the system that handles that data should be able to keep up with it and often does that mean that the system would be more complex.
10/04/2011 (4:11 am)
@Andrew. If you store the dialogue text in the NPC object and you load all the NPC objects at the start of your game and keep them in memory for the complete game session you can be in trouble if the number of NPC's are growing, but that is not really dialog text related.If you have a dynamical allocate/unallocate system for your NPC's it would save memory. You could even have your dialog text in the NPC object if you like.
Whether you need such a system or not really depends on the scale of your game. If the amount of data grows, the system that handles that data should be able to keep up with it and often does that mean that the system would be more complex.
#6
I'm diving back into our mmorpg, and reading this thread I thought of using a state machine for the chats. That way NPC's can do their idle stuff, and only chew memory when activated. something along the line of...

Then my NPC's can be of as little impact as possible, and only when activated will they query the server for their quest/dialogue/shop list. And in case its a quest liner, compare it with the characters.
Only in the Questing state is interaction allowed, and when leaving is the interaction object killed.
Not sure this is the best approach, but was my 5 minute thougths on how I would do it -time will show if I end up doing it this way.
PS: my quests items etc. would be in a realtional database, looking up what tuples match the NPC's id. (that way you can also do a many2many relation on npc's and quests.
10/04/2011 (10:58 am)
Save memory for the actual game and not for something only needed 'in case'.I'm diving back into our mmorpg, and reading this thread I thought of using a state machine for the chats. That way NPC's can do their idle stuff, and only chew memory when activated. something along the line of...

Then my NPC's can be of as little impact as possible, and only when activated will they query the server for their quest/dialogue/shop list. And in case its a quest liner, compare it with the characters.
Only in the Questing state is interaction allowed, and when leaving is the interaction object killed.
Not sure this is the best approach, but was my 5 minute thougths on how I would do it -time will show if I end up doing it this way.
PS: my quests items etc. would be in a realtional database, looking up what tuples match the NPC's id. (that way you can also do a many2many relation on npc's and quests.
#7
10/04/2011 (2:08 pm)
I appreciate all the feedback! I was under the impression that all objects were deleted when I load up an new area? I guess I need to go in there and make sure I know everything that is going on. If they are being deleted when I load up a new area, that should take care of the problem though shouldn't it? Unless, of course, I make an extremely large area that has massive amounts of NPCs with massive amounts of text? I'm working on an action-rpg but the most NPC-dialog ridden areas will be towns with probably no more than 20-30 people in one area at the most and only about 5 of these may have some robust dialog.
#8
Oh, and thanks for the offer, Ted, but I don't have a budget for the game :( I'm just trying to do what I can on my own right now, which makes me really appreciate the help from everybody! May all your code be bug-free! :)
10/04/2011 (4:05 pm)
Thanks, everybody! I'm a little out of the loop right now because I'm right into the school year, but I'll check on your advice when I get back to programming and try to implement my dialogue…Oh, and thanks for the offer, Ted, but I don't have a budget for the game :( I'm just trying to do what I can on my own right now, which makes me really appreciate the help from everybody! May all your code be bug-free! :)
#9
10/05/2011 (12:22 pm)
Yes, by default everything in a level is restored to its initial state when you load the level file. You will have to work out some way of having objects serialize themselves to storage either when touched/modified or when the level exits. Then you'll have to set them up to restore their states when the level file loads. Persistence is a fun topic.
#10
@Joseph: Like Richard mentioned, once you load a different area, the memory usage of the previous one gets cleaned. That means, next time you reload that area (Player get's back to village after completing quest), NPC's are set back to original state - so player gets asked to perform the same quest again.
Unless you persist quest state. Then after you load the area you will need to check all persisted items/variables/objects and adjust the scene accordingly.
But for that you will need to persist items/variables/objects as needed
10/08/2011 (8:59 am)
Persistence - oh yeah. So much fun. Forget to persist one item/variable/object, then the real fun starts.@Joseph: Like Richard mentioned, once you load a different area, the memory usage of the previous one gets cleaned. That means, next time you reload that area (Player get's back to village after completing quest), NPC's are set back to original state - so player gets asked to perform the same quest again.
Unless you persist quest state. Then after you load the area you will need to check all persisted items/variables/objects and adjust the scene accordingly.
But for that you will need to persist items/variables/objects as needed
#11
10/08/2011 (1:03 pm)
nice.
Torque Owner J Olde Bijvank
Ladybird Games
Which character says what, and when?
One list containing all lines of text of your game is very hard to maintain when your game is expanding as you develop it.
Maybe you can invest some time in designing a dialog system in which you can setup a conversation flow between characters?
If you think of it there are only a few properties needed for a simple system. There is a dialogue number, a sequence number, at least two actors, there is a start trigger and there is text.
-example-
Dialogue: 1
Sequence: 1
Actor 1: Player
Actor 2: NPC Bill
Trigger: Actor 1 clicks on Actor 2
Text: "Hi there!"
Dialogue: 1
Sequence: 2
Actor 1: Player
Actor 2: NPC Bill
Trigger: Actor 2 gets clicked by Actor 1
Text: "Why are you clicking on me?"
This is a very simple example. To make it more interesting for the player if you add some dynamics to the system. Let the player choose from a few lines of dialog sequences and let a conversation be controlled by the choice of the player. You can even add some external factors like the mood of the actors, the role of the actors and even the relationship between them and a little piece of randomness to make it really appealing to the player.
There are lots of interesting options to add in a dialogue system (add a chatbot for example).
I hope this will help you a bit.