4
\$\begingroup\$

In the wonderful anydice program I created a simulation of the rolls and damage of my level 1 Rogue character in 5e DnD against an enemy of AC of 16. My maximum damage should be 25 (6 from sneak attack, 8 from rapier, 6 from shortsword, 5 from dex). It may appear as though I am adding an extra 1d6 but that is the sneak attack that should only activate when I missed my first attack. I have been trying to work this out for the last hour with test cases and all but I can't figure out why the damage is going above 25. I have coded before so I know that sometimes the best solution is fresh eyes.

Here is the anydice code:

\Probability of Damage\
AC: 16
FH: ((1d20 + 7) >= AC)
SH: (1d20 >= AC)
SA: \1d2 - 1\ 1
output  ((FH*(1d6*SA + 1d8 + 5)) + (SH*(1d6 + (FH=0)*1d6*SA)))

If you can find any mistakes that would lead to an inflated damage please answer.

\$\endgroup\$
  • \$\begingroup\$ Check out our formatting help on preformatted text for how to insert code blocks into your posts. I've edited your post to use that formatting. \$\endgroup\$ – doppelgreener Apr 7 '17 at 0:35
  • \$\begingroup\$ You can't use a rapier with a shortsword without the Dual Wielder feat. If you have it, you can use two rapiers. \$\endgroup\$ – András Apr 7 '17 at 7:45
  • \$\begingroup\$ Yeah my DM let me. It's probably because we have a really weak front line. But if I want 2 rapiers I still have to get the feat. \$\endgroup\$ – Vicidsmart Apr 7 '17 at 15:33
7
\$\begingroup\$

This is hard to explain, because it has to do with how Anydice works on a fundamental level. It's easy to show how it doesn't work, though. Replace your output with this:

output FH + FH

The fact that 1 is a possible result here is why your code isn't working the way you want it to. As I said, it's hard to explain why that is. Rather than try to write an explanation myself, possibly giving you all kinds of incorrect notions, I'll pass the buck to this answer on another question, which includes a pretty good explanation of this phenomenon.

It's a lot easier to fix than it is to explain, though!

AC: 16
DEX: 5
PROF: 2
SA: 1d6

function: first A:n second B:n {
  if A + DEX + PROF >= AC & B + DEX + PROF >= AC {result: 1d8 + 1d6 + DEX + SA}
  if A + DEX + PROF >= AC {result: 1d8 + DEX + SA}
  if B + DEX + PROF >= AC {result: 1d6 + SA}
  result: 0
}

output [first d20 second d20]

Link

You'll note that I've added 7 to your second attack as well as your first. This is because I'm assuming you're two-weapon fighting, and while two-weapon fighting doesn't add your Dex mod to the damage of the attack, it still adds it (as well as your proficiency) to the attack roll.

Also, whether you get Sneak Attack isn't a matter of probability, so I've put this in as an extra parameter. You just add the applicable dice for your sneak attack.

| improve this answer | |
\$\endgroup\$
  • 3
    \$\begingroup\$ You should explain as well as fix \$\endgroup\$ – Please stop being evil Apr 7 '17 at 3:43
  • 2
    \$\begingroup\$ That's pretty cool, that actually helps a lot and you also cleaned up the code and made it look pretty. I believe this will help when leveling up as you included proficiency modifier as a variable. This has to be one of the best responses I've ever gotten to like any question in my life. \$\endgroup\$ – Vicidsmart Apr 7 '17 at 3:59
  • 1
    \$\begingroup\$ @Vicidsmart keep asking questions here, then =) Q&A we do well. \$\endgroup\$ – nitsua60 Apr 7 '17 at 4:03
  • 1
    \$\begingroup\$ @Vicidsmart Thanks! That means a lot to me. \$\endgroup\$ – Miniman Apr 7 '17 at 4:04
  • 1
    \$\begingroup\$ @Vicidsmart: He has a couple of typos in the response. Specifically, the example code given still includes the "+ DEX" damage bonus in the case where only the second attack hits (and also the following link just goes to the first example again). Here's a corrected version. \$\endgroup\$ – Carcer Apr 7 '17 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.