# How do I calculate the chance to hit a given AC?

My current level 2 variant Ranger has the Sharpshooter Feat.

His hit modifier is normally +7, but with Sharpshooter it's +2 (due to the −5).

I am wondering what the % based chance to hit is when using the feat, dependent on the AC of the enemy.

Example: What is the chance to hit a creature with AC 14?

Finding out the specific probability between critical miss, miss, hit, and critical hit gets a lot more complicated, but a "hit and miss" probability can be shown with a simple output d20 + 2 in AnyDice

Using the table looking at "At least", you can see your percent chance to hit any AC, knowing that you always have a 5% chance to critically fail and a 5% chance to critically hit. In this case, you have a 40% chance to meet a 15 AC

Here is a small AnyDice program that you can use to calculate hit, miss, critical hit, and critical miss, if you want to be more specific with your rolls. This is easily modified to allow crits on 19s and to eliminate critical misses as well. Be aware that it does not output your rolls, only numbers to represent the result. You also need to input an AC to roll against, since this program doesn't output a probability curve.

0 = critical miss.
1 = miss.
2 = hit.
3 = critical hit.

The question Incorporating expanded crit-range into anydice? would also be helpful in learning how Anydice can be used and what it can be used for.

• Ok great so with the +2 I have a 35.5% Chance to hit a AC 15 creature. Oct 26, 2015 at 16:40
• No... each +1 to hit, is effectively +5% chance to hit (in most cases). Oct 26, 2015 at 17:05
• Sharpshooter is the -5 to hit, +10 to damage, right? If so, the original question was not including a +9 to hit, it was going from a +7 to a +2. Also, regardless, I'm not sure where you get that you only have a 15% chance to miss a 15 AC with +9 even. Oct 26, 2015 at 18:00

$$P = \frac{21 - (AC - M)} {20} \times 100$$

P = Your percentage chance of hitting (P for probability)
AC = The Armor Class you're trying to beat
M = Your total to-hit Modifier (including proficiency and ability bonuses)

This equation first subtracts your to-hit modifier from your target's AC, which will get you the minimum number you need to roll in order to hit.

Once we have that number, we subtract it from 21 to get the range of numbers you can roll (how many results on the d20 will let me hit?). If your minimum roll is 20, you subtract from 21 to get 1 (one result on the d20 will let you hit).

Next, we divide the result by 20 to get a decimal between 0 and 1, which will represent our percentage to hit. If you prefer reading a decimal to a whole number, you can omit the "*100" and leave it at that

Finally, we multiply by 100 to get a whole number to read (0.6 become 60, 0.45 becomes 45, etc.)

Example

Say your entire to-hit modifier is +6, and you want to hit something with an Armor Class of 17

$$\frac{21 - (17 - 6)} {20} \times 100$$

Firstly, we evaluate the 17-6 to get 11

$$\frac{21 - 11} {20} \times 100$$

Next, we take 11 away from 21 to get 10

$$\frac{10} {20} \times 100$$

After that, we divide 10 by 20 to get 0.50

$$0.50 \times 100$$

Finally, we multiply 0.50 by 100 to get...

$$50$$

With a +6 to your attack, you have a 50% chance to hit someone with AC 17.

NOTE: This equation will also work with negative to-hit modifiers, following the rules of two negatives making a positive. For example, with an AC of 17 and a to-hit of -6, $17 - (-6)$ would become $17 + 6$.

• Forgot nat 1 and nat 20, which are a constant 5% to miss and to hit, respectively. It doesn't change anything except for $|(AC - M)| > 20$, though. Essentially, the actual answer is max(min(P, 95), 5). (I.e. you can't ever go over 95% to hit or under 5%) Jul 4, 2018 at 0:06
• How is this formula affected by lowered critical hit's threshold (e.g. via Fighter Champion's Improved Critical)? Jul 4, 2018 at 8:16

# Normal Chance to Hit

Your chance to hit can be calculated by:

$$\frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }$$

Note that attack bonus is your total attack bonus with all modifiers. We can test this out pretty easily. If you have a +7 to hit and are attacking a target with AC of 18, you need an 11 to hit. 11 through 20 is 10 faces on the d20, so it's half the die. A 50% chance to hit.

$$\frac{ 21 + 7 - 18 }{ 20 } = 0.50$$

And so it is.

If you are attacking the same AC 18 target and have a +2 attack bonus, you need a 16 or better to hit. You hit on 16, 17, 18, 19, or 20. That's five of the twenty sides of a d20, which is a quarter or 25% of the die.

$$\frac{ 21 + 2 - 18 }{ 20 } = 0.25$$

And so it is.

It's also worth remembering that a natural 1 always misses and a natural 20 always hits regardless of the attack bonus or AC involved. If you need a natural 20 to hit, your chance to hit is $$\\frac{1}{20} = 0.05\$$ (5%). This is the minimum chance to hit. If you need a natural 2 or better to hit, your chance to hit is $$\\frac{19}{20} = 0.95\$$ (95%). This is the maximum chance to hit.

# Chance to Hit with Disadvantage

If you have disadvantage, you effectively have to hit with both die rolls. To calculate that, simply multiply the chance to hit by itself.

$$\left(\frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }\right) \times \left(\frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }\right)$$

Which can be simplified to:

$$\frac{ (21 + Attack\,Bonus - Target\,AC)^2 }{ 400 }$$

So, with an an attack bonus of +7 and AC 18, the chance to hit with disadvantage is:

$$\frac{ (21 + 7 - 18)^2 }{ 400 } = \frac{ 10^2 }{ 400 } = \frac{ 100 }{ 400 } = 0.25$$

Again, a natural 1 always hits and a natural 20 always misses. If you need a natural 20 to hit, your chance to hit is $$\\frac{1}{400} = 0.0025\$$ (0.25%). This is the minimum chance to hit with disadvantage. If you need a natural 2 or better to hit, however, your chance to hit is $$\\frac{19^{2}}{400} = \frac{361}{400} = 0.9025\$$ (90.25%). This is the maximum chance to hit with disadvantage.

# Chance to Hit with Advantage

If you have advantage, it's a little bit more complex. Here, we have to calculate if either die hits or both dice hit. It turns out to be easier to calculate the chance to miss. That is, the chance to hit with advantage is equal to the chance to not miss with both dice. If the chance to hit is this:

$$\frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }$$

Then the chance to miss with one die is:

$$1 - \frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }$$

This is true because you either hit or miss, so the chances of hitting or missing always total to 1 (or 100%).

And the chance to miss with both dice is just the product of missing with each die. We used that above when calculating to hit with disadvantage:

$$\left(1 - \frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }\right) \times \left( 1 - \frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 } \right)$$

So, the chance to hit with advantage is the above subtracted from 1:

$$1 - \left[ \left(1 - \frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 }\right) \times \left( 1 - \frac{ 21 + Attack\,Bonus - Target\,AC }{ 20 } \right) \right]$$

Which simplifies to:

$$1 - \frac{(Target\,AC - Attack\,Bonus - 1)^2 }{ 400 }$$

(Note the AC and attack bonus swapped places in the simplified formula. You could also write it as $$\1 - \frac{(1 + Attack\,Bonus - Target\,AC)^2 }{ 400 }\$$, but this is how Wolfram Alpha simplified my algebra.)

So, with an an attack bonus of +7 and AC 18, the chance to hit with advantage is:

$$1 - \frac{(18 - 7 - 1)^2 }{ 400 } = 1 - \frac{{10}^2 }{ 400 } = 1 - \frac{100}{400} = 1 - 0.25 = 0.75$$

And, of course, a natural 1 always misses and a natural 20 always hits. If you need a natural 20 to hit, your chance to hit is $$\1 - \frac{(19)^{2}}{400} = 1 - \frac{361}{400} = 0.0975\$$ (9.75%). That is the minimum chance to hit with advantage. If you need a natural 2 or better to hit, your chance to hit is $$\1 - \frac{(1)^{2}}{400} = 0.9975\$$ (99.75%). That is the maximum chance to hit with advantage.

• Forgot nat 1 and nat 20, which are a constant 5% to miss and to hit, respectively. It doesn't change anything except for $|(AC - M)| > 20$, though. Jul 4, 2018 at 0:06
• Oh, I missed that you had comments on it. My bad. In my defense, the order was awkward. You put that, which is a general statement, after the numerical example with the 18 AC, and indeed I skipped for the next section after you started the example. I would change that order, letting the example be always the last thing, and the Remark immediately after the "theorem". Jul 4, 2018 at 23:04
• @HellSaint I put the comments on natural 1 ceiling and natural 20 floor at the end of each section because they are special exceptions or limitations. They're corner cases that are not particularly common. They're important to remember, but not interesting to the discussion. To me they're only worthy of being footnotes. Apr 6, 2021 at 13:15

Yes, you can use anydice, but it is generally far simpler to realise that, in general, ±1 changes your chance to hit by ±5%. This is only not the case when you run into the end of the ranges at 1 or 20; your chance to hit can never be less than 5% or greater than 95%.

For your example, +2 to hit is 25% worse than +7 to hit.

With +7 for AC 9 or less you have a 95% chance to hit, this goes down by 5% each AC until AC 27 (and all higher AC) when you have 5% (which will always be a critical).

With +2 your range runs from AC 4 or less to AC 22 or more and is 25% worse for each AC all the way along.

Specifically +7 vs AC14 is 70% hit chance, +2 is 45%.

Take the minimum number on a D20 that you can hit with, subtract that number from twenty, add one because the number the die lands on is included in the percentage calculation, and then multiply that result by 5. That's the percentage chance of you being able to hit a certain target.

The mathematical formula for this is

$$y = 5((20-x)+1)$$

$x$ is the minimum roll you need to hit the target. $y$ is the percentage chance to hit the target.

For example, if you need to roll a 14 to hit an armor class on a D20, The formula becomes:

$$y = 5((20-14)+1)$$

Twenty minus fourteen is six, plus one is seven. Seven times five is 35. Therefore there is a 35% chance that a roll on the D20 will result in you hitting said armor class.

In the above example, against an AC of 14 with a +7 to hit you need a 7 to hit AC 14, so your hit chance is

$$y = 5((20-7)+1)$$

Or in other words, you have a 70% chance to hit a creature with AC 14 normally. With a +2 to hit you need a minimum 12 on the die, so the hit chance becomes

$$y = 5((20-12)+1)$$

For a percentage total 45% chance that you will successfully hit.

I was bored and ended up creating a calculator for this. I used the formula ((21 - (AC - MOD)) / 20) * 100.

It still needs to be tweaked and I need to make it sexier; http://ecal.defigo.us/. If you get a chance let me know what you think and if my math is wonky.

• Just pointing out a few typos on your linked page: "Encounter" is misspelled as "Enoucnter" several times (including in the page/tab title), once as "Enouncter" and once as "Enocunter". "Attack(s)" is misspelled as "atack(s)" and once as "tacks". "will" is misspelled as "waill". "experience" is misspelled as "expirince", and "can" is misspelled as "cna". (Also, it should be "an encounter", not "a encounter".) Jul 2, 2018 at 17:48
• Thanks for the corrections, I should have it updated shortly. It was about 2 this morning when I finished the logic and thought o ya I should add some verbiage. Next time more coffee. Jul 2, 2018 at 18:09

# A Table of Statistics

I have pulled together the below table which lists the probability to hit for both a normal shot (+7 to hit) and a sharpshooter shot (+2 to hit). I have also detailed the expected damage output for both types of shot. For this is have made the following assumptions based on you saying you are a level 2 ranger and based on the numbers you have given.

• Proficiency Bonus: +2
• Dexterity Modifier: +3
• Archery Fighting Style: +2 to attack rolls with ranged weapons
• Weapon: Longbow, dealing 1d8 + 3 damage

Do let me know if these assumptions are incorrect and I will update my table. • For lower AC creatures, the additional damage from the sharpshooter will, on average, outweigh the to-hit penalty.
• For higher AC creatures, this is no longer the case and the more accurate shot is better
• Once a creature leaves your to-hit range (so you will only hit on a natural 20) it makes sense to always take the to-hit penalty since this wont make a difference to your chance to hit

Note: If an enemy is low enough health that a normal attack will probably kill them then it becomes much better to take a normal shot!

• Just to clarify, the "hit chance" column is excluding crits, right? (Hence it never being 95%, only 90% at most.) Aug 8, 2018 at 19:05
• V2Blast, that is correct. The hit chance is for a regular hit only. Aug 9, 2018 at 8:13