# RPG Math: Calculating Chance to Hit in D&D 5e

This time we will be system-specific and look into a valuable formula for D&D 5e, chance to hit. This formula will allow you to make an educated guess for how likely you are to hit your target with your spell or weapon attack. The best part is that the math is even easier than our **previous article** which was calculating the average dice roll! Let’s get to it.

## Definitions

### Probability

The chance for a specific outcome to happen. When you see the word “chance” in mathematics, it’s safe to assume probability is involved.

### Chance to Hit

The likelihood of landing a successful attack on your target. This is calculated as a percentage.

## Chance to Hit Formula

Chance to Hit = ( ( 21 – ( Target’s AC – Player’s Attack Bonus ) / 20 ) * 100

This is an extremely simple formula as we merely have to add all the numbers in the numerator together and then divide by 20. Next, we will multiply the decimal value by 100 to put it into the proper percentage format.

Why do we have a 21 in the numerator when we only have a 20-sided die? You will always have at least a 5% chance to hit any target in D&D 5e as rolling a 20 is an automatic hit. Conversely, you will never have a greater chance than 95% to hit as a 1 is an automatic miss.

## Examples

### Fighter vs. Dragon

For our first example, we will be a fighter with a +9 to hit. Its target is an **Adult Bronze Dragon** with an AC of 19. This is going to be a tough fight. What’re our chances of dealing some damage?

1) Chance to Hit = ( ( 21 – ( 19 – 9) / 20 ) * 100

2) Chance to Hit = ( ( 21 – 10) / 20 ) * 100

3) Chance to Hit = ( 11 / 20 ) * 100

4) Chance to Hit = 55%

55% is certainly not the best odds, but worth a shot. This is a situation where you have found yourself swinging above your weight class.

### Sorcerer vs. Ogre

In our second example, we are a sorcerer with a +7 to hit with our spells. Our target is an **ogre** with an AC of 11, which our** frontline is keeping at bay** for us to unleash our **scorching ray**.

1) Chance to Hit = ( ( 21 – ( 11 – 7 ) / 20 ) * 100

2) Chance to Hit = ( ( 21 – 4 ) / 20 ) * 100

3) Chance to Hit = ( 17 / 20 ) * 100

4) Chance to Hit = 85%

85% are some great odds! However, this is only the chance for a single ray to hit. What if we wanted to know what the likelihood of all 3 rays hitting was?

While it’s a bit more tricky, all you’ll have to do is take the value of your chance to hit and raise it to the power of attack rolls you are making. In our case, we have 3 rays so we will take 0.85³ which is 0.614125. This is roughly 61.4%. We have an above-average chance at hitting with all 3 of our rays which is pretty rare.

## Use Cases

The obvious use case for this formula is to calculate our chance to hit an enemy. However, we can also use it to determine our likelihood of success on ability checks and saving throws in D&D, given that we know the DC. Simply change the formula to the following:

Chance to Succeed = ( ( 20 – ( DC of the check – Ability Score – Proficiency) / 20 ) * 100

Did you notice that we are using 20 instead of 21? Although it is a popular house rule, a natural 20 is not an automatic success on saving throws and ability checks. Likewise, a natural 1 is not an automatic failure. Therefore, our maximum chance to hit with this formula is 100% and our minimum chance to hit is 0%.

Knowing how to use this formula can grant you many advantages in D&D. There are many situations in which missing an attack or failing a check is worse than attempting the action. Having the ability to know when to avoid these checks can be the difference between life and death.

## Conclusions

My intention for this semi-regular series is not to have a lot of D&D 5e-specific formulas. However, I felt that this formula is a great introduction to calculating basic probabilities. Having an understanding of probability will be helpful for the more complex formulas in RPGs! I’ve written **a different article** on calculating probability before as well.

It is possible to calculate your chance to hit with advantage and disadvantage. However, I will save that for another post where I can go into much more detail on the math as it is much more complicated. I also intend to write an entire post on advantage and disadvantage beforehand.

Depending on the system you are playing this formula could be tweaked based on how your dice rolls, bonuses, and enemy armor works in another system. So long as you have all 3 of these components, you can make a chance to hit formula for that system.

Thank you for writing this, Its been very helpful to me as a creator, Just wondering if there is a formula for calculating chances to hit at least once within a single turn if there are multiple attacks per turn, I did find a website that can do that for me but I think it would just be fun to know.

Nice writeup. No game lends itself as good as D&D to get to the basics of statistics. However, you’ve got your math a bit wrong for extreme high/low cases. If I have a +10 on attack vs an AC of 11, I should always hit, except in case of a natural 1. Hence, probability 95%. Your formula gives 100% in that case.

Also, the ability check formula is wrong; it should still be 21 instead of 20. Check it yourself: if the DC is 15 and I have a +2 modifier, I’ll succeed when rolling 13, 14, 15, 16, 17, 18, 19, 20. That is 8 rolls out of 20, hence 40%. Your formula gives 35%.

The difference between 20 and 21 does not represent the usage or not of an automatic hit/miss like you seem to believe. It should always be 21, as this is dictated by statistics (it comes from the fact that a roll equal to AC also hits – if this would not be the case, we would use 20). The use of automatic hit/miss should be implemented differently.

The correct way to deal with this type of probabilities, is to count success configurations (21 – AC/DC + modifier) and divide them over total configurations (20). For attack rolls, you should take into account that you always have minimally 1 success configuration (instead of 0, due to natural 20), and maximally 19 (instead of 20, due to epic fail). This can be done by using min/max:

# of success configurations = min[ max[ (21 – AC + modifier) , 1 ] , 19 ]

Then you should also cap the probability at 0% and 100% (probabilities cannot be negative nor larger than 1). This can also be done with a min/max. You can combine both steps into one:

ability roll probability: min[ max[ (21 – DC + modifier) / 20 *100 , 0 ] , 100 ]

attack roll probability: min[ max[ (21 – AC + modifier) / 20 *100 , 5 ] , 95 ]

You can easily check this yourself by listing all possible roll outcomes for different AC/DC and modifiers (try a few cases: one where the modifier equals the DC/AC, one where it is bigger than the DC/AC, and one where it is smaller than the DC/AC). You’ll come to the same conclusion :-).

Thanks for putting the effort in this!

Cheers

This is fantastic info! I’ll need to take a deeper look at this and make some revisions to the original article. Thank you!

This was very helpful, thank you.

I’ve seen this formula before but I hate looking at formulas and not knowing how they got there. The 21 in the formula in particular was bothering me. I knew the article was off with its reasoning (not meant to throw shade, very grateful for the article and the author) but I couldnt figure out why the formula was what it was, so I went about figuring it out in my own frazzle brained way. Below is my process for figuring out how the formula came about using my rudimentary math. I’m sorry it’s so long.

I used my intuition first: if my character has +4 in Bonuses and the enemy has AC of 19, I know in my head I need to roll a 15 or greater, because 15 + 4 = 19, the target AC I need to hit. That means out of 20 possibilities, only 6 land: 15, 16, 17, 18, 19, and 20. So, 6 out of 20 or 30%. Not great odds.

But how to get there with a formula? Let’s call the roll I need = x, the AC of the target = A, and my bonuses = B. First we need to find x. This part is simple. My roll + my bonuses have to equal my targets AC, so x + B = A. Take away B from both sides because math and you get A – B = x.

Now how to account for percentages in my formula? For this, I think I found it easier to come at by figuring out %chance of failure instead of success. Why is failure easier? Let’s take the last example: I know I need to roll a 15 or greater to succeed, or, in other words, a 14 or less fails. Let’s call the number of possibilities of failed roll = f. In this case, f=14 because any roll from 1-14 is a fail. Your f, the number of rolls you can fail with, will always be 1 less than x, the roll you need to succeed. If you need to roll an 18 to hit, f = 17 because 17 outcomes fail. If you need to roll a 5 to hit, f = 4. If you need to roll an 11, f=10 etc. So, f = x-1.

Because of this relationship between the roll you need and the chances of failure, I found failure to be a simpler road to understanding the concept.

To recap: f, the number of rolls that lead to failure, is always 1 less than x, the roll you need to hit, or, in math, f = x-1, and x is always AC – bonuses or x = A-B. Combining those leads to: f = A – B – 1.

Now remember, f is the number of different rolls that leads to failure which is not the same as a percentage or odds. To find the odds of failing, we divide the number of rolls that lead to failure by the number of possibilities on the die: 20. To rewrite in math you get: %fail = f/20.

Going back to our earlier equation f = (A-B) -1, we can find the formula for %fail by dividing both sides of the equation by 20. It now looks like this:

%fail = f/20 = (A – B – 1)/20

Now for finding % success:

The simplest way, if you already have the %fail is to find the composite: 100 – %fail = %success. That could look like 1 – ((A – B – 1)/20) = %success. And that is a formula that is totally correct but looks nothing like the formula in the article which is also correct. Sure we could play around with the equation and force it to look like that for our own entertainment, but I needed to know how to get directly to (21 – (A-B))/20 = #success, and understanding how we got to the formula with %fail is the key to getting directly to the formula above.

With our earlier example, instead of counting all the possible failures (1-14), we count all the possible successes (15-20). If we need to roll 15, there are 6 ways to succeed out of 20 (15, 16, 17, 18, 19, 20). If we need to roll 19, there are 2 ways to succeed (19, 20). If we need to roll a 5, there are 16 ways to succeed (5, 6, 7…20).

Let’s play with variables again. We’ll call the number of possibilities of a successful roll = s. You may have noticed already, but the sum of the number you need to roll (x) and the number of possible successes (s) will always equal 21. This is because the tie goes to the attacker.

So x + s = 21. We play with that a bit and get s = 21 – x. Remember x hasn’t changed – it still represents the roll you need for success, just like above. So, x = A-B. And just like above, we can combine our formulas:

s = 21 – (A-B)

And, as with discovering odds of failure, finding s here doesn’t give us odds at success, but rather a whole number representing the number of different values on the die that lead to success. If s = 6 then there are 6 possible outcomes for my roll to be successful. And, as we did with failure, we can divide by the 20 total possible outcomes on the d20 to get our odds.

#success = s/20

And we know s = 21 – (A-B) so we can combine the formulas to get:

%success = (21 – (A-B))/20

Hope this was helpful for someone. Conceptually, it was definitely helpful for me to write.

All I’d say to add is that you should include another parentheses after the modifier to hit because following order of operations im dividing AC-modifier before doing anything with that 21 the way it is written. It should look like ((21-(AC-mod))/20)*100. Thank you!

Thanks for the article. You seem to be missing one of your closing parenthesis, though, which makes things a bit confusing for those trying to actually use the darn thing.

Chance to Hit = ( ( 21 – ( Target’s AC – Player’s Attack Bonus )) / 20 ) * 100

Thanks, this is useful! One thing, though, you forgot to actually put the 21 in the numerator. The parenthesis are wrong. It should be:

( (21- Target’s AC – Player’s Attack Bonus ) / 20 ) * 100

sorry, ( (21- (Target’s AC – Player’s Attack Bonus) ) / 20 ) * 100

OK, checking it out. Thanks for the reply – isnt this the same as your previous comment?