Welcome, Guest. Please login or register.

Pages: [1]
Print
Author Topic: Inventory and object database  (Read 5210 times)
Beliar
Community member

Posts: 71

KarstenBock@gmx.net
View Profile Email
« 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 (http://forums.parpg.net/index.php?topic=631.0) 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?
Logged

Wing IDE - http://wingide.com/wingide - Free for OS use
b0rland
Community member

Posts: 105



View Profile Email
« Reply #1 on: April 07, 2010, 09:07:40 PM »

I'd rather keep it in proper xml:
 <inventory>
 <object name='book' id=55>
 </inventory>

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.
\
Logged
Beliar
Community member

Posts: 71

KarstenBock@gmx.net
View Profile Email
« Reply #2 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?
<ObjectDatabase>
    <object id=0 name="" imagefile="">
    <object...>
</ObjectDatabase>
Logged

Wing IDE - http://wingide.com/wingide - Free for OS use
b0rland
Community member

Posts: 105



View Profile Email
« Reply #3 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.
Logged
Beliar
Community member

Posts: 71

KarstenBock@gmx.net
View Profile Email
« Reply #4 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:

Book:
  Name:
  ImageFile:
  ...

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?
Logged

Wing IDE - http://wingide.com/wingide - Free for OS use
b0rland
Community member

Posts: 105



View Profile Email
« Reply #5 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.
Logged
Beliar
Community member

Posts: 71

KarstenBock@gmx.net
View Profile Email
« Reply #6 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:
PythonClass:
  Attribute1: value
  Attribute2: value
  ...


Example:

Footlocker:
  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
ObjectDatabase
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 script.objects.__init__.py with those attributes

Edit:
Oh, and i will add setting to specify the filename of the database.
« Last Edit: April 14, 2010, 07:14:53 PM by Beliar » Logged

Wing IDE - http://wingide.com/wingide - Free for OS use
zenbitz
Community member

Posts: 1164



View Profile
« Reply #7 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)
« Last Edit: June 14, 2010, 08:55:16 PM by zenbitz » Logged

We are not denying them an ending...
We are denying them a DISNEY ending - Icelus
Pages: [1]
Print
Jump to: