コード例 #1
0
function shipping_distance($start, $dest)
{
  global $playerinfo;
  global $shipinfo;
  global $level_factor;
  global $db, $dbtables;

  $retvalue[triptime] = 0;
  $query = $db->Execute("SELECT * FROM $dbtables[universe] WHERE sector_id=$start");
  $start = $query->fields;
  $query = $db->Execute("SELECT * FROM $dbtables[universe] WHERE sector_id=$dest");
  $dest = $query->fields;

  if($start[sector_id] == $dest[sector_id])
  {
    return 1;
  }

  $distance=calc_dist($start,$dest);
  if($distance<1) {
    $distance = 1;
    // TODO: The query failed. What now?
  }

  $shipspeed = mypw($level_factor, $shipinfo[engines]);
  $triptime = round($distance / $shipspeed);

  if(!$triptime && $destination != $playerinfo[sector])
    $triptime = 1;

  $triptime+=1;
  return $triptime;
}
コード例 #2
0
<?

  if (preg_match("/sched_IGB.php/i", $PHP_SELF)) {
      echo "You can not access this file directly!";
      die();
  }
  if (empty($multiplier)) {
  	$multiplier = 1;
  } 
  $exponinter = mypw($ibank_interest + 1, $multiplier);
  $expoloan = mypw($ibank_loaninterest + 1, $multiplier);

  //echo "<B>IBANK</B><p>";
  $igb_time=time();

  //echo "CHECKING FOR DELINQUENT LOANS<BR>";
  // Start to collect on loans
  $IGB_crate = 2880;
  $ctime=time(); // Debt collection time
  $res = $db->Execute("SELECT player_id, balance, loan, UNIX_TIMESTAMP(loantime) as epoch FROM $dbtables[ibank_accounts] WHERE loan>0");
  while(!$res->EOF)
  {
    $account=$res->fields;
	$difftime = ($ctime - $account[epoch])/60;
	//echo "Loan unpaid for $difftime minutes<br>";
	if ( $difftime > $IGB_crate) {
		//echo "Delinquent loan: $account[player_id] owes ".NUMBER($account[loan])."<br>";
		$res2 = $db->Execute("SELECT * from $dbtables[players] WHERE player_id=$account[player_id]");
		$playerinfo = $res2->fields;
		$logentry = "";
		$newsentry = "";
コード例 #3
0
ファイル: attack.php プロジェクト: antt1995/starkicktraders
          }
          if($free_holds > $free_organics)
          {
            $salv_organics=$free_organics;
            $free_holds=$free_holds-$free_organics;
          }
          elseif($free_holds > 0)
          {
            $salv_organics=$free_holds;
            $free_holds=0;
          }
          else
          {
            $salv_organics=0;
          }
          $ship_value=$upgrade_cost*(floor(mypw($upgrade_factor, $shipinfo[hull]))+floor(mypw($upgrade_factor, $shipinfo[engines]))+floor(mypw($upgrade_factor, $shipinfo[power]))+floor(mypw($upgrade_factor, $shipinfo[computer]))+floor(mypw($upgrade_factor, $shipinfo[sensors]))+floor(mypw($upgrade_factor, $shipinfo[beams]))+floor(mypw($upgrade_factor, $shipinfo[torp_launchers]))+floor(mypw($upgrade_factor, $shipinfo[shields]))+floor(mypw($upgrade_factor, $shipinfo[armour]))+floor(mypw($upgrade_factor, $shipinfo[cloak])));
          $ship_salvage_rate=rand(10,20);
          $ship_salvage=$ship_value*$ship_salvage_rate/100;
		  // Triple salvage if you were an outlaw
		  $result3 = $db->Execute ("SELECT amount FROM $dbtables[bounty] WHERE placed_by=0 AND bounty_on=$playerinfo[player_id]");
		  if (!$result3->EOF) {
		  	echo "Triple outlaw salvage bonus for $targetinfo[character_name]!<br>";
		  	$ship_salvage *=3;
		  }

          $l_att_salv=str_replace("[salv_ore]",NUMBER($salv_ore),$l_att_salv);
          $l_att_salv=str_replace("[salv_organics]",NUMBER($salv_organics),$l_att_salv);
          $l_att_salv=str_replace("[salv_goods]",NUMBER($salv_goods),$l_att_salv);
          $l_att_salv=str_replace("[ship_salvage_rate]",$ship_salvage_rate,$l_att_salv);
          $l_att_salv=str_replace("[ship_salvage]",NUMBER($ship_salvage),$l_att_salv);
          $l_att_salv=str_replace("[name]",$targetinfo[character_name],$l_att_salv);
コード例 #4
0
<?

  if (preg_match("/sched_planets.php/i", $PHP_SELF)) {
      echo "You can not access this file directly!";
      die();
  }

  $expoprod = mypw($colonist_reproduction_rate + 1, $multiplier);
  $expoprod *=$multiplier;

  $expocreds = mypw($interest_rate, $multiplier);
  $tech_prate = 0.02;
  echo "<B>PLANETS</B><p>";
  $temp_time=time();
  $planetupdate = "UPDATE $dbtables[planets] SET " .
    "organics=organics + GREATEST(((LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $organics_prate * prod_organics / 100.0 * $expoprod) - LEAST(colonists, $colonist_limit) * $colonist_production_rate * $organics_consumption * $expoprod,0)," .
    "ore=ore + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $ore_prate * prod_ore / 100.0 * $expoprod," .
    "goods=goods + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $goods_prate * prod_goods / 100.0 * $expoprod," .
    "energy=energy + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $energy_prate * prod_energy / 100.0 * $expoprod," .
    "colonists=LEAST(colonists + (colonists - (colonists * $starvation_death_rate)) * $colonist_reproduction_rate * $expoprod, $colonist_limit)," .
	"credits=credits * $expocreds + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $credits_prate * (100.0 - prod_organics - prod_ore - prod_goods - prod_energy - prod_fighters - prod_torp) / 100.0 * $expoprod," .
    "tech_level=tech_level + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $tech_prate * (100.0 - prod_organics - prod_ore - prod_goods - prod_energy - prod_fighters - prod_torp) / 100.0 * $expoprod";
	echo $planetupdate."<br>";
/*
$planetupdate = "UPDATE $dbtables[planets] SET " .
    "organics=organics + GREATEST(((LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $organics_prate * prod_organics / 100.0 * $expoprod) - LEAST(colonists, $colonist_limit) * $colonist_production_rate * $organics_consumption * $expoprod,0)," .
    "ore=ore + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $ore_prate * prod_ore / 100.0 * $expoprod," .
    "goods=goods + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $goods_prate * prod_goods / 100.0 * $expoprod," .
    "energy=energy + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $energy_prate * prod_energy / 100.0 * $expoprod," .
    "colonists=LEAST(colonists + (colonists - (colonists * $starvation_death_rate)) * $colonist_reproduction_rate * $expoprod, $colonist_limit)," .
    "credits=credits * $expocreds + (LEAST(colonists, $colonist_limit) * $colonist_production_rate) * $credits_prate * (100.0 - prod_organics - prod_ore - prod_goods - prod_energy - prod_fighters - prod_torp) / 100.0 * $expoprod";
コード例 #5
0
ファイル: shipyard.php プロジェクト: antt1995/starkicktraders
              break;
            }
          }
          
          $hull_bars = MakeBars($sship[minhull], $sship[maxhull]);
          $engines_bars = MakeBars($sship[minengines], $sship[maxengines]);
          $power_bars = MakeBars($sship[minpower], $sship[maxpower]);
          $computer_bars = MakeBars($sship[mincomputer], $sship[maxcomputer]);
          $sensors_bars = MakeBars($sship[minsensors], $sship[maxsensors]);
          $armour_bars = MakeBars($sship[minarmour], $sship[maxarmour]);
          $shields_bars = MakeBars($sship[minshields], $sship[maxshields]);
          $beams_bars = MakeBars($sship[minbeams], $sship[maxbeams]);
          $torp_launchers_bars = MakeBars($sship[mintorp_launchers], $sship[maxtorp_launchers]);
          $cloak_bars = MakeBars($sship[mincloak], $sship[maxcloak]);
		  $std_value = $upgrade_cost*(round(mypw($upgrade_factor, $sship[minhull]))+round(mypw($upgrade_factor, $sship[minengines]))+round(mypw($upgrade_factor, $sship[minpower]))+round(mypw($upgrade_factor, $sship[mincomputer]))+round(mypw($upgrade_factor, $sship[minsensors]))+round(mypw($upgrade_factor, $sship[minbeams]))+round(mypw($upgrade_factor, $sship[mintorp_launchers]))+round(mypw($upgrade_factor, $sship[minshields]))+round(mypw($upgrade_factor, $sship[minarmour]))+round(mypw($upgrade_factor, $sship[mincloak])));
		  $max_value = $upgrade_cost*(round(mypw($upgrade_factor, $sship[maxhull]))+round(mypw($upgrade_factor, $sship[maxengines]))+round(mypw($upgrade_factor, $sship[maxpower]))+round(mypw($upgrade_factor, $sship[maxcomputer]))+round(mypw($upgrade_factor, $sship[maxsensors]))+round(mypw($upgrade_factor, $sship[maxbeams]))+round(mypw($upgrade_factor, $sship[maxtorp_launchers]))+round(mypw($upgrade_factor, $sship[maxshields]))+round(mypw($upgrade_factor, $sship[maxarmour]))+round(mypw($upgrade_factor, $sship[maxcloak])));
		  //$bestprice = floor($std_value+sqrt($max_value))*1000;
          
          echo "<table border=0 cellpadding=5>" .
               "<tr><td valign=top>" .
               "<font size=4 color=white><b>$sship[name]</b></font><p>" .
               "<font size=2 color=silver><b>$sship[description]</b></font><p>" .
               "</td><td valign=top><img src=images/big$sship[image]></td></tr>" .
               "</table>" .
               "<table border=0 cellpadding=2>" .
               "<tr><td valign=top><font size=4 color=white><b>Ship Components Levels</b></font><br>&nbsp;</td></tr>" .
               "<tr><td><font size=2><b>Hull</b> ($sship[minhull]/$sship[maxhull])</td>" .
               "<td valign=bottom>$hull_bars</td></tr>" .
               "<tr><td><font size=2><b>Engines</b> ($sship[minengines]/$sship[maxengines])</td>" .
               "<td valign=bottom>$engines_bars</td></tr>" .
               "<tr><td><font size=2><b>Power</b> ($sship[minpower]/$sship[maxpower])</td>" .
コード例 #6
0
function NUM_SHIELDS($level_shields)
{
  global $level_factor;
  return round(mypw($level_factor, $level_shields) * 100);
}
コード例 #7
0
ファイル: combat.php プロジェクト: antt1995/starkicktraders
function shiptoship($target_id)
{
	global $upgrade_cost, $upgrade_factor;
    global $attackerbeams;
    global $attackerfighters;
    global $attackershields;
    global $attackertorps;
    global $attackerarmor;
    global $attackertorpdamage;
    global $start_energy;
    global $playerinfo;
    global $l_cmb_attackershields, $l_cmb_attackertorps, $l_cmb_attackerarmor, $l_cmb_attackertorpdamage;
    global $l_cmb_startingstats, $l_cmb_statattackerbeams, $l_cmb_statattackerfighters, $l_cmb_statattackershields, $l_cmb_statattackertorps;
    global $l_cmb_statattackerarmor, $l_cmb_statattackertorpdamage, $l_cmb_isattackingyou, $l_cmb_beamexchange, $l_cmb_beamsdestroy;
    global $l_cmb_beamsdestroy2, $l_cmb_nobeamsareleft, $l_cmb_beamshavenotarget, $l_cmb_fighterdestroyedbybeams, $l_cmb_beamsdestroystillhave;
    global $l_cmb_fighterunhindered, $l_cmb_youhavenofightersleft, $l_cmb_breachedsomeshields, $l_cmb_shieldsarehitbybeams, $l_cmb_nobeamslefttoattack;
    global $l_cmb_yourshieldsbreachedby, $l_cmb_yourshieldsarehit, $l_cmb_hehasnobeamslefttoattack, $l_cmb_yourbeamsbreachedhim;
    global $l_cmb_yourbeamshavedonedamage, $l_cmb_nobeamstoattackarmor, $l_cmb_yourarmorbreachedbybeams, $l_cmb_yourarmorhitdamaged;
    global $l_cmb_torpedoexchange, $l_cmb_hehasnobeamslefttoattackyou, $l_cmb_yourtorpsdestroy, $l_cmb_yourtorpsdestroy2;
    global $l_cmb_youhavenotorpsleft, $l_cmb_hehasnofighterleft, $l_cmb_torpsdestroyyou, $l_cmb_someonedestroyedfighters, $l_cmb_hehasnotorpsleftforyou;
    global $l_cmb_youhavenofightersanymore, $l_cmb_youbreachedwithtorps, $l_cmb_hisarmorishitbytorps, $l_cmb_notorpslefttoattackarmor;
    global $l_cmb_yourarmorbreachedbytorps, $l_cmb_yourarmorhitdmgtorps, $l_cmb_hehasnotorpsforyourarmor, $l_cmb_fightersattackexchange;
    global $l_cmb_enemylostallfighters, $l_cmb_helostsomefighters, $l_cmb_youlostallfighters, $l_cmb_youalsolostsomefighters, $l_cmb_hehasnofightersleftattack;
    global $l_cmb_younofightersattackleft, $l_cmb_youbreachedarmorwithfighters, $l_cmb_youhitarmordmgfighters, $l_cmb_youhavenofighterstoarmor;
    global $l_cmb_hasbreachedarmorfighters, $l_cmb_yourarmorishitfordmgby, $l_cmb_nofightersleftheforyourarmor, $l_cmb_hehasbeendestroyed;
    global $l_cmb_escapepodlaunched, $l_cmb_yousalvaged, $l_cmb_youdidntdestroyhim, $l_cmb_shiptoshipcombatstats;
    global $db, $dbtables;

    //$db->Execute("LOCK TABLES $dbtables[players] WRITE, $dbtables[ships] WRITE, $dbtables[universe] WRITE, $dbtables[zones] READ");
    $result2 = $db->Execute ("SELECT * FROM $dbtables[ships] WHERE ship_id=$target_id");
    $targetshipinfo=$result2->fields;
    $result2 = $db->Execute ("SELECT * FROM $dbtables[players] WHERE player_id=$targetshipinfo[player_id]");
    $targetinfo=$result2->fields;

    $targetbeams = NUM_BEAMS($targetshipinfo[beams]);
    if($targetbeams>$targetshipinfo[ship_energy])
    {
        $targetbeams=$targetshipinfo[ship_energy];
    }
    $targetshipinfo[ship_energy]=$targetshipinfo[ship_energy]-$targetbeams;
    $targetshields = NUM_SHIELDS($targetshipinfo[shields]);
    if($targetshields>$targetshipinfo[ship_energy])
    {
        $targetshields=$targetshipinfo[ship_energy];
    }
    $targetshipinfo[ship_energy]=$targetshipinfo[ship_energy]-$targetshields;

    $targettorpnum = round(mypw($level_factor,$targetshipinfo[torp_launchers]))*2;
    if($targettorpnum > $targetshipinfo[torps])
    {
        $targettorpnum = $targetshipinfo[torps];
    }
    $targettorpdmg = $torp_dmg_rate*$targettorpnum;
    $targetarmor = $targetshipinfo[armour_pts];
    $targetfighters = $targetshipinfo[ship_fighters];
    $targetdestroyed = 0;
    $playerdestroyed = 0;
    echo "-->$targetshipinfo[ship_name] $l_cmb_isattackingyou<BR><BR>";
	// ***************** BEAM EXCHANGE *************************
    echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_beamexchange</font><BR>";
    if($targetfighters > 0 && $attackerbeams > 0)
    {
        if($attackerbeams > round($targetfighters / 2))
        {
            $temp = round($targetfighters/2);
            $lost = $targetfighters-$temp;
            $targetfighters = $temp;
            $attackerbeams = $attackerbeams-$lost;
            $l_cmb_beamsdestroy = str_replace("[cmb_lost]", $lost, $l_cmb_beamsdestroy);
            echo "<-- $l_cmb_beamsdestroy<BR>";
        }
        else
        {
            $targetfighters = $targetfighters-$attackerbeams;
            $l_cmb_beamsdestroy2 = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_beamsdestroy2);
            echo "--> $l_cmb_beamsdestroy2<BR>";
            $attackerbeams = 0;
        }
    }
    elseif ($targetfighters > 0 && $attackerbeams < 1)
    echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_nobeamsareleft</font><BR>";
    else
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_beamshavenotarget</font><BR>";
    if($attackerfighters > 0 && $targetbeams > 0)
    {
        if($targetbeams > round($attackerfighters / 2))
        {
            $temp=round($attackerfighters/2);
            $lost=$attackerfighters-$temp;
            $attackerfighters=$temp;
            $targetbeams=$targetbeams-$lost;
            $l_cmb_fighterdestroyedbybeams = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_fighterdestroyedbybeams);
            $l_cmb_fighterdestroyedbybeams = str_replace("[cmb_lost]", $lost, $l_cmb_fighterdestroyedbybeams);
            echo "--> $l_cmb_fighterdestroyedbybeams";
        }
        else
        {
            $attackerfighters=$attackerfighters-$targetbeams;
            $l_cmb_beamsdestroystillhave = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_beamsdestroystillhave);
            $l_cmb_beamsdestroystillhave = str_replace("[cmb_targetbeams]", $targetbeams, $l_cmb_beamsdestroystillhave);
            $l_cmb_beamsdestroystillhave = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_beamsdestroystillhave);
            echo "<-- $l_cmb_beamsdestroystillhave<BR>";
            $targetbeams=0;
        }
    }
    elseif ($attackerfighters > 0 && $targetbeams < 1)
    echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_fighterunhindered</font><BR>";
    else
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_youhavenofightersleft</font><BR>";
    if($attackerbeams > 0)
    {
        if($attackerbeams > $targetshields)
        {
            $attackerbeams=$attackerbeams-$targetshields;
            $targetshields=0;
            $l_cmb_breachedsomeshields = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_breachedsomeshields);
            echo "<-- $l_cmb_breachedsomeshields<BR>";
        }
        else
        {
            $l_cmb_shieldsarehitbybeams = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_shieldsarehitbybeams);
            $l_cmb_shieldsarehitbybeams = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_shieldsarehitbybeams);
            echo "$l_cmb_shieldsarehitbybeams<BR>";
            $targetshields=$targetshields-$attackerbeams;
            $attackerbeams=0;
        }
    }
    else
    {
        $l_cmb_nobeamslefttoattack = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_nobeamslefttoattack);
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_nobeamslefttoattack</font><BR>";
    }
    if($targetbeams > 0)
    {
        if($targetbeams > $attackershields)
        {
            $targetbeams=$targetbeams-$attackershields;
            $attackershields=0;
            $l_cmb_yourshieldsbreachedby = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourshieldsbreachedby);
            echo "--> $l_cmb_yourshieldsbreachedby<BR>";
        }
        else
        {
            $l_cmb_yourshieldsarehit = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourshieldsarehit);
            $l_cmb_yourshieldsarehit = str_replace("[cmb_targetbeams]", $targetbeams, $l_cmb_yourshieldsarehit);
            echo "<-- $l_cmb_yourshieldsarehit<BR>";
            $attackershields=$attackershields-$targetbeams;
            $targetbeams=0;
        }
    }
    else
    {
        $l_cmb_hehasnobeamslefttoattack = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnobeamslefttoattack);
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_hehasnobeamslefttoattack</font><BR>";
    }
    if($attackerbeams > 0)
    {
        if($attackerbeams > $targetarmor)
        {
            $targetarmor=0;
            $l_cmb_yourbeamsbreachedhim = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourbeamsbreachedhim);
            echo "--> $l_cmb_yourbeamsbreachedhim<BR>";
        }
        else
        {
            $targetarmor=$targetarmor-$attackerbeams;
            $l_cmb_yourbeamshavedonedamage = str_replace("[cmb_attackerbeams]", $attackerbeams, $l_cmb_yourbeamshavedonedamage);
            $l_cmb_yourbeamshavedonedamage = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourbeamshavedonedamage);
            echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_yourbeamshavedonedamage</font><BR>";
        }
    }
    else
    {
        $l_cmb_nobeamstoattackarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_nobeamstoattackarmor);
        echo "<FONT SIZE='+2' COLOR='RED'>$l_cmb_nobeamstoattackarmor</font><BR>";
    }
    if($targetbeams > 0)
    {
        if($targetbeams > $attackerarmor)
        {
            $attackerarmor=0;
            $l_cmb_yourarmorbreachedbybeams = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorbreachedbybeams);
            echo "--> $l_cmb_yourarmorbreachedbybeams<BR>";
        }
        else
        {
            $attackerarmor=$attackerarmor-$targetbeams;
            $l_cmb_yourarmorhitdamaged = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorhitdamaged);
            $l_cmb_yourarmorhitdamaged = str_replace("[cmb_targetbeams]", $targetbeams, $l_cmb_yourarmorhitdamaged);
            echo "<-- $l_cmb_yourarmorhitdamaged<BR>";
        }
    }
    else
    {
        $l_cmb_hehasnobeamslefttoattackyou = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnobeamslefttoattackyou);
        echo "$l_cmb_hehasnobeamslefttoattackyou<BR>";
    }
	// ****************** TORPEDO EXCHANGE ***********************
    echo "<BR><FONT SIZE='+2' COLOR='RED'>$l_cmb_torpedoexchange</font><BR>";
    if($targetfighters > 0 && $attackertorpdamage > 0)
    {
        if($attackertorpdamage > round($targetfighters / 2))
        {
            $temp=round($targetfighters/2);
            $lost=$targetfighters-$temp;
            $targetfighters=$temp;
            $attackertorpdamage=$attackertorpdamage-$lost;
            $l_cmb_yourtorpsdestroy = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourtorpsdestroy);
            $l_cmb_yourtorpsdestroy = str_replace("[cmb_lost]", $lost, $l_cmb_yourtorpsdestroy);
            echo "--> $l_cmb_yourtorpsdestroy<BR>";
        }
        else
        {
            $targetfighters=$targetfighters-$attackertorpdamage;
            $l_cmb_yourtorpsdestroy2 = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourtorpsdestroy2);
            $l_cmb_yourtorpsdestroy2 = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_yourtorpsdestroy2);
            echo "<-- $l_cmb_yourtorpsdestroy2<BR>";
            $attackertorpdamage=0;
        }
    }
    elseif ($targetfighters > 0 && $attackertorpdamage < 1)
    {
        $l_cmb_youhavenotorpsleft = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhavenotorpsleft);
        echo "$l_cmb_youhavenotorpsleft<BR>";
    }
    else
    {
        $l_cmb_hehasnofighterleft = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnofighterleft);
        echo "$_cmb_hehasnofighterleft<BR>";
    }
    if($attackerfighters > 0 && $targettorpdmg > 0)
    {
        if($targettorpdmg > round($attackerfighters / 2))
        {
            $temp=round($attackerfighters/2);
            $lost=$attackerfighters-$temp;
            $attackerfighters=$temp;
            $targettorpdmg=$targettorpdmg-$lost;
            $l_cmb_torpsdestroyyou = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_torpsdestroyyou);
            $l_cmb_torpsdestroyyou = str_replace("[cmb_lost]", $lost, $l_cmb_torpsdestroyyou);
            echo "--> $l_cmb_torpsdestroyyou<BR>";
        }
        else
        {
            $attackerfighters=$attackerfighters-$targettorpdmg;
            $l_cmb_someonedestroyedfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_someonedestroyedfighters);
            $l_cmb_someonedestroyedfighters = str_replace("[cmb_targettorpdmg]", $targettorpdmg, $l_cmb_someonedestroyedfighters);
            echo "<-- $l_cmb_someonedestroyedfighters<BR>";
            $targettorpdmg=0;
        }
    }
    elseif ($attackerfighters > 0 && $targettorpdmg < 1)
    {
        $l_cmb_hehasnotorpsleftforyou = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnotorpsleftforyou);
        echo "$l_cmb_hehasnotorpsleftforyou<BR>";
    }
    else
    {
        $l_cmb_youhavenofightersanymore = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhavenofightersanymore);
        echo "$l_cmb_youhavenofightersanymore<BR>";
    }
    if($attackertorpdamage > 0)
    {
        if($attackertorpdamage > $targetarmor)
        {
            $targetarmor=0;
            $l_cmb_youbreachedwithtorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youbreachedwithtorps);
            echo "--> $l_cmb_youbreachedwithtorps<BR>";
        }
        else
        {
            $targetarmor=$targetarmor-$attackertorpdamage;
            $l_cmb_hisarmorishitbytorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hisarmorishitbytorps);
            $l_cmb_hisarmorishitbytorps = str_replace("[cmb_attackertorpdamage]", $attackertorpdamage, $l_cmb_hisarmorishitbytorps);
            echo "<-- $l_cmb_hisarmorishitbytorps<BR>";
        }
    }
    else
    {
        $l_cmb_notorpslefttoattackarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_notorpslefttoattackarmor);
        echo "$l_cmb_notorpslefttoattackarmor<BR>";
    }
    if($targettorpdmg > 0)
    {
        if($targettorpdmg > $attackerarmor)
        {
            $attackerarmor=0;
            $l_cmb_yourarmorbreachedbytorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorbreachedbytorps);
            echo "<-- $l_cmb_yourarmorbreachedbytorps<BR>";
        }
        else
        {
            $attackerarmor=$attackerarmor-$targettorpdmg;
            $l_cmb_yourarmorhitdmgtorps = str_replace("[cmb_targettorpdmg]", $targettorpdmg, $l_cmb_yourarmorhitdmgtorps);
            $l_cmb_yourarmorhitdmgtorps = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorhitdmgtorps);
            echo "<-- $l_cmb_yourarmorhitdmgtorps<BR>";
        }
    }
    else
    {
        $l_cmb_hehasnotorpsforyourarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnotorpsforyourarmor);
        echo "$l_cmb_hehasnotorpsforyourarmor<BR>";
    }
	// *******************8 FIGHTERS EXCHANGE ******************	
    echo "<BR><FONT SIZE='+2' COLOR='RED'>$l_cmb_fightersattackexchange</FONT><BR>";
    if($attackerfighters > 0 && $targetfighters > 0)
    {
        if($attackerfighters > $targetfighters)
        {
            $l_cmb_enemylostallfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_enemylostallfighters);
            echo "--> $l_cmb_enemylostallfighters<BR>";
            $temptargfighters=0;
        }
        else
        {
            $l_cmb_helostsomefighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_helostsomefighters);
            $l_cmb_helostsomefighters = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_helostsomefighters);
            echo "$l_cmb_helostsomefighters<BR>";
            $temptargfighters=$targetfighters-$attackerfighters;
        }
        if($targetfighters > $attackerfighters)
        {
            echo "<-- $l_cmb_youlostallfighters<BR>";
            $tempplayfighters=0;
        }
        else
        {
            $l_cmb_youalsolostsomefighters = str_replace("[cmb_targetfighters]", $targetfighters, $l_cmb_youalsolostsomefighters);
            echo "<-- $l_cmb_youalsolostsomefighters<BR>";
            $tempplayfighters=$attackerfighters-$targetfighters;
        }
        $attackerfighters=$tempplayfighters;
        $targetfighters=$temptargfighters;
    }
    elseif ($attackerfighters > 0 && $targetfighters < 1)
    {
        $l_cmb_hehasnofightersleftattack = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasnofightersleftattack);
        echo "$l_cmb_hehasnofightersleftattack<BR>";
    }
    else
    {
        $l_cmb_younofightersattackleft = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_younofightersattackleft);
        echo "$l_cmb_younofightersattackleft<BR>";
    }
    if($attackerfighters > 0)
    {
        if($attackerfighters > $targetarmor)
        {
            $targetarmor=0;
            $l_cmb_youbreachedarmorwithfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youbreachedarmorwithfighters);
            echo "--> $l_cmb_youbreachedarmorwithfighters<BR>";
        }
        else
        {
            $targetarmor=$targetarmor-$attackerfighters;
            $l_cmb_youhitarmordmgfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhitarmordmgfighters);
            $l_cmb_youhitarmordmgfighters = str_replace("[cmb_attackerfighters]", $attackerfighters, $l_cmb_youhitarmordmgfighters);
            echo "<-- $l_cmb_youhitarmordmgfighters<BR>";
        }
    }
    else
    {
        $l_cmb_youhavenofighterstoarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youhavenofighterstoarmor);
        echo "$l_cmb_youhavenofighterstoarmor<BR>";
    }
    if($targetfighters > 0)
    {
        if($targetfighters > $attackerarmor)
        {
            $attackerarmor=0;
            $l_cmb_hasbreachedarmorfighters = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hasbreachedarmorfighters);
            echo "<-- $l_cmb_hasbreachedarmorfighters<BR>";
        }
        else
        {
            $attackerarmor=$attackerarmor-$targetfighters;
            $l_cmb_yourarmorishitfordmgby = str_replace("[cmb_targetfighters]", $targetfighters, $l_cmb_yourarmorishitfordmgby);
            $l_cmb_yourarmorishitfordmgby = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_yourarmorishitfordmgby);
            echo "--> $l_cmb_yourarmorishitfordmgby<BR>";
        }
    }
    else
    {
        $l_cmb_nofightersleftheforyourarmor = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_nofightersleftheforyourarmor);
        echo "$l_cmb_nofightersleftheforyourarmor<BR>";
    }
    if($targetarmor < 1)
    {
        $l_cmb_hehasbeendestroyed = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_hehasbeendestroyed);
        echo "<BR>$l_cmb_hehasbeendestroyed<BR>";
		// news
		$headline="Ship blown up on planet!";
		$newstext="The ship ".$targetshipinfo[ship_name]." was destroyed today by ".$playerinfo[character_name]." during a planet attack. ";
        if($targetshipinfo[dev_escapepod] == "Y")
        {
            $rating=round($targetinfo[rating]/2);
            echo "$l_cmb_escapepodlaunched<BR><BR>";
            echo "<BR><BR>player_id=$targetinfo[player_id]<BR><BR>";
            $test = $db->Execute("UPDATE $dbtables[players] SET on_planet='N',rating='$rating',sector=0 WHERE player_id=$targetinfo[player_id]");
			// Immediately release any ships being towed 
    		if ($targetshipinfo[tow] > 0) {
				$db->Execute("UPDATE $dbtables[ships] SET player_id=0,on_planet='N',sector=$targetshipinfo[sector] WHERE ship_id=$targetshipinfo[tow]");
  			}
			$db->Execute("UPDATE $dbtables[ships] SET ship_destroyed ='Y', sector=0, tow=0 WHERE player_id=$targetinfo[player_id] AND ship_id=$targetinfo[currentship]");
            playerlog($targetinfo[player_id],LOG_ATTACK_LOSE, "$playerinfo[character_name]|Y");
            collect_bounty($playerinfo[player_id],$targetinfo[player_id]);
			$newstext = $newstext.$targetinfo[character_name]." survived and podded off to Sector 0.";
        }
        else
        {
            playerlog($targetinfo[player_id], LOG_ATTACK_LOSE, "$playerinfo[character_name]|N");
            db_kill_player($targetinfo[player_id],$targetinfo[currentship],$playerinfo[player_id]);
            collect_bounty($playerinfo[player_id],$targetinfo[player_id]);
			$newstext .= $targetinfo[character_name]." did not survive the attack.";
        }
		$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($attackerarmor > 0)
        {
            $rating_change=round($targetinfo[rating]*$rating_combat_factor);
            $free_ore = round($targetshipinfo[ship_ore]/2);
            $free_organics = round($targetshipinfo[ship_organics]/2);
            $free_goods = round($targetshipinfo[ship_goods]/2);
            $free_holds = NUM_HOLDS($shipinfo[hull]) - $shipinfo[ship_ore] - $shipinfo[ship_organics] - $shipinfo[ship_goods] - $shipinfo[ship_colonists];
            if($free_holds > $free_goods)
            {
                $salv_goods=$free_goods;
                $free_holds=$free_holds-$free_goods;
            }
            elseif($free_holds > 0)
            {
                $salv_goods=$free_holds;
                $free_holds=0;
            }
            else
            {
                $salv_goods=0;
            }
            if($free_holds > $free_ore)
            {
                $salv_ore=$free_ore;
                $free_holds=$free_holds-$free_ore;
            }
            elseif($free_holds > 0)
            {
                $salv_ore=$free_holds;
                $free_holds=0;
            }
            else
            {
                $salv_ore=0;
            }
            if($free_holds > $free_organics)
            {
                $salv_organics=$free_organics;
                $free_holds=$free_holds-$free_organics;
            }
            elseif($free_holds > 0)
            {
                $salv_organics=$free_holds;
                $free_holds=0;
            }
            else
            {
                $salv_organics=0;
            }
            $ship_value=$upgrade_cost*(round(mypw($upgrade_factor, $targetshipinfo[hull]))+round(mypw($upgrade_factor, $targetshipinfo[engines]))+round(mypw($upgrade_factor, $targetshipinfo[power]))+round(mypw($upgrade_factor, $targetshipinfo[computer]))+round(mypw($upgrade_factor, $targetshipinfo[sensors]))+round(mypw($upgrade_factor, $targetshipinfo[beams]))+round(mypw($upgrade_factor, $targetshipinfo[torp_launchers]))+round(mypw($upgrade_factor, $targetshipinfo[shields]))+round(mypw($upgrade_factor, $targetshipinfo[armor]))+round(mypw($upgrade_factor, $targetshipinfo[cloak])));
            $ship_salvage_rate=rand(10,20);
            $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=$targetinfo[player_id]");
		  	if (!$result3->EOF) {
		  		$ship_salvage *=3;
				echo "You destroyed a Federation fugitive! Triple hull salvage!<br>";
		  	}
            $l_cmb_yousalvaged = str_replace("[cmb_salv_ore]", NUMBER($salv_ore), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salv_organics]", NUMBER($salv_organics), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salv_goods]", NUMBER($salv_goods), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salvage_rate]", $ship_salvage_rate, $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_salvage]", NUMBER($ship_salvage), $l_cmb_yousalvaged);
            $l_cmb_yousalvaged = str_replace("[cmb_number_rating_change]", NUMBER(abs($rating_change)), $l_cmb_yousalvaged);
            echo "$l_cmb_yousalvaged";
            $update3 = $db->Execute ("UPDATE $dbtables[players] SET credits=credits+$ship_salvage WHERE player_id=$playerinfo[player_id]");
			$update3 = $db->Execute ("UPDATE $dbtables[ships] SET ship_ore=ship_ore+$salv_ore, ship_organics=ship_organics+$salv_organics, ship_goods=ship_goods+$salv_goods WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
        }
    }
    else
    {
        $l_cmb_youdidntdestroyhim = str_replace("[cmb_targetinfo_ship_name]", $targetshipinfo[ship_name], $l_cmb_youdidntdestroyhim);
        echo "$l_cmb_youdidntdestroyhim<BR>";
        $target_rating_change=round($targetinfo[rating]*.1);
        $target_armor_lost=$targetshipinfo[armour_pts]-$targetarmor;
        $target_fighters_lost=$targetshipinfo[ship_fighters]-$targetfighters;
        $target_energy=$targetshipinfo[ship_energy];
        playerlog($targetinfo[player_id], LOG_ATTACKED_WIN, "$playerinfo[character_name]|$target_armor_lost|$target_fighters_lost");
        $update4 = $db->Execute ("UPDATE $dbtables[ships] SET ship_energy=$target_energy,ship_fighters=ship_fighters-$target_fighters_lost, armour_pts=armour_pts-$target_armor_lost, torps=torps-$targettorpnum WHERE player_id=$targetinfo[player_id] AND ship_id=$targetinfo[currentship]");
	}
    $db->Execute("UNLOCK TABLES");
}
コード例 #8
0
ファイル: rsmove.php プロジェクト: antt1995/starkicktraders
	  {
		$l_rs_engage_link= "<A HREF=rsmove.php?engage=1&destination=$destination>" . $l_rs_engage_link . "</A>";
		$l_rs_engage=str_replace("[turns]",NUMBER($playerinfo[turns]),$l_rs_engage);
		$l_rs_engage=str_replace("[engage]",$l_rs_engage_link,$l_rs_engage);
		echo "$l_rs_engage<BR><BR>";
	  }
	}
	elseif($destination <= $sector_max && $engage == 1)
	{
	   $distance=calc_dist($playerinfo['sector'],$destination);
	
	  if($distance<1) {
		// TODO: The query failed. What now?
		$distance = 1;
	  }
	  $shipspeed = mypw($level_factor, $shipinfo[engines]);
	  $triptime = round($distance / $shipspeed);
	  if($triptime == 0 && $destination != $playerinfo[sector])
	  {
		$triptime = 1;
	  }
	  if($shipinfo[dev_fuelscoop] == "Y")
	  {
		$energyscooped = $distance * 100;
	  }
	  else
	  {
		$energyscooped = 0;
	  }
	  if($shipinfo[dev_fuelscoop] == "Y" && $energyscooped == 0 && $triptime == 1)
	  {
コード例 #9
0
function Real_Space_Move($destination)
{
  global $db;
  global $dbtables;
  global $level_factor;
  global $username;
  global $lang;

  $res = $db->Execute("SELECT * FROM $dbtables[players] WHERE email='$username'");
  $playerinfo = $res->fields;
  // Check if player is on a planet or not
  if ($playerinfo[on_planet] == 'Y') {
	  echo "You cannot realspace when on a planet!<br><br>";
	  return("ON_PLANET");
  }	
  $res = $db->Execute("SELECT * FROM $dbtables[ships] WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
  $shipinfo = $res->fields;
  
  $distance=calc_dist($playerinfo['sector'],$destination);

  if($distance<1) {
    // TODO: The query failed. What now?
	$distance = 1;
  }

  $shipspeed = mypw($level_factor, $shipinfo[engines]);
  $triptime = round($distance / $shipspeed);






  if($triptime == 0 && $destination != $playerinfo[sector])
  {
    $triptime = 1;
  }


  if($playerinfo[dev_fuelscoop] == "Y")
  {
    $energyscooped = $distance * 100;
  }
  else
  {
    $energyscooped = 0;
  }

 
  if($shipinfo[dev_fuelscoop] == "Y" && $energyscooped == 0 && $triptime == 1)
  {
    $energyscooped = 100;
  }
  $free_power = NUM_ENERGY($shipinfo[power]) - $shipinfo[ship_energy];

  // amount of energy that can be stored is less than amount scooped amount scooped is set to what can be stored
  if($free_power < $energyscooped)
  {
    $energyscooped = $free_power;
  }

  // make sure energyscooped is not null
  if(!isset($energyscooped))
  {
    $energyscooped = "0";
  }

  // make sure energyscooped not negative, or decimal
  if($energyscooped < 1)
  {
    $energyscooped = 0;
  }

  // check to see if already in that sector
  if($destination == $playerinfo[sector])
  {
    $triptime = 0;
    $energyscooped = 0;
  }

  if($triptime > $playerinfo[turns])
  {
    $l_rs_movetime=str_replace("[triptime]",NUMBER($triptime),$l_rs_movetime);
    echo "$l_rs_movetime<BR><BR>";
    echo "$l_rs_noturns";
    $db->Execute("UPDATE $dbtables[players] SET cleared_defences=' ' where player_id=$playerinfo[player_id]");

    $retval = "BREAK-TURNS";
  }
  else
  {

// ********************************
// ***** Sector Defense Check *****
// ********************************

  $result99 = $db->Execute("SELECT * FROM $dbtables[players] LEFT JOIN $dbtables[sector_defence] ON ( $dbtables[players].player_id = $dbtables[sector_defence].player_id ) WHERE sector_id = $destination AND ( team = 0 OR team != $playerinfo[team] ) AND $dbtables[sector_defence].player_id != $playerinfo[player_id]");
  if(!$result99->EOF)
  {
	$retval = "HOSTILE";
	// need to add a language value for this
	echo "YOU CANNOT MOVE TO SECTOR $destination: THERE ARE HOSTILE SECTOR DEFENSES THERE!<br>";
  } else
  {
       $stamp = date("Y-m-d H-i-s");
       $update = $db->Execute("UPDATE $dbtables[players] SET last_login='******',sector=$destination,turns=turns-$triptime,turns_used=turns_used+$triptime WHERE player_id=$playerinfo[player_id]");
	   $update = $db->Execute("UPDATE $dbtables[ships] SET ship_energy=ship_energy+$energyscooped WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
       $l_rs_ready=str_replace("[sector]",$destination,$l_rs_ready);
   
       $l_rs_ready= str_replace("[triptime]",NUMBER($triptime),$l_rs_ready);
       $l_rs_ready=str_replace("[energy]",NUMBER($energyscooped),$l_rs_ready);
       echo "$l_rs_ready<BR>";
       $retval = "GO";	
  }
 }
  return($retval);
}
コード例 #10
0
ファイル: port2.php プロジェクト: antt1995/starkicktraders
function phpChangeDelta($desiredvalue,$currentvalue)
{
global $upgrade_cost;

  $Delta=0; $DeltaCost=0;
  $Delta = $desiredvalue - $currentvalue;

    while($Delta>0) 
    {
     $DeltaCost=$DeltaCost + mypw(2,$desiredvalue-$Delta); 
     $Delta=$Delta-1;
    }
    $DeltaCost=$DeltaCost * $upgrade_cost;
    
  return $DeltaCost;
}
コード例 #11
0
function furangeetoplanet($planet_id)
{
  // ***********************************
  // *** Furangee Planet Attack Code ***
  // ***********************************

  // *********************************
  // *** SETUP GENERAL VARIABLES  ****
  // *********************************
  global $playerinfo;
  global $shipinfo;
  global $planetinfo;

  global $torp_dmg_rate;
  global $level_factor;
  global $rating_combat_factor;
  global $upgrade_cost;
  global $upgrade_factor;
  global $sector_max;
  global $furangeeisdead;
  global $db, $dbtables;

  // *** LOCKING TABLES ****
  //$db->Execute("LOCK TABLES $dbtables[players] WRITE, $dbtables[ships] WRITE, $dbtables[universe] WRITE, $dbtables[planets] WRITE, $dbtables[news] WRITE, $dbtables[logs] WRITE");

  // ********************************
  // *** LOOKUP PLANET DETAILS   ****
  // ********************************
  //$resultp = $db->Execute ("SELECT * FROM $dbtables[planets] WHERE planet_id='$planet_id'");
  echo "The planet ID (ship id) = $planet_id<br>";
  $resultp = $db->Execute ("SELECT * FROM $dbtables[planets] WHERE owner='$planet_id'");
  if ($resultp->EOF) {
  	echo "Asked to get info on $planet_id and failed<br>";
	return;
  }
  $planetinfo=$resultp->fields;

  // ********************************
  // *** LOOKUP OWNER DETAILS    ****
  // ********************************
  $resulto = $db->Execute ("SELECT * FROM $dbtables[players] WHERE player_id='$planet_id'");
  $ownerinfo=$resulto->fields;

  // **********************************
  // *** SETUP PLANETARY VARIABLES ****
  // **********************************
  $base_factor = ($planetinfo[base] == 'Y') ? $basedefense : 0;

  // *** PLANET BEAMS ***
  $targetbeams = NUM_BEAMS($ownerinfo[beams] + $base_factor);
  if ($targetbeams > $planetinfo[energy]) $targetbeams = $planetinfo[energy];
  $planetinfo[energy] -= $targetbeams;
    
  // *** PLANET SHIELDS ***
  $targetshields = NUM_SHIELDS($ownerinfo[shields] + $base_factor);
  if ($targetshields > $planetinfo[energy]) $targetshields = $planetinfo[energy];
  $planetinfo[energy] -= $targetshields;
    
  // *** PLANET TORPS ***
  $torp_launchers = round(mypw($level_factor, ($ownerinfo[torp_launchers])+ $base_factor)) * 10;
  $torps = $planetinfo[torps];
  $targettorps = $torp_launchers;
  if ($torp_launchers > $torps) $targettorps = $torps;
  $planetinfo[torps] -= $targettorps;
  $targettorpdmg = $torp_dmg_rate * $targettorps;

  // *** PLANET FIGHTERS ***
  $targetfighters = $planetinfo[fighters];

  // *********************************
  // *** SETUP ATTACKER VARIABLES ****
  // *********************************

  // *** ATTACKER BEAMS ***
  $attackerbeams = NUM_BEAMS($shipinfo[beams]);
  if ($attackerbeams > $shipinfo[ship_energy]) $attackerbeams = $shipinfo[ship_energy];
  $shipinfo[ship_energy] -= $attackerbeams;

  // *** ATTACKER SHIELDS ***
  $attackershields = NUM_SHIELDS($shipinfo[shields]);
  if ($attackershields > $shipinfo[ship_energy]) $attackershields = $shipinfo[ship_energy];
  $shipinfo[ship_energy] -= $attackershields;

  // *** ATTACKER TORPS ***
  $attackertorps = round(mypw($level_factor, $shipinfo[torp_launchers])) * 2;
  if ($attackertorps > $shipinfo[torps]) $attackertorps = $shipinfo[torps]; 
  $shipinfo[torps] -= $attackertorps;
  $attackertorpdamage = $torp_dmg_rate * $attackertorps;

  // *** ATTACKER FIGHTERS ***
  $attackerfighters = $shipinfo[ship_fighters];

  // *** ATTACKER ARMOUR ***
  $attackerarmor = $shipinfo[armour_pts];

  // *********************************
  // **** BEGIN COMBAT PROCEDURES ****
  // *********************************
  if($attackerbeams > 0 && $targetfighters > 0)
  {                         //******** ATTACKER HAS BEAMS - TARGET HAS FIGHTERS - BEAMS VS FIGHTERS ********
    if($attackerbeams > $targetfighters)
    {                                  //****** ATTACKER BEAMS GT TARGET FIGHTERS ******
      $lost = $targetfighters;
      $targetfighters = 0;                                     //**** T LOOSES ALL FIGHTERS ****
      $attackerbeams = $attackerbeams-$lost;                   //**** A LOOSES BEAMS EQ TO T FIGHTERS ****
    } else
    {                                  //****** ATTACKER BEAMS LE TARGET FIGHTERS ******
      $targetfighters = $targetfighters-$attackerbeams;        //**** T LOOSES FIGHTERS EQ TO A BEAMS ****
      $attackerbeams = 0;                                      //**** A LOOSES ALL BEAMS ****
    }   
  }
  if($attackerfighters > 0 && $targetbeams > 0)
  {                         //******** TARGET HAS BEAMS - ATTACKER HAS FIGHTERS - BEAMS VS FIGHTERS ********
    if($targetbeams > round($attackerfighters / 2))
    {                                  //****** TARGET BEAMS GT HALF ATTACKER FIGHTERS ******
      $lost=$attackerfighters-(round($attackerfighters/2));
      $attackerfighters=$attackerfighters-$lost;               //**** A LOOSES HALF ALL FIGHTERS ****
      $targetbeams=$targetbeams-$lost;                         //**** T LOOSES BEAMS EQ TO HALF A FIGHTERS ****
    } else
    {                                  //****** TARGET BEAMS LE HALF ATTACKER FIGHTERS ******
      $attackerfighters=$attackerfighters-$targetbeams;        //**** A LOOSES FIGHTERS EQ TO T BEAMS **** 
      $targetbeams=0;                                          //**** T LOOSES ALL BEAMS ****
    }
  }
  if($attackerbeams > 0)
  {                         //******** ATTACKER HAS BEAMS LEFT - CONTINUE COMBAT - BEAMS VS SHIELDS ********
    if($attackerbeams > $targetshields)
    {                                  //****** ATTACKER BEAMS GT TARGET SHIELDS ******
      $attackerbeams=$attackerbeams-$targetshields;            //**** A LOOSES BEAMS EQ TO T SHIELDS ****
      $targetshields=0;                                        //**** T LOOSES ALL SHIELDS ****
    } else
    {                                  //****** ATTACKER BEAMS LE TARGET SHIELDS ******
      $targetshields=$targetshields-$attackerbeams;            //**** T LOOSES SHIELDS EQ TO A BEAMS ****
      $attackerbeams=0;                                        //**** A LOOSES ALL BEAMS ****
    }
  }
  if($targetbeams > 0)
  {                         //******** TARGET HAS BEAMS LEFT - CONTINUE COMBAT - BEAMS VS SHIELDS ********
    if($targetbeams > $attackershields)
    {                                  //****** TARGET BEAMS GT ATTACKER SHIELDS ******
      $targetbeams=$targetbeams-$attackershields;              //**** T LOOSES BEAMS EQ TO A SHIELDS ****
      $attackershields=0;                                      //**** A LOOSES ALL SHIELDS ****
    } else
    {                                  //****** TARGET BEAMS LE ATTACKER SHIELDS ****** 
      $attackershields=$attackershields-$targetbeams;          //**** A LOOSES SHIELDS EQ TO T BEAMS ****
      $targetbeams=0;                                          //**** T LOOSES ALL BEAMS ****
    }
  }
  if($targetbeams > 0)
  {                        //******** TARGET HAS BEAMS LEFT - CONTINUE COMBAT - BEAMS VS ARMOR ******** 
    if($targetbeams > $attackerarmor)
    {                                 //****** TARGET BEAMS GT ATTACKER ARMOR ******
      $targetbeams=$targetbeams-$attackerarmor;                //**** T LOOSES BEAMS EQ TO A ARMOR ****
      $attackerarmor=0;                                        //**** A LOOSES ALL ARMOR (A DESTROYED) ****
    } else
    {                                 //****** TARGET BEAMS LE ATTACKER ARMOR ******
      $attackerarmor=$attackerarmor-$targetbeams;              //**** A LOOSES ARMOR EQ TO T BEAMS ****
      $targetbeams=0;                                          //**** T LOOSES ALL BEAMS ****
    } 
  }
  if($targetfighters > 0 && $attackertorpdamage > 0)
  {                        //******** ATTACKER FIRES TORPS - TARGET HAS FIGHTERS - TORPS VS FIGHTERS ********
    if($attackertorpdamage > $targetfighters)
    {                                 //****** ATTACKER FIRED TORPS GT TARGET FIGHTERS ******
      $lost=$targetfighters;
      $targetfighters=0;                                       //**** T LOOSES ALL FIGHTERS ****
      $attackertorpdamage=$attackertorpdamage-$lost;           //**** A LOOSES FIRED TORPS EQ TO T FIGHTERS ****
    } else
    {                                 //****** ATTACKER FIRED TORPS LE HALF TARGET FIGHTERS ******
      $targetfighters=$targetfighters-$attackertorpdamage;     //**** T LOOSES FIGHTERS EQ TO A TORPS FIRED ****
      $attackertorpdamage=0;                                   //**** A LOOSES ALL TORPS FIRED ****
    }
  }
  if($attackerfighters > 0 && $targettorpdmg > 0)
  {                        //******** TARGET FIRES TORPS - ATTACKER HAS FIGHTERS - TORPS VS FIGHTERS ********
    if($targettorpdmg > round($attackerfighters / 2))
    {                                 //****** TARGET FIRED TORPS GT HALF ATTACKER FIGHTERS ******
      $lost=$attackerfighters-(round($attackerfighters/2));
      $attackerfighters=$attackerfighters-$lost;               //**** A LOOSES HALF ALL FIGHTERS ****
      $targettorpdmg=$targettorpdmg-$lost;                     //**** T LOOSES FIRED TORPS EQ TO HALF A FIGHTERS ****
    } else
    {                                 //****** TARGET FIRED TORPS LE HALF ATTACKER FIGHTERS ******
      $attackerfighters=$attackerfighters-$targettorpdmg;      //**** A LOOSES FIGHTERS EQ TO T TORPS FIRED ****
      $targettorpdmg=0;                                        //**** T LOOSES ALL TORPS FIRED ****
    }
  }
  if($targettorpdmg > 0)
  {                        //******** TARGET FIRES TORPS - CONTINUE COMBAT - TORPS VS ARMOR ********
    if($targettorpdmg > $attackerarmor)
    {                                 //****** TARGET FIRED TORPS GT HALF ATTACKER ARMOR ******
      $targettorpdmg=$targettorpdmg-$attackerarmor;            //**** T LOOSES FIRED TORPS EQ TO A ARMOR ****
      $attackerarmor=0;                                        //**** A LOOSES ALL ARMOR (A DESTROYED) ****
    } else
    {                                 //****** TARGET FIRED TORPS LE HALF ATTACKER ARMOR ******
      $attackerarmor=$attackerarmor-$targettorpdmg;            //**** A LOOSES ARMOR EQ TO T TORPS FIRED ****
      $targettorpdmg=0;                                        //**** T LOOSES ALL TORPS FIRED ****
    } 
  }
  if($attackerfighters > 0 && $targetfighters > 0)
  {                        //******** ATTACKER HAS FIGHTERS - TARGET HAS FIGHTERS - FIGHTERS VS FIGHTERS ********
    if($attackerfighters > $targetfighters)
    {                                 //****** ATTACKER FIGHTERS GT TARGET FIGHTERS ******
      $temptargfighters=0;                                     //**** T WILL LOOSE ALL FIGHTERS ****
    } else
    {                                 //****** ATTACKER FIGHTERS LE TARGET FIGHTERS ******
      $temptargfighters=$targetfighters-$attackerfighters;     //**** T WILL LOOSE FIGHTERS EQ TO A FIGHTERS ****
    }
    if($targetfighters > $attackerfighters)
    {                                 //****** TARGET FIGHTERS GT ATTACKER FIGHTERS ******
      $tempplayfighters=0;                                     //**** A WILL LOOSE ALL FIGHTERS ****
    } else
    {                                 //****** TARGET FIGHTERS LE ATTACKER FIGHTERS ******
      $tempplayfighters=$attackerfighters-$targetfighters;     //**** A WILL LOOSE FIGHTERS EQ TO T FIGHTERS ****
    }     
    $attackerfighters=$tempplayfighters;
    $targetfighters=$temptargfighters;
  }
  if($targetfighters > 0)
  {                        //******** TARGET HAS FIGHTERS - CONTINUE COMBAT - FIGHTERS VS ARMOR ********
    if($targetfighters > $attackerarmor)
    {                                 //****** TARGET FIGHTERS GT ATTACKER ARMOR ******
      $attackerarmor=0;                                        //**** A LOOSES ALL ARMOR (A DESTROYED) ****
    } else
    {                                 //****** TARGET FIGHTERS LE ATTACKER ARMOR ******
      $attackerarmor=$attackerarmor-$targetfighters;           //**** A LOOSES ARMOR EQ TO T FIGHTERS ****
    }
  }

  // *********************************
  // **** FIX NEGATIVE VALUE VARS ****
  // *********************************
  if ($attackerfighters < 0) $attackerfighters = 0;
  if ($attackertorps    < 0) $attackertorps = 0;
  if ($attackershields  < 0) $attackershields = 0;
  if ($attackerbeams    < 0) $attackerbeams = 0;
  if ($attackerarmor    < 0) $attackerarmor = 0;
  if ($targetfighters   < 0) $targetfighters = 0;
  if ($targettorps      < 0) $targettorps = 0;
  if ($targetshields    < 0) $targetshields = 0;
  if ($targetbeams      < 0) $targetbeams = 0;

  // ******************************************
  // *** CHECK IF ATTACKER SHIP DESTROYED   ***
  // ******************************************
  if(!$attackerarmor>0)
  {
    playerlog($playerinfo[player_id], LOG_RAW, "Ship destroyed by planetary defenses on planet $planetinfo[name]");
    $furangeeisdead = 1;
// news
	$headline="Furangee Attacks ".$planetinfo[name]."!";
	$newstext="Furangee ".$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]." was blinded by the huge riches stored on the planet.";
	} else {
		$newstext = $newstext . $playerinfo[character_name]." thought it would be easy money but underestimated the planet defenses.";
	}
	$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')");

    $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(10,20);
    $ship_salvage=$ship_value*$ship_salvage_rate/100;
    $fighters_lost = $planetinfo[fighters] - $targetfighters;

    db_kill_player($playerinfo[player_id],$playerinfo[currentship],$planetinfo[owner]);

    // *** LOG ATTACK TO PLANET OWNER ***
    playerlog($planetinfo[owner], LOG_PLANET_NOT_DEFEATED, "$planetinfo[name]|$planetinfo[sector_id]|Furangee $playerinfo[character_name]|".NUMBER($free_ore)."|".NUMBER($free_organics)."|".NUMBER($free_goods)."|".NUMBER($ship_salvage_rate)."|".NUMBER($ship_salvage));

    // *** UPDATE PLANET ***
    $db->Execute("UPDATE $dbtables[planets] SET energy=$planetinfo[energy],fighters=fighters-$fighters_lost, torps=torps-$targettorps, ore=ore+$free_ore, goods=goods+$free_goods, organics=organics+$free_organics, credits=credits+$ship_salvage WHERE planet_id=$planetinfo[planet_id]");
  
  }
  // **********************************************
  // *** MUST HAVE MADE IT PAST PLANET DEFENSES ***
  // **********************************************
  else
  {
    $armor_lost = $shipinfo[armour_pts] - $attackerarmor;
    $fighters_lost = $shipinfo[ship_fighters] - $attackerfighters;
    $target_fighters_lost = $planetinfo[fighters] - $targetfighters;
    playerlog($playerinfo[player_id], LOG_RAW, "Made it past defenses on planet $planetinfo[name]");

    // *** UPDATE ATTACKER ***
    $db->Execute ("UPDATE $dbtables[ships] SET energy=$shipinfo[ship_energy],fighters=fighters-$fighters_lost, torps=torps-$attackertorps, armour_pts=armour_pts-$armor_lost WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]");
    $shipinfo[ship_fighters] = $attackerfighters;
    $shipinfo[torps] = $attackertorps;
    $shipinfo[armour_pts] = $attackerarmor;


    // *** UPDATE PLANET ***
    $db->Execute ("UPDATE $dbtables[planets] SET energy=$planetinfo[energy], fighters=$targetfighters, torps=torps-$targettorps WHERE planet_id=$planetinfo[planet_id]");
    $planetinfo[fighters] = $targetfighters;
    $planetinfo[torps] = $targettorps;

    // *** NOW WE MUST ATTACK ALL SHIPS ON THE PLANET ONE BY ONE ***
	echo "Planet Info Bug tracker<br>";
	echo "Planet info planet ID = $planetinfo[planet_id]<br>";
    $resultps = $db->Execute("SELECT * FROM $dbtables[players] WHERE planet_id=$planetinfo[planet_id] AND on_planet='Y'");
    $shipsonplanet = $resultps->RecordCount();
    if ($shipsonplanet > 0)
    {
      while (!$resultps->EOF && $furangeeisdead < 1)
      {
        $onplanet = $resultps->fields;
        furangeetoship($onplanet[player_id]);
        $resultps->MoveNext();
      }
    }
    $resultps = $db->Execute("SELECT * FROM $dbtables[players] WHERE planet_id=$planetinfo[planet_id] AND on_planet='Y'");
    $shipsonplanet = $resultps->RecordCount();
    if ($shipsonplanet == 0 && $furangeeisdead < 1)
    {
      // *** MUST HAVE KILLED ALL SHIPS ON PLANET ***
      playerlog($playerinfo[player_id], LOG_RAW, "Defeated all ships on planet $planetinfo[name]");
      // *** LOG ATTACK TO PLANET OWNER ***
      playerlog($planetinfo[owner], LOG_PLANET_DEFEATED, "$planetinfo[name]|$planetinfo[sector_id]|Furangee $playerinfo[character_name]");
	  // news
	  $headline="Furangee Defeat Planet ".$planetinfo[name]."!";
	  $newstext="Furangee ".$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]." mentioned that the bigger they are, the easier the fall.";
		} else {
			$newstext = $newstext . $playerinfo[character_name]." took the weak out and stamped on them.";
		}
		$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 PLANET ***
      $db->Execute("UPDATE $dbtables[planets] SET fighters=0, torps=0, base='N', owner=0, corp=0 WHERE planet_id=$planetinfo[planet_id]"); 
      calc_ownership($planetinfo[sector_id]);

    } else {
      // *** MUST HAVE DIED TRYING ***
      playerlog($playerinfo[player_id], LOG_RAW, "We were KILLED by ships defending planet $planetinfo[name]");
		// news
		$headline="Furangee burns up in attack!";
		$newstext="Furangee ".$playerinfo[character_name]." got intimate with deep space today when he tried to attack ".$ownerinfo[character_name]."s planet ".$planetinfo[name].". ";
		if ($playerinfo[score] < $ownerinfo[score]) {
			$newstext = $newstext . $playerinfo[character_name]." felt like his time had come and in a note left on the Intergalactic Bulletin Board he said that he wanted to go out in at least a modicum of style.";
		} else {
			$newstext = $newstext . $playerinfo[character_name]." was blinded by his own feelings of superiority.";
		}
		$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')");
      // *** LOG ATTACK TO PLANET OWNER ***
      playerlog($planetinfo[owner], LOG_PLANET_NOT_DEFEATED, "$planetinfo[name]|$planetinfo[sector_id]|Furangee $playerinfo[character_name]|0|0|0|0|0");

      // *** NO SALVAGE FOR PLANET BECAUSE WENT TO SHIP WHO WON **
    }

  }


  // *** END OF FURANGEE PLANET ATTACK CODE ***
  //$db->Execute("UNLOCK TABLES");

}