4
\$\begingroup\$

I am trying to create a damage percentage study on AnyDice.com for a 5e Rogue using both an Attack and a Bonus Action attack with two different weapons. Most of this is pretty straightforward, in that I can setup both of the weapon attacks and apply the Sneak Attack to either one of these attacks (though it makes the most sense to apply this to the first attack so that it is used). However, there is the MISS case of the first Attack, which means I would definitely want to use (i.e., apply) the Sneak Attack to the Bonus Action attack since it is still available. But I cannot figure out how to apply the Sneak iff the first Attack missed.
I have been using the example functions from AnyDice tutorials for attacks:

function: attack ROLL:n plus BONUS:n vs AC:n hit HIT:d miss MISS:d crit CRIT:d on CRIT_RANGE:n {
    if ROLL = 1 { result: MISS }
    if ROLL >= CRIT_RANGE { result: CRIT }
    if ROLL + BONUS >= AC { result: HIT }
    result: MISS
}
function: attack ROLL:n plus BONUS:n vs AC:n for DMG:d crit CRIT_DMG:d on CRIT_RANGE:n {
    result: [attack ROLL plus BONUS vs AC hit DMG miss 0 crit DMG + CRIT_DMG on CRIT_RANGE]
}

ADVANTAGE: [highest 1 of 2d20]
ABONUS: 2 + 3
SNEAK_ATTACK: 1d6
DBONUS: 3
DAMAGE: 1d8
HITDMG: DAMAGE + DBONUS + SNEAK_ATTACK 
CRITDMG: DAMAGE + SNEAK_ATTACK 
RAPIER_ATTACK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]
 
DAMAGE: 1d6
HITDMG: DAMAGE + DBONUS + SNEAK_ATTACK 
CRITDMG: DAMAGE + SNEAK_ATTACK 
HANDCROSSBOW_ATTACK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]

output RAPIER_ATTACK named "Rapier with Sneak"
output HANDCROSSBOW_ATTACK named "HandCrossbow with Sneak"

Any recommendations on how I can apply the Sneak Attack to the second attack if and only if the first attack (with the rapier) misses? E.g.,

output RAPIER_ATTACK + HANDCROSSBOW_ATTACK named "Rapier & Hand Crossbow using Sneak Attack only once"

Please note that I did see a similar post with an excellent reply by Ilmari Karonen, which I cannot quite make work since the two attacks in my case are not using the same weapon repeatedly.

\$\endgroup\$
2
  • \$\begingroup\$ Does the combined output need to be appended to the existing output (ie., resulting in 3 tables) or can it stand alone (ie., resulting in 1 table)? \$\endgroup\$
    – minnmass
    May 12, 2023 at 20:15
  • \$\begingroup\$ @minnmass, if I am understanding this correctly, I am currently looking to have a stand-alone result (i.e., the combined damage probability for both weapon attacks. In my ideal case, I am hoping I can also incorporate haste; that is, I could specify three attacks where the first and second are the haste'd actions with the primary weapon (e.g., rapier) and the final attack would be the bonus action weapon (e.g., hand crossbow). Thus the table would reflect the combined damage of all the attacks. \$\endgroup\$
    – Buckley
    May 12, 2023 at 20:58

1 Answer 1

4
\$\begingroup\$

This program should do it.

function: attack ROLL:n plus BONUS:n vs AC:n hit HIT:d miss MISS:d crit CRIT:d on CRIT_RANGE:n {
    if ROLL = 1 { result: MISS }
    if ROLL >= CRIT_RANGE { result: CRIT }
    if ROLL + BONUS >= AC { result: HIT }
    result: MISS
}
function: attack ROLL:n plus BONUS:n vs AC:n for DMG:d crit CRIT_DMG:d on CRIT_RANGE:n {
    result: [attack ROLL plus BONUS vs AC hit DMG miss 0 crit DMG + CRIT_DMG on CRIT_RANGE]
}


function: plussneakattack BASE_DAMAGE:n plus SA:d {
 if BASE_DAMAGE = 0 { result: 0 }
 result: BASE_DAMAGE + SA
}

AC: 17
MYCRIT: 20
ADVANTAGE: [highest 1 of 2d20]
ABONUS: 2 + 3
SNEAK_ATTACK: 1d6
DBONUS: 3
DAMAGE: 1d8
HITDMG: DAMAGE + DBONUS
CRITDMG: DAMAGE + SNEAK_ATTACK 
RAPIER_ATTACK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]
RAPIER_SNEAK: [plussneakattack RAPIER_ATTACK plus SNEAK_ATTACK]
 
DAMAGE: 1d6
HITDMG: DAMAGE + DBONUS
CRITDMG: DAMAGE + SNEAK_ATTACK 
HANDCROSSBOW_ATTACK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]
HANDCROSSBOW_SNEAK: [plussneakattack HANDCROSSBOW_ATTACK plus SNEAK_ATTACK]

TOTAL_ATTACK: HANDCROSSBOW_ATTACK + RAPIER_ATTACK
TOTAL_SNEAK: [plussneakattack TOTAL_ATTACK plus SNEAK_ATTACK]

output RAPIER_ATTACK named "Rapier"
output RAPIER_SNEAK named "Rapier with Sneak"
output HANDCROSSBOW_ATTACK named "HandCrossbow"
output HANDCROSSBOW_SNEAK named "HandCrossbow with Sneak"
output TOTAL_ATTACK named "Full Attack Without Sneak"
output TOTAL_SNEAK named "Full Attack with Sneak"

The plussneakattack function takes advantage of the fact that a miss will do 0 damage and a hit will do non-zero damage: if the input damage is 0, it returns 0 back out; if the input damage is non-zero, it adds the sneak attack damaged passed in.

The one caveat as-written is that critting on both the rapier and the crossbow will apply sneak attack a total of three times, since CRITDMG includes sneak attack damage. My understanding is that 5e doesn't work that way, but it'd be easy enough to change CRITDMG if needed.

Any number of attacks (to AnyDice's limits, of course) can be added to TOTAL_ATTACK, then add the plussneakattack call just once at the end to get the "with sneak damage exactly once (plus crits)" for the whole round.


The above works for the question as-asked, which assumes that crits always add sneak attack damage. I don't believe that's correct for 5e RAW, but it may be at some tables.

I believe that this program calculates sneak attack more correctly by pulling it out into a virtual additional attack when determining the round's damage. Again, though, any number of attack can be added together:

function: attack ROLL:n plus BONUS:n vs AC:n hit HIT:d miss MISS:d crit CRIT:d on CRIT_RANGE:n {
    if ROLL = 1 { result: MISS }
    if ROLL >= CRIT_RANGE { result: CRIT }
    if ROLL + BONUS >= AC { result: HIT }
    result: MISS
}
function: attack ROLL:n plus BONUS:n vs AC:n for DMG:d crit CRIT_DMG:d on CRIT_RANGE:n {
    result: [attack ROLL plus BONUS vs AC hit DMG miss 0 crit DMG + CRIT_DMG on CRIT_RANGE]
}


AC: 17
MYCRIT: 20
ADVANTAGE: [highest 1 of 2d20]
ABONUS: 2 + 3
SNEAK_ATTACK: 1d6
DBONUS: 3


DAMAGE: 1d8
HITDMG: DAMAGE + DBONUS
CRITDMG: DAMAGE
RAPIER_ATTACK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]

DAMAGE: 1d8 + SNEAK_ATTACK
HITDMG: DAMAGE + DBONUS
CRITDMG: DAMAGE
RAPIER_SNEAK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]

DAMAGE: 1d6
HITDMG: DAMAGE + DBONUS
CRITDMG: DAMAGE
HANDCROSSBOW_ATTACK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]

DAMAGE: 1d6 + SNEAK_ATTACK
HITDMG: DAMAGE + DBONUS
CRITDMG: DAMAGE
HANDCROSSBOW_SNEAK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]

DAMAGE: SNEAK_ATTACK
HITDMG: DAMAGE
CRITDMG: DAMAGE
ROUND_SNEAK: [attack ADVANTAGE plus ABONUS vs AC for HITDMG crit CRITDMG on MYCRIT]

TOTAL_ATTACK: HANDCROSSBOW_ATTACK + RAPIER_ATTACK
TOTAL_SNEAK: TOTAL_ATTACK + ROUND_SNEAK

output RAPIER_ATTACK named "Rapier"
output RAPIER_SNEAK named "Rapier with Sneak"
output HANDCROSSBOW_ATTACK named "HandCrossbow"
output HANDCROSSBOW_SNEAK named "HandCrossbow with Sneak"
output TOTAL_ATTACK named "Full Attack Without Sneak"
output ROUND_SNEAK named "Round's Sneak Attack"
output TOTAL_SNEAK named "Full Attack with Sneak"
\$\endgroup\$
4
  • \$\begingroup\$ Technically, in 5e,: ``` HITDMG: DAMAGE + DBONUS + SNEAK_ATTACK CRITDMG: DAMAGE + SNEAK_ATTACK ``` I will continue to look at this, but it does seem that the Sneak Attack bonus can be calculated more than once, and this gets even more likely when Elven Accuracy feat is added with it 1@3d20. \$\endgroup\$
    – Buckley
    May 13, 2023 at 12:38
  • 1
    \$\begingroup\$ @Buckley: I think I see what's going on (and have corrected for it). The OP and original code says "when you crit, you also get sneak attack", where RAW says "if you're sneak attacking and happen to crit, you roll sneak attack twice". Elven Accuracy would be easy enough to add either by changing the ADVANTAGE variable or adding a new ELVEN_ACCURACY variable and using that for the relevant attacks. \$\endgroup\$
    – minnmass
    May 13, 2023 at 14:52
  • \$\begingroup\$ This works pretty well, @minnmass, and definitely only computes the sneak attack once. There is a slight inaccuracy if the attack probabilities of the two weapons are different (e.g., one weapon is mundane and the other is a +2); as is, this approach assumes both weapons have the same chance to hit (which is less than norm in most games), and will use the attack stats of the weapon above the sneak setup. My current AnyDice with your sneak breakout is here. Note the damage diff if you move sneak after handcrossbow: changes from 128 to 122 @ level 20. \$\endgroup\$
    – Buckley
    May 13, 2023 at 23:56
  • \$\begingroup\$ @Buckley: that'd be a good answer. In my program, you could largely emulate that by changing ABONUS for the crossbow, though I grant that the total would be off due to the sneak attack addition being incorrect (that could be mitigated by changing ABONUS yet again to the average of the two bonuses - still not perfect due to nat-1s and crits, but close. \$\endgroup\$
    – minnmass
    May 14, 2023 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .