Proper way to implement vast amounts of character dialogue?

I’ve been working on a pretty standard role-playing game for quite a while now. It’s coming along nicely, but I still don’t have a good solution for a major part of the game: handling large amounts of character dialogue and scripted cutscenes.

The simplest (and least-ideal) solution would be to simply make a new class for each cutscene that contains info on where the camera needs to be looking, who needs to say what, etc etc. This doesn’t seem like a very good approach to me.

Another idea would be to have a bunch of XML (or something like XML) files that contain the data.

So, my question to anyone who has tackled this issue in the past: how did you do it? If you haven’t done this before, what would you do in this situation?

Thanks a bunch for your time.

Take a pencil and paper and write down all kinds of elements a cutscene could be made of, like text block, camera movement, sound, sprites, etc.
Create classes for each type and a common super type or interface.
Identify attributes of each element like text, screen positions, start time, end time, duration, sound name, event listeners for starting and stopping, etc.

Put a cutscene class together, give it a list of elements (of the element base class), a play method, timer. The cutscene does not know individual element classes.
Think of the environment that cutscene elements need to know to be properly run. Pass it as parameter into the play methods.
Add a timer or event listeners to step from element to element.

Then, after it works, you could think of how to compose, load and save cutscenes. But that is a different task, do not mix it up.

If that is what you meant…

You could save it in text files and load them when needed.

Again I end up agreeing with 65k.

Games like TA:Kingdoms, if i recall correctly, used something like a custom INI file for scripted scenes and events. Xml is the rage now I suppose, but dude(?) is right. I would handle breaking up the elements and methods first, then worry about storage.

Please keep us posted as well, I am honestly a little curious myself, as I will eventually need to do something similar.

If the cut scene needs to be exact, like a movie, I’d just look into YUNPM and try to make a full movie cut scene using the normal video tools.

If it is one of those interactive cut scenes, then I’d handle it the way movie scripts are handled in code. I’d write all the dialogue for the cut scene in one XML file stating the characters as the tags. Then, I’d add the cues and camera positions to the specific points in the file where characters need to move, and the camera angle needs to change. Kind of like this code snippet…


<Barbera> "You can't let that kind of thing get to you!" </Barbera>
<Cathy movex=17 movey=18></Cathy>
<Barbera movex=13 movey=14> "He doesn't know anything..." </Barbera>
<Camera movex=18 movey=19 movez=9 rotate=0.15></Camera>
<Cathy rotateHead=0.15> "I know he seems inconsiderate sometimes, but I can sense a change in him." </Cathy>

Disclaimer: This is a mock up example. It hasn’t really been tested so don’t ask what the numbers mean :stuck_out_tongue:

Literally everything is a text file. And he’s asking for specifically how to store things inside the text file.

For a visual novel engine I wrote a complete script language based on Java Reflection. It turned out pretty nicely, although I’m not sure it was worth it when it comes to productivity.