Damage is calculated in several steps. It is not essential to understand how these numbers arise, but it is beneficial for players who want to make the most informed decisions.
Updated for 1.0.0RC3.
Basic damage calculation
Step 1: Stats Surprisingly (for people who have played other RPGs), your stats are actually the most important factor in determining your combat damage. Which stats are used depends on the weapon, and in some cases, on your talents.
For example, a longsword says 100% Str which means it uses your Strength and nothing else. A dagger says 50% Str, 50% Dex which means it uses your Strength (times 0.50) plus your Dexterity (times 0.50). However, if you have the Lethality talent, this overrides the 50% Str part and forces the calculation to use your Cunning (times 0.50) instead. So a Bulwark's damage with a longsword is somewhat proportional to Str*1.0; for a Rogue with a dagger, it would be Cun*0.50+Dex*0.50.
Mindslayers have some additional modifications during this step, for telekinetically wielded weapons: the stats used for such weapons are swapped around, and multiplied by the telekinetic grasp talent level, and then multiplied by 0.6. We won't be showing examples of this because it's already confusing enough just using the standard stuff.
The result of this step is stored in a variable called totstat (for "total stats").
As an example, let's take a Rogue with 41 Dexterity and 35 Cunning, who has the Lethality talent. His totstat (using a dagger) is 41*0.50 + 35*0.50, or 38. His Strength doesn't matter, because Lethality overrides it.
Step 2: Base weapon damage
The second most important factor in determining your damage is your weapon's base damage.
This is usually displayed as a range of numbers; we want the lower one. ToME 4 is all about diminishing returns (except when it isn't), and so we convert the weapon's power into a multiplying factor. We use this formula:
power = (sqrt(base_dmg / 10) - 1) * 0.5 + 1
If weapon's base damage is 28, then power comes out to approximately 1.337. If you have Advanced Weapon Statistics turned on, this is displayed as a percentage, 137%.
Step 3: Talent modifier Each type of weapon has a talent that boosts its damage output. For most weapons, this is Weapons Mastery. For daggers, it is Dagger Mastery (called "Knife Mastery" in some versions). Bows and slings use Bow Mastery and Sling Mastery respectively. For Stone Wardens using shields as weapons, the relevant talent is Stoneshield. For mindstars, it is Psiblades.
We use this formula:
talented_mod = sqrt(eff_talent_level / 5) / 2 + 1
With a raw Knife Mastery talent level of 5, and a mastery of 1.30 in Combat training, this gives an effective talent level of 6.5. Therefore the talented_mod variable is about 1.570.
This can also be found in the relevant talent's description: increases weapon damage by 57% when using daggers.
Step 4: Physical power
Physical power is a rescaled combat stat. We won't go into the factors that affect it here; get it from your character's tooltip.
For our example, we'll assume our Rogue has a physical power of 27.
Step 5: Total damage before rescaling
Now we combine all our numbers together, using this formula:
dam = 0.3 * (phys_power + totstat) * power * talented_mod
The dam variable does not actually exist in the code. It is only used here for clarity.
Continuing our example, our Rogue has a pre-rescaling damage of 0.3 * (27 + 38) * 1.337 * 1.570, or about 40.932.
Step 6: Rescale damage This is the final step in determining the base damage shown on the character sheet. The damage figure calculated in the previous step is run through this formula:
damage = dam ^ 1.04
So, the final output in our Rogue example is 40.932 ^ 1.04, or 47.48.
This will be shown as 44 on the character sheet.
Applying the damage
Step 1: Weapon damage The base damage of a weapon attack is shown in the attack tab of your character sheet, using the calculations shown above.
Accuracy (main Hand) 45 Damage (main Hand) 50 APR (main Hand) 8 Crit (main Hand) 8% Speed (main Hand) 100.00%
Result so far: 50
Step 2: Armour and Armour Hardiness Armour reduces damage at this point, making it very effective. Armour is capped by armour hardiness, and reduced by armour piercing (APR). Enemy armour and armour hardiness are shown in their tooltip.
Hardiness/Armour: 30% / 12
Armour Hardiness specifies the maximum amount that can be reduced by armour. Squishy's hardiness is 30%, which means that it can reduce a maximum of 15 base damage (30% of 50). Squishy's armour is 12, which is modified by APR before subtracting from base damage. The attacker's APR is 8, leading to an effective armour of 4. 4 is less than the maximum allowable by Hardiness (15), so it is used. This is subtracted from Smasher's base damage, which reduces it to 46.
Result so far: 46
Step 3: Damage Range Damage range can only be found by dividing the second number in the power of your weapon by the first number. This is then used to increase the damage to between the base damage and the base damage multiplied by the range, randomly. Smasher is using a Dwarven-Steel Longsword, that shows up like:
Base Power: 20 - 28
By dividing (28/20), you can get the damage range of 1.4. A random number is then chosen between 46 (the damage after armour) and 64.4 (46 * 1.4). In this example, it is 57 (whole numbers only).
Result so far: 57
Step 4: Talents Smasher attacked with Dirty Fighting (lvl 2) for 52% damage, which is a fairly straightforward multiplication. 57 * 52% = 29.64
Result so far: 29.64
Step 5: Critical Hits Critical hits are a chance to do extra damage. The chance is found in the attack tab, near the damage and APR found previously, and is 8% in this example. The amount of damage that a critical hit does is multiplied by the "Critical mult.", found under the Damage Mods column. The default is 150%, and it can be raised by various means. Smasher got lucky, and got a critical hit. 29.64 * 150% = 44.46
Result so far: 44.46
Step 6: Offhand Multiplier Offhand daggers only do 50% damage, unless the attacker has the Dual Weapon Training talent. Offhand shields being used by Stone Wardens also do 50% damage. Offhand mindstars do full damage.
Since this is not an offhand weapon, there is no adjustment in this step.
Result so far: 44.46
Step 7: Resistances, shields, +damage%, etc... This is in common with talent damage, and will be found in a forthcoming page.