Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $race = 45; //race exp table percentage
- $class = 250; //class exp table percentage
- $startlevel = 25; //return exp needed starting at this level
- $numlevels = 10; //return this many levels starting from startlevel
- $get_single_level = 0; //override start and numlevel and just return this level
- $exptable = GetExpTable($race, $class, $startlevel, $numlevels, $get_single_level);
- echo '<pre>'.print_r($exptable, true).'</pre>';
- function GetExpTable($racepct, $classpct, $startlevel=1, $numlevels=100, $returnlevel=0) {
- $i = 0; $m1 = 0; $m2 = 0; $iExp = 0; $iE1 = 0; $iE2 = 0; $ret = array();
- $uint = 4294967295;
- if ($returnlevel > 0) { $startlevel = 1; $numlevels = $returnlevel; }
- // Calculate experience
- for ($i = 1; $i <= ($startlevel+$numlevels-1); $i++) {
- if ($i == 1) {
- $iExp = 0;
- } elseif ($i == 2) {
- $iExp = ($racepct + $classpct) * 10;
- } else {
- list($m1, $m2) = GetExpModifiers($i);
- // Method 1
- if ($m1 == 0 || $m2 == 0) {
- $iE1 = 0;
- } else {
- $iE1 = $iExp * $m1;
- $iE1 = floor($iE1 / $m2);
- }
- // Method 2
- $iE2 = floor($iExp / 100);
- if ($i >= 55) {
- $iE2 = $iE2 * 110;
- } else {
- $iE2 = $iE2 * 115;
- }
- // Experience exceed long limit?
- if ($iE2 < floor($uint / 100)) {
- $iExp = $iE1;
- } else {
- $iE2 = floor($iE2 / 100);
- $iE2 = $iE2 * 100;
- $iExp = $iE2;
- }
- }
- if ($returnlevel > 0) {
- if ($returnlevel == $i) {
- $ret[$i] = $iExp;
- }
- } elseif ($i >= $startlevel) {
- $ret[$i] = $iExp;
- }
- }
- return $ret;
- }
- // Returns the experience modifiers for a given level.
- function GetExpModifiers($iLevel) {
- switch ($iLevel) {
- case 3:
- return [40, 20];
- case 4:
- case 5:
- return [44, 24];
- case 6:
- case 7:
- return [48, 28];
- case 8:
- case 9:
- return [52, 32];
- case 10:
- case 11:
- return [56, 36];
- case 12:
- case 13:
- return [60, 40];
- case 14:
- case 15:
- return [65, 45];
- case 16:
- case 17:
- return [70, 50];
- case 18:
- return [75, 55];
- default:
- if ($iLevel <= 26) {
- return [50, 40];
- } else {
- return [23, 20];
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement