adonthell-devel
[Top][All Lists]
Advanced

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

Re: [Adonthell-devel] Items basics


From: Kai Sterker
Subject: Re: [Adonthell-devel] Items basics
Date: Thu, 22 Jan 2004 20:30:04 +0100

Am Donnerstag, 22.01.04 um 01:36 Uhr schrieb Andrew Michael Phillips:

Could someone summarize the current approach to items for me? I'm most
interested in the attributes every item must have to remain compatible
with the engine, but also in how item templates will be stored before
item instances are created for the game and whether there is room in the
item class for the history or description of special items.

Well, most inventory related item functionality is implemented in the C++ item_base class (currently found in the 0.3 source tree). It also contains some functionality to access basic item attributes in the actual item class on Python side.

That Python item class (or any class derived from it) is the item template. (I call it template, because initialized with different values will produce different items).

To create an item, a python script can be used that instanciates a template, inserts the initial values and finally saves it to disk. Afterwards it can be used from within the game. The templates themselves are kept on the filesystem, in the scripts/item/ folder.


Attributes required by the engine are the following:
* Mutable (0 or 1):
Whether the item can change during its lifetime. Items that cannot change can be handled much more efficient. However, there use is of course restricted. Good canditates for immutable items are coins, gems, books and the like.

* Name:
A unique identifier for items. It is displayed to the user, but also used to compare items for equality (to decide whether an item can go ontop of a stack
  or not).

* MaxStack: (0 - 2^16):
Whether the item can be stacked in the inventory and how many items fit into a
  stack.

* MaxCharge / Charge (optional):
For items that can be used up, these values hold the maximum amount of 'power' an item can have, as well as its current power. That can be used for torches, potions and the like, i.e. for items that can be used multiple times or over a
  period of time.

* Categories (optional):
Additional identifiers for an item. These are mainly meant for identifying item types in game scripts. Does a character carry any 'WEAPON's? Are any of
  his items 'MAGICAL'? Etc. ...
An item can have any number of categories assigned. Any string can be used as
  category.
This is also used to decide whether an item is allowed to go into a certain
  equipment slot.


For now, there isn't any field to attach a history or other information to an item. We can add something like Description to the Python item class, though, if you want.

I have attached all the item testing stuff I have written so far. It did still work for me, so you might get it running too. Otherwise you have at least the code to read.

To run it, extract stuff into the adonthell/src/pydonthell directory of the 0.3 tree. Configure with --enable-tools and compile pydonthell. Then run all the *-test.py scripts to see some action. All the .item files have been created with item/create-items.py. So that should give you an idea about how to create new items. Of course, you might have to come up with the proper templates first, or make changes to the existing (which are also found in the item/ directory).

In case you are interested, the relevant C++ sources are:
item_base.h/.cc
item_storage.h/.cc
inventory.h/.cc
slot.h/.cc
manager.h/.cc

They can all be found in the 0.3 tree under src/.

If you have questions, I will try to answer them. Also feel free to browse the devel archives. Mails from early 2003 deal mostly with the item/inventory stuff.

Attachment: item-test-04-01-22.tar.gz
Description: GNU Zip compressed data


reply via email to

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