View Full Version : Hits to Kill Script
Russt
2008-12-07, 03:26 AM
http://sidequest.awardspace.info/hits.html
Finally figured this out.
You could call this a "calculator", I suppose, but it's very basic. Put in a damage range and it spits out probabilities. If you want to include skills and defense and whatnot, you have to do it yourself first.
Since it (theoretically) doesn't get rid of fractional points of damage, it might return slightly inaccurate results with small damage ranges (max < 50). Otherwise, you should be fine.
Also, it tends to return NaN randomly if you average more than about 40 hits, or max over 100. Most likely because some value or other (there's a factorial and a big exponential in there...) starts overflowing and returning screwy results. Oh well.
No support for crits and slash/stab and whatnot. Perhaps in the future, but that's even harder to figure out than just basic, same damage range over and over. So yeah, don't count on it.
Have fun.
Technolink
2008-12-08, 06:32 PM
Amazing. For crits couldn't you just take your average damage with skills taken into consideration? Or would that make screwy results?
Russt
2008-12-08, 08:31 PM
That wouldn't be exact, but you can still approximate.
Like, if you had 60~100 nocrit, 120~200 crit, 40% rate, your average damage would be 112. But if you just put in 60~200, you'd average 130, so the damage would be off. And if you put in something like 84~140, it would also be off because it'd give you a smaller range than your actual.
Edit: Added multi-hit skills, to some extent.
Shidoshi
2008-12-09, 08:17 PM
well, you can use this calculator basically for sword warriors, crusher/fury dragon knights, pirates and mages \o/ (since they don't have slash/stab or critical)
Awesome! I've often wondered how much my average # of hits to kill a monster would be affected if I, say, wore my +5 str, +8 speed boots instead of my +16 speed boots. Or how much the +5 str from leveling up affects it. Now I can find out. (I'd have to look up how much my advanced combo adds to my damage though.)
:glitter: :glitter: :heart: :heart:
It would be great if this formula was incorporated into a calculator for all of the known MS formulas so that damage range could be easily determined...
Edit: If it's too difficult to work out the math for criticals and such, you could try the simulation approach - simulate, say, 1000 monster kills and use the statistics from that. It would be inexact and you'd get a different answer every time, but it's better than nothing, assuming the number of simulated kills needed to get reasonably good results doesn't take more than a couple seconds to compute.
Russt
2008-12-10, 11:09 PM
I've written a script that returns simulated results before. It was alright, but it's nice to actually have an explicit formula.
Solving crit -may- be more possible than I originally thought. I haven't attempted it, but it should be relatively simple to work out the numbers up to 4 attacks or so. Once I get there it's a matter of whether a visible pattern emerges or not.
singularity
2008-12-11, 11:47 PM
I did something like this for the NL Damage Calculator that banditcom originally made. However, it's still unreleased because there's some issues we need to fix, and we're both extremely lazy to fix them. :f2:
Anyway, here's an excerpt of code from the script I wrote. Note that this is written in VBA (for Excel) because I wrote the script to integrate directly with banditcom's spreadsheet. Below is excerpt of code dealing with hits to kill with TT and TT w/ SE:
' Skips TT calculation if TT value is blank or empty or if Excel would have reached an error calculating factorials
' (Excel errors when trying to calculate 85 factorial or higher.)
Dim CritDam3 As Double
Dim CritChance3 As Double
Dim MinHits3 As Double
Dim MaxHits3 As Double
CritDam3 = CritDam
CritChance3 = CritChance
singlehit = 3 * (Int(TTMax * (TT + CritDam3)) + Int(ShadowDam * Int(TTMax * (TT + CritDam3))))
If singlehit < 6 Then
If Shadow = 1 Then
singlehit = 6
End If
End If
If singlehit < 3 Then
singlehit = 3
End If
MinHits3 = -1 * Int((-1) * (MonHP / singlehit))
If Shadow = 1 Then
MaxHits3 = ActiveSheet.Cells(67, 10)
Else
MaxHits3 = ActiveSheet.Cells(67, 5)
End If
Dim TTArray As Double
Dim TTSEArray As Double
If IsEmpty(ActiveSheet.Range("H22").Value) = True Or TT = 0 Then
TTArray = 0
TTSEArray = 0
End If
If MaxHits3 > 85 Then
TTArray = 0
TTSEArray = 0
Answer = MsgBox("Cannot compute TT Hit Distribution. Max Hits of TT must be 85 or less. Click OK to continue.", vbOKCancel, "TT Calculation Error")
If Answer = vbCancel Then
Exit Sub ' the macro ends if the user selects the CANCEL-button
End If
Else
' Declaration of the Array that holds the TT NHit Percentages
TTArray = 1
Dim NHitArray3() As Double
Dim A3 As Double
Dim B3 As Double
sum = 0
Pc = 0
ReDim NHitArray3(1 To MaxHits3)
For z = 1 To Int(MinHits3 - 1)
NHitArray3(z) = 1
Next z
For h = (MinHits3) To (MaxHits3)
For i = 0 To (3 * h)
' Next two if-statements force Pc to range from 0 to (numer/denom)
A3 = i * (Int(TTMin * (TT + CritDam3)) + Int(ShadowDam * Int(TTMin * (TT + CritDam3)))) + (3 * h - i) * (Int(TTMin * TT) + Int(ShadowDam * Int(TTMin * TT)))
If A3 < 6 * h Then
If Shadow = 1 Then
A3 = 6 * h
End If
End If
If A3 < 3 * h Then
A3 = 3 * h
End If
If A3 < MonHP Then
A3 = A3
Else
A3 = MonHP
End If
B3 = i * (Int(TTMax * (TT + CritDam3)) + Int(ShadowDam * Int(TTMax * (TT + CritDam3)))) + (3 * h - i) * (Int(TTMax * TT) + Int(ShadowDam * Int(TTMax * TT)))
If B3 < 6 * h Then
If Shadow = 1 Then
B3 = 6 * h
End If
End If
If B3 < 3 * h Then
B3 = 3 * h
End If
If B3 > MonHP Then
B3 = B3
Else
B3 = MonHP
End If
numer = fact(3 * h)
denom = (fact(i)) * (fact((3 * h) - i))
If (B3 - A3) = 0 Then
Pc = Pc
Else
Pc = Pc + (numer / denom) * (CritChance3 ^ i) * ((1 - CritChance3) ^ (3 * h - i)) * ((MonHP - A3) / (B3 - A3))
End If
Next i
NHitArray3(h) = Pc
Pc = 0
Next h
' Changes each element of the array to a percentage. Then recalculates each element
' so that each element contains the percentage of KO's in exactly N-hits. Because we
' previously had KO's in at least N-hits stored in each element of the array.
For k = 1 To Int(MaxHits3)
NHitArray3(k) = 100 * NHitArray3(k)
NHitArray3(k) = 100 - NHitArray3(k) - sum
sum = sum + NHitArray3(k)
Next k
' Declaration of the Array that holds the TT+SE NHit Percentages
If IsEmpty(SEDam.Value) = True Or IsEmpty(SEChance.Value) = True Or SEDam.Value = 0 Or SEChance.Value = 0 Or TTArray = 0 Then
TTSEArray = 0
Else
TTSEArray = 1
Dim NHitArray4() As Double
Dim MinHits4 As Double
Dim MaxHits4 As Double
Dim A4 As Double
Dim B4 As Double
Dim CritDam4 As Double
Dim CritChance4 As Double
sum = 0
Pc = 0
CritDam4 = CritDam + ActiveSheet.Cells(29, 8) + 1
CritChance4 = CritChance + ActiveSheet.Cells(30, 8)
If Shadow = 1 Then
MinHits4 = ActiveSheet.Cells(68, 10)
MaxHits4 = ActiveSheet.Cells(67, 10)
Else
MinHits4 = ActiveSheet.Cells(68, 5)
MaxHits4 = ActiveSheet.Cells(67, 5)
End If
ReDim NHitArray4(1 To MaxHits4)
For z = 1 To Int(MinHits4 - 1)
NHitArray4(z) = 1
Next z
For h = (MinHits4) To (MaxHits4)
For i = 0 To (3 * h)
' Next two if-statements force Pc to range from 0 to (numer/denom)
A4 = i * (Int(TTMin * (TT + CritDam4)) + Int(ShadowDam * Int(TTMin * (TT + CritDam4)))) + (3 * h - i) * (Int(TTMin * TT) + Int(ShadowDam * Int(TTMin * TT)))
If A4 < 6 * h Then
If Shadow = 1 Then
A4 = 6 * h
End If
End If
If A4 < 3 * h Then
A4 = 3 * h
End If
If A4 < MonHP Then
A4 = A4
Else
A4 = MonHP
End If
B4 = i * (Int(TTMax * (TT + CritDam4)) + Int(ShadowDam * Int(TTMax * (TT + CritDam4)))) + (3 * h - i) * (Int(TTMax * TT) + Int(ShadowDam * Int(TTMax * TT)))
If B4 < 6 * h Then
If Shadow = 1 Then
B4 = 6 * h
End If
End If
If B4 < 3 * h Then
B4 = 3 * h
End If
If B4 > MonHP Then
B4 = B4
Else
B4 = MonHP
End If
numer = fact(3 * h)
denom = (fact(i)) * (fact((3 * h) - i))
If (B4 - A4) = 0 Then
Pc = Pc
Else
Pc = Pc + (numer / denom) * (CritChance4 ^ i) * ((1 - CritChance4) ^ (3 * h - i)) * ((MonHP - A4) / (B4 - A4))
End If
Next i
NHitArray4(h) = Pc
Pc = 0
Next h
' Changes each element of the array to a percentage. Then recalculates each element
' so that each element contains the percentage of KO's in exactly N-hits. Because we
' previously had KO's in at least N-hits stored in each element of the array.
For k = 1 To Int(MaxHits4)
NHitArray4(k) = 100 * NHitArray4(k)
NHitArray4(k) = 100 - NHitArray4(k) - sum
sum = sum + NHitArray4(k)
Next k
End If
End If
Also, here is a function to calculate a factorial. I found it easier to write the function myself than try to call Excel's factorial function with VBA.
Function fact(number) As Double
fact = 1
For j = 1 To Int(number)
fact = fact * j
Next j
End Function
Hopefully, the variables names I chose to use in the script should be quite evident or easily deducible. Some of the stuff might seem like they're not useful at all, but again.... the above part was an excerpt so it'd find a use outside of the above excerpt. I'll check the thread as often as I can to clear up anything else you may think is confusing.
Oh, and a note about the variable Pc in my script. At first, I calculate the probability of NOT killing for each number of hits in question. Then the line: "NHitArray3(h) = Pc" in each iteration builds an array of these values. With that, it's easy to build the array of probabilities of killing in exactly a certain number of hits -- done by that For function at the end. Kind of a roundabout way of getting the results we want, but it works. :redface: And I thought it was easier to program it in this way. :f3:
Russt
2008-12-13, 03:09 PM
I'm not quite understanding your formula o-o :f4:
singularity
2008-12-14, 05:23 AM
Looks like the formatting of the script wasn't preserved when I posted. Anyway, I'll go ahead and break down the algorithm in my script. Oh, I'll say right now that it would be more accurate if I had used "attacks" instead of "hits" in my code.
My commentary is enclosed in the spoiler below because it is quite long.
I'm just going to explicate the first half of the excerpt. The second half just basically uses the same stuff except with different variable names and has a couple lines to account for SE.
' Skips TT calculation if TT value is blank or empty or if Excel would have reached an error calculating factorials
' (Excel errors when trying to calculate 85 factorial or higher.)
Dim CritDam3 As Double
Dim CritChance3 As Double
Dim MinHits3 As Double
Dim MaxHits3 As Double
CritDam3 = CritDam
CritChance3 = CritChance
singlehit = 3 * (Int(TTMax * (TT + CritDam3)) + Int(ShadowDam * Int(TTMax * (TT + CritDam3))))
If singlehit < 6 Then
If Shadow = 1 Then
singlehit = 6
End If
End If
If singlehit < 3 Then
singlehit = 3
End If
MinHits3 = -1 * Int((-1) * (MonHP / singlehit))
If Shadow = 1 Then
MaxHits3 = ActiveSheet.Cells(67, 10)
Else
MaxHits3 = ActiveSheet.Cells(67, 5)
End IfThis section is to calculate the values for the minimum and maximum number of attacks required to KO. The variable singlehit would be more appropriately named if it read "singleattack." Specifically, I store the maximum possible damage from a single attack in the variable. It is determined by the line: "singlehit = 3 * (Int(TTMax * (TT + CritDam3)) + Int(ShadowDam * Int(TTMax * (TT + CritDam3))))" -- and I account for exceptions in the two if-statements below it.
The Int() function in VBA takes the Floor of the value enclosed in the parentheses. TTMax is a value that can be taken off banditcom's spreadsheet. Essentially, this is the maximum value on the range after having taken WDEF (or MDEF) into account. TT+CritDam3 is just the % multiplier (e.g., 2.5 for maxed triple throw, 2.4 for Level 20 triple throw, etc.).
Anyway, we want to know the maximum number of attacks required to kill so that the script can check when to stop. The minimum number of attacks required to kill is also useful because it can be used to speed up the calculation. In particular, we know that any number of attacks less than the minimum required to kill has a 0% probability to kill, or alternatively, a 100% probability to not kill.
Dim TTArray As Double
Dim TTSEArray As Double
If IsEmpty(ActiveSheet.Range("H22").Value) = True Or TT = 0 Then
TTArray = 0
TTSEArray = 0
End If
If MaxHits3 > 85 Then
TTArray = 0
TTSEArray = 0
Answer = MsgBox("Cannot compute TT Hit Distribution. Max Hits of TT must be 85 or less. Click OK to continue.", vbOKCancel, "TT Calculation Error")
If Answer = vbCancel Then
Exit Sub ' the macro ends if the user selects the CANCEL-button
End If
ElseChecks whether TT skill level is greater than 0. If it is equal to 0, it sets some variables to 0 so that code later on in the script can be skipped.
The test "If MaxHits3 > 85" is very important. Later, we use the binomial coefficient to determine the probabilities so the factorial of the number stored in this variable is needed. Apparently, no errors occur when the value here is 84 or lower (I determined this through trial and error). I think Excel can actually handle up to 170!, but there's a multiplication in the denominator for the binomial coefficient.
Anyway, if the test fails, it prompts the user to say that the calculation will be skipped. The user can then choose "Cancel" to exit the script and fix the problem, or the user can choose "OK" and let the script calculate anything it can (e.g., the script can still try to calculate for Lucky Seven or Avenger).
' Declaration of the Array that holds the TT NHit Percentages
TTArray = 1
Dim NHitArray3() As Double
Dim A3 As Double
Dim B3 As Double
sum = 0
Pc = 0
ReDim NHitArray3(1 To MaxHits3)
For z = 1 To Int(MinHits3 - 1)
NHitArray3(z) = 1
Next zOkay, done with preliminary checks to make sure the calculation can actually be done! Now, for the actual meat of the calculation.
For now, ignore the line "sum = 0." In my earlier post, I explained that the variable "Pc" is the probability that a monster is still alive after so-and-so many attacks. Here, I am just setting their initial values before we perform any calculations.
"ReDim NHitArray3(1 To MaxHits3)" sets the length of the array in which I am going to save all the Pc values to. Then the following For-loop sets the entries in the array corresponding to a number of attacks less than the required to kill to have a value of 1. Again, I use the value '1' because there is 100% probability to not kill for these numbers of attacks.
For h = (MinHits3) To (MaxHits3)
For i = 0 To (3 * h)
' Next two if-statements force Pc to range from 0 to (numer/denom)
A3 = i * (Int(TTMin * (TT + CritDam3)) + Int(ShadowDam * Int(TTMin * (TT + CritDam3)))) + (3 * h - i) * (Int(TTMin * TT) + Int(ShadowDam * Int(TTMin * TT)))
If A3 < 6 * h Then
If Shadow = 1 Then
A3 = 6 * h
End If
End If
If A3 < 3 * h Then
A3 = 3 * h
End If
If A3 < MonHP Then
A3 = A3
Else
A3 = MonHP
End If
B3 = i * (Int(TTMax * (TT + CritDam3)) + Int(ShadowDam * Int(TTMax * (TT + CritDam3)))) + (3 * h - i) * (Int(TTMax * TT) + Int(ShadowDam * Int(TTMax * TT)))
If B3 < 6 * h Then
If Shadow = 1 Then
B3 = 6 * h
End If
End If
If B3 < 3 * h Then
B3 = 3 * h
End If
If B3 > MonHP Then
B3 = B3
Else
B3 = MonHP
End If
numer = fact(3 * h)
denom = (fact(i)) * (fact((3 * h) - i))
If (B3 - A3) = 0 Then
Pc = Pc
Else
Pc = Pc + (numer / denom) * (CritChance3 ^ i) * ((1 - CritChance3) ^ (3 * h - i)) * ((MonHP - A3) / (B3 - A3))
End If
Next i
NHitArray3(h) = Pc
Pc = 0
Next hThe first for-loop basically tells the script for which numbers of attacks that we want to calculate Pc (probability to not kill). So the variable 'h' in each iteration of the loop is the number of attacks. For TT, there is either 0-3 criticals per attack. Thus, we nest a for-loop, and 'i' is the number of criticals for each given 'h', and the value of 'i' can vary from 0 to 3*h.
A3 is the lowest possible damage for a given 'h' and a given 'i', and B3 is the highest possible damage. Notice that A3 and B3 basically calculates the damage for TT given that we know the base range of TT (e.g., TTMin and TTMax) and its multipliers 'TT+CritDam3' when we crit and just 'TT' when we do not crit. 'i' is the number of criticals and '(3 * h - i)' is the number of non-criticals.
Following that are a couple if-statements for both A3 and B3 to account for situations where we would actually hit for just 1 damage on every hit of the attack.
The variable MonHP should be obvious (it holds the value for monster's HP). For now, ignore the if-statements that do tests comparing A3 or B3 vs. MonHP and leave the values alone or change them to equal to MonHP. I'll address these later.
'numer' is the numerical part of the binomial coefficient, and 'denom' is the denominator. Skip down to 'Pc = Pc + (numer / denom)...' This part of the line after the addition operation: '(numer / denom) * (CritChance3 ^ i) * ((1 - CritChance3) ^ (3 * h - i))' is just the binomial distribution in statistics (http://en.wikipedia.org/wiki/Binomial_distribution). '(numer/denom)' is the binomial coefficient. The rest is basically a straight substitution given that:
1) 'CritChance3' is your value for p.
2) 'i' is your value for k.
3) '3*h' is your value for n.
Then the final part: '((MonHP - A3) / (B3 - A3))' is just 'probability to not kill'. Note that without the two if-statements comparing A3 or B3 vs. MonHP, then this would be inaccurate and skew your results. So that whole line after the addition operator basically says to find probability to not kill and give it the appropriate weighting for given values of 'h' and 'i'.
Since the value of 'i' can vary for a given 'h', you can see why the line reads: 'Pc = Pc + (numer / denom)...' instead of simply: 'Pc = (numer / denom)...' They have to be added together to get the correct value of 'Pc' for each given 'h'.
In the if-statement testing whether B3-A3 is zero:
For the true case, I think it might be correct if it instead was: 'Pc = Pc + (numer / denom)'. Truthfully, it's been so long since I originally wrote this script that I've forgotten why I have 'Pc = Pc' in that line. :f7:
Okay, that brings us outside of the nested for-loop. Now the final two lines of the outer for-loop just stores the value of Pc to the array and resets the value of Pc to zero so it is ready to be used in the next iteration.
' Changes each element of the array to a percentage. Then recalculates each element
' so that each element contains the percentage of KO's in exactly N-hits. Because we
' previously had KO's in at least N-hits stored in each element of the array.
For k = 1 To Int(MaxHits3)
NHitArray3(k) = 100 * NHitArray3(k)
NHitArray3(k) = 100 - NHitArray3(k) - sum
sum = sum + NHitArray3(k)
Next kThe first line in this for-loop changes all the values to percentages. The other two lines change the values from 'probability to not kill' to 'probability to kill in exactly N-attacks'. (Again, it would be more appropriate if I had 'N-attacks' in the commented part of the code instead of 'N-hits'.)
Technolink
2008-12-14, 10:28 AM
That wouldn't be exact, but you can still approximate.
Like, if you had 60~100 nocrit, 120~200 crit, 40% rate, your average damage would be 112. But if you just put in 60~200, you'd average 130, so the damage would be off. And if you put in something like 84~140, it would also be off because it'd give you a smaller range than your actual.
Edit: Added multi-hit skills, to some extent.
Yea, adding average crit to your damage on large number of attacks would probably work. Like obviously just attacking once it would be inaccurate, but putting my stats into the calc (with avg crit) it returned a reasonable result for 7-8hit Newts.
Nikkey
2008-12-14, 01:50 PM
Well, with binomial distribution at higher rates, the average hits/mob is about equal to
http://i422.photobucket.com/albums/pp302/DevilsSunrise/maths/dmg.png
where:
M = Monster HP
μ=[Average Slash Damage]×n+ [Average Stab Damage] ×(n-k)
σ= (([Max Slash Damage]×n+[Max Stab Damage]×(n-k) )- ([Min Slash Damage]×n+[Min Stab Damage]×(n-k) ))/6
when np > 10 and n(1-p)>10.
If you know statistics and binomial probability, this shouldn't really surprise you :P
Technolink
2008-12-14, 05:00 PM
Sap, I know you're on the quest to find a perfect formula, but why not brute force it? It'd be so much easier! =P
Nikkey
2008-12-14, 05:28 PM
Sap, I know you're on the quest to find a perfect formula, but why not brute force it? It'd be so much easier! =P
It's possible to brute force it, but meh, lol. Say np and n(1-p) over 30 then. It should give calculations quite exact, barely any difference, I assume.
Then brute force the rest? Happy? :heart:
Technolink
2008-12-17, 10:30 PM
Your browser can brute force quite efficiently. I just made an array of 100k numbers with very little delay (the ok button froze for half a second, then it was fine)
Nikkey
2008-12-18, 12:30 AM
Your browser can brute force quite efficiently. I just made an array of 100k numbers with very little delay (the ok button froze for half a second, then it was fine)
Try to find the mean hkoing for first Horntail head, and you'll see what I mean. :eek:
Technolink
2008-12-18, 03:24 PM
With a for loop to 100000 hits that shouldn't be a problem (once it gets 0% it stops executing, so that wouldn't effect your 8 hit things).
And with that many hits, an average damage would probably do the trick =P
I feel like making on in java now =P
EDIT: Took around 45 minutes. Almost done, but 2x just started >_>
EDIT2: Works like a charm, just trying to remember how to do a scrollable output.
EDIT3: http://www.mediafire.com/?z0ewq534gin
It brute forces the answer, critical and skills included. Its an executable JAR file so you'll need JSE environment to run it (if you have java you should have this). I'll try to get it into an exe, or hosted on the web tomorrow.
Sap, this is great for you to use to double check your formula, but in the mean time this can provide quite accurate results ^^
Russt
2008-12-22, 01:24 AM
Sweet victory!
I got it to work with criticals, play around with it if you like. I also fixed the glitch with the outputs' precision. Stupid me, didn't know toFixed() existed so I was using Math.floor(x*1000)/1000... >_>
And yeah, I know criticals aren't the only thing of this kind, you could also use it for slash/stab etc, but critical is just the most common implementation so yeah.
Hmm, now that I have that down, it wouldn't be too difficult to implement Final Attack as well... nah, not worth it.
@ Mondays
Try to find the mean hkoing for first Horntail head using any method... it's not easy no matter what you do, any formulas will involve summations and factorials that will get very ugly.
With anything above 100 hits, HP/meanhit is usually the quickest way to get a meaningful answer.
Nikkey
2008-12-22, 04:33 AM
@ Mondays
Try to find the mean hkoing for first Horntail head using any method... it's not easy no matter what you do, any formulas will involve summations and factorials that will get very ugly.
With anything above 100 hits, HP/meanhit is usually the quickest way to get a meaningful answer.
Obviously. It's just a matter of precision. First 20 hits should be able through straight binomial, rest should be done with another formula replacing it because the difference between the answers lower. Then finally, use mean.
ZachAttack
2008-12-28, 12:37 AM
Of course this doesn't take in account wdef of monsters - and for something like Windraiders that might matter x_x
Russt
2008-12-28, 12:40 AM
Of course this doesn't take in account wdef of monsters - and for something like Windraiders that might matter x_x
The idea is that you multiply skills and subtract defense yourself :wink:. The formula thread in my sig would help with that.
Or get some other calculator to help you. This could make a good addition to someone else's damage calculator (-prods JoeTang-) but I've no intention of making one myself just to make my page more usable.
ZachAttack
2008-12-28, 12:49 AM
Okay, got it.
Do I do skills before or after subtracting defense?
Like, for Corkscrew for instance, 420% onto my range, then do the max/min defense reduc?
Would it even matter?
Russt
2008-12-28, 12:51 AM
Order of Operations says it all, but subtract defense first.
And tbh it wouldn't work very well for a Brawler because they don't spam skills.
ZachAttack
2008-12-28, 12:52 AM
Okay, I did that.
How come nothing is coming up now?
It says
"Mean:" And then blankness.
I put 16000 for hp
1742 for Min
3401 for max
1 hit per attack
Russt
2008-12-28, 12:58 AM
Hm. I'm getting a result, 6.74 hits on average. It might not work on your browser, I didn't check for that. I'm using Firefox 3.
Critical damage is unchecked, right?
Edit: Works on IE as well, but the mean damage displays in the wrong place. The result is still the same, though.
ZachAttack
2008-12-28, 01:04 AM
I'm on Opera - that's probably why.
And yes, it's unchecked.
Technolink
2008-12-31, 12:35 AM
So what's the formula you ended up using?
I'm quite curious
Russt
2008-12-31, 03:12 PM
Copypasta:
/* probability to deal x or greater damage in n hits with damage range a to b */
function dicecdf(x,a,b,n) {
var result = 0;
var c;
for(k=0;k<=n;k++) {
c = a*(n-k)+b*k;
if(x>=c) result += choose(n,k)*Math.pow(-1,k)*Math.pow(x-c,n);
}
result = 1-result/Math.pow(b-a,n)/factorial(n);
if(result < 0) result = 0;
return result;
}
/* factorial function */
function factorial(x) {
var result = 1;
for(i=1;i<=x;i++) {
result *= i;
}
return result;
}
/* choose function */
function choose(a,b) {
var result = 1;
for(i=1;i<=b;i++) {
result *= (a-i+1)/i;
}
return result;
}
Powered by vBulletin® Version 4.1.10 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.