adonthell-devel
[Top][All Lists]
Advanced

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

[Adonthell-devel] Damage functions, objects & chains


From: Kai Sterker
Subject: [Adonthell-devel] Damage functions, objects & chains
Date: Fri, 25 Apr 2003 23:48:09 +0200

Finally, some new stuff :).

After thinking a little about combat and damage related issues, I came
to the conclusion that my current ideas weren't good enough. Especially
the code was too simple and probably wouldn't have worked out.

Since all the implementation is on python side, there is no need to be
generic, though I made a fresh start today. The system I came up with
works as follows:

Each object that wants to deal damage needs a damage function: i.e. if
characters should be able to fight without weapon, the character class
needs a damage function/method. Weapons will need such a method, as will
projectiles, feats and spells. However, in most cases it should suffice
if the respective base class implements this method.

When called, the damage method does a damage object, filled with the
most important attributes of the character, feat, spell or item. As
there are very different types of damage, we'll need quite different
kind of damage objects with different kinds of attributes.

The damage object is that which will actually deal the damage to a
target. As different spells, feats or poisons will behave differently,
different damage objects have to exist. One could say that a damage
object is the implementation of a certain spell or fighting feat.
Whenever the effect of some weapon, feat or spell is the same, save the
actual numbers, they can use the same damage object. For example, a
single damage object should be enough to handle Physical Damage, while
another one can take care of all Fire Damage.

Most often, attacks involve different type of damage. As explained
earlier, a weapon could have runes inscribed and poison applied and the
attacker could further use a fighting feat. All that is handled by a
damage chain. That means, all the different effects are combined in some
fashion. That is mostly fine, but may also cause some problems:

Imagine that the defender has a Physical resistance of 10, and the
attacker has a sword (physical 3-8), inscribed with runes (physical
4-7). If both effects where applied on their own, the attacker would
never deal any damage. But if both were combined (as it should be the
case), there'd be a chance to hit the defender.

For that reason, similar damage objects will be merged whenever a damage
chain is executed. (This is another reason for having those damage
objects) Would one just chain damage methods, the merging would be much
more complex and hardly controllable.

When a damage chain is executed, the damage types are returned in a
certain order. Right now, Magic comes first, then Poison, Fire and
finally Physical damage. That ensures that damage is applied in this
order. (Not sure if that is the most sensible one though.)

I've introduced a fifth type (Special) that can be used to apply
modifiers to any of the other damage type. For example, one could
imagine a fighting feat that doubles the physical damage a character
would normally deal.

Furthermore, each damage object contains a textual description of the
damage it does. A damage chain can combine these description to a list.
That way, we can easily display the effects of enhanced weapons and the
like.

That about is it. I'm not that far with my implementation. Haven't
integrated stuff with characters and items yet. Maybe I'll find time
over the weekend. However, I've written a few tests that are attached.
Just run the damage-test script. Since no Adonthell-related code is
involved yet, plain Python 2.2 will do :).

Kai

Attachment: damage.tar.gz
Description: GNU Zip compressed data


reply via email to

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