im trying to get the players hp mana and ac
i think the calculations are all wrong becuase there not coming up the same in the game as they are on my website. i used code from the old magelo clone and the server scorce file client_mods.cpp
her is what im using.
Code:
function getACmod($agility, $level) {
if ($agility >=1 && $agility <=74){
if ($agility == 1)
return -24;
else if ($agility >=2 && $agility <=3)
return -23;
else if ($agility == 4)
return -22;
else if ($agility >=5 && $agility <=6)
return -21;
else if ($agility >=7 && $agility <=8)
return -20;
else if ($agility == 9)
return -19;
else if ($agility >=10 && $agility <=11)
return -18;
else if ($agility == 12)
return -17;
else if ($agility >=13 && $agility <=14)
return -16;
else if ($agility >=15 && $agility <=16)
return -15;
else if ($agility == 17)
return -14;
else if ($agility >=18 && $agility <=19)
return -13;
else if ($agility == 20)
return -12;
else if ($agility >=21 && $agility <=22)
return -11;
else if ($agility >=23 && $agility <=24)
return -10;
else if ($agility == 25)
return -9;
else if ($agility >=26 && $agility <=27)
return -8;
else if ($agility == 28)
return -7;
else if ($agility >=29 && $agility <=30)
return -6;
else if ($agility >=31 && $agility <=32)
return -5;
else if ($agility == 33)
return -4;
else if ($agility >=34 && $agility <=35)
return -3;
else if ($agility == 36)
return -2;
else if ($agility >=37 && $agility <=38)
return -1;
else if ($agility >=39 && $agility <=65)
return 0;
else if ($agility >=66 && $agility <=70)
return 1;
else if ($agility >=71 && $agility <=74)
return 5;
}
else {
if ($agility == 75){
if ($level >= 1 && $level <= 6)
return 9;
else if ($level >= 7 && $level <= 19)
return 23;
else if ($level >= 20 && $level <= 39)
return 33;
else if ($level >= 40)
return 39;
}
else if ($agility >= 76 && $agility <= 79){
if ($level >= 1 && $level <= 6)
return 10;
else if ($level >= 7 && $level <= 19)
return 23;
else if ($level >= 20 && $level <= 39)
return 33;
else if ($level >= 40)
return 40;
}
else if ($agility == 80){
if ($level >= 1 && $level <= 6)
return 11;
else if ($level >= 7 && $level <= 19)
return 24;
else if ($level >= 20 && $level <= 39)
return 34;
else if ($level >= 40)
return 41;
}
else if ($agility >= 81 && $agility <= 85){
if ($level >= 1 && $level <= 6)
return 12;
else if ($level >= 7 && $level <= 19)
return 25;
else if ($level >= 20 && $level <= 39)
return 35;
else if ($level >= 40)
return 42;
}
else if ($agility >= 86 && $agility <= 90){
if ($level >= 1 && $level <= 6)
return 12;
else if ($level >= 7 && $level <= 19)
return 26;
else if ($level >= 20 && $level <= 39)
return 36;
else if ($level >= 40)
return 42;
}
else if ($agility >= 91 && $agility <= 95){
if ($level >= 1 && $level <= 6)
return 13;
else if ($level >= 7 && $level <= 19)
return 26;
else if ($level >= 20 && $level <= 39)
return 36;
else if ($level >= 40)
return 43;
}
else if ($agility >= 96 && $agility <= 99){
if ($level >= 1 && $level <= 6)
return 14;
else if ($level >= 7 && $level <= 19)
return 27;
else if ($level >= 20 && $level <= 39)
return 37;
else if ($level >= 40)
return 44;
}
else if ($agility == 100 && $level >= 7){
if ($level >= 7 && $level <= 19)
return 28;
else if ($level >= 20 && $level <= 39)
return 38;
else if ($level >= 40)
return 45;
}
else if ($level >= 1 && $level <= 6) {
return 15;
}
else if ($agility >= 101 && $agility <= 105){
if ($level >= 7 && $level <= 19)
return 29;
else if ($level >= 20 && $level <= 39)
return 39;// not verified
else if ($level >= 40)
return 45;
}
else if ($agility >= 106 && $agility <= 110){
if ($level >= 7 && $level <= 19)
return 29;
else if ($level >= 20 && $level <= 39)
return 39;// not verified
else if ($level >= 40)
return 46;
}
else if ($agility >= 111 && $agility <= 115){
if ($level >= 7 && $level <= 19)
return 30;
else if ($level >= 20 && $level <= 39)
return 40;// not verified
else if ($level >= 40)
return 47;
}
else if ($agility >= 116 && $agility <= 119){
if ($level >= 7 && $level <= 19)
return 31;
else if ($level >= 20 && $level <= 39)
return 41;
else if ($level >= 40)
return 47;
}
else if ($agility == 120 && $level >= 20){
if ($level >= 20 && $level <= 39)
return 42;
else if ($level >= 40)
return 48;
}
else if ($level >= 7 && $level <= 19) {
return 32;
}
else if ($agility >= 121 && $agility <= 125){
if ($level >= 20 && $level <= 39)
return 42;
else if ($level >= 40)
return 49;
}
else if ($agility >= 126 && $agility <= 135){
if ($level >= 20 && $level <= 39)
return 42;
else if ($level >= 40)
return 50;
}
else if ($agility >= 136){
if ($level >= 20 && $level <= 39)
return 42;
else if ($level >= 40)
return 51;
}
}
}
function getAC($class, $agility, $level, $defense, $itemAC) {
$avoidance = 0;
$avoidance = getACmod($agility, $level) + (($defense * 17) / 9);
if($avoidance < 0) {
$avoidance = 0;
}
$mitigation = 0;
if($class == 'Wizard' || $class == 'Magician' || $class == 'Necromancer' || $class == 'Echanter') {
$mitigation = ($defense / 3) + (($itemAC * 4) / 3);
} else {
$mitigation = ($defense / 2) + ($itemAC + 1);
}
return floor((($avoidance + $mitigation) * 1000) / 800);
}
function LevelFactor($class, $level){
$multiplier = 0;
$mlevel=$level;
switch($class)
{
case '1':{
if ($mlevel < 20)
$multiplier = 220;
else if ($mlevel < 30)
$multiplier = 230;
else if ($mlevel < 40)
$multiplier = 250;
else if ($mlevel < 53)
$multiplier = 270;
else if ($mlevel < 57)
$multiplier = 280;
else if ($mlevel < 60)
$multiplier = 290;
else if ($mlevel < 70)
$multiplier = 300;
else
$multiplier = 311;
break;
}
case '6':
case '2':
case '10':{
if ($mlevel < 70)
$multiplier = 150;
else
$multiplier = 157;
break;
}
case '16':
case '3':
case '5':{
if ($mlevel < 35)
$multiplier = 210;
else if ($mlevel < 45)
$multiplier = 220;
else if ($mlevel < 51)
$multiplier = 230;
else if ($mlevel < 56)
$multiplier = 240;
else if ($mlevel < 60)
$multiplier = 250;
else if ($mlevel < 68)
$multiplier = 260;
else
$multiplier = 270;
break;
}
case '7':
case '8':
case '9':
case '15':{
if ($mlevel < 51)
$multiplier = 180;
else if ($mlevel < 58)
$multiplier = 190;
else if ($mlevel < 70)
$multiplier = 200;
else
$multiplier = 210;
break;
}
case '4':{
if ($mlevel < 58)
$multiplier = 200;
else if ($mlevel < 70)
$multiplier = 210;
else
$multiplier = 220;
break;
}
case '13':
case '12':
case '11':
case '14':{
if ($mlevel < 70)
$multiplier = 120;
else
$multiplier = 127;
break;
}
default:{
if ($mlevel < 35)
$multiplier = 210;
else if ($mlevel < 45)
$multiplier = 220;
else if ($mlevel < 51)
$multiplier = 230;
else if ($mlevel < 56)
$multiplier = 240;
else if ($mlevel < 60)
$multiplier = 250;
else
$multiplier = 260;
break;
}
}
return $multiplier;
}
$lm=LevelFactor($class, $level);
$Post255;
if(($sta-255)/2 > 0){
$Post255 = ($sta-255)/2;
}else{
$Post255 = 0;
}
$hpcal = floor((5)+($level*$lm/10)) + floor(((($sta-Post255)*$level*$lm/3000)));
$hp = MaxHP($hpcal, $itemHP);
$mana = $Profile["mana"];
$mana += $itemMP;
$ac = getAC($class, $agi, $level, $defense, $itemAC);
im also useing code from the wiki at
wiki