NEWS

All Purpose Shadowrun Hit chance and Damage probability

  • 17 Replies
  • 15129 Views

Insaniac99

  • *
  • Omae
  • ***
  • Posts: 450
« on: (05:26:58/10-15-13) »
This started as a way to figure out the most optimal defense combination, and is now a great all-purpose roller to compare skills and limits and how much damage you will take.

You pick any two characters, plug in the 6 or 7 values (only 3-4 if just checking skills) and hit calculate.  you will get you
  • Attacker's Hits Rolled
  • Defender's Hits Rolled
  • chance for Attacker to hit Defender
  • the distribution of net hits (or how much you will miss by)
  • the modified damage of the attack,
  • the chance of each number of hits on your soak roll
  • and the chance of each damage after your soak roll is factored in
   

I'm not sure what forum is the proper location for this, but I hope everyone finds it useful, please let me know how you like or of any bugs or issues you find and I'll correct them.

EDIT: New Version:
Version 1.2
Changes:
  • numerous optimizations (now easily handles over 30 dice in rolls; specifically tested it with 40 and used exploding 6s)
  • ability to enter armor penetration
    • armor penetration is normally entered as a negative number
    • if AP is more than armor, no armor is rolled
    • if there is no armor in the first place, only Body is every rolled (I believe this is the proper interaction with flechette ammo and no armor, please let me knwo if incorrect)
  • Ability for Edge! This will ignore the attacker's limit and do exploding sixes  must use all caps for TRUE/FALSE
  • Tells you your chance of rolling hits over your limit (by amounts of hits lost)


http://anydice.com/program/2be4
[spoiler]
Code: [Select]
\
Shadowrun Fifth Edition
To Hit Chance and
Damage Probability Calculator Version 1.2
By Insaniac99, modified from code by Slippery_Chicken
\

FALSE:0
TRUE:1
\ Attacker Diepool \   A: 19
\ Use Edge? \   E: FALSE \ (Explode dice & remove limit) FALSE/TRUE\
\Weapon Damage Value\  V: 8
\Weapon Limit\        AL: 7
\armor penetration\   AP: -1

\ Defender Diepool \   D: 15
\ Defender Limit \    DL: 15
\ Defender's Body \   DB: 3
\ Defender's Armor\   DA: 12

function: explode N:n {
 if N = 6 { result: 1 + [explode d6] }
 result: N = 5
}

function: limit HITS:n by LIMIT:n{
 if HITS > LIMIT {result: LIMIT}
 result: HITS
}

function: hitslost HITS:n by LIMIT:n{
 if HITS > LIMIT {result: (HITS-LIMIT)}
 result: 0
}

function: calculatedamage DAMAGE:n plus NETHITS:n {
 if NETHITS < 1 { result: 0 }
 result: DAMAGE + NETHITS
}

function: rollsoak body BODY:n armor ARMOR:n armpen ARMPEN:n {
 if ARMOR = 0 { result: (BODYd(d6>4)) }
 TA: ARMOR + ARMPEN
 if TA<0 { result: BODYd(d6>4)}
 result: (BODYd(d6>4) + TAd(d6>4))
}

function: resistdamage DAMAGE:n minus SOAK:n {
 if (DAMAGE < 1) {
  result: 0
 }
 if (DAMAGE - SOAK) < 1 {
  result: 0
 }
 result: DAMAGE - SOAK
}

\Attacker's Roll Result\
AR:0
if E {
AR: Ad[explode d6]
\Attacker's roll with Limit\ ARL: AR
AOL: 0
} else {
AR: Ad(d6 > 4)
\Attacker's roll with Limit\ARL: [limit AR by AL]
AOL: [hitslost AR by AL]
}




\Defender's Roll Result\ DR: [limit Dd(d6 > 4) by DL]
\Attacker Net Hits\       X: AR - DR
\Damage to Soak \        SD: [calculatedamage V plus X]
\Soak Roll Result \      SR: [rollsoak body DB armor DA armpen AP]
\unsoaked damage \       US: [resistdamage SD minus SR]

output ARL named "Attacker's Hits Rolled"
output AOL named "Attacker's Hits wasted (over limit)"
output DR  named "Defender's Hits Rolled"
output X>0 named "Attacker's chance to hit"
output X   named "Attacker's net hits"
output SD  named "Damage before Soak Roll"
output SR  named "Hits on soak test"
output US  named "Damage after Soak Roll"
[/spoiler]

OLD Versions: 1.0
http://anydice.com/program/2baf

[spoiler]
Code: [Select]
\
Shadowrun Fifth Edition
To Hit Chance and
Damage Probability Calculator
By Insaniac99, modified from code by Slippery_Chicken
\

\ Attacker Diepool \   A: 3
\Weapon Damage Value\  V: 3
\Weapon Limit\        AL: 3

\ Defender Diepool \   D: 3
\ Defender Limit \    DL: 3
\ Defender's Body \   DB: 3
\ Defender's Armor\   DA: 3

function: shadowrunfive DICE:s{
   COUNT: 0
 loop P over {1..6} {
  COUNT: COUNT + (P@{5,6} = DICE)
 }
 result: COUNT
}

function: limit DICE:s by LIMIT:n{
   COUNT: 0
 loop P over {1..6} {
  COUNT: COUNT + (P@{5,6} = DICE)
 }
 if COUNT > LIMIT {result: LIMIT}
 result: COUNT
}

function: calculatedamage DAMAGE:n plus NETHITS:s {
 if NETHITS < 1 { result: 0 }
 result: DAMAGE + NETHITS
}

function: resistdamage DAMAGE:s minus SOAK:s {
 if DAMAGE < 1 { result: 0 }
 if (DAMAGE - SOAK) < 1 {result: 0}
 result: DAMAGE - SOAK
}

\Attacker's Roll Result\ AR: [limit Ad6 by AL]
\Defender's Roll Result\ DR: [limit Dd6 by DL]
\Attacker Net Hits\       X: AR - DR
\Damage to Soak \        SD: [calculatedamage V plus X]
\Soak Roll Result \      SR: [shadowrunfive DBd6]+ [shadowrunfive DAd6]
\unsoaked damage \       US: [resistdamage SD minus SR]

output AR  named "Attacker's Hits Rolled"
output DR  named "Defender's Hits Rolled"
output X>0 named "Attacker's chance to hit"
output X   named "Attacker's net hits"
output SD  named "Damage before Soak Roll"
output SR  named "Hits on soak test"
output US  named "Damage after Soak Roll"
[/spoiler]
« Last Edit: (05:54:49/10-17-13) by Insaniac99 »
Check out my all purpose Shadowrun Die roller and Probability generator: http://forums.shadowruntabletop.com/index.php?topic=13241.0

reyjinn

  • *
  • Omae
  • ***
  • Posts: 641
« Reply #1 on: (06:12:37/10-15-13) »
Very cool :) Is it possible to show what percentage of rolls was over your attack limit?
[Time&Date|Place|Area] "Dialogue" "Non-English" >>Matrix/"Commlink" "Astral" <<Text&email>> Internal&"subvocal"

Top Dog

  • *
  • Ace Runner
  • ****
  • Posts: 1219
« Reply #2 on: (11:04:06/10-15-13) »
Very nice indeed! Only thing I'm missing is AP, but that can be done manually too.

Reylinn, I don't think this is really the script for this (it's more complex then you need for that), but you can manually put the limit on 1 higher then your attack limit and then see what percentage you get for that amount of net hits. It'd require you to roll it separately for that, though.

Slippery_Chicken

  • *
  • Chummer
  • **
  • Posts: 113
« Reply #3 on: (14:25:56/10-15-13) »
I'm partly here to thank you for giving me credit (Thanks! ;D), partly to offer advice.

Only thing I'm missing is AP, but that can be done manually too.

We'll want to make a new variable for Armor Piercing, which will likely modify the Armor Value, but write somewhere that it can't bring AV below zero (or some logical statement like "if AV-AP is less than 1, then AV is zero").

Very cool :) Is it possible to show what percentage of rolls was over your attack limit?


Here's how I'd program it*, since I'm not quite as good at anydice coding as Insaniac99:

*(normally I'd just look at the distribution in "at least" view and see what percent are "at least" the limit plus one)
Quote
\Attack Diepool\A: 15
\Attack Limit\L: 5
\Attack Roll\ R: [count {5,6} in Ad6]

output R named "Attack Roll"

output R>L named "Percent of rolls over limit (1=over, 0=under)"

Is it just me or does it have issues calculating high dice pools? I get timeouts when trying to roll 20 to hit dice vs high armor targets.

Yeah, Anydice does have issues with big numbers of dice. For example, it rounds probabilities less than 0.01 down to zero, and it does have timeouts.
« Last Edit: (14:38:21/10-15-13) by Slippery_Chicken »

martinchaen

  • *
  • Guest
« Reply #4 on: (14:35:44/10-15-13) »
Is it just me or does it have issues calculating high dice pools? I get timeouts when trying to roll 20 to hit dice vs high armor targets.

Crunch

  • *
  • Ace Runner
  • ****
  • Posts: 2268
« Reply #5 on: (14:40:05/10-15-13) »
Where is the defender's limit being used?

Insaniac99

  • *
  • Omae
  • ***
  • Posts: 450
« Reply #6 on: (15:38:03/10-15-13) »
Very cool :) Is it possible to show what percentage of rolls was over your attack limit?

Not as written. when I have time, I will add a function for it. heh just did a riff off of what Slippery_Chicken wrote, new link: http://anydice.com/program/2bbd

on thinking, I'll want to change that to a new function, so it actually tells you how many hits past the limit you are rolling each time.  I know how I'll do it.  I'll just do it later after I get my real work done.

Very nice indeed! Only thing I'm missing is AP, but that can be done manually too.

AP would be nice, I'll factor that in when I have the chance (I'm trying to get work done right now but I wanted to see how people liked it :))

Is it just me or does it have issues calculating high dice pools? I get timeouts when trying to roll 20 to hit dice vs high armor targets.

Yes it does.  It also can't handle exploding 6s without choking when only rolling 14d6.  I asked the developer if he has an offline version and am waiting for a reply and I might make a Java version when I get a big chunk of free time, but I dislike doing graphics and it will be a lot more time intensive so it would be a while before I get to that.

Where is the defender's limit being used?

It is the dodge roll (Defender's diepool) that is limited.  this is for factoring in Parry and Dodge which introduce a limit to the roll.  the Soak roll is never limited (which is how it works if I understand RAW correctly). 

I'm partly here to thank you for giving me credit (Thanks! ;D), partly to offer advice.
Hey thanks for laying the groundwork and giving me the motivation to do it.  I've never used anydice beyond simple stuff before.

Here's how I'd program it*, since I'm not quite as good at anydice coding as Insaniac99:
Thanks again. I'm a software engineer IRL and like doing small coding projects.  Figuring out how to program in anydice was a fun diversion last night (when I should have been working ;D)
« Last Edit: (15:46:08/10-15-13) by Insaniac99 »
Check out my all purpose Shadowrun Die roller and Probability generator: http://forums.shadowruntabletop.com/index.php?topic=13241.0

Crunch

  • *
  • Ace Runner
  • ****
  • Posts: 2268
« Reply #7 on: (15:43:58/10-15-13) »

It is the dodge roll (Defender's diepool) that is limited.  this is for factoring in Parry and Dodge which introduce a limit to the roll.  the Soak roll is never limited (which is how it works if I understand RAW correctly). 

That's correct, I was just wondering if the program is using the limit for any roll in which a limit is entered?

Insaniac99

  • *
  • Omae
  • ***
  • Posts: 450
« Reply #8 on: (16:30:27/10-15-13) »

It is the dodge roll (Defender's diepool) that is limited.  this is for factoring in Parry and Dodge which introduce a limit to the roll.  the Soak roll is never limited (which is how it works if I understand RAW correctly). 

That's correct, I was just wondering if the program is using the limit for any roll in which a limit is entered?

The limit is factored in anytime the Defense rolls.  The way the program calculates the hits for both attacking and defending is this:

  • it rolls X dice and stores them as a sequence of numbers (so 7d6 gets rolled and is stored as [6, 1, 3, 6, 2, 4, 5 ])
  • it counts the 5s and 6s and stores it as an integer (in this example 3)
  • it compares that number to the limit,
    • Under the limit is just reports the number,
    • over the limit it reports the limit
  • This is then rolled hundreds of times to get the averages.

the best thing to do is to set limit equal or higher than the diepool anytime you don't actually wan a limit.

does that answer properly?  I always feel that I am going way past what the person is asking and/or not going nearly far enough in my explanation.
Check out my all purpose Shadowrun Die roller and Probability generator: http://forums.shadowruntabletop.com/index.php?topic=13241.0

Crunch

  • *
  • Ace Runner
  • ****
  • Posts: 2268
« Reply #9 on: (16:32:13/10-15-13) »
That's what I thought. Thanks.

Slippery_Chicken

  • *
  • Chummer
  • **
  • Posts: 113
« Reply #10 on: (17:16:50/10-15-13) »
the best thing to do is to set limit equal or higher than the diepool anytime you don't actually wan a limit.

I tried putting in a variable LI which asks whether to use limits (currently a number because I don't remember how to do boolean), then I modified the "limit" function to check for it.


Quote
function: limit DICE:s by LIMIT:n{
   COUNT: 0
 loop P over {1..6} {
  COUNT: COUNT + (P@{5,6} = DICE)
 }
if LI=0 {result: COUNT}
 if COUNT > LIMIT {result: LIMIT}
 result: COUNT
}

That function applies to both attack and defense limits, so perhaps using separate functions for attack and defense limits might be in order? Granted, there might be a more efficient way to separate the limits.

We could have it so that instead of checking a new "do you want to use limits?" variable, it could check the limit number (AL and DL) and then say something like "if AL=0 {result: COUNT}". Then just tell the user to input 0 for "limit" when he/she doesn't want to use that limit.

Thanks again. I'm a software engineer IRL and like doing small coding projects.  Figuring out how to program in anydice was a fun diversion last night (when I should have been working ;D)

Awesome. I'm actually a business major, and don't have much programming experience outside basic HTML, JS, and Excel for a class. I do enjoy doing this kind of thing to make my life easier in RPGs (like making an Excel sheet which generates all of a summoned spirit's stats based on a Force value entered by the user). I should probably be working too though :P

Insaniac99

  • *
  • Omae
  • ***
  • Posts: 450
« Reply #11 on: (17:47:12/10-15-13) »
the best thing to do is to set limit equal or higher than the diepool anytime you don't actually wan a limit.

I tried putting in a variable LI which asks whether to use limits (currently a number because I don't remember how to do boolean), then I modified the "limit" function to check for it.


Quote
function: limit DICE:s by LIMIT:n{
   COUNT: 0
 loop P over {1..6} {
  COUNT: COUNT + (P@{5,6} = DICE)
 }
if LI=0 {result: COUNT}
 if COUNT > LIMIT {result: LIMIT}
 result: COUNT
}

That function applies to both attack and defense limits, so perhaps using separate functions for attack and defense limits might be in order? Granted, there might be a more efficient way to separate the limits.

We could have it so that instead of checking a new "do you want to use limits?" variable, it could check the limit number (AL and DL) and then say something like "if AL=0 {result: COUNT}". Then just tell the user to input 0 for "limit" when he/she doesn't want to use that limit.

Thanks again. I'm a software engineer IRL and like doing small coding projects.  Figuring out how to program in anydice was a fun diversion last night (when I should have been working ;D)

Awesome. I'm actually a business major, and don't have much programming experience outside basic HTML, JS, and Excel for a class. I do enjoy doing this kind of thing to make my life easier in RPGs (like making an Excel sheet which generates all of a summoned spirit's stats based on a Force value entered by the user). I should probably be working too though :P

I think coding something to check for a non-existent limit (either by magic number or a boolean) is an extra coding time, without benefitting the user.  Telling the user to set the limit to 0 is no different than telling the user to set the limit to the diepool.

If others want that, it is easy enough to put it in, but I figured time on the armor penetration (which is important IMO) would be the next place to spend time.  Or making a Java version.

back to work I go.
Check out my all purpose Shadowrun Die roller and Probability generator: http://forums.shadowruntabletop.com/index.php?topic=13241.0

Insaniac99

  • *
  • Omae
  • ***
  • Posts: 450
« Reply #12 on: (05:56:19/10-17-13) »
I updated this! Lots of new features. I optimized it so it handles lots of dice really well, I specifically tested 40 dice with exploding 6s (oh, did I not mention that yet? I have Edge working!)
Check out my all purpose Shadowrun Die roller and Probability generator: http://forums.shadowruntabletop.com/index.php?topic=13241.0

Kincaid

  • *
  • Freelancer
  • Prime Runner
  • ***
  • Posts: 2623
« Reply #13 on: (10:42:46/10-17-13) »
This is really fantastic and deserves a sticky.
Killing so many sacred cows, I'm banned from India.

martinchaen

  • *
  • Guest
« Reply #14 on: (11:04:11/10-17-13) »
I second the sticky; thanks, Insaniac99!