Shadowrun

Shadowrun Play => Character creation and critique => Topic started by: Insaniac99 on <10-15-13/0526:58>

Title: All Purpose Shadowrun Hit chance and Damage probability
Post by: Insaniac99 on <10-15-13/0526:58>
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
   

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:


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]
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: reyjinn on <10-15-13/0612:37>
Very cool :) Is it possible to show what percentage of rolls was over your attack limit?
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Top Dog on <10-15-13/1104:06>
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.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Slippery_Chicken on <10-15-13/1425:56>
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.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: martinchaen on <10-15-13/1435:44>
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.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Crunch on <10-15-13/1440:05>
Where is the defender's limit being used?
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Insaniac99 on <10-15-13/1538:03>
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)
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Crunch on <10-15-13/1543:58>

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?
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Insaniac99 on <10-15-13/1630:27>

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:


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.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Crunch on <10-15-13/1632:13>
That's what I thought. Thanks.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Slippery_Chicken on <10-15-13/1716:50>
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
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Insaniac99 on <10-15-13/1747:12>
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.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Insaniac99 on <10-17-13/0556:19>
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!)
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Kincaid on <10-17-13/1042:46>
This is really fantastic and deserves a sticky.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: martinchaen on <10-17-13/1104:11>
I second the sticky; thanks, Insaniac99!
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Jimmy_Pvish on <11-10-13/1133:55>
Sorry for necropost.

First, I have to thank you a million time for this awesome program.

But, It seem that attacker's limit don't function property.
Attacker's Hits Rolled
Attacker's Hits wasted (over limit)

both are fine.

But other than that are still not use attacker's limit, Net hit calculate with all hit (no limit)

Result with damage calculate are all the same no matter the attacker's limit.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: Insaniac99 on <11-10-13/1639:53>
Sorry for necropost.

First, I have to thank you a million time for this awesome program.

But, It seem that attacker's limit don't function property.
Attacker's Hits Rolled
Attacker's Hits wasted (over limit)

both are fine.

But other than that are still not use attacker's limit, Net hit calculate with all hit (no limit)

Result with damage calculate are all the same no matter the attacker's limit.
Don't worry about the necroing, I was planning on doing it for an extended text calculator that I wasn't able to integrate (takes too long to calculate)

I am on my phone but I will take a look when I can.
Title: Re: All Purpose Shadowrun Hit chance and Damage probability
Post by: raleel on <01-21-14/0844:56>
Necro again! Thanks. This is a great tool. Well done