Calculate average wounds and expected damage for tabletop wargaming.
Attacker Profile
Defender Profile
Simulation Results
Hit Chance:0%
Average Hits:0
Wound Roll Needed:0+
Average Successful Wounds:0
Effective Save (Sv vs Inv):0+
Unsaved Wounds (Through Armor):0
Total Expected Damage:0
Understanding Mathhammer: 40k Damage Mechanics
In the Warhammer 40,000 tabletop game, victory often relies on understanding the statistical probability of your attacks dealing damage. This "Mathhammer" calculator simulates the sequence of dice rolls required to eliminate enemy models, from the initial Hit Roll to the final Feel No Pain save.
The Attack Sequence
Damage calculation in 40k follows a strict hierarchy. To effectively use this tool, you must understand the four primary stages of an attack:
1. Hit Roll: Determined by your model's Weapon Skill (WS) for melee or Ballistic Skill (BS) for shooting. A lower number represents higher skill (e.g., BS 2+ is better than BS 4+).
2. Wound Roll: This compares the weapon's Strength (S) against the target's Toughness (T).
If Strength is double Toughness (or higher): Wound on 2+
If Strength is greater than Toughness: Wound on 3+
If Strength equals Toughness: Wound on 4+
If Strength is less than Toughness: Wound on 5+
If Strength is half Toughness (or lower): Wound on 6+
3. Saving Throw: The defender rolls to prevent damage. This is the Armor Save (Sv) modified by the weapon's Armor Penetration (AP). For example, a 3+ Save hit by AP -1 becomes a 4+ Save. If the model has an Invulnerable Save, they use whichever is better (AP does not affect Invulnerable Saves).
4. Damage Allocation: Any unsaved wounds apply damage. Some units have a secondary save known as "Feel No Pain" (FNP), which allows them to ignore individual points of damage on a specific die roll.
Interpreting the Results
This calculator provides "Expected Values" (averages). While dice are random, over the course of a game with dozens of rolls, the results tend to converge on these averages.
Average Hits: The number of attacks that successfully land on the target.
Unsaved Wounds: How many shots penetrated the enemy armor. This is a critical metric for clearing hordes of low-health infantry.
Total Expected Damage: The raw amount of damage dealt. Use this to determine if a unit can destroy a high-wound vehicle or monster (e.g., trying to deal 12 damage to a tank).
Strategic Tips
When selecting targets, consider the efficiency of your weapon's profile. Firing high-strength, low-AP weapons at heavily armored terminators (2+ save) is often inefficient compared to using high-AP plasma weapons. Conversely, high-damage weapons are wasted on 1-wound infantry models. Use this calculator to optimize your target priority phase.
function calculateDamage() {
// Inputs
var attacks = parseFloat(document.getElementById('attacks').value);
var wsBs = parseFloat(document.getElementById('wsBs').value);
var strength = parseFloat(document.getElementById('strength').value);
var ap = parseFloat(document.getElementById('ap').value);
var damage = parseFloat(document.getElementById('damage').value);
var toughness = parseFloat(document.getElementById('toughness').value);
var save = parseFloat(document.getElementById('save').value);
var invuln = document.getElementById('invuln').value ? parseFloat(document.getElementById('invuln').value) : 99; // 99 effectively means none
var fnp = document.getElementById('fnp').value ? parseFloat(document.getElementById('fnp').value) : 99;
// Validation
if (isNaN(attacks) || isNaN(wsBs) || isNaN(strength) || isNaN(toughness) || isNaN(save) || isNaN(damage)) {
alert("Please fill in all required fields with valid numbers.");
return;
}
// Handle AP (ensure it's treated as a modifier).
// If user types "-1", abs is 1. If "1", abs is 1.
// Convention: AP reduces the roll, effectively increasing the target number.
var apMod = Math.abs(ap || 0);
// 1. Calculate Hit Chance
// Roll needed is wsBs. Success is (7 – wsBs)/6
var hitChance = (7 – wsBs) / 6;
if (hitChance 1) hitChance = 5/6; // Usually 1s always fail
var avgHits = attacks * hitChance;
// 2. Calculate Wound Chance
// Compare S and T
var woundRollNeeded = 4;
if (strength >= 2 * toughness) {
woundRollNeeded = 2;
} else if (strength > toughness) {
woundRollNeeded = 3;
} else if (strength == toughness) {
woundRollNeeded = 4;
} else if (strength <= toughness / 2) {
woundRollNeeded = 6;
} else {
woundRollNeeded = 5; // strength < toughness
}
var woundChance = (7 – woundRollNeeded) / 6;
var avgWounds = avgHits * woundChance;
// 3. Calculate Save Chance
// Modified Armor Save = Save + AP modifier
var modifiedArmorSave = save + apMod;
// Determine which save to use (Armor vs Invuln)
// A player chooses the best save (lowest number).
var bestSaveToUse = modifiedArmorSave;
// If Invuln is better (lower) than modified armor save, use Invuln
if (invuln 6) {
saveChance = 0; // Impossible to save on a D6
} else {
saveChance = (7 – bestSaveToUse) / 6;
}
// Probability to FAIL the save (take damage)
var failSaveChance = 1 – saveChance;
var unsavedWounds = avgWounds * failSaveChance;
// 4. Calculate Final Damage
var totalRawDamage = unsavedWounds * damage;
// 5. Apply FNP (Feel No Pain)
// FNP is a roll to ignore DAMAGE, not wounds (usually).
// e.g. 5+ FNP means 1/3 chance to ignore a point of damage.
var damageMultiplier = 1;
if (fnp 6 ? "None" : bestSaveToUse + "+";
document.getElementById('resEffSave').innerHTML = saveText;
document.getElementById('resUnsaved').innerHTML = unsavedWounds.toFixed(2);
document.getElementById('resTotalDamage').innerHTML = finalDamage.toFixed(2);
}