Combat revolves around the Offense and Defense values of every battler. For players, these values are bound between 1 and 1000, while monsters range from 1 to 1500 in almost all cases.
To determine chance to hit, you take the attackers offense, divide it by the defender's defense, and multiply by the chance to hit if the values are equal (currently 60%). So, for example, if the attack's offense is half the defender's defense, the chance to hit is half of 60%, or 30%. The chance to hit is bound between 10 and 95. This means a battler is never unhittable or unmissable, no matter what the values are. It is important to note that this equation makes combat more hit-centric, where it is easier to get skill to hit someone then it is to get the ability to be missed all the time.
Note that these values can be gathered in-game by use of the "evaluate" spell. This DM-only spell will give the combat abilities of any target. This spell should be used sparingly, however, because the side-effects of combat (such as wear and tear on equipment, etc) will happen when the target is evaluated. The effect should be small, but repeated use can cause unwanted effects.
When an attack is made, we start in TryAttack. This is the core message used for combat. If we hit, we call AssessDamage to the target (so that it can record the damage) and AssessHit to self. AssessHit is used by battler for side-effects, like poisoning, etc. If we kill the target, we send KilledSomething to ourselves, otherwise we send DidDamage to ourselves. If we miss, we call AssessMiss to ourself (to see if any catastrophic side-effects happen). We always send SomethingAttacked to our owner for an attack.
The attacker is responsible for miss messages in combat. If the attacker misses, the it queries the defender for the reason of the miss. Right now, defenders can block, parry, dodge or "avoid" (generic catch-all) an attack. The attacker is responsible for hit messages in combat. The defender gives the type of damage it suffered and amount of damage, which the attacker reports in a combat message.
A player's offense is calculated from the following equation: (Stroke*3) + (Proficiency*2) + (Aim*4) + (Base Max Health*3/2).
If we hit, we poll the stroke for the type of damage we do. If there is no stroke object, then we query the weapon for damage. Note that touch attacks are both stokes and weapons in this case. Attack modifiers and faction bonuses can modify the damage. The base damage never exceeds 10 damage, Might adds (Might-20)/10 damage (minimum of 0), Proficiency (for weapons) adds ((percent+1)/20) damage, and all other bonuses are limited to 7 points of bonus damage. This means that no hit should do more than 25 points of damage.
A player's defense is calculated from the following equation: (Parry*2) + (Block) + (Dodge*3) + (Agility*4) + (Base Max Health*3/2)
If we are hit, our defense modifiers can reduce damage. Currently, armor is designed to make the player easier to hit (it lowers the Defense value), but it absorbs damage from blows. Resistances also reduce damage depending on damage type.
As a note: The message LookupPlayerWeapon will return the melee
weapon
the player wields (or $ if they have no melee weapon), where
GetWeapon
will return the weapon the player is using, including any touch
attack
spells, or it will return $ if they are using punch.
A monster's offense is piOffense, or (3*viLevel) +
(60*viDifficulty)
if that variable is $.
A monster's defense is piDefense, or (3*viLevel) +
(60*viDifficulty)
if that variable is $.
A monster's damage is random(piMinDamage,piMaxDamage), or 80-120%
of
viLevel/Random(10,15) if those values do not make sense (EG, are
$, or
Min is greater than Max, etc).
The damage value code is a bit unsteady, so it is recommended you do NOT change the values if the monster is in combat. It is also recommended that you pay careful attention to the values, and make sure they make sense (IE, piMinDamage is less than piMaxDamage).
In combat equations, monsters use themselves as stroke objects and weapons. Therefore, when a battler sees if it can dodge a stroke object, it checks that in the monster directly.
Other numbers:
Monsters can see (4 + viDifficulty/2) units away.
Monsters can attack (2 + viDifficulty/6) (either 2 or 3) units
away.