adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] Item templates, items and item instances


From: Kai Sterker
Subject: [Adonthell-devel] Item templates, items and item instances
Date: Mon, 13 Jan 2003 16:37:29 +0100

What occured to me that morning is the following:

We have the python item class (like torch.py), which I will call an
'item template'. Why? Because it describes a whole range of different
items (all kinds of torches).

An item template is turned into an actual item (a Large Torch or a Small
Torch or a Burnt Torch) by filling it's attributes with according
values. As such, an item is nothing but a little data file. For the
above examples you'd have the files large_torch.item, small_torch.item,
etc ...

Same could be true for simple weapons. I.e an axe and a sword would use
the same item template, but have different attributes and gfx.


The first entry of each .item file would be the item template used for
that item. As a direct consequence, I would change the item_base
constructor. Instead of receiving the name of an item template as it
does now, it should get the name of an item file.

Those .item files would be the product of the item editor, of course.
Other editors, like character and mapeditor could then present the
player a list of availble items, possibly sorted into categories. Only
items on that list could be placed on the map or into character's
inventories, etc. They make up all the items known by the game. 

Just as with characters, one might keep them in a single file instead of
many, but then loading an individual item would be more difficult.


Finally, when an item is in use by the game it will be called an 'item
instance'. Item instances will often differ slightly from the original
item. Charges could be used up, the item might be enhanced or damaged or
whatever.


With all this in mind, something like item transformation becomes
suddenly incredibly easy. Lets stay with the stupid bottle example:

Here's an excerpt from the potions 'use' method:

    ...
    self.charge = self.charge - 1

    if self.charge == 0:
        base_item.clear (self)
        base_item.load (self, "empty_bottle")

That's it. Our item is now an empty bottle.


Of course there are other cases that aren't as easy. 'Upgrading' for
example, because we will most likely change the item template (e.g from
weapon to magic_weapon) but need to keep the old attributes of weapon
(so that an axe turns into a magic axe, not into a magic sword or
somesuch) and only fill in some new ones.

But as I said earlier, we should first get the basic things going. Then
we can think about the complex stuff.

Kai




reply via email to

[Prev in Thread] Current Thread [Next in Thread]