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.