function PlanetSizeRandomiser($Position, $HomeWorld = false) { global $game_config, $user; $ClassicBase = $game_config['initial_fields']; if (!$HomeWorld) { if (chance(60)) { //There is a 60% chance that the table to the left is applied. The other 40% is totally random. So it's possible that you get a slot 1 or 15 colony with 360 fields, but you can also get a slot 6 colony with only 40 fields. $Average = array(84, 88, 93, 193, 187, 175, 164, 170, 179, 121, 118, 125, 130, 104, 121); $SixtyMin = array(59, 73, 54, 103, 104, 102, 136, 143, 149, 82, 101, 105, 80, 62, 74); $SixtyMax = array(109, 103, 102, 326, 252, 348, 193, 197, 223, 142, 136, 149, 211, 192, 170); $FrmAvgMin = $SixtyMin[$Position - 1] - $Average[$Position - 1]; $FrmAvgMax = $SixtyMax[$Position - 1] - $Average[$Position - 1]; //$FrmAvgMin*x + $FrmAvgMin*x should average at 0 $DifInDeveation = $FrmAvgMin + $FrmAvgMax; $BaseIncDeveatn = $Average[$Position - 1] - $DifInDeveation / 2; $PlanetFieldsLow = mt_rand($SixtyMin[$Position - 1], $BaseIncDeveatn); $PlanetFieldsUpp = mt_rand($BaseIncDeveatn, $SixtyMax[$Position - 1]); $PlanetFields = ($PlanetFieldsLow + $PlanetFieldsUpp) / 2; } else { $MinSize = 45; $MaxSize = 360; $PlanetFields = mt_rand($MinSize, $MaxSize); } } else { $PlanetFields = $game_config['initial_fields']; } $SettingSize = $game_config['initial_fields']; $PlanetFields = $PlanetFields / $ClassicBase * $game_config['initial_fields']; $PlanetFields = floor($PlanetFields); $PlanetSize = ($PlanetFields ^ 14 / 1.5) * 75; $return['diameter'] = $PlanetSize; $return['field_max'] = $PlanetFields; return $return; }
function PlanetSizeRandomiser($Position, $HomeWorld = false) { global $game_config; $ClassicBase = 163; if (!$HomeWorld) { if (chance(60)) { //There is a 60% chance that the table to the left is applied. The other 40% is totally random. So it's possible that you get a slot 1 or 15 colony with 300 fields, but you can also get a slot 6 colony with only 40 fields. $Average = array(64, 68, 73, 173, 167, 155, 144, 150, 159, 101, 98, 105, 110, 84, 101); $SixtyMin = array(39, 53, 34, 83, 84, 82, 116, 123, 129, 62, 81, 85, 60, 42, 54); $SixtyMax = array(89, 83, 82, 306, 232, 328, 173, 177, 203, 122, 116, 129, 191, 172, 150); $FrmAvgMin = $SixtyMin[$Position - 1] - $Average[$Position - 1]; $FrmAvgMax = $SixtyMax[$Position - 1] - $Average[$Position - 1]; //$FrmAvgMin*x + $FrmAvgMin*x should average at 0 $DifInDeveation = $FrmAvgMin + $FrmAvgMax; $BaseIncDeveatn = $Average[$Position - 1] - $DifInDeveation / 2; $PlanetFieldsLow = mt_rand($SixtyMin[$Position - 1], $BaseIncDeveatn); $PlanetFieldsUpp = mt_rand($BaseIncDeveatn, $SixtyMax[$Position - 1]); $PlanetFields = ($PlanetFieldsLow + $PlanetFieldsUpp) / 2; } else { $MinSize = 30; $MaxSize = 330; $PlanetFields = mt_rand($MinSize, $MaxSize); } } else { $PlanetFields = $ClassicBase; } $SettingSize = $game_config['initial_fields']; $PlanetFields = $PlanetFields / $ClassicBase * $game_config['initial_fields']; $PlanetFields = floor($PlanetFields); $PlanetSize = ($PlanetFields ^ 14 / 1.5) * 75; $return['diameter'] = $PlanetSize; $return['field_max'] = $PlanetFields; return $return; }
function PlanetSizeRandomiser($Position, $HomeWorld = false) { global $config, $user; //$ClassicBase = 163; if (!$HomeWorld) { if (chance(60)) { $Average = array(64, 68, 73, 173, 167, 155, 144, 150, 159, 101, 98, 105, 110, 84, 101); $SixtyMin = array(39, 53, 34, 83, 84, 82, 116, 123, 129, 62, 81, 85, 60, 42, 54); $SixtyMax = array(89, 83, 82, 306, 232, 328, 173, 177, 203, 122, 116, 129, 191, 172, 150); $FrmAvgMin = $SixtyMin[$Position - 1] - $Average[$Position - 1]; $FrmAvgMax = $SixtyMax[$Position - 1] - $Average[$Position - 1]; $DifInDeveation = $FrmAvgMin + $FrmAvgMax; $BaseIncDeveatn = $Average[$Position - 1] - $DifInDeveation / 2; $PlanetFieldsLow = mt_rand($SixtyMin[$Position - 1], $BaseIncDeveatn); $PlanetFieldsUpp = mt_rand($BaseIncDeveatn, $SixtyMax[$Position - 1]); $PlanetFields = ($PlanetFieldsLow + $PlanetFieldsUpp) / 2; } else { $MinSize = 30; $MaxSize = 330; $PlanetFields = mt_rand($MinSize, $MaxSize); } } else { $PlanetFields = $config->initial_fields; } // $SettingSize = $config->initial_fields; // $PlanetFields = ($PlanetFields / $ClassicBase) * $config->initial_fields; $PlanetFields = floor($PlanetFields); $PlanetSize = ($PlanetFields ^ 14 / 1.5) * 75; $return['diameter'] = $PlanetSize; $return['field_max'] = $PlanetFields; return $return; }
/** * Close */ public function close() { // 5 percent chance to call garbage collector if (chance(5)) { $this->gc(1); } return ['success' => true, 'error' => []]; }
/** * CreateOnePlanetRecord.php * * @version 2 * @copyright 2008 by Anthony (MadnessRed) for Darkness * GPL Liscence - See LICENCE.TXT */ function PlanetSizeRandomiser($Position, $HomeWorld = false, $debug = false) { global $game_config; //Source of datavalues and 60% rule. lines http://ogame.wikia.com/wiki/Colony $ClassicBase = 163; if (!$HomeWorld) { if (chance(60)) { //There is a 60% chance that the table to the left is applied. The other 40% is totally random. So it's possible that you get a slot 1 or 15 colony with 300 fields, but you can also get a slot 6 colony with only 40 fields. $Average = array(64, 68, 73, 173, 167, 155, 144, 150, 159, 101, 98, 105, 110, 84, 101); $SixtyMin = array(39, 53, 34, 83, 84, 82, 116, 123, 129, 62, 81, 85, 60, 42, 54); $SixtyMax = array(89, 83, 82, 306, 232, 328, 173, 177, 203, 122, 116, 129, 191, 172, 150); $FrmAvgMin = $SixtyMin[$Position - 1] - $Average[$Position - 1]; $FrmAvgMax = $SixtyMax[$Position - 1] - $Average[$Position - 1]; //$FrmAvgMin*x + $FrmAvgMin*x should average at 0 $DifInDeveation = $FrmAvgMin + $FrmAvgMax; $BaseIncDeveatn = $Average[$Position - 1] - $DifInDeveation / 2; $PlanetFieldsLow = mt_rand($SixtyMin[$Position - 1], $BaseIncDeveatn); $PlanetFieldsUpp = mt_rand($BaseIncDeveatn, $SixtyMax[$Position - 1]); $PlanetFields = ($PlanetFieldsLow + $PlanetFieldsUpp) / 2; if ($debug) { echo "<u>Planet in the 60% Bracket</u><br />"; echo "60% Greater than: " . $SixtyMin[$Position - 1] . "<br />"; echo "60% Less than: " . $SixtyMax[$Position - 1] . "<br />"; echo "Average: " . $Average[$Position - 1] . "<br /><br />"; echo "Fields OGame would give: " . floor($PlanetFields) . "<br /><br /><hr /><br />"; } } else { $MinSize = 30; $MaxSize = 330; $PlanetFields = mt_rand($MinSize, $MaxSize); if ($debug) { echo "<u>Planet outside the 60% Bracket</u><br />"; echo "Fields OGame would give: " . $PlanetFields . "<br /><br /><hr /><br />"; } } } else { $PlanetFields = $ClassicBase; } $SettingSize = $game_config['initial_fields']; $PlanetFields = $PlanetFields / $ClassicBase * $game_config['initial_fields']; $PlanetFields = floor($PlanetFields); if ($debug) { echo "OGame homeworld size: " . $ClassicBase . "<br />"; echo "DarkEvo homeworld size: " . $game_config['initial_fields'] . "<br /><br />"; echo "Fields DarkEvo would give: " . $PlanetFields . "<br /><br /><hr />"; } $PlanetSize = ($PlanetFields ^ 14 / 1.5) * 75; $return['diameter'] = $PlanetSize; $return['field_max'] = $PlanetFields; return $return; }
function mr_attack($att_ships, $def_ships, $debug) { global $CombatCaps, $pricelist; //list any new fucntions used here for furture use. // chance() functions.php //Lets set set stuff straight here. //There are 6 rounds. $maxrounds = 6; $debris_pc = 0.3; //30% $shipsend = 299; //ships are less than $def2deb = false; //Defence counts toward debrisfield. //Start the running totals. $attlost = 0; $deflost = 0; $debrmet = 0; $debrcry = 0; //Start the results array $results = array(); //Start the rounds $rounddata = array(); //Whilst neither side has won it is still a draw. $results['won'] = 'd'; //For each round... for ($round = 1; $round <= $maxrounds; $round++) { //Start round info. $roundinfo = array(); //Check that one side hasn't won yet. if (count($def_ships) == 0) { $results['won'] = 'a'; $round = $maxrounds + 1; } elseif (count($att_ships) == 0) { $results['won'] = 'v'; $round = $maxrounds + 1; } else { //First attacker fires, so, for each attacker. foreach ($att_ships as $id => $info) { if ($debug) { echo "Ship: " . $id . "."; echo "<br />"; } //Don't stop firing yet, haven't even done one shot. $stopfiring = false; while ($stopfiring == false) { $target = array_rand($def_ships); //$target = $target['id']; if ($debug) { echo "Target: " . $target . "."; echo "<br />"; } if (strlen($target) > 0) { //our target is $def_ships[$target]. //our target is not destroyed and has shields $destroyed = false; $noshields = false; //Our target is ship type. $element = $def_ships[$target]['type']; if ($debug) { echo "Target type: " . $element . "."; echo "<br />"; } //Are his shields still intact? if ($def_ships[$target]['shields'] > 0) { //Does boucing effect apply. (http://ogame.wikia.com/wiki/Bouncing_Effect) if ($def_ships[$target]['shields'] <= $info['weaps'] * 100) { //Did we destroy the shields? if ($def_ships[$target]['shields'] <= $info['weaps']) { $curattack = $info['weaps']; $curattack -= $def_ships[$target]['shields']; $def_ships[$target]['shields'] -= $def_ships[$target]['shields']; $def_ships[$target]['hull'] -= $curattack; $noshields = true; $roundinfo['attblock'] += $def_ships[$target]['shields']; } else { $def_ships[$target]['shields'] -= $info['weaps']; $roundinfo['attblock'] += $info['weaps']; } } else { $roundinfo['attblock'] += $info['weaps']; } } else { $noshields = true; } //OK, we have fired, now stop firing and log it as a fire. $stopfiring = true; $roundinfo['attfires']++; $roundinfo['attpower'] += $info['weaps']; //Have we destroyed his shields? if ($noshields) { $orighull = ($pricelist[$element]['metal'] + $pricelist[$element]['crystal']) / 10; $nowhull = $def_ships[$target]['hull']; //Is the ship already destroyed. if ($nowhull <= 0) { $destroyed = true; } //The chance that the ship is destroyed is the percentage remaining of the hull. $chance = $nowhull / $orighull; //So there is a $chance chance if it beign destroyed, so run chance function. (or it may already be dead) if (chance($chance) || $destroyed) { //Ship destroyed. Lets inspect the costs. $element = $def_ships[$target]['type']; $deflost += $pricelist[$element]['metal'] + $pricelist[$element]['crystal'] + $pricelist[$element]['deuterium']; if ($element <= $shipsend || $def2deb) { //it counts toward debris field. $debrmet += $pricelist[$element]['metal'] * $debris_pc; $debrcry += $pricelist[$element]['crystal'] * $debris_pc; } //Uh oh, ship destroyed, remove it from the array. unset($def_ships[$target]); //now for rapidfire. $rapidfire = $CombatCaps[$info['type']]['sd'][$element]; $fireagain = (1 - 1 / $rapidfire) * 100; //So does he fire again? if (chance($fireagain)) { if ($debug) { echo "Rapid Fire: Go."; echo "<br />"; } //yes he, does, cancel that stop firing command. $stopfiring = false; } } } } else { $stopfiring = true; } } } //Payback time foreach ($def_ships as $id => $info) { //Don't stop firing yet, haven't even done one shot. $stopfiring = false; while ($stopfiring == false) { $targt = array_rand($att_ships); $target = $targt['id']; //our target is $att_ships[$target]. //our target is not destroyed and has shields $destroyed = false; $noshields = false; //Our target is ship type. $element = $att_ships[$target]['type']; //Do is his shield intact? if ($att_ships[$target]['shields'] > 0) { //Does boucing effect apply. (http://ogame.wikia.com/wiki/Bouncing_Effect) if ($att_ships[$target]['shields'] <= $info['weaps'] * 100) { //Did we destroy the shields? if ($att_ships[$target]['shields'] <= $info['weaps']) { $curattack = $info['weaps']; $curattack -= $att_ships[$target]['shields']; $att_ships[$target]['shields'] -= $att_ships[$target]['shields']; $att_ships[$target]['hull'] -= $curattack; $noshields = true; $roundinfo['defblock'] += $def_ships[$target]['shields']; } else { $att_ships[$target]['shields'] -= $info['weaps']; $roundinfo['defblock'] += $info['weaps']; } } else { $roundinfo['defblock'] += $info['weaps']; } } else { $noshields = true; } //OK, we have fired, now stop firing. $stopfiring = true; $roundinfo['deffires']++; $roundinfo['defpower'] += $info['weaps']; //Have we destroyed his shields? if ($noshields) { $orighull = ($pricelist[$element]['metal'] + $pricelist[$element]['crystal']) / 10; $nowhull = $att_ships[$target]['hull']; //Is the ship already destroyed. if ($nowhull <= 0) { $destroyed = true; } //The chance that the ship is destroyed is the percentage remaining of the hull. $chance = $nowhull / $orighull; //So there is a $chance chance if it beign destroyed, so run chance function. (or it may already be dead) if (chance($chance) || $destroyed) { //Ship destroyed. Lets inspect the costs. $element = $att_ships[$target]['type']; $attlost += $pricelist[$element]['metal'] + $pricelist[$element]['crystal'] + $pricelist[$element]['deuterium']; if ($element <= $shipsend || $def2deb) { //it counts toward debris field. $debrmet += $pricelist[$element]['metal'] * $debris_pc; $debrcry += $pricelist[$element]['crystal'] * $debris_pc; } //Uh oh, ship destroyed, remove it from the array. unset($att_ships[$target]); //now for rapidfire. $rapidfire = $CombatCaps[$info['type']]['sd'][$att_ships[$target]['type']]; $fireagain = (1 - 1 / $rapidfire) * 100; //So does he fire again? if (chance($fireagain)) { //yes he, does, cancel that stop firing command. $stopfiring = false; } } } } } } //Now return the round info. $rounddata[$round]['atts'] = $att_ships; $rounddata[$round]['defs'] = $def_ships; $rounddata[$round]['info'] = $roundinfo; } //Make array from the the running totals. $losses['att'] = $attlost; $losses['def'] = $deflost; $losses['debm'] = $debrmet; $losses['debc'] = $debrcry; //Add losses to results. $results['losses'] = $losses; //Add round data to the results. $results['rounds'] = $rounddata; //Return the end result. return $results; }