Originally posted by KyrosKrane

PrecapRate + ((1-PrecapRate)*0.5) = 1-((1-PrecapRate)*0.5)
PrecapRate + .5 - .5*PrecapRate = 1-.5 + .5*PrecapRate
.5*PrecapRate + .5 = .5 + .5*PrecapRate
Function SuccessRate(Trivial As Integer, RawSkill As Integer, Optional Modifier As Integer = 0, Optional Mastery As Integer = 0) As Double 'Expected Inputs: 'Trivial: Integer greater than or equal to zero 'RawSkill: Integer in the range of 0 to 300 'Modifier: Integer greater than or equal to zero. 5 indicates 5%, etc. This is optional; you may choose to not include it. The default value is no modifier. However, you must include it if you use mastery. 'Mastery: Integer from 0 to 3, inclusive. 0 = no mastery, 1 = Crafting Mastery 1, etc. This is optional; you may choose to not include it. The default value is no mastery. 'Returns: The predicted average success rate for a given combine, as a Double between 0 and 1, inclusive. Multiply by 100 to get the percentage as a number between 0 and 100. 'If invalid arguments are supplied, the function returns -1. 'Error Checking If Trivial < 0 Or RawSkill < 0 Or RawSkill > 300 Or Modifier < 0 Or Mastery < 0 Or Mastery > 3 Then SuccessRate = -1 Exit Function End If 'Combines with trivial 16 or less always succeed: If Trivial <= 15 Then SuccessRate = 1 Exit Function End If 'The skill modified by a geerlok or similar Dim ModifiedSkill As Double 'The base chance of success, before caps are applied Dim PrecapRate As Double 'The maximum chance to succeed a combine -- this is calcuated Dim UpperCap As Double 'The minimum chance to succeed is fixed Const LowerCap = 0.05 'Calculate modified skill to account for geerloks or similar ModifiedSkill = Int(RawSkill * (Modifier / 100 + 1)) 'Calculate the chance of success before the upper and lower caps are applied If Trivial < 68 Then PrecapRate = (ModifiedSkill - Trivial + 66) / 100 Else PrecapRate = (ModifiedSkill - 0.75 * Trivial + 51.5) / 100 End If 'Apply mastery if appropriate If RawSkill <> 0 Then Select Case Mastery Case 1 'Mastery 1 reduces the chance to fail by 10% PrecapRate = PrecapRate + ((1 - PrecapRate) * 0.1) Case 2 'Mastery 2 reduces the chance to fail by 25% PrecapRate = PrecapRate + ((1 - PrecapRate) * 0.25) Case 3 'Mastery 3 reduces the chance to fail by 50% PrecapRate = PrecapRate + ((1 - PrecapRate) * 0.5) End Select End If 'Calculate the upper cap for the chance of success If RawSkill >= Trivial + 40 Then 'Apply check for very trivial combines; it can reduce the chance to fail slightly UpperCap = 0.95 + (Int((RawSkill - Trivial) / 40)) / 100 'Chance to succeed can never exceed 100%, so check to make sure we never get above that If UpperCap > 1 Then UpperCap = 1 Else UpperCap = 0.95 End If 'Apply upper and lower caps, and return the appropriate result If PrecapRate > UpperCap Then SuccessRate = UpperCap ElseIf PrecapRate < LowerCap Then SuccessRate = LowerCap Else SuccessRate = PrecapRate End If End Function
![]() Ngreth nice Ogre. Ngreth not eat you. Well.... Ngreth not eat you if you still wiggle! Grandmaster Smith 250 Master Tailor 200 Ogres not dumb - we not lose entire city to froggies |
/*************************************************************************** // Make sure all data sent to the sheet is within allowable parameters // // skill: from 0 to 300 inclusive // prime: Prime Stat no lower than 0 (curently no cap set since this bar keeps moving). Form limits to 999 // trivial: no lower than 0. No max set since no max has been indicated. Form limits to 999 // mod: tradeskill mod limited from 0 to 100 inclusive. */ if ($data) { if ($data['skill'] < 1) $data['skill'] = '0'; if ($data['skill'] > 300) $data['skill'] = 300; if ($data['prime'] < 1) $data['prime'] = '0'; //if ($data['prime'] > 405) $data['prime'] = 405; if ($data['trivial'] < 1) $data['trivial'] = '0'; if ($data['mod'] < 1) $data['mod'] = '0'; if ($data['mod'] > 100) $data['mod'] = 100; } /*************************************************************************** // HTML form display bellow */?> HTML cut out here... <?php /*************************************************************************** // // If data is set. start the table below the HTML form */ if (isset($data)) { print "<table cellpadding=\"2\" hspace=\"10\" bordercolor=\"#400000\" border=\"2\" cellspacing=\"0\"> <tr bgcolor=\"#E3E4D3\"><td>"; //set a modified skill value $skill = floor($data['skill']*(100+$data['mod'])/100); //run the base success formula as decided by the community if ($data['trivial'] < 68) { $success = $skill - $data['trivial'] + 66; } else { $success = ($skill-($data['trivial'] * 0.75)) + 51.5; } // If skill is 0, ignore tradeskill AA // if skill is greater, calculate the fail modifier to success, and increment success by that. if ($data['skill'] > 0) { $fail = 100-$success; $fail = $aa*$fail/100; $success += $fail; } //cap success if ($success < 5) $success = 5; if ($success > 95) $success = 95; //as skill gets greater than trivial, in steps of 40, reduce the chance to fail further. //this could probably be done formulaicly instead of conditionally if ($data['skill'] > $data['trivial']) { if (($data['skill']-$data['trivial']) >= 200) { $success = 100; } else if (($data['skill']-$data['trivial']) >= 160) { $success = 100 - ((100-$success)*(.20)); } else if (($data['skill']-$data['trivial']) >= 120) { $success = 100 - ((100-$success)*(.40)); } else if (($data['skill']-$data['trivial']) >= 80) { $success = 100 - ((100-$success)*(.60)); } else if (($data['skill']-$data['trivial']) >= 40) { $success = 100 - ((100-$success)*(.80)); } } //display the new calculated data print "Ajusted Skill = $skill<br>"; print "Success chance = $success%<br>"; /*************************************************************************** // calculate the success chances. Sorry about the nonsense variable names, I was making them for the original formulas // from soe. // Also $si is an array for easy future changes when all data for tradeskill dificulties are in and I make a dropdown // with the apropriate data. // // $s = stat // $si[0] = tradeskill dificulty // $si[1] = is the flag (1|0) for if there is an alternate stat // $second = second check. Used to signify the chance for skillup on the second pass. // n is used to signify the chance of skillup on first pass // $nf = n for failed combine. (n was used in original formula given by SOE.) N is the FIRST check. // $ns = n for success. (again, this is the first check) // $suf = skillup chance on a failed combine. // $sus = skillup chance on a combine that succeded. // $sut = overall chance of skillup // */ if (($data['trivial'] > $data['skill']) and ($data['skill'] < 300)) { // standby code for if I implement the dropdown //$si=split('-',$data['trade']); // if the stat used is for a tradeskill that has an alternate stat, leave the stat as is // otherwise, reduce the stat by 15. It cannot be less than 0. if ($si[1]) { $s = $data['prime']; } else { $s = $data['prime']-15; } if ($s < 0) $s=0; // calculate the chance of skillup from pass one. // note that there is half the chance if the combine was a fialure // cap both at 100 $nf = ($s*10)/($si[0]*2)/10; $ns = ($s*10)/$si[0]/10; if ($ns > 100) $ns = 100; if ($nf > 100) $nf = 100; // calculate the chance of skillup from pass two. // // if BASE skill is less than or equal to 15, pass two is 100% // or do the new formula is the base skill is greater than 175 // else, the skill is between 15 and 176, use the old formula // if ($data['skill'] <= 15) { $second = 1; } else if ($data['skill'] > 175) { $second = (12.5-((10/125.0)*($data['skill']-175)))/100; } else { $second = (200-$data['skill'])/200; } // round the two chances, and make a total chance. $suf = round($nf*$second,2); $sus = round($ns*$second,2); $sut = round((($sus*$success/100) + ($suf*(100-$success)/100)),2); } else { // if base skill is higher than the trivial, or base skill is 300 (or more) there is no chance of skillup. $sus = 0; $suf = 0; $sut = 0; } print "Chance of skill up on Success: $sus%, on failure: $suf%, <strong>overall $sut%</strong>"; print "</td></tr></table>"; } ?>
![]() Ngreth nice Ogre. Ngreth not eat you. Well.... Ngreth not eat you if you still wiggle! Grandmaster Smith 250 Master Tailor 200 Ogres not dumb - we not lose entire city to froggies |
//as skill gets greater than trivial, in steps of 40, reduce the chance to fail further. //this could probably be done formulaicly instead of conditionally if ($data['skill'] > $data['trivial']) { if (($data['skill']-$data['trivial']) >= 200) { $success = 100; } else if (($data['skill']-$data['trivial']) >= 160) { $success = 100 - ((100-$success)*(.20)); } else if (($data['skill']-$data['trivial']) >= 120) { $success = 100 - ((100-$success)*(.40)); } else if (($data['skill']-$data['trivial']) >= 80) { $success = 100 - ((100-$success)*(.60)); } else if (($data['skill']-$data['trivial']) >= 40) { $success = 100 - ((100-$success)*(.80)); } }
//as skill gets greater than trivial, in steps of 40, reduce the chance to fail further. if ($data['skill'] >= $data['trivial'] + 40) { $success = 95 + floor(($data['skill'] - $data['trivial']) / 40); }
![]() | Master Artisan Xulan Du'Traix Dark Elven Scourge Knight Sanctus Arcanum Drinal My Tradeskill Services |
![]() | Master Artisan Xulan Du'Traix Dark Elven Scourge Knight Sanctus Arcanum Drinal My Tradeskill Services |
Tradeskill AA: no<input type="radio" name="aa" value="0"<?php if ($aa <= 9) print " checked";?>> 1<input type="radio" name="aa" value="10"<?php if ($aa == 10) print " checked";?>> 2<input type="radio" name="aa" value="25"<?php if ($aa == 25) print " checked";?>> 3<input type="radio" name="aa" value="50"<?php if ($aa == 50) print " checked";?>>
//as skill gets greater than trivial, in steps of 40, reduce the chance to fail further. //this could probably be done formulaicly instead of conditionally if ($data['skill'] > $data['trivial']) { if (($data['skill']-$data['trivial']) >= 200) { $success = 100; } else if (($data['skill']-$data['trivial']) >= 160) { $success = 100 - ((100-$success)*(.20)); } else if (($data['skill']-$data['trivial']) >= 120) { $success = 100 - ((100-$success)*(.40)); } else if (($data['skill']-$data['trivial']) >= 80) { $success = 100 - ((100-$success)*(.60)); } else if (($data['skill']-$data['trivial']) >= 40) { $success = 100 - ((100-$success)*(.80)); } }
//as skill gets greater than trivial, in steps of 40, reduce the chance to fail further. if ($data['skill'] >= $data['trivial'] + 40) { $success = 95 + floor(($data['skill'] - $data['trivial']) / 40); }
![]() Ngreth nice Ogre. Ngreth not eat you. Well.... Ngreth not eat you if you still wiggle! Grandmaster Smith 250 Master Tailor 200 Ogres not dumb - we not lose entire city to froggies |
![]() Ngreth nice Ogre. Ngreth not eat you. Well.... Ngreth not eat you if you still wiggle! Grandmaster Smith 250 Master Tailor 200 Ogres not dumb - we not lose entire city to froggies |
![]() Ngreth nice Ogre. Ngreth not eat you. Well.... Ngreth not eat you if you still wiggle! Grandmaster Smith 250 Master Tailor 200 Ogres not dumb - we not lose entire city to froggies |
Comment