adonthell-devel
[Top][All Lists]
Advanced

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

[Adonthell-devel] equipping items


From: Kai Sterker
Subject: [Adonthell-devel] equipping items
Date: Fri, 16 May 2003 14:34:45 +0200

As characters will have to equip items in order to do proper combat
calculations, I'd like to sort this out over the next few days.

Currently, an item's equip method does both check whether the item can
be equipped and apply the item effects when it is equipped. But since we
decided to not apply item effects to the character at all, this has to
be changed.

So, first of all we'll need a method like can_equip that gets a
character and returns true or false. If an item does not implement the
method, we would assume false.

Another task is finding out into which slot an item fits. This would be
taken care of by the item manager, as discussed. The neccessary
information could be take from the item's categories. The manager could
have a mapping from categories to slots, since 1 category could fit into
several slots. That mapping shouldn't be hard-coded, but read from a
data file, so that it remains flexible.

So there could be a number of methods that build on each other (but may
also be useful on their own):

* vector<string> allowed_slots (item_base *)
  A list of slots the given item will fit. Can be empty. Might be useful
  to highlight possible slots in the inventory GUI.

* bool fits (item_base*, slot*)
  Test whether the given item fits into the given slot. Will make use 
  of the method above, of course. Can be used to construct a list of
  items that may go into a certain slot.

* bool equip (item_base*, slot*)
  Actually equips the given item in the given slot. Returns true on
  success, false on failure. If an item is already equipped, the
  two items should be swapped. NULL should be allowed as item, which
  would just unequip the equipped item (and place it in the character's
  inventory).

As an alternative, equip could return the item that is replaced and
leave it to the caller to take care of it. But then one couldn't really
check whether equipping was successful or not.

A second alternative would be to exchange newly and currently equipped
item. But unequipping an item without equipping a new one would be
handled by an unequip method that would indeed return the item, so that
the caller can decide what to do. In that case, passing NULL as item
wouldn't be valid.

One should also note that it is possible to retrieve the character that
shall equip the item from the given slot. (As slot points to an
inventory and each inventory has an owner: the character). So the fits
method would also check whether the character may actually equip the
item or not.


Remains the question whether we still need the (optional) equip and
unequip method of items. We don't have to apply or remove item effects
to characters, so they wouldn't be needed for that. The question is
whether they might be of any use for setting/unsetting plot-related
flags. However, at present I couldn't think of a situation that would
absolutely require this. Whether a character wears an item or not can be
detected otherwise, adjustments to character attributes are handled by
the manager. OTOH, it wouldn't hurt to keep these two methods around,
just in case equipping/removing an item will have to trigger a dialogue
or cutscene or some other event.


So much for that. If you think that above is okay, I could start with
the implementation. Shouldn't be too difficult, as a lot of the required
functionality is already in place.

Further suggestions or improvents also welcome, of course :).

Kai




reply via email to

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