示例#1
0
function zoneedit_die($error_msg)
{
    echo "<p>" . $error_msg . "<p>";
    TEXT_GOTOMAIN();
    ?>
</div></div>
<?php 
    include "footer.php";
    die;
}
示例#2
0
            $row = $result3->fields;
            $cur_sector = $cur_sector + 1;
        } else {
            $p = 'unknown';
            // Build the alt text for each image
            $alt = $c + $div_xmax * $r . " - " . $l_unknown . " ";
            // I have not figured out why this formula works, but $row[sector_id] doesn't, so I'm not switching it.
            echo "<a href=\"rsmove.php?engage=1&amp;destination=" . ($c + $div_xmax * $r) . "\">";
            echo "<img class='map un' src='images/" . $tile[$p] . "' alt='" . $alt . "'></a> ";
            $cur_sector = $cur_sector + 1;
        }
    }
}
// This is the row numbers on the side of the map
for ($a = 1; $a < $sector_max / $div_xmax + 1; $a++) {
    echo "\n<div style='position:absolute;left:" . ($map_width + 10) . "px;top:" . ($a - 1) * ($div_h + $div_border) . "px;'>" . ($a * $div_xmax - 1) . "</div>";
}
echo "</div><div style='clear:both'></div><br>";
echo "    <div><img alt='" . $l_port . ": " . $l_special_port . "' src='images/{$tile['special']}'> &lt;- " . $l_special_port . "</div>\n";
echo "    <div><img alt='" . $l_port . ": " . $l_ore_port . "' src='images/{$tile['ore']}'> &lt;- " . $l_ore_port . "</div>\n";
echo "    <div><img alt='" . $l_port . ": " . $l_organics_port . "' src='images/{$tile['organics']}'> &lt;- " . $l_organics_port . "</div>\n";
echo "    <div><img alt='" . $l_port . ": " . $l_energy_port . "' src='images/{$tile['energy']}'> &lt;- " . $l_energy_port . "</div>\n";
echo "    <div><img alt='" . $l_port . ": " . $l_goods_port . "' src='images/{$tile['goods']}'> &lt;- " . $l_goods_port . "</div>\n";
echo "    <div><img alt='" . $l_port . ": " . $l_no_port . "' src='images/{$tile['none']}'> &lt;- " . $l_no_port . "</div>\n";
echo "    <div><img alt='" . $l_port . ": " . $l_unexplored . "' src='images/{$tile['unknown']}'> &lt;- " . $l_unexplored . "</div>\n";
echo "<br><br>";
TEXT_GOTOMAIN();
?>
</div></div>
<?php 
include "footer.php";
示例#3
0
function planetcombat()
{
	global $upgrade_cost, $upgrade_factor;
    global $playerinfo;
	global $shipinfo;
    global $ownerinfo;
	global $ownershipinfo;
    global $sectorinfo;
    global $planetinfo;
    global $torpedo_price;
    global $colonist_price;
    global $ore_price;
    global $organics_price;
    global $goods_price;
    global $energy_price;
	global $ibank_paymentfee;
    global $planetbeams;
    global $planetfighters;
    global $planetshields;
    global $planettorps;
    global $attackerbeams;
    global $attackerfighters;
    global $attackershields;
    global $attackertorps;
    global $attackerarmor;
    global $torp_dmg_rate;
    global $level_factor;
    global $attackertorpdamage;
    global $start_energy;
    global $min_value_capture;
    global $l_cmb_atleastoneturn;
    global $l_cmb_atleastoneturn, $l_cmb_shipenergybb, $l_cmb_shipenergyab, $l_cmb_shipenergyas, $l_cmb_shiptorpsbtl, $l_cmb_shiptorpsatl;
    global $l_cmb_planettorpdamage, $l_cmb_attackertorpdamage, $l_cmb_beams, $l_cmb_fighters, $l_cmb_shields, $l_cmb_torps;
    global $l_cmb_torpdamage, $l_cmb_armor, $l_cmb_you, $l_cmb_planet, $l_cmb_combatflow, $l_cmb_defender, $l_cmb_attackingplanet;
    global $l_cmb_youfireyourbeams, $l_cmb_defenselost, $l_cmb_defenselost2, $l_cmb_planetarybeams, $l_cmb_planetarybeams;
    global $l_cmb_youdestroyedplanetshields, $l_cmb_beamsexhausted, $l_cmb_breachedyourshields, $l_cmb_destroyedyourshields;
    global $l_cmb_breachedyourarmor, $l_cmb_destroyedyourarmor, $l_cmb_torpedoexchangephase, $l_cmb_nofightersleft;
    global $l_cmb_youdestroyfighters, $l_cmb_planettorpsdestroy, $l_cmb_planettorpsdestroy2, $l_cmb_torpsbreachedyourarmor;
    global $l_cmb_planettorpsdestroy3, $l_cmb_youdestroyedallfighters, $l_cmb_youdestroyplanetfighters, $l_cmb_fightercombatphase;
    global $l_cmb_youdestroyedallfighters2, $l_cmb_youdestroyplanetfighters2, $l_cmb_allyourfightersdestroyed, $l_cmb_fightertofighterlost;
    global $l_cmb_youbreachedplanetshields, $l_cmb_shieldsremainup, $l_cmb_fighterswarm, $l_cmb_swarmandrepel, $l_cmb_engshiptoshipcombat;
    global $l_cmb_shipdock, $l_cmb_approachattackvector, $l_cmb_noshipsdocked, $l_cmb_yourshipdestroyed, $l_cmb_escapepod;
    global $l_cmb_finalcombatstats, $l_cmb_youlostfighters, $l_cmb_youlostarmorpoints, $l_cmb_energyused, $l_cmb_planetdefeated;
    global $l_cmb_citizenswanttodie, $l_cmb_youmaycapture, $l_cmb_youmaycapture2, $l_cmb_planetnotdefeated, $l_cmb_planetstatistics;
    global $l_cmb_fighterloststat, $l_cmb_energyleft;
    global $db, $dbtables;
    //$debug = true;




    if($playerinfo[turns] < 1)
    {
        echo "$l_cmb_atleastoneturn<BR><BR>";
        TEXT_GOTOMAIN();
        include("footer.php");
        die();
    }

    // Planetary defense system calculation

    $planetbeams 		= calcplanetbeams();
    $planetfighters		= calcplanetfighters();
    $planetshields		= calcplanetshields();
    $planettorps		= calcplanettorps();

    // Attacking ship calculations

    $attackerbeams		= NUM_BEAMS($shipinfo[beams]);
    $attackerfighters	= $shipinfo[ship_fighters];
    $attackershields	= NUM_SHIELDS($shipinfo[shields]);
    $attackertorps		= round(mypw($level_factor, $shipinfo[torp_launchers])) * 2;
    $attackerarmor		= $shipinfo[armour_pts];

    // Now modify player beams, shields and torpedos on available materiel
    $starting_energy = $shipinfo[ship_energy];

    // Beams
    if ($debug)
        echo "$l_cmb_shipenergybb: $shipinfo[ship_energy]<BR>\n";
    if ($attackerbeams > $shipinfo[ship_energy])
        $attackerbeams   = $shipinfo[ship_energy];
    $shipinfo[ship_energy] = $shipinfo[ship_energy] - $attackerbeams;
    if ($debug)
        echo "$l_cmb_shipenergyab (before shields): $shipinfo[ship_energy]<BR>\n";

    // Shields
    if ($attackershields > $shipinfo[ship_energy])
        $attackershields = $shipinfo[ship_energy];
    $shipinfo[ship_energy] = $shipinfo[ship_energy] - $attackershields;
    if ($debug)
        echo "$l_cmb_shipenergyas: $shipinfo[ship_energy]<BR>\n";

    // Torpedos
    if ($debug)
        echo "$l_cmb_shiptorpsbtl: $attackertorps ($shipinfo[torps] / $shipinfo[torp_launchers])<BR>\n";
    if ($attackertorps > $shipinfo[torps])
        $attackertorps = $shipinfo[torps];
    $shipinfo[torps] = $shipinfo[torps] - $attackertorps;
    if ($debug)
        echo "$l_cmb_shiptorpsatl: $attackertorps ($shipinfo[torps] / $shipinfo[torp_launchers])<BR>\n";

    // Setup torp damage rate for both Planet and Ship
    $planettorpdamage	= $torp_dmg_rate * $planettorps;
    $attackertorpdamage	= $torp_dmg_rate * $attackertorps;
    if ($debug)
        echo "$l_cmb_planettorpdamage: $planettorpdamage<BR>\n";
    if ($debug)
        echo "$l_cmb_attackertorpdamage: $attackertorpdamage<BR>\n";


    echo "
    <CENTER>
    <HR>
    <table width='75%' border='0'>
    <tr ALIGN='CENTER'>
    <td width='9%' height='27'></td>
    <td width='12%' height='27'><FONT COLOR='WHITE'>$l_cmb_beams</FONT></td>
    <td width='17%' height='27'><FONT COLOR='WHITE'>$l_cmb_fighters</FONT></td>
    <td width='18%' height='27'><FONT COLOR='WHITE'>$l_cmb_shields</FONT></td>
    <td width='11%' height='27'><FONT COLOR='WHITE'>$l_cmb_torps</FONT></td>
    <td width='22%' height='27'><FONT COLOR='WHITE'>$l_cmb_torpdamage</FONT></td>
    <td width='11%' height='27'><FONT COLOR='WHITE'>$l_cmb_armor</FONT></td>
    </tr>
    <tr ALIGN='CENTER'>
    <td width='9%'> <FONT COLOR='RED'>$l_cmb_you</td>
    <td width='12%'><FONT COLOR='RED'><B>$attackerbeams</B></FONT></td>
    <td width='17%'><FONT COLOR='RED'><B>$attackerfighters</B></FONT></td>
    <td width='18%'><FONT COLOR='RED'><B>$attackershields</B></FONT></td>
    <td width='11%'><FONT COLOR='RED'><B>$attackertorps</B></FONT></td>
    <td width='22%'><FONT COLOR='RED'><B>$attackertorpdamage</B></FONT></td>
    <td width='11%'><FONT COLOR='RED'><B>$attackerarmor</B></FONT></td>
    </tr>
    <tr ALIGN='CENTER'>
    <td width='9%'> <FONT COLOR='#6098F8'>$l_cmb_planet</FONT></td>
    <td width='12%'><FONT COLOR='#6098F8'><B>$planetbeams</B></FONT></td>
    <td width='17%'><FONT COLOR='#6098F8'><B>$planetfighters</B></FONT></td>
    <td width='18%'><FONT COLOR='#6098F8'><B>$planetshields</B></FONT></td>
    <td width='11%'><FONT COLOR='#6098F8'><B>$planettorps</B></FONT></td>
    <td width='22%'><FONT COLOR='#6098F8'><B>$planettorpdamage</B></FONT></td>
    <td width='11%'><FONT COLOR='#6098F8'><B>N/A</B></FONT></td>
    </tr>
    </table>
    <HR>
    </CENTER>
    ";
    // Begin actual combat calculations

    $planetdestroyed   = 0;
    $attackerdestroyed = 0;

    echo "<BR><CENTER><B><FONT SIZE='+2'>$l_cmb_combatflow</FONT></B><BR><BR>\n";
    echo "<table width='75%' border='0'><tr align='center'><td><FONT COLOR='RED'>$l_cmb_you</FONT></td><td><FONT COLOR='#6098F8'>$l_cmb_defender</FONT></td>\n";
    echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_attackingplanet $playerinfo[sector]</b></FONT></td><td></td>";
    echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youfireyourbeams</b></FONT></td><td></td>\n";
    if($planetfighters > 0 && $attackerbeams > 0)
    {
        if($attackerbeams > $planetfighters)
        {
            $l_cmb_defenselost = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_defenselost);
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_defenselost</B></FONT>";
            $planetfighters = 0;
            $attackerbeams = $attackerbeams - $planetfighters;
        }
        else
        {
            $l_cmb_defenselost2 = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_defenselost2);
            $planetfighters = $planetfighters - $attackerbeams;
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_defenselost2</B></FONT>";
            $attackerbeams = 0;
        }
    }

    if($attackerfighters > 0 && $planetbeams > 0)
    {
        // If there are more beams on the planet than attacker has fighters
        if($planetbeams > round($attackerfighters / 2))
        {
            // Half the attacker fighters
            $temp = round($attackerfighters / 2);
            // Attacker loses half his fighters
            $lost = $attackerfighters - $temp;
            // Set attacker fighters to 1/2 it's original value
            $attackerfighters = $temp;
            // Subtract half the attacker fighters from available planetary beams
            $planetbeams = $planetbeams - $lost;
            $l_cmb_planetarybeams = str_replace("[cmb_temp]", $temp, $l_cmb_planetarybeams);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_planetarybeams</B></FONT><TD></TD>";
        }
        else
        {
            $l_cmb_planetarybeams2 = str_replace("[cmb_planetbeams]", $planetbeams, $l_cmb_planetarybeams2);
            $attackerfighters = $attackerfighters - $planetbeams;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_planetarybeams2</B></FONT><TD></TD>";
            $planetbeams = 0;
        }
    }
    if($attackerbeams > 0)
    {
        if($attackerbeams > $planetshields)
        {
            $attackerbeams = $attackerbeams - $planetshields;
            $planetshields = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyedplanetshields</FONT></B><td></td>";
        }
        else
        {
            $l_cmb_beamsexhausted = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_beamsexhausted);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_beamsexhausted</FONT></B><td></td>";
            $planetshields = $planetshields - $attackerbeams;
            $attackerbeams = 0;
        }
    }
    if($planetbeams > 0)
    {
        if($planetbeams > $attackershields)
        {
            $planetbeams = $planetbeams - $attackershields;
            $attackershields = 0;
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_breachedyourshields</FONT></B></td>";
        }
        else
        {
            $attackershields = $attackershields - $planetbeams;
            $l_cmb_destroyedyourshields = str_replace("[cmb_planetbeams]", $planetbeams, $l_cmb_destroyedyourshields);
            echo "<tr align='center'><td></td><FONT COLOR='#6098F8'><B>$l_cmb_destroyedyourshields</FONT></B></td>";
            $planetbeams = 0;
        }
    }
    if($planetbeams > 0)
    {
        if($planetbeams > $attackerarmor)
        {
            $attackerarmor = 0;
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_cmb_breachedyourarmor</B></FONT></td>";
        }
        else
        {
            $attackerarmor = $attackerarmor - $planetbeams;
            $l_cmb_destroyedyourarmor = str_replace("[cmb_planetbeams]", $planetbeams, $l_cmb_destroyedyourarmor);
            echo "<tr align='center'><td></td><td><FONT COLOR='#6098F8'><B>$l_destroyedyourarmor</FONT></B></td>";
        }
    }
    echo "<tr align='center'><td><FONT COLOR='YELLOW'><B>$l_cmb_torpedoexchangephase</b></FONT></td><td><b><FONT COLOr='YELLOW'>$l_cmb_torpedoexchangephase</b></FONT></td><BR>";
    if($planetfighters > 0 && $attackertorpdamage > 0)
    {
        if($attackertorpdamage > $planetfighters)
        {
            $l_cmb_nofightersleft = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_nofightersleft);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_nofightersleft</FONT></B></td><td></td>";
            $planetfighters = 0;
            $attackertorpdamage = $attackertorpdamage - $planetfighters;
        }
        else
        {
            $planetfighters = $planetfighters - $attackertorpdamage;
            $l_cmb_youdestroyfighters = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_youdestroyfighters);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyfighters</FONT></B></td><td></td>";
            $attackertorpdamage = 0;
        }
    }
    if($attackerfighters > 0 && $planettorpdamage > 0)
    {
        if($planettorpdamage > round($attackerfighters / 2))
        {
            $temp = round($attackerfighters / 2);
            $lost = $attackerfighters - $temp;
            $attackerfighters = $temp;
            $planettorpdamage = $planettorpdamage - $lost;
            $l_cmb_planettorpsdestroy = str_replace("[cmb_temp]", $temp, $l_cmb_planettorpsdestroy);
            echo "<tr align='center'><td></td><td><FONT COLOR='RED'><B>$l_cmb_planettorpsdestroy</B></FONT></td>";
        }
        else
        {
            $attackerfighters = $attackerfighters - $planettorpdamage;
            $l_cmb_planettorpsdestroy2 = str_replace("[cmb_planettorpdamage]", $planettorpdamage, $l_cmb_planettorpsdestroy2);
            echo "<tr align='center'><td></td><td><FONT COLOR='RED'><B>$l_cmb_planettorpsdestroy2</B></FONT></td>";
            $planettorpdamage = 0;
        }
    }
    if($planettorpdamage > 0)
    {
        if($planettorpdamage > $attackerarmor)
        {
            $attackerarmor = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_torpsbreachedyourarmor</B></FONT></td><td></td>";
        }
        else
        {
            $attackerarmor = $attackerarmor - $planettorpdamage;
            $l_cmb_planettorpsdestroy3 = str_replace("[cmb_planettorpdamage]", $planettorpdamage, $l_cmb_planettorpsdestroy3);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_planettorpsdestroy3</B></FONT></td><td></td>";
        }
    }
    if($attackertorpdamage > 0 && $planetfighters > 0)
    {
        $planetfighters = $planetfighters - $attackertorpdamage;
        if ($planetfighters < 0)
        {
            $planetfighters = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyedallfighters</B></FONT></td><td></td>";
        }
        else
        {
            $l_cmb_youdestroyplanetfighters = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_youdestroyplanetfighters);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyplanetfighters</B></FONT></td><td></td>";
        }
    }
    echo "<tr align='center'><td><FONT COLOR='YELLOW'><B>$l_cmb_fightercombatphase</b></FONT></td><td><b><FONT COLOr='YELLOW'>$l_cmb_fightercombatphase</b></FONT></td><BR>";
    if($attackerfighters > 0 && $planetfighters > 0)
    {
        if($attackerfighters > $planetfighters)
        {
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyedallfighters2</B></FONT></td><td></td>";
            $tempplanetfighters = 0;
        }
        else
        {
            $l_cmb_youdestroyplanetfighters2 = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_youdestroyplanetfighters2);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youdestroyplanetfighters2</B></FONT></td><td></td>";
            $tempplanetfighters = $planetfighters - $attackerfighters;
        }
        if($planetfighters > $attackerfighters)
        {
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_allyourfightersdestroyed</B></FONT></td><td></td>";
            $tempplayfighters = 0;
        }
        else
        {
            $tempplayfighters = $attackerfighters - $planetfighters;
            $l_cmb_fightertofighterlost = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fightertofighterlost);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_fightertofighterlost</B></FONT></td><td></td>";
        }
        $attackerfighters = $tempplayfighters;
        $planetfighters = $tempplanetfighters;
    }
    if($attackerfighters > 0 && $planetshields > 0)
    {
        if($attackerfighters > $planetshields)
        {
            $attackerfighters = $attackerfighters - round($planetshields / 2);
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_youbreachedplanetshields</B></FONT></td><td></td>";
            $planetshields = 0;
        }
        else
        {
            $l_cmb_shieldsremainup = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_shieldsremainup);
            echo "<tr align='center'><td></td><FONT COLOR='#6098F8'><B>$l_cmb_shieldsremainup</B></FONT></td>";
            $planetshields = $planetshields - $attackerfighters;
        }
    }
    if($planetfighters > 0)
    {
        if($planetfighters > $attackerarmor)
        {
            $attackerarmor = 0;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_fighterswarm</B></FONT></td><td></td>";
        }
        else
        {
            $attackerarmor = $attackerarmor - $planetfighters;
            echo "<tr align='center'><td><FONT COLOR='RED'><B>$l_cmb_swarmandrepel</B></FONT></td><td></td>";
        }
    }

    echo "</TABLE></CENTER>\n";
    // Send each docked ship in sequence to attack agressor
    $result4 = $db->Execute("SELECT * FROM $dbtables[players] WHERE planet_id=$planetinfo[planet_id] AND on_planet='Y'");
    $playersonplanet = $result4->RecordCount();

    if ($playersonplanet > 0)
    {
        $l_cmb_shipdock = str_replace("[cmb_shipsonplanet]", $shipsonplanet, $l_cmb_shipdock);
        echo "<BR><BR><CENTER>$l_cmb_shipdock<BR>$l_cmb_engshiptoshipcombat</CENTER><BR><BR>\n";
        while (!$result4->EOF)
        {
            $onplanet = $result4->fields;
            //$shipinfo[ship_fighters] 	= $attackerfighters;
            //$shipinfo[armour_pts] 	= $attackerarmor;
            //$shipinfo[torps]			= $shipinfo[torps] - $attackertorps;

            if ($attackerfighters < 0)
                $attackerfighters = 0;
            if ($attackertorps    < 0)
                $attackertorps = 0;
            if ($attackershields  < 0)
                $attackershields = 0;
            if ($attackerbeams    < 0)
                $attackerbeams = 0;
            if ($attackerarmor    < 1)
                break;

            echo "<BR>-$onplanet[character_name] $l_cmb_approachattackvector-<BR>";
            shiptoship($onplanet[currentship]);
            $result4->MoveNext();
        }
    }
    else
        echo "<BR><BR><CENTER>$l_cmb_noshipsdocked</CENTER><BR><BR>\n";

    if($attackerarmor < 1)
    {
		// Planet attacked and attacked blew up
        $free_ore = round($shipinfo[ship_ore]/2);
        $free_organics = round($shipinfo[ship_organics]/2);
        $free_goods = round($shipinfo[ship_goods]/2);
        $ship_value=$upgrade_cost*(round(mypw($upgrade_factor, $shipinfo[hull]))+round(mypw($upgrade_factor, $shipinfo[engines]))+round(mypw($upgrade_factor, $shipinfo[power]))+round(mypw($upgrade_factor, $shipinfo[computer]))+round(mypw($upgrade_factor, $shipinfo[sensors]))+round(mypw($upgrade_factor, $shipinfo[beams]))+round(mypw($upgrade_factor, $shipinfo[torp_launchers]))+round(mypw($upgrade_factor, $shipinfo[shields]))+round(mypw($upgrade_factor, $shipinfo[armor]))+round(mypw($upgrade_factor, $shipinfo[cloak])));
        $ship_salvage_rate=rand(0,10);
        $ship_salvage=$ship_value*$ship_salvage_rate/100;
		// Triple salvage if this is an outlaw
		$result3 = $db->Execute ("SELECT amount FROM $dbtables[bounty] WHERE placed_by=0 AND bounty_on=$playerinfo[player_id]");
		$fugitive="";
		if (!$result3->EOF) {
			echo "Triple hull salvage goes to $ownerinfo[character_name] because you were a fugitive!<br>";
			$ship_salvage *=3;
			$fugitive = "Fugitive from justice ";
		}

        echo "<BR><CENTER><FONT SIZE='+2' COLOR='RED'><B>$l_cmb_yourshipdestroyed</FONT></B></CENTER><BR>";
		// news
		$headline="Planet Attacked!";
		$newstext=$fugitive.$playerinfo[character_name]." in the ship ".$shipinfo[ship_name]." led an attack today against ".$ownerinfo[character_name]."'s planet ".$planetinfo[name]." but was brought down by heavy planetary defenses. ";
		if ($playerinfo[score] < $ownerinfo[score]) {
			$newstext = $newstext . $playerinfo[character_name]." knew it would be an uphill battle and it was. Too bad.";
		} else {
			$newstext = $newstext . $playerinfo[character_name]." thought it would be an easy battle but underestimated the planet defenses. Next time look before you leap.";
		}
		if ($fugitive != "") {
			$newstext .= " $ownerinfo[character_name] collected triple salvage from the outlaw's ship wreckage!";
		}
		$newstext = addslashes($newstext);
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");

        if($shipinfo[dev_escapepod] == "Y")
        {
            echo "<CENTER><FONT COLOR='WHITE'>$l_cmb_escapepod</FONT></CENTER><BR><BR>";
            $db->Execute("UPDATE $dbtables[players] SET on_planet='N',sector=0 WHERE player_id=$playerinfo[player_id]");
			// Immediately release any ships being towed 
    		if ($shipinfo[tow] > 0) {
				$db->Execute("UPDATE $dbtables[ships] SET player_id=0,on_planet='N',sector=$shipinfo[sector] WHERE ship_id=$shipinfo[tow]");
  			}
		$db->Execute("UPDATE $dbtables[ships] SET ship_destroyed ='Y', sector=0, tow=0 WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
            collect_bounty($planetinfo[owner],$playerinfo[player_id]);
        }
        else
        {
            db_kill_player($playerinfo[player_id],$playerinfo[currentship],$planetinfo[owner]);
            collect_bounty($planetinfo[owner],$playerinfo[player_id]);
        }
    }
    else
    {
		// ********************* Attacker survived ****************************
        $free_ore=0;
        $free_goods=0;
        $free_organics=0;
        $ship_salvage_rate=0;
        $ship_salvage=0;
        $planetrating = $ownershipinfo[hull] + $ownershipinfo[engines] + $ownershipinfo[computer] + $ownershipinfo[beams] + $ownershipinfo[torp_launchers] + $ownershipinfo[shields] + $ownershipinfo[armor];
        if($ownerinfo[rating]!=0)
        {
            $rating_change=($ownerinfo[rating]/abs($ownerinfo[rating]))*$planetrating*10;
        }
        else
        {
            $rating_change=-100;
        }
        echo "<CENTER><BR><B><FONT SIZE='+2'>$l_cmb_finalcombatstats</FONT></B><BR><BR>";
        $fighters_lost = $shipinfo[ship_fighters] - $attackerfighters;
        $l_cmb_youlostfighters = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_youlostfighters);
        $l_cmb_youlostfighters = str_replace("[cmb_playerinfo_ship_fighters]", $shipinfo[ship_fighters], $l_cmb_youlostfighters);
        echo "$l_cmb_youlostfighters<BR>";
        $armor_lost = $shipinfo[armour_pts] - $attackerarmor;
        $l_cmb_youlostarmorpoints = str_replace("[cmb_armor_lost]", $armor_lost, $l_cmb_youlostarmorpoints);
        $l_cmb_youlostarmorpoints = str_replace("[cmb_playerinfo_armour_pts]", $shipinfo[armour_pts], $l_cmb_youlostarmorpoints);
        $l_cmb_youlostarmorpoints = str_replace("[cmb_attackerarmor]", $attackerarmor, $l_cmb_youlostarmorpoints);
        echo "$l_cmb_youlostarmorpoints<BR>";
        $energy=$shipinfo[ship_energy];
        $energy_lost = $starting_energy - $shipinfo[ship_energy];
        $l_cmb_energyused = str_replace("[cmb_energy_lost]", $energy_lost, $l_cmb_energyused);
        $l_cmb_energyused = str_replace("[cmb_playerinfo_ship_energy]", $starting_energy, $l_cmb_energyused);
        echo "$l_cmb_energyused<BR></CENTER>";
        $db->Execute("UPDATE $dbtables[players] SET rating=rating-$rating_change WHERE player_id=$playerinfo[player_id]");
		$db->Execute("UPDATE $dbtables[ships] SET ship_energy=$energy,ship_fighters=ship_fighters-$fighters_lost, torps=torps-$attackertorps,armour_pts=armour_pts-$armor_lost WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
    }

    $result4 = $db->Execute("SELECT * FROM $dbtables[players] WHERE planet_id=$planetinfo[planet_id] AND on_planet='Y'");
    $shipsonplanet = $result4->RecordCount();

    if($planetshields < 1 && $planetfighters < 1 && $attackerarmor > 0 && $shipsonplanet == 0)
    {
		// ************************  Planet defeated ***********************************
        echo "<BR><BR><CENTER><FONT COLOR='GREEN'><B>$l_cmb_planetdefeated</b></FONT></CENTER><BR><BR>";
		// news
		$headline="Planetary Defeat!";
		$newstext=$playerinfo[character_name]." in the ship ".$shipinfo[ship_name]." defeated ".$ownerinfo[character_name]."s planet ".$planetinfo[name].". ";
		if ($playerinfo[score] < $ownerinfo[score]) {
			$newstext = $newstext . $playerinfo[character_name]." knew it would be a difficult battle but succeeded!";
		} else {
			$newstext = $newstext . $playerinfo[character_name]." crushed the weak.";
		}
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");
	
        if($min_value_capture != 0)
        {
            $playerscore = gen_score($playerinfo[player_id]);
            $playerscore *= $playerscore;

            $planetscore = $planetinfo[organics] * $organics_price + $planetinfo[ore] * $ore_price + $planetinfo[goods] * $goods_price + $planetinfo[energy] * $energy_price + $planetinfo[fighters] * $fighter_price + $planetinfo[torps] * $torpedo_price + $planetinfo[colonists] * $colonist_price + $planetinfo[credits];
            $planetscore = $planetscore * $min_value_capture / 100;

            //            echo "playerscore $playerscore, planetscore $planetscore";
            if($playerscore < $planetscore)
            {
                echo "<CENTER>$l_cmb_citizenswanttodie</CENTER><BR><BR>";
                $db->Execute("DELETE FROM $dbtables[planets] WHERE planet_id=$planetinfo[planet_id]");
                playerlog($ownerinfo[player_id], LOG_PLANET_DEFEATED_D, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
                adminlog(LOG_ADMIN_PLANETDEL, "$playerinfo[character_name]|$ownerinfo[character_name]|$playerinfo[sector]");
                gen_score($ownerinfo[player_id]);
            }
            else
            {
                $l_cmb_youmaycapture = str_replace("[cmb_planetinfo_planet_id]", $planetinfo[planet_id], $l_cmb_youmaycapture);
                echo "<CENTER><font color=red>$l_cmb_youmaycapture</font></CENTER><BR><BR>";
                playerlog($ownerinfo[player_id], LOG_PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
                gen_score($ownerinfo[player_id]);
				// Make sure that credits are reduced on the planet
                $update7a = $db->Execute("UPDATE $dbtables[planets] SET owner=0, fighters=0, torps=torps-$planettorps, base='N', defeated='Y',credits=(credits*(1-$ibank_paymentfee*5)) WHERE planet_id=$planetinfo[planet_id]");
            }
        }
        else
        {
            $l_cmb_youmaycapture2 = str_replace("[cmb_planetinfo_planet_id]", $planetinfo[planet_id], $l_cmb_youmaycapture2);
            echo "<CENTER>$l_cmb_youmaycapture2</CENTER><BR><BR>";
            playerlog($ownerinfo[player_id], LOG_PLANET_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
            gen_score($ownerinfo[player_id]);
            $update7a = $db->Execute("UPDATE $dbtables[planets] SET owner=0,fighters=0, torps=torps-$planettorps, base='N', defeated='Y', credits=(credits*(1-$ibank_paymentfee*5)) WHERE planet_id=$planetinfo[planet_id]");
        }
        calc_ownership($planetinfo[sector_id]);
    }
    else if($attackerarmor < 1)
    {
		// *****************************   Planet not defeated and attacker blew up ************************
        echo "<BR><BR><CENTER><FONT COLOR='#6098F8'><B>$l_cmb_planetnotdefeated</B></FONT></CENTER><BR><BR>";
        if ($debug)
            echo "<BR><BR>$l_cmb_planetstatistics<BR><BR>";
        $fighters_lost = $planetinfo[fighters] - $planetfighters;
        $l_cmb_fighterloststat = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetinfo_fighters]", $planetinfo[fighters], $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fighterloststat);
        if ($debug)
            echo "$l_cmb_fighterloststat<BR>";
        $energy=$planetinfo[energy];
        if ($debug)
            echo "$l_cmb_energyleft: $planetinfo[energy]<BR>";
        playerlog($ownerinfo[player_id], LOG_PLANET_NOT_DEFEATED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]|".NUMBER($free_ore)."|".NUMBER($free_organics)."|".NUMBER($free_goods)."|$ship_salvage_rate|".NUMBER($ship_salvage));
        gen_score($ownerinfo[player_id]);
        $update7b = $db->Execute("UPDATE $dbtables[planets] SET energy=$energy,fighters=fighters-$fighters_lost, torps=torps-$planettorps, ore=ore+$free_ore, goods=goods+$free_goods, organics=organics+$free_organics, credits=credits+$ship_salvage WHERE planet_id=$planetinfo[planet_id]");
        if ($debug)
            echo "<BR>Set: energy=$energy, fighters lost=$fighters_lost, torps=$planetinfo[torps], sectorid=$sectorinfo[sector_id]<BR>";
    } else {
		// *****************************   Planet not defeated and attacker survived ************************
        echo "<BR><BR><CENTER><FONT COLOR='#6098F8'><B>$l_cmb_planetnotdefeated</B></FONT></CENTER><BR><BR>";
        $fighters_lost = $planetinfo[fighters] - $planetfighters;
        $l_cmb_fighterloststat = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetinfo_fighters]", $planetinfo[fighters], $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fighterloststat);
        $energy=$planetinfo[energy];
        playerlog($ownerinfo[player_id], LOG_PLANET_SURVIVED, "$planetinfo[name]|$playerinfo[sector]|$playerinfo[character_name]");
        gen_score($ownerinfo[player_id]);
        $update7b = $db->Execute("UPDATE $dbtables[planets] SET energy=$energy,fighters=fighters-$fighters_lost, torps=torps-$planettorps WHERE planet_id=$planetinfo[planet_id]");
		// news
		$headline="Planet Attack Fails!";
		$newstext=$playerinfo[character_name]." in the ship ".$shipinfo[ship_name]." attacked ".$ownerinfo[character_name]."'s planet ".$planetinfo[name]." but the planet's citizens put up an unexpected defense and forced $playerinfo[character_name] to retreat! SUN will continue to report this story as the news breaks!";
		$newstext = addslashes($newstext);
		$player_id = $playerinfo[player_id];
		$news = $db->Execute("INSERT INTO $dbtables[news] (headline, newstext, user_id, date, news_type) VALUES ('$headline','$newstext','$player_id',NOW(), 'attack')");
 	}
    $update = $db->Execute("UPDATE $dbtables[players] SET turns=turns-1, turns_used=turns_used+1 WHERE player_id=$playerinfo[player_id]");
}
示例#4
0
function traderoute_new($traderoute_id)
{
    global $playerinfo, $color_line1, $color_line2, $color_header;
    global $num_traderoutes, $servertimezone;
    global $max_traderoutes_player;
    global $l_tdr_editerr, $l_tdr_maxtdr, $l_tdr_createnew, $l_tdr_editinga, $l_tdr_traderoute, $l_tdr_unnamed;
    global $l_tdr_cursector, $l_tdr_selspoint, $l_tdr_port, $l_tdr_planet, $l_tdr_none, $l_tdr_insector, $l_tdr_selendpoint;
    global $l_tdr_selmovetype, $l_tdr_realspace, $l_tdr_warp, $l_tdr_selcircuit, $l_tdr_oneway, $l_tdr_bothways, $l_tdr_create;
    global $l_tdr_modify, $l_tdr_returnmenu, $l_tdr_none;
    global $l_footer_until_update, $l_footer_players_on_1, $l_footer_players_on_2, $l_footer_one_player_on, $sched_ticks, $l_here;
    global $db;
    global $db_logging;
    $editroute = null;
    if (!empty($traderoute_id)) {
        $result = $db->Execute("SELECT * FROM {$db->prefix}traderoutes WHERE traderoute_id=?;", array($traderoute_id));
        db_op_result($db, $result, __LINE__, __FILE__, $db_logging);
        if (!$result || $result->EOF) {
            traderoute_die($l_tdr_editerr);
        }
        $editroute = $result->fields;
        if ($editroute['owner'] != $playerinfo['ship_id']) {
            traderoute_die($l_tdr_notowner);
        }
    }
    if ($num_traderoutes >= $max_traderoutes_player && is_null($editroute)) {
        traderoute_die("<p>{$l_tdr_maxtdr}<p>");
    }
    echo "<p><font size=3 color=blue><strong>";
    if (is_null($editroute)) {
        echo $l_tdr_createnew;
    } else {
        echo "{$l_tdr_editinga} ";
    }
    echo "{$l_tdr_traderoute}</strong></font><p>";
    // Get Planet info Corp and Personal
    $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE owner=? ORDER BY sector_id;", array($playerinfo['ship_id']));
    db_op_result($db, $result, __LINE__, __FILE__, $db_logging);
    $num_planets = $result->RecordCount();
    $i = 0;
    while (!$result->EOF) {
        $planets[$i] = $result->fields;
        if ($planets[$i]['name'] == "") {
            $planets[$i]['name'] = $l_tdr_unnamed;
        }
        $i++;
        $result->MoveNext();
    }
    $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE corp=? AND corp!=0 AND owner<>? ORDER BY sector_id;", array($playerinfo['team'], $playerinfo['ship_id']));
    db_op_result($db, $result, __LINE__, __FILE__, $db_logging);
    $num_corp_planets = $result->RecordCount();
    $i = 0;
    while (!$result->EOF) {
        $planets_corp[$i] = $result->fields;
        if ($planets_corp[$i]['name'] == "") {
            $planets_corp[$i]['name'] = $l_tdr_unnamed;
        }
        $i++;
        $result->MoveNext();
    }
    // Display Current Sector
    echo "{$l_tdr_cursector} {$playerinfo['sector']}<br>";
    // Start of form for starting location
    echo "\n        <form action=traderoute.php?command=create method=post>\n        <table border=0><tr>\n        <td align=right><font size=2><strong>{$l_tdr_selspoint} <br>&nbsp;</strong></font></td>\n        <tr>\n        <td align=right><font size=2>{$l_tdr_port} : </font></td>\n        <td><input type=radio name=\"ptype1\" value=\"port\"\n        ";
    if (is_null($editroute) || !is_null($editroute) && $editroute['source_type'] == 'P') {
        echo " checked";
    }
    echo "\n        ></td>\n        <td>&nbsp;&nbsp;<input type=text name=port_id1 size=20 align='center'\n        ";
    if (!is_null($editroute) && $editroute['source_type'] == 'P') {
        echo " value=\"{$editroute['source_id']}\"";
    }
    echo "\n        ></td>\n        </tr><tr>\n        ";
    // Personal Planet
    echo "\n        <td align=right><font size=2>Personal {$l_tdr_planet} : </font></td>\n        <td><input type=radio name=\"ptype1\" value=\"planet\"\n        ";
    if (!is_null($editroute) && $editroute['source_type'] == 'L') {
        echo " checked";
    }
    echo '
        ></td>
        <td>&nbsp;&nbsp;<select name=planet_id1>
        ';
    if ($num_planets == 0) {
        echo "<option value=none>{$l_tdr_none}</option>";
    } else {
        $i = 0;
        while ($i < $num_planets) {
            echo "<option ";
            if ($planets[$i]['planet_id'] == $editroute['source_id']) {
                echo "selected ";
            }
            echo "value=" . $planets[$i]['planet_id'] . ">" . $planets[$i]['name'] . " {$l_tdr_insector} " . $planets[$i]['sector_id'] . "</option>";
            $i++;
        }
    }
    // Corp Planet
    echo "\n        </tr><tr>\n        <td align=right><font size=2>Corporate {$l_tdr_planet} : </font></td>\n        <td><input type=radio name=\"ptype1\" value=\"corp_planet\"\n        ";
    if (!is_null($editroute) && $editroute['source_type'] == 'C') {
        echo " checked";
    }
    echo '
        ></td>
        <td>&nbsp;&nbsp;<select name=corp_planet_id1>
        ';
    if ($num_corp_planets == 0) {
        echo "<option value=none>{$l_tdr_none}</option>";
    } else {
        $i = 0;
        while ($i < $num_corp_planets) {
            echo "<option ";
            if ($planets_corp[$i]['planet_id'] == $editroute['source_id']) {
                echo "selected ";
            }
            echo "value=" . $planets_corp[$i]['planet_id'] . ">" . $planets_corp[$i]['name'] . " {$l_tdr_insector} " . $planets_corp[$i]['sector_id'] . "</option>";
            $i++;
        }
    }
    echo "\n        </select>\n        </tr>";
    // Begin Ending point selection
    echo "\n        <tr><td>&nbsp;\n        </tr><tr>\n        <td align=right><font size=2><strong>{$l_tdr_selendpoint} : <br>&nbsp;</strong></font></td>\n        <tr>\n        <td align=right><font size=2>{$l_tdr_port} : </font></td>\n        <td><input type=radio name=\"ptype2\" value=\"port\"\n        ";
    if (is_null($editroute) || !is_null($editroute) && $editroute['dest_type'] == 'P') {
        echo " checked";
    }
    echo '
        ></td>
        <td>&nbsp;&nbsp;<input type=text name=port_id2 size=20 align="center"
        ';
    if (!is_null($editroute) && $editroute['dest_type'] == 'P') {
        echo " value=\"{$editroute['dest_id']}\"";
    }
    echo "\n        ></td>\n        </tr>";
    // Personal Planet
    echo "\n        <tr>\n        <td align=right><font size=2>Personal {$l_tdr_planet} : </font></td>\n        <td><input type=radio name=\"ptype2\" value=\"planet\"\n        ";
    if (!is_null($editroute) && $editroute['dest_type'] == 'L') {
        echo " checked";
    }
    echo '
        ></td>
        <td>&nbsp;&nbsp;<select name=planet_id2>
        ';
    if ($num_planets == 0) {
        echo "<option value=none>{$l_tdr_none}</option>";
    } else {
        $i = 0;
        while ($i < $num_planets) {
            echo "<option ";
            if ($planets[$i]['planet_id'] == $editroute['dest_id']) {
                echo "selected ";
            }
            echo "value=" . $planets[$i]['planet_id'] . ">" . $planets[$i]['name'] . " {$l_tdr_insector} " . $planets[$i]['sector_id'] . "</option>";
            $i++;
        }
    }
    // Corp Planet
    echo "\n        </tr><tr>\n        <td align=right><font size=2>Corporate {$l_tdr_planet} : </font></td>\n        <td><input type=radio name=\"ptype2\" value=\"corp_planet\"\n        ";
    if (!is_null($editroute) && $editroute['dest_type'] == 'C') {
        echo " checked";
    }
    echo '
        ></td>
        <td>&nbsp;&nbsp;<select name=corp_planet_id2>
        ';
    if ($num_corp_planets == 0) {
        echo "<option value=none>{$l_tdr_none}</option>";
    } else {
        $i = 0;
        while ($i < $num_corp_planets) {
            echo "<option ";
            if ($planets_corp[$i]['planet_id'] == $editroute['dest_id']) {
                echo "selected ";
            }
            echo "value=" . $planets_corp[$i]['planet_id'] . ">" . $planets_corp[$i]['name'] . " {$l_tdr_insector} " . $planets_corp[$i]['sector_id'] . "</option>";
            $i++;
        }
    }
    echo "\n        </select>\n        </tr>";
    echo "\n        </select>\n        </tr><tr>\n        <td>&nbsp;\n        </tr><tr>\n        <td align=right><font size=2><strong>{$l_tdr_selmovetype} : </strong></font></td>\n        <td colspan=2 valign=top><font size=2><input type=radio name=\"move_type\" value=\"realspace\"\n        ";
    if (is_null($editroute) || !is_null($editroute) && $editroute['move_type'] == 'R') {
        echo " checked";
    }
    echo "\n        >&nbsp;{$l_tdr_realspace}&nbsp;&nbsp<font size=2><input type=radio name=\"move_type\" value=\"warp\"\n        ";
    if (!is_null($editroute) && $editroute['move_type'] == 'W') {
        echo " checked";
    }
    echo "\n        >&nbsp;{$l_tdr_warp}</font></td>\n        </tr><tr>\n        <td align=right><font size=2><strong>{$l_tdr_selcircuit} : </strong></font></td>\n        <td colspan=2 valign=top><font size=2><input type=radio name=\"circuit_type\" value=\"1\"\n        ";
    if (is_null($editroute) || !empty($editroute) && $editroute['circuit'] == '1') {
        echo " checked";
    }
    echo "\n        >&nbsp;{$l_tdr_oneway}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name=\"circuit_type\" value=\"2\"\n        ";
    if (!is_null($editroute) && $editroute['circuit'] == '2') {
        echo " checked";
    }
    echo "\n        >&nbsp;{$l_tdr_bothways}</font></td>\n        </tr><tr>\n        <td>&nbsp;\n        </tr><tr>\n        <td><td><td>\n        ";
    if (is_null($editroute)) {
        echo "<input type=submit value=\"{$l_tdr_create}\">";
    } else {
        echo "<input type=hidden name=editing value={$editroute['traderoute_id']}>";
        echo "<input type=submit value=\"{$l_tdr_modify}\">";
    }
    $l_tdr_returnmenu = str_replace("[here]", "<a href='traderoute.php'>" . $l_here . "</a>", $l_tdr_returnmenu);
    echo "\n        </table>\n        {$l_tdr_returnmenu}<br>\n        </form>\n        ";
    echo "<div style='text-align:left;'>\n";
    TEXT_GOTOMAIN();
    echo "</div>\n";
    include "footer.php";
    die;
}
示例#5
0
function planetcombat()
{
    global $playerinfo, $ownerinfo, $sectorinfo, $planetinfo, $torpedo_price, $colonist_price, $ore_price, $organics_price, $goods_price, $energy_price;
    global $planetbeams, $planetfighters, $planetshields, $planettorps, $attackerbeams, $attackerfighters, $attackershields, $upgrade_factor, $upgrade_cost;
    global $attackertorps, $attackerarmor, $torp_dmg_rate, $level_factor, $attackertorpdamage, $start_energy, $min_value_capture, $l_cmb_atleastoneturn;
    global $l_cmb_atleastoneturn, $l_cmb_shipenergybb, $l_cmb_shipenergyab, $l_cmb_shipenergyas, $l_cmb_shiptorpsbtl, $l_cmb_shiptorpsatl;
    global $l_cmb_planettorpdamage, $l_cmb_beams, $l_cmb_fighters, $l_cmb_shields, $l_cmb_torps;
    global $l_cmb_torpdamage, $l_cmb_armor, $l_cmb_you, $l_cmb_planet, $l_cmb_combatflow, $l_cmb_defender, $l_cmb_attackingplanet;
    global $l_cmb_youfireyourbeams, $l_cmb_defenselost, $l_cmb_defenselost2, $l_cmb_planetarybeams, $l_cmb_planetarybeams2;
    global $l_cmb_youdestroyedplanetshields, $l_cmb_beamsexhausted, $l_cmb_breachedyourshields, $l_cmb_destroyedyourshields;
    global $l_cmb_breachedyourarmor, $l_cmb_destroyedyourarmor, $l_cmb_torpedoexchangephase, $l_cmb_nofightersleft;
    global $l_cmb_youdestroyfighters, $l_cmb_planettorpsdestroy, $l_cmb_planettorpsdestroy2, $l_cmb_torpsbreachedyourarmor;
    global $l_cmb_planettorpsdestroy3, $l_cmb_youdestroyedallfighters, $l_cmb_youdestroyplanetfighters, $l_cmb_fightercombatphase;
    global $l_cmb_youdestroyedallfighters2, $l_cmb_youdestroyplanetfighters2, $l_cmb_allyourfightersdestroyed, $l_cmb_fightertofighterlost;
    global $l_cmb_youbreachedplanetshields, $l_cmb_shieldsremainup, $l_cmb_fighterswarm, $l_cmb_swarmandrepel, $l_cmb_engshiptoshipcombat;
    global $l_cmb_shipdock, $l_cmb_approachattackvector, $l_cmb_noshipsdocked, $l_cmb_yourshipdestroyed, $l_cmb_escapepod;
    global $l_cmb_finalcombatstats, $l_cmb_youlostfighters, $l_cmb_youlostarmorpoints, $l_cmb_energyused, $l_cmb_planetdefeated;
    global $l_cmb_citizenswanttodie, $l_cmb_youmaycapture, $l_cmb_planetnotdefeated, $l_cmb_planetstatistics;
    global $l_cmb_fighterloststat, $l_cmb_energyleft;
    global $db, $db_logging;
    if ($playerinfo['turns'] < 1) {
        echo $l_cmb_atleastoneturn . "<br><br>";
        TEXT_GOTOMAIN();
        ?>
</div></div>
<?php 
        include "footer.php";
        die;
    }
    // Planetary defense system calculation
    $planetbeams = calcplanetbeams();
    $planetfighters = $planetinfo['fighters'];
    $planetshields = calcplanetshields();
    $planettorps = calcplanettorps();
    // Attacking ship calculations
    $attackerbeams = NUM_BEAMS($playerinfo['beams']);
    $attackerfighters = $playerinfo['ship_fighters'];
    $attackershields = NUM_SHIELDS($playerinfo['shields']);
    $attackertorps = round(pow($level_factor, $playerinfo['torp_launchers'])) * 2;
    $attackerarmor = $playerinfo['armor_pts'];
    // Now modify player beams, shields and torpedos on available materiel
    $start_energy = $playerinfo['ship_energy'];
    // Beams
    if ($attackerbeams > $playerinfo['ship_energy']) {
        $attackerbeams = $playerinfo['ship_energy'];
    }
    $playerinfo['ship_energy'] = $playerinfo['ship_energy'] - $attackerbeams;
    // Shields
    if ($attackershields > $playerinfo['ship_energy']) {
        $attackershields = $playerinfo['ship_energy'];
    }
    $playerinfo['ship_energy'] = $playerinfo['ship_energy'] - $attackershields;
    // Torpedos
    if ($attackertorps > $playerinfo['torps']) {
        $attackertorps = $playerinfo['torps'];
    }
    $playerinfo['torps'] = $playerinfo['torps'] - $attackertorps;
    // Setup torp damage rate for both Planet and Ship
    $planettorpdamage = $torp_dmg_rate * $planettorps;
    $attackertorpdamage = $torp_dmg_rate * $attackertorps;
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>STATS</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    // Begin actual combat calculations
    $planetdestroyed = 0;
    $attackerdestroyed = 0;
    echo "<br/>You are now engaging the planet in sector " . $playerinfo[sector] . "!<br/><br/>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>";
    echo "<td width=\"50%\">You</td>";
    echo "<td width=\"50%\">Planet</td>";
    echo "</tr>";
    echo "<tr><td colspan=\"2\"><span class=\"table_word_yellow\">Firing Your Beams</span></td></tr>";
    if ($planetfighters > 0 && $attackerbeams > 0) {
        if ($attackerbeams > $planetfighters) {
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary defense lost " . $planetfighters . " fighters to your beams</span></td></tr>";
            $attackerbeams = $attackerbeams - $planetfighters;
            $planetfighters = 0;
        } else {
            $planetfighters = $planetfighters - $attackerbeams;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary defense lost " . $planetfighters . " fighters, but there are more coming!</span></td></tr>";
            $attackerbeams = 0;
        }
    }
    if ($attackerfighters > 0 && $planetbeams > 0) {
        // If there are more beams on the planet than attacker has fighters
        if ($planetbeams > round($attackerfighters / 2)) {
            // Half the attacker fighters
            $temp = round($attackerfighters / 2);
            // Attacker loses half his fighters
            $lost = $attackerfighters - $temp;
            // Set attacker fighters to 1/2 it's original value
            $attackerfighters = $temp;
            // Subtract half the attacker fighters from available planetary beams
            $planetbeams = $planetbeams - $lost;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary beams destroy " . $temp . " of your fighters</span></td></tr>";
        } else {
            $attackerfighters = $attackerfighters - $planetbeams;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary beams destroy " . $planetbeams . " of your fighters</span></td></tr>";
            $planetbeams = 0;
        }
    }
    if ($attackerbeams > 0) {
        if ($attackerbeams > $planetshields) {
            $attackerbeams = $attackerbeams - $planetshields;
            $planetshields = 0;
            echo "<tr><td><span class=\"table_word_green\">Your beams have destroyed the planetary shields</span></td><td></td></tr>";
        } else {
            echo "<tr><td><span class=\"table_word_orange\">You destroy " . $attackerbeams . " planetary shields before your beams are exhausted</span></td><td></td></tr>";
            $planetshields = $planetshields - $attackerbeams;
            $attackerbeams = 0;
        }
    }
    if ($planetbeams > 0) {
        if ($planetbeams > $attackershields) {
            $planetbeams = $planetbeams - $attackershields;
            $attackershields = 0;
            echo "<tr><td></td><td><span class=\"table_word_red\">Planetary beams have breached your shields</span></td></tr>";
        } else {
            $attackershields = $attackershields - $planetbeams;
            echo "<tr><td></td><td><span class=\"table_word_red\">Planetary beams have destroyed " . $planetbeams . " of your shields</span></td></tr>";
            $planetbeams = 0;
        }
    }
    if ($planetbeams > 0) {
        if ($planetbeams > $attackerarmor) {
            $attackerarmor = 0;
            echo "<tr><td></td><td><span class=\"table_word_red\">Planetary beams have breached your armor</span></td></tr>";
        } else {
            $attackerarmor = $attackerarmor - $planetbeams;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary beams have destroyed " . $planetbeams . " points of armor</span></td></tr>";
        }
    }
    if ($planetshields > 0) {
    } else {
        echo "<tr><td></td><td><span class=\"table_word_green\">Planets shields have been breached!</span></td></tr>";
    }
    echo "</tbody></table></div>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>UPDATE</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>";
    echo "<td width=\"50%\">You</td>";
    echo "<td width=\"50%\">Planet</td>";
    echo "</tr>";
    echo "<tr><td colspan=\"2\"><span class=\"table_word_yellow\">Torpedo Exchange Phase</span></td></tr>";
    if ($planetfighters > 0 && $attackertorpdamage > 0) {
        if ($attackertorpdamage > $planetfighters) {
            echo "<tr><td>Your torpedos destroy " . $planetfighters . " planetary fighters, no fighters are left</td><td></td></tr>";
            $attackertorpdamage = $attackertorpdamage - $planetfighters;
            $planetfighters = 0;
        } else {
            $planetfighters = $planetfighters - $attackertorpdamage;
            echo "<tr><td><span class=\"table_word_orange\">Your torpedos destroy " . $attackertorpdamage . " planetary fighters</span></td><td></td></tr>";
            $attackertorpdamage = 0;
        }
    }
    if ($attackerfighters > 0 && $planettorpdamage > 0) {
        if ($planettorpdamage > round($attackerfighters / 2)) {
            $temp = round($attackerfighters / 2);
            $lost = $attackerfighters - $temp;
            $attackerfighters = $temp;
            $planettorpdamage = $planettorpdamage - $lost;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary torpedos destroy " . $temp . " of your fighters</span></td></tr>";
        } else {
            $attackerfighters = $attackerfighters - $planettorpdamage;
            echo "<tr><td></td><td><span class=\"table_word_orange\">Planetary torpedos destroy " . $planettorpdamage . " of your fighters</span></td></tr>";
            $planettorpdamage = 0;
        }
    }
    if ($planettorpdamage > 0) {
        if ($planettorpdamage > $attackerarmor) {
            $attackerarmor = 0;
            echo "<tr><td><span class=\"table_word_red\">Planetary torpedos have breached your armor</span></td><td></td></tr>";
        } else {
            $attackerarmor = $attackerarmor - $planettorpdamage;
            echo "<tr><td><span class=\"table_word_orange\">Planetary torpedos have destroyed " . $planettorpdamage . " points of armor</span></td><td></td></tr>";
        }
    }
    if ($attackertorpdamage > 0 && $planetfighters > 0) {
        $planetfighters = $planetfighters - $attackertorpdamage;
        if ($planetfighters < 0) {
            $planetfighters = 0;
            echo "<tr><td><span class=\"table_word_green\">Your torpedos have destroyed all the planetary fighters</span></td><td></td></tr>";
        } else {
            echo "<tr><td><span class=\"table_word_orange\">Your torpedos destroy " . $attackertorpdamage . " planetary fighters</span></td><td></td></tr>";
        }
    } else {
        echo "<tr><td></td><td><span class=\"table_word_green\">Planet has no torpedoes</span></td></tr>";
    }
    echo "</tbody></table></div>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>UPDATE</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>";
    echo "<td width=\"50%\">You</td>";
    echo "<td width=\"50%\">Planet</td>";
    echo "</tr>";
    echo "<tr><td colspan=\"2\"><span class=\"table_word_yellow\">Fighter Combat Phase</span></td></tr>";
    if ($attackerfighters > 0 && $planetfighters > 0) {
        if ($attackerfighters > $planetfighters) {
            echo "<tr><td><span class=\"table_word_green\">Your fighters have destroyed all the planetary fighters</span></td><td></td></tr>";
            $tempplanetfighters = 0;
        } else {
            echo "<tr><td><span class=\"table_word_orange\">Your fighters have destroyed " . $attackerfighters . " planetary fighters</span></td><td></td></tr>";
            $tempplanetfighters = $planetfighters - $attackerfighters;
        }
        if ($planetfighters > $attackerfighters) {
            echo "<tr><td><span class=\"table_word_red\">All your fighters were destroyed</span></td><td></td></tr>";
            $tempplayfighters = 0;
        } else {
            $tempplayfighters = $attackerfighters - $planetfighters;
            echo "<tr><td><span class=\"table_word_orange\">You lost " . $planetfighters . " fighters in fighter to fighter combat</span></td><td></td></tr>";
        }
        $attackerfighters = $tempplayfighters;
        $planetfighters = $tempplanetfighters;
    }
    if ($attackerfighters > 0 && $planetshields > 0) {
        if ($attackerfighters > $planetshields) {
            $attackerfighters = $attackerfighters - round($planetshields / 2);
            echo "<tr><td><span class=\"table_word_green\">Your fighters have breached the planetary shields</span></td><td></td></tr>";
            $planetshields = 0;
        } else {
            echo "<tr><td></td><td><span class=\"table_word_orange\">Your fighters destroyed " . $attackerfighters . " planetary shields, but they remain up</span></td></tr>";
            $planetshields = $planetshields - $attackerfighters;
        }
    }
    if ($planetfighters > 0) {
        if ($planetfighters > $attackerarmor) {
            $attackerarmor = 0;
            echo "<tr><td><span class=\"table_word_red\">Planetary fighters swarm your ship, your armor has been breached</span></td><td></td></tr>";
        } else {
            $attackerarmor = $attackerarmor - $planetfighters;
            echo "<tr><td><span class=\"table_word_orange\">Planetary fighters swarm your ship, but your armor repels them</span></td><td></td></tr>";
        }
    } else {
        echo "<tr><td></td><td><span class=\"table_word_green\">Planet has no fighters</span></td></tr>";
    }
    echo "</tbody></table></div>";
    /*
    Build table
    */
    ?>
	<div class="general-table-container">
	<?php 
    echo "<table><tbody>";
    echo "<tr>\n\t<td>UPDATE</td>\n    <td>Beams</td>\n    <td>Fighters</td>\n    <td>Shields</td>\n    <td>Torpedoes Warhead Strength</td>\n    <td>Armour</td>\n    </tr><tr>\n    <td><span class=\"table_word_blue\">Your Ship</span></td>\n    <td>{$attackerbeams}</td>\n    <td>{$attackerfighters}</td>\n    <td>{$attackershields}</td>\n    <td>{$attackertorpdamage}</td>\n    <td>{$attackerarmor}</td>\n    </tr><tr>\n    <td><span class=\"table_word_orange\">The Planet</span></td>\n    <td>{$planetbeams}</td>\n    <td>{$planetfighters}</td>\n    <td>{$planetshields}</td>\n    <td>{$planettorpdamage}</td>\n    <td>N/A</td>\n    </tr>";
    echo "</tbody></table></div>";
    // Send each docked ship in sequence to attack agressor
    $result4 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE planet_id={$planetinfo['planet_id']} AND on_planet='Y'");
    db_op_result($db, $result4, __LINE__, __FILE__, $db_logging);
    $shipsonplanet = $result4->RecordCount();
    if ($shipsonplanet > 0) {
        echo "<br/>There are " . $shipsonplanet . " ships docked at Spacedock!<br>Engaging in Ship to Ship combat.<br/><br/>";
        while (!$result4->EOF) {
            $onplanet = $result4->fields;
            if ($attackerfighters < 0) {
                $attackerfighters = 0;
            }
            if ($attackertorps < 0) {
                $attackertorps = 0;
            }
            if ($attackershields < 0) {
                $attackershields = 0;
            }
            if ($attackerbeams < 0) {
                $attackerbeams = 0;
            }
            if ($attackerarmor < 1) {
                break;
            }
            echo "<br/>" . $onplanet[ship_name] . " is approaching on an attack vector<br/>";
            /*ENGAGE EACH SHIP ONE BY ONE!!!*/
            shiptoship($onplanet['ship_id']);
            $result4->MoveNext();
        }
    } else {
        /*no SHIPS on the planet, noting to worry about*/
    }
    if ($attackerarmor < 1) {
        $free_ore = round($playerinfo['ship_ore'] / 2);
        $free_organics = round($playerinfo['ship_organics'] / 2);
        $free_goods = round($playerinfo['ship_goods'] / 2);
        $ship_value = $upgrade_cost * (round(pow($upgrade_factor, $playerinfo['hull'])) + round(pow($upgrade_factor, $playerinfo['engines'])) + round(pow($upgrade_factor, $playerinfo['power'])) + round(pow($upgrade_factor, $playerinfo['computer'])) + round(pow($upgrade_factor, $playerinfo['sensors'])) + round(pow($upgrade_factor, $playerinfo['beams'])) + round(pow($upgrade_factor, $playerinfo['torp_launchers'])) + round(pow($upgrade_factor, $playerinfo['shields'])) + round(pow($upgrade_factor, $playerinfo['armor'])) + round(pow($upgrade_factor, $playerinfo['cloak'])));
        $ship_salvage_rate = mt_rand(0, 10);
        $ship_salvage = $ship_value * $ship_salvage_rate / 100;
        echo "<br><center><font size='+2' COLOR='red'>{$l_cmb_yourshipdestroyed}</font></center><br>";
        if ($playerinfo['dev_escapepod'] == "Y") {
            echo "<center><font color='white'>{$l_cmb_escapepod}</font></center><br><br>";
            $resx = $db->Execute("UPDATE {$db->prefix}ships SET hull=0,engines=0,power=0,sensors=0,computer=0,beams=0,torp_launchers=0,torps=0,armor=0,armor_pts=100,cloak=0,shields=0,sector=0,ship_organics=0,ship_ore=0,ship_goods=0,ship_energy={$start_energy},ship_colonists=0,ship_fighters=100,dev_warpedit=0,dev_genesis=0,dev_beacon=0,dev_emerwarp=0,dev_escapepod='N',dev_fuelscoop='N',dev_minedeflector=0,on_planet='N',dev_lssd='N' WHERE ship_id={$playerinfo['ship_id']}");
            db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
            collect_bounty($planetinfo['owner'], $playerinfo['ship_id']);
        } else {
            db_kill_player($playerinfo['ship_id']);
            collect_bounty($planetinfo['owner'], $playerinfo['ship_id']);
        }
    } else {
        $free_ore = 0;
        $free_goods = 0;
        $free_organics = 0;
        $ship_salvage_rate = 0;
        $ship_salvage = 0;
        $planetrating = $ownerinfo['hull'] + $ownerinfo['engines'] + $ownerinfo['computer'] + $ownerinfo['beams'] + $ownerinfo['torp_launchers'] + $ownerinfo['shields'] + $ownerinfo['armor'];
        if ($ownerinfo['rating'] != 0) {
            $rating_change = $ownerinfo['rating'] / abs($ownerinfo['rating']) * $planetrating * 10;
        } else {
            $rating_change = -100;
        }
        echo "<br/>Final Combat Stats<br/><br/>";
        $fighters_lost = $playerinfo['ship_fighters'] - $attackerfighters;
        echo "You lost " . $fighters_lost . " out of " . $playerinfo['ship_fighters'] . " total fighters.<br/>";
        $armor_lost = $playerinfo['armor_pts'] - $attackerarmor;
        echo "You lost " . $armor_lost . " out of " . $playerinfo['armor_pts'] . " total armor points, you have " . $attackerarmor . " points remaining.<br/>";
        $energy = $playerinfo['ship_energy'];
        $energy_lost = $start_energy - $playerinfo['ship_energy'];
        echo "You used " . $energy_lost . " energy, from a total of " . $start_energy . " energy.<br/>";
        $resx = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy={$energy},ship_fighters=ship_fighters-{$fighters_lost}, torps=torps-{$attackertorps},armor_pts=armor_pts-{$armor_lost}, rating=rating-{$rating_change} WHERE ship_id={$playerinfo['ship_id']}");
        db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
    }
    $result4 = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE planet_id={$planetinfo['planet_id']} AND on_planet='Y'");
    db_op_result($db, $result4, __LINE__, __FILE__, $db_logging);
    $shipsonplanet = $result4->RecordCount();
    #################
    ### LOG AND UPDATE THE STATS
    ##################
    if ($planetshields < 1 && $planetfighters < 1 && $attackerarmor > 0 && $shipsonplanet == 0) {
        echo "<br/><br/><span class=\"table_word_green\">Planet defeated</span><br/><br/>";
        // Patch to stop players dumping credits for other players.
        $self_tech = get_avg_tech($playerinfo);
        $target_tech = round(get_avg_tech($ownerinfo));
        $roll = mt_rand(0, (int) $target_tech);
        if ($roll > $self_tech) {
            // Reset Planet Assets.
            $sql = "UPDATE {$db->prefix}planets ";
            $sql .= "SET organics = '0', ore = '0', goods = '0', energy = '0', colonists = '2', credits = '0', fighters = '0', torps = '0', corp = '0', base = 'N', sells = 'N', prod_organics = '20', prod_ore = '20', prod_goods = '20', prod_energy = '20', prod_fighters = '10', prod_torp = '10' ";
            $sql .= "WHERE `dev_planets`.`planet_id` ={$planetinfo['planet_id']} LIMIT 1;";
            $resx = $db->Execute($sql);
            db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
            echo "<div style='text-align:center; font-size:18px; color:#f00;'>The planet become unstable due to not being looked after, and all life and assets have been destroyed.</div>\n";
        }
        if ($min_value_capture != 0) {
            $playerscore = gen_score($playerinfo['ship_id']);
            $playerscore *= $playerscore;
            $planetscore = $planetinfo['organics'] * $organics_price + $planetinfo['ore'] * $ore_price + $planetinfo['goods'] * $goods_price + $planetinfo['energy'] * $energy_price + $planetinfo['fighters'] * $fighter_price + $planetinfo['torps'] * $torpedo_price + $planetinfo['colonists'] * $colonist_price + $planetinfo['credits'];
            $planetscore = $planetscore * $min_value_capture / 100;
            if ($playerscore < $planetscore) {
                echo "The citizens of this planet have decided they'd rather die than serve a pathetic ruler like you. They use a laser drill to dig a hole to the planet's core. You barely have time to escape into orbit before the whole planet is reduced to a ball of molten lava.<br/><br/>";
                $resx = $db->Execute("DELETE FROM {$db->prefix}planets WHERE planet_id={$planetinfo['planet_id']}");
                db_op_result($db, $resx, __LINE__, __FILE__, $db_logging);
                playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_DEFEATED_D, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}");
                adminlog($db, LOG_ADMIN_PLANETDEL, "{$playerinfo['character_name']}|{$ownerinfo['character_name']}|{$playerinfo['sector']}");
                gen_score($ownerinfo['ship_id']);
            } else {
                echo "You may <a href='planet.php?planet_id=", $planetinfo['planet_id'] . "&amp;command=capture'>capture</a> the planet or just leave it undefended.<br><br>";
                playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_DEFEATED, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}");
                gen_score($ownerinfo['ship_id']);
                $update7a = $db->Execute("UPDATE {$db->prefix}planets SET owner=0, fighters=0, torps=torps-{$planettorps}, base='N', defeated='Y' WHERE planet_id={$planetinfo['planet_id']}");
                db_op_result($db, $update7a, __LINE__, __FILE__, $db_logging);
            }
        } else {
            echo "You may <a href='planet.php?planet_id=", $planetinfo['planet_id'] . "&amp;command=capture'>capture</a> the planet or just leave it undefended.<br><br>";
            playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_DEFEATED, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}");
            gen_score($ownerinfo['ship_id']);
            $update7a = $db->Execute("UPDATE {$db->prefix}planets SET owner=0,fighters=0, torps=torps-{$planettorps}, base='N', defeated='Y' WHERE planet_id={$planetinfo['planet_id']}");
            db_op_result($db, $update7a, __LINE__, __FILE__, $db_logging);
        }
        calc_ownership($planetinfo['sector_id']);
    } else {
        echo "<br><br><span class=\"table_word_red\">Planet Not Defeated</span><br><br>";
        $fighters_lost = $planetinfo['fighters'] - $planetfighters;
        $l_cmb_fighterloststat = str_replace("[cmb_fighters_lost]", $fighters_lost, $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetinfo_fighters]", $planetinfo['fighters'], $l_cmb_fighterloststat);
        $l_cmb_fighterloststat = str_replace("[cmb_planetfighters]", $planetfighters, $l_cmb_fighterloststat);
        $energy = $planetinfo['energy'];
        playerlog($db, $ownerinfo['ship_id'], LOG_PLANET_NOT_DEFEATED, "{$planetinfo['name']}|{$playerinfo['sector']}|{$playerinfo['character_name']}|{$free_ore}|{$free_organics}|{$free_goods}|{$ship_salvage_rate}|{$ship_salvage}");
        gen_score($ownerinfo['ship_id']);
        $update7b = $db->Execute("UPDATE {$db->prefix}planets SET energy={$energy},fighters=fighters-{$fighters_lost}, torps=torps-{$planettorps}, ore=ore+{$free_ore}, goods=goods+{$free_goods}, organics=organics+{$free_organics}, credits=credits+{$ship_salvage} WHERE planet_id={$planetinfo['planet_id']}");
        db_op_result($db, $update7b, __LINE__, __FILE__, $db_logging);
    }
    $update = $db->Execute("UPDATE {$db->prefix}ships SET turns=turns-1, turns_used=turns_used+1 WHERE ship_id={$playerinfo['ship_id']}");
    db_op_result($db, $update, __LINE__, __FILE__, $db_logging);
}
示例#6
0
function shipyard_die($error_msg)
{
  global $l_footer_until_update, $l_footer_players_on_1, $l_footer_players_on_2, $l_footer_one_player_on, $sched_ticks;
  echo "<p>$error_msg<p>";

  TEXT_GOTOMAIN();
  include("footer.php");
  die();
}
示例#7
0
function zoneedit_die($error_msg)
{
  echo "<p>$error_msg<p>";

  TEXT_GOTOMAIN();
  include("footer.php");
  die();
}