2021/03/29

Calculating damage is a common — perhaps the *most* common — task inanalyzing builds and theorycrafting in Dungeons and Dragons. It is notan easy one, however. Like many other concepts in DnD, damage comesat the whims of dice. For this reason, damage cannot be effective describedas a single number, but rather as a distribution of possible values. On topof that, there are a number of rules and spell-specific effects that must beaccounted for when determining the range of outcomes.

In this post we’ll lay out the general framework of the damage distribution andcalculate it for a basic attack roll.

## Describing damage as a probability distribution

When a character attacks or casts a spell there are typically two steps thatoccur: 1) a roll by either the player or the DM to determine the degree towhich the target is affected and 2) a subsequent damage roll that determineshow much damage is taken by the target. There is randomness at every step ofthis process so we can best represent its outcome as a probabilitydistribution $p(d)$p(d), which is the probability that an attack does $d$d damage.

Let’s think about how we can compute this for a standard attack roll. We startby recognizing that a target can be affected by an attack in three ways: amiss, a normal hit, or a critical hit. A miss deals no damage, a normal hitwill deal damage as written in the ability block, and a critical hit dealsdamage but with double the number of dice rolled. These three possibilitiescan be represented by breaking down our damage into conditional components:

$p(d) = \sum_{h\in H} p(d \,|\, h) \,p(h)$p(d)=h∈H∑p(d∣h)p(h)

Where $H = \lbrace \textrm{Miss}, \textrm{Normal}, \textrm{Crit} \rbrace$H={Miss,Normal,Crit}. Theabove expression states that the probability that $d$d damage is done is theweighted sum of doing that damage under each of our three hit types. Bybreaking it down like this, we can directly compute $p(d)$p(d) by first lookingat the hit probabilities, $p(h)$p(h), and conditional damage distributions,$p(d|h)$p(d∣h).

It’s not too hard to see that this general formula can represent other damageprocesses. For a spell with a saving throw we could have $H = \lbrace\textrm{Success}, \textrm{Fail} \rbrace$H={Success,Fail}. From there, it comes down todefining the conditional damage distributions.

## The hit probabilities of an attack roll

The first step of computing our attack damage distribution is calculating thehit probabilities $p(h)$p(h). We will only concern ourselves with a standardroll, no advantage or disadvantage. Their effects could be explored with theappropriatesubstitution of probabilities given by advantage or disadvantage rules, andfollowing the structure of the rest of this post.

We’ll start with a critical hit. The rules state a critical hitoccurs when rolling a 20 on an attack roll. For a standard attack roll,this is simply:

$p(\textrm{crit}) = \frac{1}{20}$p(crit)=201

Next, we examine the probability of a normal hit, i.e. a rollthat meets or exceeds a target’s AC after bonuses but is neither a criticalhit or a critical fail (which guarantees a miss).To do this, we must reach back to our previous post on dice rolls probabilities.

We introduce two new parameters: a target roll, $t$t, and a bonus to add tothe roll, $b$b. In an attack roll, $t$t is typically the target’sarmor class. The parameter $b$b is usually a combination of a proficiencybonus and a stat modifier.

As an example, suppose a fighter with a +5 to hit attempts to strike aGoblin with AC 15, then $t = 15$t=15 and $b = 5$b=5.

If $X$X is the outcome of our attack roll, then we can write:

$p(\textrm{normal}) = \begin{cases}P(t-b \leq X \leq 19)& t-b \geq 2\\P(2 \leq X \leq 19)& \mathrm{otherwise}\end{cases}$p(normal)={P(t−b≤X≤19)P(2≤X≤19)t−b≥2otherwise

Using our dice roll probabilities, we can write this as:

$p(\textrm{normal}) = \begin{cases}\frac{19 - t + b + 1}{20}& t-b \geq 2\\\frac{18}{20}& \mathrm{otherwise}\end{cases}$p(normal)={2019−t+b+12018t−b≥2otherwise

The above expression describes the probability that a rollmeets or exceeds the target after bonuses, while excludingcritical hits and failures.

The last category to look at is the probability of a miss. Wecould calculate it directly as before, but it’s easier to justderive the result using the complement:

$p(\textrm{miss}) = 1 - p(\textrm{crit}) - p(\textrm{normal})$p(miss)=1−p(crit)−p(normal)

Then we can write:

$p(\textrm{miss}) = \begin{cases}\frac{t - b - 1}{20}& t-b \geq 2\\\frac{1}{20}& \mathrm{otherwise}\end{cases}$p(miss)={20t−b−1201t−b≥2otherwise

With this, we fully describe the probability of an attack hittingwhen accounting for the target’s AC and the attacker’s bonuses. Fromhere, we turn our attention to the conditional damage distributions.

## Damage conditional on the attack roll

The damage distributions themselves are determined by the specific attacktype or spell being used, but most follow a pattern — the total damageis determined by the sum of rolling one or more dice and adding a bonus. Wewill write ${}_{m}D_n$mDn to represent the random variable of a sum of $m$m$n$n-sided dice and $d_0$d0 will be the damage bonus added, then:

$p(d|h) = P({}_{m}D_n + d_0 = d | h) = P({}_{m}D_n = d - d_0| h)$p(d∣h)=P(mDn+d0=d∣h)=P(mDn=d−d0∣h)

With the way we’ve written the above, we can see that our damagedistribution can be written directly in terms of ${}_{m}D_n$mDn, which weconveniently defined in a prior post.

For our normal damage distribution, we write it out directly:

$p(d|\textrm{normal}) = \frac{1}{n^m}\sum_{l=0}^{\left\lfloor\frac{d - d_0 - m}{n}\right\rfloor} (-1)^l {m \choose l} {d - d_0 - nl - 1 \choose m - 1}$p(d∣normal)=nm1l=0∑⌊nd−d0−m⌋(−1)l(lm)(m−1d−d0−nl−1)

Which is the full expression of our dice roll sum distribution equal to $d -d_0$d−d0 as above.

Critical hits are a simple modification of the above, substituting $m \to 2m$m→2m,which represents doubling the number of damage dice that one rolls. Thisgives:

$p(d|\textrm{crit}) = \frac{1}{n^{2m}}\sum_{l=0}^{\left\lfloor\frac{d - d_0 - 2m}{n}\right\rfloor} (-1)^l {2m \choose l} {d - d_0 - nl - 1 \choose 2m - 1}$p(d∣crit)=n2m1l=0∑⌊nd−d0−2m⌋(−1)l(l2m)(2m−1d−d0−nl−1)

Our last distribution — damage when the attack roll is missed — is thesimplest:

$p(d|\textrm{miss}) = \begin{cases}1& d = 0\\0& \textrm{otherwise}\end{cases}$p(d∣miss)={10d=0otherwise

When an attack is missed, damage done is 0 with probability 1. Simple enough.

## Complete damage distributions

We now have all the necessary components to compute $p(d)$p(d) in its entirety.As a reminder, for an attack roll we have:

$p(d) = p(d|\textrm{miss})p(\textrm{miss}) + p(d|\textrm{normal})p(\textrm{normal}) + p(d|\textrm{crit})p(\textrm{crit})$p(d)=p(d∣miss)p(miss)+p(d∣normal)p(normal)+p(d∣crit)p(crit)

It would be too verbose to substitute all of our values directly into thisexpression, but easy enough to describe the output by looking at graphs ofdifferent damage distributions. Let’s consider some examples:

Suppose Ria, a fighter, is facing down a zombie. Her attack bonuswith her longsword is +5 and the zombie’s AC is 8. Ria’s longsword deals1d8 + 3 slashing damage. What is the damage distribution of her strike?

From the prompt, we know that $t = 8$t=8, $b=5$b=5, $m=1$m=1, $n=8$n=8, and $d_0 = 3$d0=3.All there is to do now is plug these values into our previously describedexpressions. The below graph shows the probable outcomes of her strike.

It’s not exactly a bell curve to say the least. The complex behavior isthe mixture of our three possible damage conditions — the single bar at0 is the probability of missing, the mostly uniform damage from 4 to 11is the damage from a normal hit, and the triangular distribution that lieson top of that is the critical hit damage.

The shapes and relative magnitudes depend on all the parameters present.To see just how different they can be, let’s consider another situation.

An adventuring party is going toe to toe with a large Ogre. Yar, a cleric,calls on the power of his deity to cast Inflict Wounds at 1st level. Hisspellcasting ability modifier is +5 and the AC of the Ogre is 11. Damagedealt on a hit is 3d10 necrotic damage. What is the damage distribution?

We approach this in a similar way to before, noting that $t = 11$t=11, $b=5$b=5,$m=3$m=3, $n=10$n=10, and $d_0 = 0$d0=0.

Now we see an entirely different distribution. The 0 damage possibility hasrisen to 25% and the bulk of the non-zero damage forms a familiar bell curvefrom the 3-dice sum with a long tail that represents possible crit damage.

In both of these examples, the mixture of different attack roll outcomesgives rise to non-trivial damage outcomes. Even so, thedamage from an attack roll that we explored here is one of the simplestdamage mechanics in 5e. Varying spell effects, different damage types, andother features all paint a rich mechanical picture. It suffices to say thatwe still have much to explore in this realm, but that will be for future posts.