// Function - calcDamage($array, $array, $array, $array, $int, $int) function calcDamage($myDamage, $myInnates, $myArmorIgnore, $myArmorProtect, $myCurEnergy, $myMaxEnergy) { $currentDamage = 0; $energyPercent = 0; $currentEnergy = $myCurEnergy; $theResult = array(); $damage = (array)$myDamage; $innate = (array)$myInnates; $armorIgnore = (array)$myArmorIgnore; $armorProtect = (array)$myArmorProtect; foreach( $damage as $index => $val ) { $currentDamage = $val; $currentDamage *= modVal($innate["$index"]); if( $index == "ene" ) { for($i = 0; $i < 6; $i++) { $currentDamage = ($currentDamage - $armorIgnore[$i]["$index"]) * modVal($armorProtect[$i]["$index"]); if( $currentDamage < 0 ) { $currentDamage = 0; } } $currentEnergy -= $currentDamage; if( $currentEnergy < 0 ) { $currentEnergy = 0; } $energyPercent = $currentEnergy / $myMaxEnergy; /*echo "";*/ } else { $currentDamage *= (1-$energyPercent); for($i = 0; $i < 6; $i++) { /*$temp1 = $armorIgnore[$i]["$index"]; $temp2 = modVal($armorProtect[$i]["$index"]); echo "";*/ $currentDamage = ($currentDamage - $armorIgnore[$i]["$index"]) * modVal($armorProtect[$i]["$index"]); if( $currentDamage < 0 ) { $currentDamage = 0; } } } $theResult["$index"] = $currentDamage; } return $theResult; } // Get passed vars $curEnergy = $_POST["curEnergy"]; $maxEnergy = $_POST["maxEnergy"]; $powerCell = $_POST["powerCell"]; $weaponPreset = $_POST["weaponPreset"]; $preset1 = $_POST["preset1"]; $preset2 = $_POST["preset2"]; $preset3 = $_POST["preset3"]; $preset4 = $_POST["preset4"]; $preset5 = $_POST["preset5"]; $preset6 = $_POST["preset6"]; $fieldOrder1 = $_POST["fieldOrder1"]; $fieldOrder2 = $_POST["fieldOrder2"]; $fieldOrder3 = $_POST["fieldOrder3"]; $fieldOrder4 = $_POST["fieldOrder4"]; $fieldOrder5 = $_POST["fieldOrder5"]; $fieldOrder6 = $_POST["fieldOrder6"]; $classInnate = $_POST["classInnate"]; $kinDamInner = $_POST["kinDamInner"]; $kinDamOuter = $_POST["kinDamOuter"]; $expDamInner = $_POST["expDamInner"]; $expDamOuter = $_POST["expDamOuter"]; $plaDamInner = $_POST["plaDamInner"]; $plaDamOuter = $_POST["plaDamOuter"]; $cheDamInner = $_POST["cheDamInner"]; $cheDamOuter = $_POST["cheDamOuter"]; $psyDamInner = $_POST["psyDamInner"]; $psyDamOuter = $_POST["psyDamOuter"]; $eneDamInner = $_POST["eneDamInner"]; $eneDamOuter = $_POST["eneDamOuter"]; $kinIgnore1 = $_POST["kinIgnore1"]; $kinProtect1 = $_POST["kinProtect1"]; $expIgnore1 = $_POST["expIgnore1"]; $expProtect1 = $_POST["expProtect1"]; $plaIgnore1 = $_POST["plaIgnore1"]; $plaProtect1 = $_POST["plaProtect1"]; $cheIgnore1 = $_POST["cheIgnore1"]; $cheProtect1 = $_POST["cheProtect1"]; $psyIgnore1 = $_POST["psyIgnore1"]; $psyProtect1 = $_POST["psyProtect1"]; $eneIgnore1 = $_POST["eneIgnore1"]; $eneProtect1 = $_POST["eneProtect1"]; $kinIgnore2 = $_POST["kinIgnore2"]; $kinProtect2 = $_POST["kinProtect2"]; $expIgnore2 = $_POST["expIgnore2"]; $expProtect2 = $_POST["expProtect2"]; $plaIgnore2 = $_POST["plaIgnore2"]; $plaProtect2 = $_POST["plaProtect2"]; $cheIgnore2 = $_POST["cheIgnore2"]; $cheProtect2 = $_POST["cheProtect2"]; $psyIgnore2 = $_POST["psyIgnore2"]; $psyProtect2 = $_POST["psyProtect2"]; $eneIgnore2 = $_POST["eneIgnore2"]; $eneProtect2 = $_POST["eneProtect2"]; $kinIgnore3 = $_POST["kinIgnore3"]; $kinProtect3 = $_POST["kinProtect3"]; $expIgnore3 = $_POST["expIgnore3"]; $expProtect3 = $_POST["expProtect3"]; $plaIgnore3 = $_POST["plaIgnore3"]; $plaProtect3 = $_POST["plaProtect3"]; $cheIgnore3 = $_POST["cheIgnore3"]; $cheProtect3 = $_POST["cheProtect3"]; $psyIgnore3 = $_POST["psyIgnore3"]; $psyProtect3 = $_POST["psyProtect3"]; $eneIgnore3 = $_POST["eneIgnore3"]; $eneProtect3 = $_POST["eneProtect3"]; $kinIgnore4 = $_POST["kinIgnore4"]; $kinProtect4 = $_POST["kinProtect4"]; $expIgnore4 = $_POST["expIgnore4"]; $expProtect4 = $_POST["expProtect4"]; $plaIgnore4 = $_POST["plaIgnore4"]; $plaProtect4 = $_POST["plaProtect4"]; $cheIgnore4 = $_POST["cheIgnore4"]; $cheProtect4 = $_POST["cheProtect4"]; $psyIgnore4 = $_POST["psyIgnore4"]; $psyProtect4 = $_POST["psyProtect4"]; $eneIgnore4 = $_POST["eneIgnore4"]; $eneProtect4 = $_POST["eneProtect4"]; $kinIgnore5 = $_POST["kinIgnore5"]; $kinProtect5 = $_POST["kinProtect5"]; $expIgnore5 = $_POST["expIgnore5"]; $expProtect5 = $_POST["expProtect5"]; $plaIgnore5 = $_POST["plaIgnore5"]; $plaProtect5 = $_POST["plaProtect5"]; $cheIgnore5 = $_POST["cheIgnore5"]; $cheProtect5 = $_POST["cheProtect5"]; $psyIgnore5 = $_POST["psyIgnore5"]; $psyProtect5 = $_POST["psyProtect5"]; $eneIgnore5 = $_POST["eneIgnore5"]; $eneProtect5 = $_POST["eneProtect5"]; $kinIgnore6 = $_POST["kinIgnore6"]; $kinProtect6 = $_POST["kinProtect6"]; $expIgnore6 = $_POST["expIgnore6"]; $expProtect6 = $_POST["expProtect6"]; $plaIgnore6 = $_POST["plaIgnore6"]; $plaProtect6 = $_POST["plaProtect6"]; $cheIgnore6 = $_POST["cheIgnore6"]; $cheProtect6 = $_POST["cheProtect6"]; $psyIgnore6 = $_POST["psyIgnore6"]; $psyProtect6 = $_POST["psyProtect6"]; $eneIgnore6 = $_POST["eneIgnore6"]; $eneProtect6 = $_POST["eneProtect6"]; // Init vars if nothing was passed, or if request is cherry // Presets if( !isset($weaponPreset) ) { $weaponPreset = 0; } if( !isset($preset1) ) { $preset1 = -1; } if( !isset($preset2) ) { $preset2 = -1; } if( !isset($preset3) ) { $preset3 = -1; } if( !isset($preset4) ) { $preset4 = -1; } if( !isset($preset5) ) { $preset5 = -1; } if( !isset($preset6) ) { $preset6 = -1; } //Field Orders if( !isset($fieldOrder1) ) { $fieldOrder1 = 1; } if( !isset($fieldOrder2) ) { $fieldOrder2 = 2; } if( !isset($fieldOrder3) ) { $fieldOrder3 = 3; } if( !isset($fieldOrder4) ) { $fieldOrder4 = 4; } if( !isset($fieldOrder5) ) { $fieldOrder5 = 5; } if( !isset($fieldOrder6) ) { $fieldOrder6 = 6; } // Energy - Power Cell / Current / Max if( !isset($powerCell) ) { $powerCell = 0; } if( !isset($curEnergy) ) { $curEnergy = 0; } if( !isset($maxEnergy) ) { $maxEnergy = 700; } // What class are we? if( !isset($classInnate) ) { $classInnate = 0; } // Weapon Damage - Inner / Outer if( !isset($kinDamInner) ) { $kinDamInner = 0; } if( !isset($kinDamOuter) ) { $kinDamOuter = 0; } if( !isset($expDamInner) ) { $expDamInner = 0; } if( !isset($expDamOuter) ) { $expDamOuter = 0; } if( !isset($plaDamInner) ) { $plaDamInner = 0; } if( !isset($plaDamOuter) ) { $plaDamOuter = 0; } if( !isset($cheDamInner) ) { $cheDamInner = 0; } if( !isset($cheDamOuter) ) { $cheDamOuter = 0; } if( !isset($psyDamInner) ) { $psyDamInner = 0; } if( !isset($psyDamOuter) ) { $psyDamOuter = 0; } if( !isset($eneDamInner) ) { $eneDamInner = 0; } if( !isset($eneDamOuter) ) { $eneDamOuter = 0; } // Armor - Ignore / Protection if( !isset($kinIgnore1) ) { $kinIgnore1 = 0; } if( !isset($kinProtect1) ) { $kinProtect1 = 0; } if( !isset($expIgnore1) ) { $expIgnore1 = 0; } if( !isset($expProtect1) ) { $expProtect1 = 0; } if( !isset($plaIgnore1) ) { $plaIgnore1 = 0; } if( !isset($plaProtect1) ) { $plaProtect1 = 0; } if( !isset($cheIgnore1) ) { $cheIgnore1 = 0; } if( !isset($cheProtect1) ) { $cheProtect1 = 0; } if( !isset($psyIgnore1) ) { $psyIgnore1 = 0; } if( !isset($psyProtect1) ) { $psyProtect1 = 0; } if( !isset($eneIgnore1) ) { $eneIgnore1 = 0; } if( !isset($eneProtect1) ) { $eneProtect1 = 0; } // ======================= // if( !isset($kinIgnore2) ) { $kinIgnore2 = 0; } if( !isset($kinProtect2) ) { $kinProtect2 = 0; } if( !isset($expIgnore2) ) { $expIgnore2 = 0; } if( !isset($expProtect2) ) { $expProtect2 = 0; } if( !isset($plaIgnore2) ) { $plaIgnore2 = 0; } if( !isset($plaProtect2) ) { $plaProtect2 = 0; } if( !isset($cheIgnore2) ) { $cheIgnore2 = 0; } if( !isset($cheProtect2) ) { $cheProtect2 = 0; } if( !isset($psyIgnore2) ) { $psyIgnore2 = 0; } if( !isset($psyProtect2) ) { $psyProtect2 = 0; } if( !isset($eneIgnore2) ) { $eneIgnore2 = 0; } if( !isset($eneProtect2) ) { $eneProtect2 = 0; } // ======================= // if( !isset($kinIgnore3) ) { $kinIgnore3 = 0; } if( !isset($kinProtect3) ) { $kinProtect3 = 0; } if( !isset($expIgnore3) ) { $expIgnore3 = 0; } if( !isset($expProtect3) ) { $expProtect3 = 0; } if( !isset($plaIgnore3) ) { $plaIgnore3 = 0; } if( !isset($plaProtect3) ) { $plaProtect3 = 0; } if( !isset($cheIgnore3) ) { $cheIgnore3 = 0; } if( !isset($cheProtect3) ) { $cheProtect3 = 0; } if( !isset($psyIgnore3) ) { $psyIgnore3 = 0; } if( !isset($psyProtect3) ) { $psyProtect3 = 0; } if( !isset($eneIgnore3) ) { $eneIgnore3 = 0; } if( !isset($eneProtect3) ) { $eneProtect3 = 0; } // ======================= // if( !isset($kinIgnore4) ) { $kinIgnore4 = 0; } if( !isset($kinProtect4) ) { $kinProtect4 = 0; } if( !isset($expIgnore4) ) { $expIgnore4 = 0; } if( !isset($expProtect4) ) { $expProtect4 = 0; } if( !isset($plaIgnore4) ) { $plaIgnore4 = 0; } if( !isset($plaProtect4) ) { $plaProtect4 = 0; } if( !isset($cheIgnore4) ) { $cheIgnore4 = 0; } if( !isset($cheProtect4) ) { $cheProtect4 = 0; } if( !isset($psyIgnore4) ) { $psyIgnore4 = 0; } if( !isset($psyProtect4) ) { $psyProtect4 = 0; } if( !isset($eneIgnore4) ) { $eneIgnore4 = 0; } if( !isset($eneProtect4) ) { $eneProtect4 = 0; } // ======================= // if( !isset($kinIgnore5) ) { $kinIgnore5 = 0; } if( !isset($kinProtect5) ) { $kinProtect5 = 0; } if( !isset($expIgnore5) ) { $expIgnore5 = 0; } if( !isset($expProtect5) ) { $expProtect5 = 0; } if( !isset($plaIgnore5) ) { $plaIgnore5 = 0; } if( !isset($plaProtect5) ) { $plaProtect5 = 0; } if( !isset($cheIgnore5) ) { $cheIgnore5 = 0; } if( !isset($cheProtect5) ) { $cheProtect5 = 0; } if( !isset($psyIgnore5) ) { $psyIgnore5 = 0; } if( !isset($psyProtect5) ) { $psyProtect5 = 0; } if( !isset($eneIgnore5) ) { $eneIgnore5 = 0; } if( !isset($eneProtect5) ) { $eneProtect5 = 0; } // ======================= // if( !isset($kinIgnore6) ) { $kinIgnore6 = 0; } if( !isset($kinProtect6) ) { $kinProtect6 = 0; } if( !isset($expIgnore6) ) { $expIgnore6 = 0; } if( !isset($expProtect6) ) { $expProtect6 = 0; } if( !isset($plaIgnore6) ) { $plaIgnore6 = 0; } if( !isset($plaProtect6) ) { $plaProtect6 = 0; } if( !isset($cheIgnore6) ) { $cheIgnore6 = 0; } if( !isset($cheProtect6) ) { $cheProtect6 = 0; } if( !isset($psyIgnore6) ) { $psyIgnore6 = 0; } if( !isset($psyProtect6) ) { $psyProtect6 = 0; } if( !isset($eneIgnore6) ) { $eneIgnore6 = 0; } if( !isset($eneProtect6) ) { $eneProtect6 = 0; } // Set up innates switch($classInnate) { case 0: // Assassin $innateProts = array("ene"=>5.0,"kin"=>0.5,"exp"=>0.0,"pla"=>0.5,"che"=>5.0,"psy"=>5.0); $maxEnergy = 700; break; case 1: // Biochem $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>0.0,"pla"=>0.0,"che"=>50.0,"psy"=>0.0,); $maxEnergy = 600; break; case 2: // Captain $innateProts = array("ene"=>0.0,"kin"=>5.0,"exp"=>0.0,"pla"=>5.0,"che"=>5.0,"psy"=>5.0); $maxEnergy = 650; break; case 3:// Engineer $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>5.0,"pla"=>0.0,"che"=>5.0,"psy"=>0.0); $maxEnergy = 600; break; case 4: // Heavy Weapon $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>10.0,"pla"=>0.0,"che"=>0.0,"psy"=>0.0); $maxEnergy = 600; break; case 5: // Infantry $innateProts = array("ene"=>0.0,"kin"=>5.0,"exp"=>0.0,"pla"=>0.0,"che"=>0.0,"psy"=>0.0); $maxEnergy = 550; break; case 6: // Infiltrator $innateProts = array("ene"=>5.0,"kin"=>0.0,"exp"=>0.0,"pla"=>0.0,"che"=>5.0,"psy"=>5.0); $maxEnergy = 650; break; case 7: // Jump Trooper $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>5.0,"pla"=>5.0,"che"=>0.0,"psy"=>0.0); $maxEnergy = 600; break; case 8: // MPAC $innateProts = array("ene"=>5.0,"kin"=>5.0,"exp"=>10.0,"pla"=>2.5,"che"=>5.0,"psy"=>0.0); $maxEnergy = 650; break; case 9: // Medic $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>0.0,"pla"=>0.0,"che"=>25.0,"psy"=>25.0); $maxEnergy = 550; break; case 10: // SciOps $innateProts = array("ene"=>15.0,"kin"=>0.0,"exp"=>0.0,"pla"=>0.0,"che"=>0.0,"psy"=>0.0); $maxEnergy = 650; break; case 11: // Sergeant $innateProts = array("ene"=>0.0,"kin"=>5.0,"exp"=>0.0,"pla"=>5.0,"che"=>0.0,"psy"=>5.0); $maxEnergy = 625; break; case 12: // Squad Leader $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>0.0,"pla"=>0.0,"che"=>0.0,"psy"=>0.0); $maxEnergy = 600; break; case 13: // Tech $innateProts = array("ene"=>0.0,"kin"=>0.0,"exp"=>5.0,"pla"=>0.0,"che"=>0.0,"psy"=>0.0); $maxEnergy = 550; } // Calculated vars for use in functions and results $damageSetInner = array("ene"=>$eneDamInner,"kin"=>$kinDamInner,"exp"=>$expDamInner,"pla"=>$plaDamInner,"che"=>$cheDamInner,"psy"=>$psyDamInner); $damageSetOuter = array("ene"=>$eneDamOuter,"kin"=>$kinDamOuter,"exp"=>$expDamOuter,"pla"=>$plaDamOuter,"che"=>$cheDamOuter,"psy"=>$psyDamOuter); $armorSetIgnore1 = array("ene"=>$eneIgnore1,"kin"=>$kinIgnore1,"exp"=>$expIgnore1,"pla"=>$plaIgnore1,"che"=>$cheIgnore1,"psy"=>$psyIgnore1); $armorSetProtect1 = array("ene"=>$eneProtect1,"kin"=>$kinProtect1,"exp"=>$expProtect1,"pla"=>$plaProtect1,"che"=>$cheProtect1,"psy"=>$psyProtect1); $armorSetIgnore2 = array("ene"=>$eneIgnore2,"kin"=>$kinIgnore2,"exp"=>$expIgnore2,"pla"=>$plaIgnore2,"che"=>$cheIgnore2,"psy"=>$psyIgnore2); $armorSetProtect2 = array("ene"=>$eneProtect2,"kin"=>$kinProtect2,"exp"=>$expProtect2,"pla"=>$plaProtect2,"che"=>$cheProtect2,"psy"=>$psyProtect2); $armorSetIgnore3 = array("ene"=>$eneIgnore3,"kin"=>$kinIgnore3,"exp"=>$expIgnore3,"pla"=>$plaIgnore3,"che"=>$cheIgnore3,"psy"=>$psyIgnore3); $armorSetProtect3 = array("ene"=>$eneProtect3,"kin"=>$kinProtect3,"exp"=>$expProtect3,"pla"=>$plaProtect3,"che"=>$cheProtect3,"psy"=>$psyProtect3); $armorSetIgnore4 = array("ene"=>$eneIgnore4,"kin"=>$kinIgnore4,"exp"=>$expIgnore4,"pla"=>$plaIgnore4,"che"=>$cheIgnore4,"psy"=>$psyIgnore4); $armorSetProtect4 = array("ene"=>$eneProtect4,"kin"=>$kinProtect4,"exp"=>$expProtect4,"pla"=>$plaProtect4,"che"=>$cheProtect4,"psy"=>$psyProtect4); $armorSetIgnore5 = array("ene"=>$eneIgnore5,"kin"=>$kinIgnore5,"exp"=>$expIgnore5,"pla"=>$plaIgnore5,"che"=>$cheIgnore5,"psy"=>$psyIgnore5); $armorSetProtect5 = array("ene"=>$eneProtect5,"kin"=>$kinProtect5,"exp"=>$expProtect5,"pla"=>$plaProtect5,"che"=>$cheProtect5,"psy"=>$psyProtect5); $armorSetIgnore6 = array("ene"=>$eneIgnore6,"kin"=>$kinIgnore6,"exp"=>$expIgnore6,"pla"=>$plaIgnore6,"che"=>$cheIgnore6,"psy"=>$psyIgnore6); $armorSetProtect6 = array("ene"=>$eneProtect6,"kin"=>$kinProtect6,"exp"=>$expProtect6,"pla"=>$plaProtect6,"che"=>$cheProtect6,"psy"=>$psyProtect6); $armorGroupIgnore = array($armorSetIgnore1,$armorSetIgnore2,$armorSetIgnore3,$armorSetIgnore4,$armorSetIgnore5,$armorSetIgnore6); $armorGroupProtect = array($armorSetProtect1,$armorSetProtect2,$armorSetProtect3,$armorSetProtect4,$armorSetProtect5,$armorSetProtect6); $armorGroupIgnore = orderArmorGroup( $armorSetIgnore1,$fieldOrder1,$armorSetIgnore2,$fieldOrder2,$armorSetIgnore3,$fieldOrder3, $armorSetIgnore4,$fieldOrder4,$armorSetIgnore5,$fieldOrder5,$armorSetIgnore6,$fieldOrder6 ); $armorGroupProtect = orderArmorGroup( $armorSetProtect1,$fieldOrder1,$armorSetProtect2,$fieldOrder2,$armorSetProtect3,$fieldOrder3, $armorSetProtect4,$fieldOrder4,$armorSetProtect5,$fieldOrder5,$armorSetProtect6,$fieldOrder6 ); // Inner Damage $damageResult = calcDamage($damageSetInner, $innateProts, $armorGroupIgnore, $armorGroupProtect, $curEnergy, $maxEnergy); $resultKinInner = $damageResult["kin"]; $resultExpInner = $damageResult["exp"]; $resultPlaInner = $damageResult["pla"]; $resultCheInner = $damageResult["che"]; $resultPsyInner = $damageResult["psy"]; $resultEneInner = $damageResult["ene"]; // Outer Damage $damageResult = calcDamage($damageSetOuter, $innateProts, $armorGroupIgnore, $armorGroupProtect, $curEnergy, $maxEnergy); $resultKinOuter = $damageResult["kin"]; $resultExpOuter = $damageResult["exp"]; $resultPlaOuter = $damageResult["pla"]; $resultCheOuter = $damageResult["che"]; $resultPsyOuter = $damageResult["psy"]; $resultEneOuter = $damageResult["ene"];