Skip to main content
GameDev.net gamedev.net
🔒 Locked

RPG Developers: Question to you

Started by Silent Dragon Feb 15, 2007 at 10:28 AM 9 replies 2k views
Original Post
Silent Dragon
Silent Dragon
How have you implemented the Items, Monsters and those kind of lists? SQL style database? XML and loading into memory when the game loads? your own files? your own database even? (Curious for my own project, so all answers welcomed ;) )
Ravuya
Ravuya
Previously a .ini style file format with a bunch of actor "templates" thrown in a directory, and a function that can spawn an entity from the .ini format.

Something like this:
name=Amazing Angry Monstertype=flyinghp=40mp=10item=AngerPie.def


And then inside the C++ code:
Actor* spawnMonsterFromDef(filename) {  open file from filename  load variables into stl map  if type == flying:    create new FlyingMonster    populate it with the data from the map    return this monster  else:    I dunno what the hell type of monster this is}


It's nothing really complicated. Now I'm doing it through XML, since XML is prettier and has hierarchical data, which saves me from having to do a lot of file cross-references.

I'd imagine it'd be done something like
<monster type="flying">  <name>Amazing Angry Monster</name>  <stats>    <hp>40</hp>    <mp>20</mp>  </stats>  <item>    <type>pie</pie>    <name>Anger Pie</name>    <description>Eat this and become angrier</description>    <effects>      <anger level="2"/>    </effects>  </item></monster>
eedok
eedok
csv's currently, but looking into replacing the system with sqlite databases for easier cross referencing.

stealing Ravuya's example:
name,type,hp,mp,itemAmazing Angry Monster,flying,40,10,AngerPie.defOther monster,walking,25,5,none

then edit it in like gnumeric, excel or the likes.
WolfDenProductions
WolfDenProductions
well, here's the way I've done it in the past, when I was working on MUDs:

#IdNum
keyword list~
short desc~
long desc~
hp maxhp mp maxmp
att def

each monster had a unique ID number.

the keyword list was keywords that identified the creature, unneccessary in a gfx
environment

the short desc was like this: An amazingly angry monster
the long desc was like this: An amazingly angry monster is here, roaring loudly.

the rest is fairly self-descriptive. this was then read from a text file. Nothing elegant, but it worked. The ~ let the code know when to stop reading from the entry.
Machaira
Machaira
I used to use XML, but I've switched over to having my Entity and Item classes serialize and deserialize a file stream. 2 lines of code and the data is loaded or saved. [grin]
Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development
AndreTheGiant
AndreTheGiant
I have no idea why more games dont use a real database engine. Something like mySQL or Microsoft's free SQL server engine. Databases are the shit.
superpig
superpig
Quote:
Original post by AndreTheGiant
I have no idea why more games dont use a real database engine. Something like mySQL or Microsoft's free SQL server engine. Databases are the shit.


Or even this one. There's a thread on GDAlgorithms at the moment about using it for storing game assets.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Justaddwater
Justaddwater
I agree using SQL Express is really the way to go, for no other reason then being able to easily normilize your data.

Quote:

<monster type="flying">  <name>Amazing Angry Monster</name>  <stats>    <hp>40</hp>    <mp>20</mp>  </stats>  <item>    <type>pie</pie>    <name>Anger Pie</name>    <description>Eat this and become angrier</description>    <effects>      <anger level="2"/>    </effects>  </item></monster>



In this example if you want to change the anger pie you have to find and replace and hope you make all your changes correct. Database done properly removes the guess work. You can normalize the xml as well but IMO that is more complex then just using a related db.

Quote:
SQL Example



MonsterTable
------------
MonsterID (pk)
MonsterName
MonsterDesc
MonsterStat

ItemTable
----------
ItemID (pk)
ItemName
ItemDesc
ItemStat

MonsterItemTable
--------------
MonsterID (fk)
ItemID (fk)

ChurchSkiz
ChurchSkiz
Quote:
Original post by AndreTheGiant
I have no idea why more games dont use a real database engine. Something like mySQL or Microsoft's free SQL server engine. Databases are the shit.


For me personally it was the difficulty in setting it up. Everyone learns basic file i/o fairly quickly in programming. Setting up a database, and then getting it to work properly within the code takes more time to learn. I looked for some easy mySQL interfaces but didn't find any ones that made sense to me. With the amount of time I spent searching for how to read and write to a database, I had a fully implemented csv system.
xanin
xanin
I run a mud, and since I've only been in charge of the coding for about 4 months now (the mud is around 8-9 years old now) we're still doing things the way ROM does, nasty flat-files with obscure formatting requirements. I'd like to move to a database system, but I have to qualify all my projects in terms of player-visible ROI, and there simply isn't enough return for the players for the time I'd spend. As I implement newer systems or upgrade and replace older parts though, I am replacing the file model with an XML format.
Raghar
Raghar
There is a nice requirement for data in RPG. The system must load them into the memory with low overhead. Thus if you select beginning and do one DMA load, you are all set. This approach also permits creation of a reasonable data buffering.

Now RPG developers should create theirs own data structures, so an standard database solution, that is optimized for web application is no help for them. It doesn't guarantee minimum time for information retrieval, and it has quite a lot other issues. In fact there is nothing wrong with filling a buffer, and accessing it in some OO way. (Fly wheel pattern in case of Java/C# developers, structs in case of C/C++ developers.) If you have a "database" independent system you could create it quite reliable and without dependencies.

Actually there is an additional requirement. If you would like to have something reliable, create an small simple application that would be used for a safe creation of resource files. Definitely avoid doing this by hand. It's fine in prototyping, however disastrous in production quality application.

For anything complex, or speed dependent database are more than hindrance, they are quite harmful.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.