Post-Apocalyptic RPG forums

Development => Programming => Topic started by: Beliar on April 06, 2010, 08:45:07 AM

Title: Inventory and object database
Post by: Beliar on April 06, 2010, 08:45:07 AM
This topic is about Ticket 254 ( and 185 (

Now, for the inventory:

Withtout the object database we need to store 3 values: ID, name and image.
Image can be left out if you are ok with the object having the default image.
With the object database we would only need the ID of the object.

The first question is: Do we create the database first or change the inventory parsing code once its done?
The second question is: How do we store the inventories?

I suggest we do the database first, its not like we need one with all the attributes in the ticket we just have to make sure it can be expanded later. This way we don't need to change the basic inventory loading code later.

So we need to decide which format to use for the database. We already do have a topic ( but feel free to discuss that here.

Then we need to decide how we store the inventories.
Even with the database my suggestion is still putting them inside the tags as content. But then we can just use an easy format that we can easily parse ourselves like this (Just an example): <ObjectName>, <ObjectName>, <ObjectName>,...

What do you think?

Title: Re: Inventory and object database
Post by: b0rland on April 07, 2010, 09:07:40 PM
I'd rather keep it in proper xml:
 <object name='book' id=55>

I think it's quite concise and allows for easy extension. Plus it's not like we're planning to hand-type all that stuff. We'll need at least simplistic support for that in map editor.
As for the order of those two tickets, I'm ok with doing the objects DB first. Would you like to take on that task? I didn't really go much farther in it then writing stuff on wiki/forums. So feel free to steal the ticket if you like.

Title: Re: Inventory and object database
Post by: Beliar on April 08, 2010, 06:24:02 PM
Ah right, with the overuse of attributes one can forget that it is possible to make subentities.

Anyway, i'll see if i can do the ticket.

So, the format of the database should be like this?
    <object id=0 name="" imagefile="">

Title: Re: Inventory and object database
Post by: b0rland on April 08, 2010, 08:43:03 PM
Well, the objects in DB won't normally have ids. Or maybe even never will have them. That is because objects in DB actually represent classes of objects, not individual instances. The DB will have a "Footlocker" class, but it won't store each individual footlocker instance appearing on the map. And for a class there's no use to store IDs because each instance will have its own unique ID value.

Also, we half-decided to use Yaml for all future developments and slowly move away from XML. So I suggest doing the same as you wrote, but in YAML.

Title: Re: Inventory and object database
Post by: Beliar on April 09, 2010, 09:10:34 AM
Yaml it is then, ok. I never intended to store every instance in the database.

How about this then:


Whereas Book is the class name and Name is the name as it appears in the game.

And i get that the database is for all objects? Not only CarryableItems?

Title: Re: Inventory and object database
Post by: b0rland on April 10, 2010, 08:50:27 PM
Sounds fine.
And yes, the db is for all objects. We should keep in mind that at some point we'll want to start adding NPCs there. Because there'll certainly be generic NPCs like 'villager' who all have the same inventory (maybe scripted to randomize a little), the same dialogue lines and the same stats. We'll have to store those somewhere,  and objects DB sounds like a good place to me.

Title: Re: Inventory and object database
Post by: Beliar on April 14, 2010, 07:11:02 PM
Ok, as a summary, this is the plan:

The Object informations will be stored in a yaml file.

The file has the following structure:
  Attribute1: value
  Attribute2: value


  name: Footlocker
  text: Just a normal footlocker used to store items.
  gfx: lock_box_metal01

The file will be loaded when the engine is initiaded.

When an object is about to be created it will look for the attributes in this order:
Map - This, of course, only applies to objects specified in the map
Hardcoded Default value

Or, more specifically the createObject method of the engine class will do the following:

Check if the Database contains information for the item and make a copy of the dictionary.
Update this dictionary with the dictionary from the attributes parameter.
Call the createObject function from with those attributes

Oh, and i will add setting to specify the filename of the database.

Title: Re: Inventory and object database
Post by: zenbitz on June 14, 2010, 08:53:39 PM
Beliar -
Q_x says that you are (the) active python developer, but you need some guidance.
I will try to stay in the loop and give you pointers.  I have some issues because I cannot get PARPG to run on my laptop - which is my primary computer.

I will keep watching threads in this dept if you have questions - else you can PM me.  If you need to chat on IRC let me know and I will go there (10-4) pacific US time)