• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Olle H

Datastructures for story and dialog

9 posts in this topic

Hello,

I'm working on an Amiga Games in Blitz Basic. Inspiration is from Moonstone, Diablo 3, and Monkey Island 1, but it's basically a shoot-em-up/side-scroller. It will be based on an open map, like Moonstone, where routes between places (e.g. planets or space stations) are shorter shoot-em-up stages. In each place you can buy / sell, talk to characters, etc.

Upon this, I'd like to have a story. The question is how this should be represented in the game. I have a number of types (structs) to start with, for example, Character, Dialogue and Quest. I am also thinking of making an editor where you can create new characters, and above all dialogues.

Does anyone have experience with something similar? I'd like to avoid FSM, just think it leads to cluttered code. Would also like to avoid a lot of if-statements and switch statements for each characer, like "if quest1 done then say else say blah blah".

One solution would be to implement a small scripting language that takes care of decisions for the characters, and which can be loaded dynamically (the behavior of a character can then be loaded and replaced when a certain quest is completed).

Ideas, anyone?
0

Share this post


Link to post
Share on other sites
I would personally end up with some kind of tree structure that can easily be represented in xml. You can implement some kind of serialization for this dialog tree and then you could make all of your dialog bs offline (or maybe even make a dialog creation tool if you felt extra cool). You can add some extra metadata to the dialog to define the types of characters that use it, one for merchants, one for warriors etc.

The cool thing is that you could also implement some kind of dialog engine on top of it that would unlock certain options as you progressed through the story. You can rank each dialog option with a flag. This flag could be just a simple data type like an int that denotes how far along in the story you are. I think that if you follow this idea you could also add tons of really awesome features like random dialog options appearing.
0

Share this post


Link to post
Share on other sites
[quote name='M6dEEp' timestamp='1340346701' post='4951626']
I would personally end up with some kind of tree structure that can easily be represented in xml. You can implement some kind of serialization for this dialog tree and then you could make all of your dialog bs offline (or maybe even make a dialog creation tool if you felt extra cool). You can add some extra metadata to the dialog to define the types of characters that use it, one for merchants, one for warriors etc.

The cool thing is that you could also implement some kind of dialog engine on top of it that would unlock certain options as you progressed through the story. You can rank each dialog option with a flag. This flag could be just a simple data type like an int that denotes how far along in the story you are. I think that if you follow this idea you could also add tons of really awesome features like random dialog options appearing.
[/quote]

I think that is a darn good advice. A tree structure in this case will mean a recursive data structure, something like (pseudo C):

struct dialog {
string text; // The actual dialog line
dialog answers[10]; // Answers, array of type "dialog"
int quest_id; // Which quest does this dialog belongs to
int character_id; // Who is saying this
... // More flags
}

Since I'm programming in BlitzBASIC on Amiga, I will have to do the XML-parser my self. Perhaps it will be easier to actually do that dialog creation tool instead.
0

Share this post


Link to post
Share on other sites
as far as I've seen, XML is overkill for almost everything you need, though in this situation, it *may* be justified. I personally feel a list name-value pairs is enough for dialog, because XML takes pretty long to parse (storing level data in XML isn't pretty either if your level gets pretty big).

If you want to use XML, make sure you follow the KISS principle.

If you're looking for XML parsers, I suggest you first read up on them. There are 2 types of XML parsers- DOM parsers and SAX parsers. I'm pretty sure that you're familiar with DOM. In this model, the parser creates the DOM(document object model) which can then be queried for relevant data. This has an upfront cost but (strictly IMO) allows easier manipulation.

SAX parsers on the other hand require you to register callbacks with them when they hit different XML Elements. These callbacks are then called with the required data. I haven't used a SAX parser myself because the DOM parser was in my comfort zone. you may go for either one, and I'm pretty sure there's someone with more experience than me who can tell you the pros and cons of this :)

I'm not really sure if any XML parsers are available for BlitzBasic. you'll have to research that yourself.

Hope this helps
~Siddu
0

Share this post


Link to post
Share on other sites
[quote name='lole' timestamp='1340455062' post='4951992']
[quote name='M6dEEp' timestamp='1340346701' post='4951626']
I would personally end up with some kind of tree structure that can easily be represented in xml. You can implement some kind of serialization for this dialog tree and then you could make all of your dialog bs offline (or maybe even make a dialog creation tool if you felt extra cool). You can add some extra metadata to the dialog to define the types of characters that use it, one for merchants, one for warriors etc.

The cool thing is that you could also implement some kind of dialog engine on top of it that would unlock certain options as you progressed through the story. You can rank each dialog option with a flag. This flag could be just a simple data type like an int that denotes how far along in the story you are. I think that if you follow this idea you could also add tons of really awesome features like random dialog options appearing.
[/quote]

I think that is a darn good advice. A tree structure in this case will mean a recursive data structure, something like (pseudo C):

struct dialog {
string text; // The actual dialog line
dialog answers[10]; // Answers, array of type "dialog"
int quest_id; // Which quest does this dialog belongs to
int character_id; // Who is saying this
... // More flags
}

Since I'm programming in BlitzBASIC on Amiga, I will have to do the XML-parser my self. Perhaps it will be easier to actually do that dialog creation tool instead.
[/quote]

Whoop, careful with the infinite recursion, there. "struct Dialogue" with member array of type Dialogue, so that each object spawns another 10 objects that spawn another 10 objects...

You're probably aware of it, I just felt like pointing it out for the lols. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Btw, awesome that you're programming on an Amiga. I used to program AMOS when I was a kid. :) Have you tried that? It's like QBasic, but with more powerful graphics stuff. Edited by antiHUMANDesigns
1

Share this post


Link to post
Share on other sites
[quote name='bollµ' timestamp='1340465407' post='4952021']
as far as I've seen, XML is overkill for almost everything you need, though in this situation, it *may* be justified. I personally feel a list name-value pairs is enough for dialog, because XML takes pretty long to parse (storing level data in XML isn't pretty either if your level gets pretty big).

If you want to use XML, make sure you follow the KISS principle.
[/quote]

Strongly emphasize the KISS principle and XML. I believe that XML is a great intermediate format to use for editors etc. You can easily parse it and then create a binary file that is both much smaller and faster to read in.
[CODE]
<dialogs >
<dialog characterId="2" questId="1">
<characterLines>
<text>What do you want</text>
could put tons of text elements here and randomly pick from them to add a little variety (what do you want, hi nice to see you etc)
</characterLines>
<answers>
<answer>To steal your SOUL</answer>
More answers..
</answers>
</dialog>
More dialogs..
</dialogs>
[/CODE]

Then you just serialize this to binary from your custom tool ("compile" it) and you are good to go. I think that the recursion stuff needs to be approached carefully but could be done. Another interesting thing is that you can procedurally pick from many dialog lines so even though the answers are the same you can simulate the characters having moods etc.

EDIT:

Oh and I forgot to mention, if you can work out the serialization to and from binary, you don't have to write that pesky XML parser, you could just use C#'s already excellent XML parsing mechanisms and forgo all of the headache. Edited by M6dEEp
1

Share this post


Link to post
Share on other sites
Hello!

Nice with some answers! I've tried on a number of forums without any result.

After some quick research I've decided that an XML-parser is too big for this project, for now atleast. So I'm just gonna implement some light weight configuration language which can read text into my data types. Something like so:

[CODE]
new dialog
id = d1
quest = 1
text = bla bla
answers = d2, d3, d4
end
new dialog
id = d2
quest = 1
text = but no
anwsers =
end
[/CODE]

Also, if you want to check out my project, this is the webpage: www.tonesoftales.com/blitz/

Bye!
0

Share this post


Link to post
Share on other sites
[quote name='antiHUMANDesigns' timestamp='1340505553' post='4952194']
[quote name='lole' timestamp='1340455062' post='4951992']
[quote name='M6dEEp' timestamp='1340346701' post='4951626']
I would personally end up with some kind of tree structure that can easily be represented in xml. You can implement some kind of serialization for this dialog tree and then you could make all of your dialog bs offline (or maybe even make a dialog creation tool if you felt extra cool). You can add some extra metadata to the dialog to define the types of characters that use it, one for merchants, one for warriors etc.

The cool thing is that you could also implement some kind of dialog engine on top of it that would unlock certain options as you progressed through the story. You can rank each dialog option with a flag. This flag could be just a simple data type like an int that denotes how far along in the story you are. I think that if you follow this idea you could also add tons of really awesome features like random dialog options appearing.
[/quote]

I think that is a darn good advice. A tree structure in this case will mean a recursive data structure, something like (pseudo C):

struct dialog {
string text; // The actual dialog line
dialog answers[10]; // Answers, array of type "dialog"
int quest_id; // Which quest does this dialog belongs to
int character_id; // Who is saying this
... // More flags
}

Since I'm programming in BlitzBASIC on Amiga, I will have to do the XML-parser my self. Perhaps it will be easier to actually do that dialog creation tool instead.
[/quote]

Whoop, careful with the infinite recursion, there. "struct Dialogue" with member array of type Dialogue, so that each object spawns another 10 objects that spawn another 10 objects...

You're probably aware of it, I just felt like pointing it out for the lols. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Btw, awesome that you're programming on an Amiga. I used to program AMOS when I was a kid. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Have you tried that? It's like QBasic, but with more powerful graphics stuff.
[/quote]

Hello!

It's not really infinite recursion, since the array really is pointers to dialogs, not dialogs itself. Hm, perhaps this is not appearent from my code...

Amiga is indeed a lot of awesomeness. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] I hope I will have time to finish this project. I tried Amos but switched to BlitzBasic. Don't remember why. [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] Don't know about QBasic? Edited by lole
0

Share this post


Link to post
Share on other sites
[quote name='M6dEEp' timestamp='1340530562' post='4952267']
[quote name='bollµ' timestamp='1340465407' post='4952021']
as far as I've seen, XML is overkill for almost everything you need, though in this situation, it *may* be justified. I personally feel a list name-value pairs is enough for dialog, because XML takes pretty long to parse (storing level data in XML isn't pretty either if your level gets pretty big).

If you want to use XML, make sure you follow the KISS principle.
[/quote]

Strongly emphasize the KISS principle and XML. I believe that XML is a great intermediate format to use for editors etc. You can easily parse it and then create a binary file that is both much smaller and faster to read in.
[CODE]
<dialogs >
<dialog characterId="2" questId="1">
<characterLines>
<text>What do you want</text>
could put tons of text elements here and randomly pick from them to add a little variety (what do you want, hi nice to see you etc)
</characterLines>
<answers>
<answer>To steal your SOUL</answer>
More answers..
</answers>
</dialog>
More dialogs..
</dialogs>
[/CODE]

Then you just serialize this to binary from your custom tool ("compile" it) and you are good to go. I think that the recursion stuff needs to be approached carefully but could be done. Another interesting thing is that you can procedurally pick from many dialog lines so even though the answers are the same you can simulate the characters having moods etc.

EDIT:

Oh and I forgot to mention, if you can work out the serialization to and from binary, you don't have to write that pesky XML parser, you could just use C#'s already excellent XML parsing mechanisms and forgo all of the headache.
[/quote]

Again, I'm not using C#, but a basic dialect on Amiga called BlitzBASIC. Thanks for the tip, though.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0