# What is the combat formula in Stendhal?

I would like to know precisely the influence of the different factors (equipment, attack & defense, level) in combat in the MMORPG Stendhal. I did not found the formula computing the hit points, is it available somewhere?

Edit: as answered, the formula is quite complex; a few things I was not sure of that can be confirmed by looking at the code:

1. the x between DEF and the defense provided by items is not misleading: these two stats are multiplied (similar for ATK);
2. the actual value for defense is a geometric mean (square root of the product) between the above product and the level;
3. both 1. and 2. are mitigated by additive and multiplicative constants, so at low level the level does not count very much.

There are some strange things in the code, though. For example, the weighting of the level for the computation of the max defense is given by a multiplicative constant. But inside a geometric mean, the right way to weight should be to use level raised to a constant power. This is mitigated by the additive constant NEWBIE_DEF that complicates the interpretation, but the formula still makes little sense to me.

-

The answer cannot be put into a single formula, but you can look into the code to get an idea how the damage calculation works.

Code of the class containing the damage calculation

Basically there are two methods interesting in there, as combat works in two steps:

• First decide if a hit is taken

public boolean canHit(final RPEntity defender)

• If a hit will be taken then the damage is calculated (still can be 0)

int damageDone(RPEntity defender, double attackingWeaponsValue, Nature damageType,boolean isRanged, int maxRange)

-