function xenoberegen() { global $playerinfo, $xen_unemployment, $xenobeisdead, $db; // Xenobe Unempoyment Check $playerinfo['credits'] = $playerinfo['credits'] + $xen_unemployment; $maxenergy = NUM_ENERGY($playerinfo['power']); // Regenerate energy if ($playerinfo['ship_energy'] <= $maxenergy - 50) { $playerinfo['ship_energy'] = $playerinfo['ship_energy'] + round(($maxenergy - $playerinfo['ship_energy']) / 2); // Regen half of remaining energy $gene = "regenerated Energy to {$playerinfo['ship_energy']} units,"; } $maxarmor = NUM_ARMOR($playerinfo['armor']); // Regenerate armor if ($playerinfo['armor_pts'] <= $maxarmor - 50) { $playerinfo['armor_pts'] = $playerinfo['armor_pts'] + round(($maxarmor - $playerinfo['armor_pts']) / 2); // Regen half of remaining armor $gena = "regenerated Armor to {$playerinfo['armor_pts']} points,"; } // Buy fighters & torpedos at 6 credits per fighter $available_fighters = NUM_FIGHTERS($playerinfo['computer']) - $playerinfo['ship_fighters']; if ($playerinfo['credits'] > 5 && $available_fighters > 0) { if (round($playerinfo['credits'] / 6) > $available_fighters) { $purchase = $available_fighters * 6; $playerinfo['credits'] = $playerinfo['credits'] - $purchase; $playerinfo['ship_fighters'] = $playerinfo['ship_fighters'] + $available_fighters; $genf = "purchased {$available_fighters} fighters for {$purchase} credits,"; } if (round($playerinfo['credits'] / 6) <= $available_fighters) { $purchase = round($playerinfo['credits'] / 6); $playerinfo['ship_fighters'] = $playerinfo['ship_fighters'] + $purchase; $genf = "purchased {$purchase} fighters for {$playerinfo['credits']} credits,"; $playerinfo['credits'] = 0; } } // Xenobe pay 3 credits per torpedo $available_torpedoes = NUM_TORPEDOES($playerinfo['torp_launchers']) - $playerinfo['torps']; if ($playerinfo['credits'] > 2 && $available_torpedoes > 0) { if (round($playerinfo['credits'] / 3) > $available_torpedoes) { $purchase = $available_torpedoes * 3; $playerinfo['credits'] = $playerinfo['credits'] - $purchase; $playerinfo['torps'] = $playerinfo['torps'] + $available_torpedoes; $gent = "purchased {$available_torpedoes} torpedoes for {$purchase} credits,"; } if (round($playerinfo['credits'] / 3) <= $available_torpedoes) { $purchase = round($playerinfo['credits'] / 3); $playerinfo['torps'] = $playerinfo['torps'] + $purchase; $gent = "purchased {$purchase} torpedoes for {$playerinfo['credits']} credits,"; $playerinfo['credits'] = 0; } } // Update Xenobe record $resg = $db->Execute("UPDATE {$db->prefix}ships SET ship_energy=?, armor_pts=?, ship_fighters=?, torps=?, credits=? WHERE ship_id=?", array($playerinfo['ship_energy'], $playerinfo['armor_pts'], $playerinfo['ship_fighters'], $playerinfo['torps'], $playerinfo['credits'], $playerinfo['ship_id'])); db_op_result($db, $resg, __LINE__, __FILE__); if (!$gene == '' || !$gena == '' || !$genf == '' || !$gent == '') { playerlog($db, $playerinfo[ship_id], LOG_RAW, "Xenobe {$gene} {$gena} {$genf} {$gent} and has been updated."); } }
$l_port_bounty3 = str_replace("[amount]", NUMBER($bty['total_bounty']), $l_port_bounty3); echo $l_port_bounty3 . "<br>\n"; echo "<br>\n"; echo "<a href=\"bounty.php\">" . $l_by_placebounty . "</a><br><br>"; TEXT_GOTOMAIN(); die; } } } $genesis_free = $max_genesis - $playerinfo['dev_genesis']; $beacon_free = $max_beacons - $playerinfo['dev_beacon']; $emerwarp_free = $max_emerwarp - $playerinfo['dev_emerwarp']; $warpedit_free = $max_warpedit - $playerinfo['dev_warpedit']; $fighter_max = NUM_FIGHTERS($playerinfo['computer']); $fighter_free = $fighter_max - $playerinfo['ship_fighters']; $torpedo_max = NUM_TORPEDOES($playerinfo['torp_launchers']); $torpedo_free = $torpedo_max - $playerinfo['torps']; $armor_max = NUM_ARMOR($playerinfo['armor']); $armor_free = $armor_max - $playerinfo['armor_pts']; $colonist_max = NUM_HOLDS($playerinfo['hull']) - $playerinfo['ship_ore'] - $playerinfo['ship_organics'] - $playerinfo['ship_goods']; if ($colonist_max < 0) { $colonist_max = 0; } $colonist_free = $colonist_max - $playerinfo['ship_colonists']; TEXT_JAVASCRIPT_BEGIN(); echo "function MakeMax(name, val)\n"; echo "{\n"; echo " if (document.forms[0].elements[name].value != val)\n"; echo " {\n"; echo " if (val != 0)\n"; echo " {\n";
//echo "</TD><TD VALIGN=TOP>"; echo "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%\">"; $holds_used = $shipinfo[ship_ore] + $shipinfo[ship_organics] + $shipinfo[ship_goods] + $shipinfo[ship_colonists]; $holds_max = NUM_HOLDS($shipinfo[hull]); echo "<TR BGCOLOR=\"$color_header\"><TD><B>$l_holds</B></TD><TD ALIGN=RIGHT><B>" . NUMBER($holds_used) . " / " . NUMBER($holds_max) . "</B></TD></TR>"; echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_ore</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[ship_ore]) . "</TD></TR>"; echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_organics</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[ship_organics]) . "</TD></TR>"; echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_goods</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[ship_goods]) . "</TD></TR>"; echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_colonists</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[ship_colonists]) . "</TD></TR>"; //echo "<TR><TD> </TD></TR>"; echo "</TABLE><P>"; echo "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%\">"; $armour_pts_max = NUM_ARMOUR($shipinfo[armour]); $ship_fighters_max = NUM_FIGHTERS($shipinfo[computer]); $torps_max = NUM_TORPEDOES($shipinfo[torp_launchers]); echo "<TR BGCOLOR=\"$color_header\"><TD COLSPAN=2 align=center><B>$l_arm_weap</B></TD></TR>"; echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_armourpts</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[armour_pts]) . " / " . NUMBER($armour_pts_max) . "</TD></TR>"; echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_fighters</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[ship_fighters]) . " / " . NUMBER($ship_fighters_max) . "</TD></TR>"; echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_torps</TD><TD ALIGN=RIGHT>" . NUMBER($shipinfo[torps]) . " / " . NUMBER($torps_max) . "</TD></TR>"; //echo "<TR><TD> </TD></TR>"; echo "</TABLE><p>"; //echo "</TD><TD VALIGN=TOP>"; echo "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%\">"; $energy_max = NUM_ENERGY($shipinfo[power]); echo "<TR BGCOLOR=\"$color_header\"><TD><B>$l_energy</B></TD><TD ALIGN=RIGHT><B>" . NUMBER($shipinfo[ship_energy]) . " / " . NUMBER($energy_max) . "</B></TD></TR>"; echo "</TABLE><P>"; echo "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%\">"; echo "<TR BGCOLOR=\"$color_header\"><TD COLSPAN=2 align=center><B>$l_devices</B></TD></TR>"; echo "<TR BGCOLOR=\"$color_line1\"><TD>$l_beacons</TD><TD ALIGN=RIGHT>$shipinfo[dev_beacon]</TD></TR>"; echo "<TR BGCOLOR=\"$color_line2\"><TD>$l_warpedit</TD><TD ALIGN=RIGHT>$shipinfo[dev_warpedit]</TD></TR>";
$makepass=""; $syllables="er,in,tia,wol,fe,pre,vet,jo,nes,al,len,son,cha,ir,ler,bo,ok,tio,nar,sim,ple,bla,ten,toe,cho,co,lat,spe,ak,er,po,co,lor,pen,cil,li,ght,wh,at,the,he,ck,is,mam,bo,no,fi,ve,any,way,pol,iti,cs,ra,dio,sou,rce,sea,rch,pa,per,com,bo,sp,eak,st,fi,rst,gr,oup,boy,ea,gle,tr,ail,bi,ble,brb,pri,dee,kay,en,be,se"; $syllable_array=explode(",", $syllables); srand((double)microtime()*1000000); for ($count=1;$count<=4;$count++) { if (rand()%10 == 1) { $makepass .= sprintf("%0.0f",(rand()%50)+1); } else { $makepass .= sprintf("%s",$syllable_array[rand()%62]); } } if ($furlevel=='') $furlevel=0; $maxenergy = NUM_ENERGY($furlevel); $maxarmour = NUM_ARMOUR($furlevel); $maxfighters = NUM_FIGHTERS($furlevel); $maxtorps = NUM_TORPEDOES($furlevel); $stamp=date("Y-m-d H:i:s"); // ***************************************************************************** // *** ADD FURANGEE RECORD TO ships TABLE ... MODIFY IF ships SCHEMA CHANGES *** // ***************************************************************************** $result2 = $db->Execute("INSERT INTO $dbtables[players] (`player_id`, `character_name`, `password`, `email`, `credits`, `sector`, `on_planet`,`turns_used`, `last_login`, `rating`, `score`, `team`, `team_invite`, `interface`, `ip_address`, `planet_id`, `preset1`, `preset2`, `preset3`, `trade_colonists`, `trade_fighters`, `trade_torps`, `trade_energy`, `cleared_defences`, `lang`, `alerts`, `alert2`, `subscribed`, `ore_price`, `organics_price`, `goods_price`, `energy_price`, `currentship`,`preset4`,`preset5`,`preset6`) VALUES ('', '$character', '$makepass', '$emailname','10000000', '$sector','N', '3000', '$stamp', '0', '0', '0', '0', 'N', '127.0.0.1', '0', '0', '0', '0', 'N', 'N', 'N', 'N', NULL, '$default_lang', 'N', 'N', NULL, '0', '0', '0', '0', '1',0,0,0)"); $res = $db->Execute("SELECT player_id from $dbtables[players] WHERE email='$emailname'"); $player_id = $res->fields[player_id]; // Calculate ship type $shipavg = $furlevel; if($shipavg < 4) $shiptype = 1; elseif($shipavg < 6) $shiptype = 2; elseif($shipavg < 10) $shiptype = 3;
function createFur($orders) { global $db,$dbtables,$sector_max; // Create A New Furangee // Create Furangee Name $nametry = 1; $namecheck = false; while ((!$namecheck) and ($nametry <= 9)) { $Sylable1 = array("Ak","Al","Ar","B","Br","D","F","Fr","G","Gr","K","Kr","N","Ol","Om","P","Qu","R","S","Z"); $Sylable2 = array("a","ar","aka","aza","e","el","i","in","int","ili","ish","ido","ir","o","oi","or","os","ov","u","un"); $Sylable3 = array("ag","al","ak","ba","dar","g","ga","k","ka","kar","kil","l","n","nt","ol","r","s","ta","til","x"); $sy1roll = rand(0,19); $sy2roll = rand(0,19); $sy3roll = rand(0,19); $character = $Sylable1[$sy1roll] . $Sylable2[$sy2roll] . $Sylable3[$sy3roll]; $emailname = str_replace(" ","_",$character) . "@furangee"; $resultnm = $db->Execute ("select email from $dbtables[players] where email='$emailname'"); if (!$resultnm->EOF) { echo "Email exists for $character [$emailname]<br>"; $nametry++; } else { $namecheck=true; } } if ($namecheck == false) { echo "Failed to create Furangee!<br>"; return; } // Create Ship Name $shipname = "Furangee- " . $character; // Select Random Sector $sector = rand(1,$sector_max); $furlevel = rand(3,30); $active="on"; $aggression=0; // 0 = Peaceful 1 = Attack Sometimes 2=Attack Always $makepass="******"; $maxenergy = NUM_ENERGY($furlevel); $maxarmour = NUM_ARMOUR($furlevel); $maxfighters = NUM_FIGHTERS($furlevel); $maxtorps = NUM_TORPEDOES($furlevel); $maxcloak = min(22,$furlevel); $stamp=date("Y-m-d H:i:s"); // ***************************************************************************** // *** ADD FURANGEE RECORD TO ships TABLE ... MODIFY IF ships SCHEMA CHANGES *** // ***************************************************************************** $result2 = $db->Execute("INSERT INTO $dbtables[players] (`player_id`, `character_name`, `password`, `email`, `credits`, `sector`, `on_planet`,`turns_used`, `last_login`, `rating`, `score`, `team`, `team_invite`, `interface`, `ip_address`, `planet_id`, `preset1`, `preset2`, `preset3`, `trade_colonists`, `trade_fighters`, `trade_torps`, `trade_energy`, `cleared_defences`, `lang`, `alerts`, `alert2`, `subscribed`, `ore_price`, `organics_price`, `goods_price`, `energy_price`, `currentship`,`preset4`,`preset5`,`preset6`) VALUES ('', '$character', '$makepass', '$emailname','10000000', '$sector','N', '3000', '$stamp', '0', '0', '0', '0', 'N', '127.0.0.1', '0', '0', '0', '0', 'N', 'N', 'N', 'N', NULL, '$default_lang', 'N', 'N', NULL, '0', '0', '0', '0', '1',0,0,0)"); $res = $db->Execute("SELECT player_id from $dbtables[players] WHERE email='$emailname'"); $player_id = $res->fields[player_id]; $shiptype=20; // We have a special furangee ship now. if ($furlevel > 16) { $ewd = rand(1,2); } else { $ewd = 0; } $result3 = $db->Execute("INSERT INTO $dbtables[ships] (`ship_id`, `player_id`, `type`, `ship_name`, `ship_destroyed`, `hull`, `engines`, `power`, `computer`, `sensors`, `beams`, `torp_launchers`, `torps`, `shields`, `armour`, `armour_pts`, `cloak`, `sector`, `ship_ore`, `ship_organics`, `ship_goods`, `ship_energy`, `ship_colonists`, `ship_fighters`, `tow`, `on_planet`, `dev_warpedit`, `dev_genesis`, `dev_beacon`, `dev_emerwarp`, `dev_escapepod`, `dev_fuelscoop`, `dev_minedeflector`, `planet_id`, `cleared_defences`, `dev_lssd`, `dev_sectorwmd`) VALUES ('', $player_id, '$shiptype', '$shipname', 'N', $furlevel,$furlevel,$furlevel,$furlevel,$furlevel,$furlevel,$furlevel,$maxtorps,$furlevel,$furlevel,$maxarmour,$maxcloak, $sector,0,0,0,$maxenergy,0,$maxfighters, '0', 'N', '0', '0', '0', '$ewd', 'N', 'N', '0', '0', NULL, 'N', 'N')"); $result4 = $db->Execute("UPDATE $dbtables[players] SET currentship=LAST_INSERT_ID() WHERE player_id=$player_id"); if(!$result2 | !result3) { echo $db->ErrorMsg() . "<br>"; } else { echo "Level $furlevel Furangee has been created.<BR>"; // Choose a preferance $commods = array("ore","goods","organics"); $prefer = $commods[rand(0,2)]; $result3 = $db->Execute("INSERT INTO $dbtables[furangee] (furangee_id,active,aggression,orders,prefer) VALUES('$emailname','Y','$aggression','$orders','$prefer')"); if(!$result3) { echo $db->ErrorMsg() . "<br>"; } else { echo "$emailname with orders $orders<br>"; } } }
function traderoute_engage($j) { global $playerinfo, $color_line1, $color_line2, $color_header; global $engage, $dist, $servertimezone; global $color_line2; global $color_line1; global $traderoutes; global $fighter_price; global $torpedo_price; global $colonist_price; global $colonist_limit; global $inventory_factor; global $ore_price; global $ore_delta; global $ore_limit; global $organics_price; global $organics_delta; global $organics_limit; global $goods_price; global $goods_delta; global $goods_limit; global $energy_price; global $energy_delta; global $energy_limit; global $mine_hullsize; global $l_tdr_turnsused, $l_tdr_turnsleft, $l_tdr_credits, $l_tdr_profit, $l_tdr_cost, $l_tdr_totalprofit, $l_tdr_totalcost; global $l_tdr_planetisovercrowded, $l_tdr_engageagain, $l_tdr_onlyonewaytdr, $l_tdr_engagenonexist, $l_tdr_notowntdr; global $l_tdr_invalidspoint, $l_tdr_inittdr, $l_tdr_invalidsrc, $l_tdr_inittdrsector, $l_tdr_organics, $l_tdr_energy, $l_tdr_loaded; global $l_tdr_nothingtoload, $l_tdr_scooped, $l_tdr_dumped, $l_tdr_portisempty, $l_tdr_portisfull, $l_tdr_ore, $l_tdr_sold; global $l_tdr_goods, $l_tdr_notyourplanet, $l_tdr_invalidssector, $l_tdr_invaliddport, $l_tdr_invaliddplanet; global $l_tdr_invaliddsector, $l_tdr_nowlink1, $l_tdr_nowlink2, $l_tdr_moreturnsneeded, $l_tdr_hostdef; global $l_tdr_globalsetbuynothing, $l_tdr_nosrcporttrade, $l_tdr_tradesrcportoutsider, $l_tdr_res, $l_tdr_torps; global $l_tdr_nodestporttrade, $l_tdr_tradedestportoutsider, $l_tdr_portin, $l_tdr_planet, $l_tdr_bought, $l_tdr_colonists; global $l_tdr_fighters, $l_tdr_nothingtotrade, $l_here, $l_tdr_five, $l_tdr_ten, $l_tdr_fifty; global $l_tdr_nothingtodump; global $db; global $db_logging; global $portfull; foreach ($traderoutes as $testroute) { if ($testroute['traderoute_id'] == $engage) { $traderoute = $testroute; } } if (!isset($traderoute)) { traderoute_die($l_tdr_engagenonexist); } if ($traderoute['owner'] != $playerinfo['ship_id']) { traderoute_die($l_tdr_notowntdr); } // Source Check if ($traderoute['source_type'] == 'P') { // Retrieve port info here, we'll need it later anyway $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id=?;", array($traderoute['source_id'])); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); // $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id=$traderoute[source_id] AND (owner = $playerinfo[ship_id] OR (corp <> 0 AND corp = $playerinfo[team]));"); if (!$result || $result->EOF) { traderoute_die($l_tdr_invalidspoint); } $source = $result->fields; if ($traderoute['source_id'] != $playerinfo['sector']) { $l_tdr_inittdr = str_replace("[tdr_source_id]", $traderoute['source_id'], $l_tdr_inittdr); traderoute_die($l_tdr_inittdr); } } elseif ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') { // $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id=$traderoute[source_id]"); $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id=? AND (owner = ? OR (corp <> 0 AND corp = ?));", array($traderoute['source_id'], $playerinfo['ship_id'], $playerinfo['team'])); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); if (!$result || $result->EOF) { traderoute_die($l_tdr_invalidsrc); } $source = $result->fields; if ($source['sector_id'] != $playerinfo['sector']) { // Check for valid Owned Source Planet // $l_tdr_inittdrsector = str_replace("[tdr_source_sector_id]", $source['sector_id'], $l_tdr_inittdrsector); // traderoute_die ($l_tdr_inittdrsector); traderoute_die("You must be in starting sector before you initiate a trade route!"); } if ($traderoute['source_type'] == 'L') { if ($source['owner'] != $playerinfo['ship_id']) { // $l_tdr_notyourplanet = str_replace("[tdr_source_name]", $source[name], $l_tdr_notyourplanet); // $l_tdr_notyourplanet = str_replace("[tdr_source_sector_id]", $source[sector_id], $l_tdr_notyourplanet); // traderoute_die ($l_tdr_notyourplanet); traderoute_die($l_tdr_invalidsrc); } } elseif ($traderoute['source_type'] == 'C') { if ($source['corp'] != $playerinfo['team']) { // $l_tdr_notyourplanet = str_replace("[tdr_source_name]", $source[name], $l_tdr_notyourplanet); // $l_tdr_notyourplanet = str_replace("[tdr_source_sector_id]", $source[sector_id], $l_tdr_notyourplanet); // $not_corp_planet = "$source[name] in $source[sector_id] not a Copporate Planet"; // traderoute_die ($not_corp_planet); traderoute_die($l_tdr_invalidsrc); } } // Store starting port info, we'll need it later $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id=?;", array($source['sector_id'])); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); if (!$result || $result->EOF) { traderoute_die($l_tdr_invalidssector); } $sourceport = $result->fields; } // Destination Check if ($traderoute['dest_type'] == 'P') { $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id=?;", array($traderoute['dest_id'])); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); if (!$result || $result->EOF) { traderoute_die($l_tdr_invaliddport); } $dest = $result->fields; } elseif ($traderoute['dest_type'] == 'L' || $traderoute['dest_type'] == 'C') { // Check for valid Owned Source Planet // This now only returns Planets that the player owns or planets that belong to the team and set as corp planets.. // $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id=$traderoute[dest_id]"); $result = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id=? AND (owner = ? OR (corp <> 0 AND corp = ?));", array($traderoute['dest_id'], $playerinfo['ship_id'], $playerinfo['team'])); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); if (!$result || $result->EOF) { traderoute_die($l_tdr_invaliddplanet); } $dest = $result->fields; if ($traderoute['dest_type'] == 'L') { if ($dest['owner'] != $playerinfo['ship_id']) { $l_tdr_notyourplanet = str_replace("[tdr_source_name]", $dest['name'], $l_tdr_notyourplanet); $l_tdr_notyourplanet = str_replace("[tdr_source_sector_id]", $dest['sector_id'], $l_tdr_notyourplanet); traderoute_die($l_tdr_notyourplanet); } } elseif ($traderoute['dest_type'] == 'C') { if ($dest['corp'] != $playerinfo['team']) { $l_tdr_notyourplanet = str_replace("[tdr_source_name]", $dest['name'], $l_tdr_notyourplanet); $l_tdr_notyourplanet = str_replace("[tdr_source_sector_id]", $dest['sector_id'], $l_tdr_notyourplanet); traderoute_die($l_tdr_notyourplanet); } } $result = $db->Execute("SELECT * FROM {$db->prefix}universe WHERE sector_id=?;", array($dest['sector_id'])); db_op_result($db, $result, __LINE__, __FILE__, $db_logging); if (!$result || $result->EOF) { traderoute_die($l_tdr_invaliddsector); } $destport = $result->fields; } if (!isset($sourceport)) { $sourceport = $source; } if (!isset($destport)) { $destport = $dest; } // Warp or RealSpace and generate distance if ($traderoute['move_type'] == 'W') { $query = $db->Execute("SELECT link_id FROM {$db->prefix}links WHERE link_start=? AND link_dest=?;", array($source['sector_id'], $dest['sector_id'])); db_op_result($db, $query, __LINE__, __FILE__, $db_logging); if ($query->EOF) { $l_tdr_nowlink1 = str_replace("[tdr_src_sector_id]", $source['sector_id'], $l_tdr_nowlink1); $l_tdr_nowlink1 = str_replace("[tdr_dest_sector_id]", $dest['sector_id'], $l_tdr_nowlink1); traderoute_die($l_tdr_nowlink1); } if ($traderoute['circuit'] == '2') { $query = $db->Execute("SELECT link_id FROM {$db->prefix}links WHERE link_start=? AND link_dest=?;", array($dest['sector_id'], $source['sector_id'])); db_op_result($db, $query, __LINE__, __FILE__, $db_logging); if ($query->EOF) { $l_tdr_nowlink2 = str_replace("[tdr_src_sector_id]", $source['sector_id'], $l_tdr_nowlink2); $l_tdr_nowlink2 = str_replace("[tdr_dest_sector_id]", $dest['sector_id'], $l_tdr_nowlink2); traderoute_die($l_tdr_nowlink2); } $dist['triptime'] = 4; } else { $dist['triptime'] = 2; } $dist['scooped'] = 0; $dist['scooped1'] = 0; $dist['scooped2'] = 0; } else { $dist = traderoute_distance('P', 'P', $sourceport, $destport, $traderoute['circuit']); } // Check if player has enough turns if ($playerinfo['turns'] < $dist['triptime']) { $l_tdr_moreturnsneeded = str_replace("[tdr_dist_triptime]", $dist['triptime'], $l_tdr_moreturnsneeded); $l_tdr_moreturnsneeded = str_replace("[tdr_playerinfo_turns]", $playerinfo['turns'], $l_tdr_moreturnsneeded); traderoute_die($l_tdr_moreturnsneeded); } // Sector Defense Check $hostile = 0; $result99 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id = ? AND ship_id <> ?;", array($source['sector_id'], $playerinfo['ship_id'])); db_op_result($db, $result99, __LINE__, __FILE__, $db_logging); if (!$result99->EOF) { $fighters_owner = $result99->fields; $nsresult = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id=?;", array($fighters_owner['ship_id'])); db_op_result($db, $nsresult, __LINE__, __FILE__, $db_logging); $nsfighters = $nsresult->fields; if ($nsfighters['team'] != $playerinfo['team'] || $playerinfo['team'] == 0) { $hostile = 1; } } $result98 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id = ? AND ship_id <> ?;", array($dest['sector_id'], $playerinfo['ship_id'])); db_op_result($db, $result98, __LINE__, __FILE__, $db_logging); if (!$result98->EOF) { $fighters_owner = $result98->fields; $nsresult = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE ship_id=?;", array($fighters_owner['ship_id'])); db_op_result($db, $nsresult, __LINE__, __FILE__, $db_logging); $nsfighters = $nsresult->fields; if ($nsfighters['team'] != $playerinfo['team'] || $playerinfo['team'] == 0) { $hostile = 1; } } if ($hostile > 0 && $playerinfo['hull'] > $mine_hullsize) { traderoute_die($l_tdr_hostdef); } // Special Port Nothing to do if ($traderoute['source_type'] == 'P' && $source['port_type'] == 'special' && $playerinfo['trade_colonists'] == 'N' && $playerinfo['trade_fighters'] == 'N' && $playerinfo['trade_torps'] == 'N') { traderoute_die($l_tdr_globalsetbuynothing); } // Check if zone allows trading SRC if ($traderoute['source_type'] == 'P') { $res = $db->Execute("SELECT * FROM {$db->prefix}zones,{$db->prefix}universe WHERE {$db->prefix}universe.sector_id=? AND {$db->prefix}zones.zone_id={$db->prefix}universe.zone_id;", array($traderoute['source_id'])); db_op_result($db, $res, __LINE__, __FILE__, $db_logging); $zoneinfo = $res->fields; if ($zoneinfo['allow_trade'] == 'N') { traderoute_die($l_tdr_nosrcporttrade); } elseif ($zoneinfo['allow_trade'] == 'L') { if ($zoneinfo['corp_zone'] == 'N') { $res = $db->Execute("SELECT team FROM {$db->prefix}ships WHERE ship_id=?;", array($zoneinfo['owner'])); db_op_result($db, $res, __LINE__, __FILE__, $db_logging); $ownerinfo = $res->fields; if ($playerinfo['ship_id'] != $zoneinfo['owner'] && $playerinfo['team'] == 0 || $playerinfo['team'] != $ownerinfo['team']) { traderoute_die($l_tdr_tradesrcportoutsider); } } else { if ($playerinfo['team'] != $zoneinfo['owner']) { traderoute_die($l_tdr_tradesrcportoutsider); } } } } // Check if zone allows trading DEST if ($traderoute['dest_type'] == 'P') { $res = $db->Execute("SELECT * FROM {$db->prefix}zones,{$db->prefix}universe WHERE {$db->prefix}universe.sector_id=? AND {$db->prefix}zones.zone_id={$db->prefix}universe.zone_id;", array($traderoute['dest_id'])); db_op_result($db, $res, __LINE__, __FILE__, $db_logging); $zoneinfo = $res->fields; if ($zoneinfo['allow_trade'] == 'N') { traderoute_die($l_tdr_nodestporttrade); } elseif ($zoneinfo['allow_trade'] == 'L') { if ($zoneinfo['corp_zone'] == 'N') { $res = $db->Execute("SELECT team FROM {$db->prefix}ships WHERE ship_id=?;", array($zoneinfo['owner'])); db_op_result($db, $res, __LINE__, __FILE__, $db_logging); $ownerinfo = $res->fields; if ($playerinfo['ship_id'] != $zoneinfo['owner'] && $playerinfo['team'] == 0 || $playerinfo['team'] != $ownerinfo['team']) { traderoute_die($l_tdr_tradedestportoutsider); } } else { if ($playerinfo['team'] != $zoneinfo['owner']) { traderoute_die($l_tdr_tradedestportoutsider); } } } } traderoute_results_table_top(); // Determine if Source is Planet or Port if ($traderoute['source_type'] == 'P') { echo "{$l_tdr_portin} {$source['sector_id']}"; } elseif ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') { echo "{$l_tdr_planet} {$source['name']} in {$sourceport['sector_id']}"; } traderoute_results_source(); // Determine if Destination is Planet or Port if ($traderoute['dest_type'] == 'P') { echo "{$l_tdr_portin} {$dest['sector_id']}"; } elseif ($traderoute['dest_type'] == 'L' || $traderoute['dest_type'] == 'C') { echo "{$l_tdr_planet} {$dest['name']} in {$destport['sector_id']}"; } traderoute_results_destination(); $sourcecost = 0; // Source is Port if ($traderoute['source_type'] == 'P') { // Special Port Section (begin) if ($source['port_type'] == 'special') { $ore_buy = 0; $goods_buy = 0; $organics_buy = 0; $energy_buy = 0; $total_credits = $playerinfo['credits']; if ($playerinfo['trade_colonists'] == 'Y') { $free_holds = NUM_HOLDS($playerinfo['hull']) - $playerinfo['ship_ore'] - $playerinfo['ship_organics'] - $playerinfo['ship_goods'] - $playerinfo['ship_colonists']; $colonists_buy = $free_holds; if ($playerinfo['credits'] < $colonist_price * $colonists_buy) { $colonists_buy = $playerinfo['credits'] / $colonist_price; } if ($colonists_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($colonists_buy) . " {$l_tdr_colonists}<br>"; } $sourcecost -= $colonists_buy * $colonist_price; $total_credits -= $colonists_buy * $colonist_price; } else { $colonists_buy = 0; } if ($playerinfo['trade_fighters'] == 'Y') { $free_fighters = NUM_FIGHTERS($playerinfo['computer']) - $playerinfo['ship_fighters']; $fighters_buy = $free_fighters; if ($total_credits < $fighters_buy * $fighter_price) { $fighters_buy = $total_credits / $fighter_price; } if ($fighters_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($fighters_buy) . " {$l_tdr_fighters}<br>"; } $sourcecost -= $fighters_buy * $fighter_price; $total_credits -= $fighters_buy * $fighter_price; } else { $fighters_buy = 0; } if ($playerinfo['trade_torps'] == 'Y') { $free_torps = NUM_FIGHTERS($playerinfo['torp_launchers']) - $playerinfo['torps']; $torps_buy = $free_torps; if ($total_credits < $torps_buy * $torpedo_price) { $torps_buy = $total_credits / $torpedo_price; } if ($torps_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($torps_buy) . " {$l_tdr_torps}<br>"; } $sourcecost -= $torps_buy * $torpedo_price; } else { $torps_buy = 0; } if ($torps_buy == 0 && $colonists_buy == 0 && $fighters_buy == 0) { echo "{$l_tdr_nothingtotrade}<br>"; } if ($traderoute['circuit'] == '1') { $resb = $db->Execute("UPDATE {$db->prefix}ships SET ship_colonists=ship_colonists+?, ship_fighters=ship_fighters+?,torps=torps+?, ship_energy=ship_energy+? WHERE ship_id=?;", array($colonists_buy, $fighters_buy, $torps_buy, $dist['scooped1'], $playerinfo['ship_id'])); db_op_result($db, $resb, __LINE__, __FILE__, $db_logging); } } else { // Sells commodities // Added below initializations, for traderoute bug $ore_buy = 0; $goods_buy = 0; $organics_buy = 0; $energy_buy = 0; if ($source['port_type'] != 'ore') { $ore_price1 = $ore_price + $ore_delta * $source['port_ore'] / $ore_limit * $inventory_factor; if ($source['port_ore'] - $playerinfo['ship_ore'] < 0) { $ore_buy = $source['port_ore']; $portfull = 1; } else { $ore_buy = $playerinfo['ship_ore']; } $sourcecost += $ore_buy * $ore_price1; if ($ore_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($ore_buy) . " {$l_tdr_ore} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($ore_buy) . " {$l_tdr_ore}<br>"; } } $playerinfo['ship_ore'] -= $ore_buy; } $portfull = 0; if ($source['port_type'] != 'goods') { $goods_price1 = $goods_price + $goods_delta * $source['port_goods'] / $goods_limit * $inventory_factor; if ($source['port_goods'] - $playerinfo['ship_goods'] < 0) { $goods_buy = $source['port_goods']; $portfull = 1; } else { $goods_buy = $playerinfo['ship_goods']; } $sourcecost += $goods_buy * $goods_price1; if ($goods_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($goods_buy) . " {$l_tdr_goods} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($goods_buy) . " {$l_tdr_goods}<br>"; } } $playerinfo['ship_goods'] -= $goods_buy; } $portfull = 0; if ($source['port_type'] != 'organics') { $organics_price1 = $organics_price + $organics_delta * $source['port_organics'] / $organics_limit * $inventory_factor; if ($source['port_organics'] - $playerinfo['ship_organics'] < 0) { $organics_buy = $source['port_organics']; $portfull = 1; } else { $organics_buy = $playerinfo['ship_organics']; } $sourcecost += $organics_buy * $organics_price1; if ($organics_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($organics_buy) . " {$l_tdr_organics} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($organics_buy) . " {$l_tdr_organics}<br>"; } } $playerinfo['ship_organics'] -= $organics_buy; } $portfull = 0; if ($source['port_type'] != 'energy' && $playerinfo['trade_energy'] == 'Y') { $energy_price1 = $energy_price + $energy_delta * $source['port_energy'] / $energy_limit * $inventory_factor; if ($source['port_energy'] - $playerinfo['ship_energy'] < 0) { $energy_buy = $source['port_energy']; $portfull = 1; } else { $energy_buy = $playerinfo['ship_energy']; } $sourcecost += $energy_buy * $energy_price1; if ($energy_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($energy_buy) . " {$l_tdr_energy} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($energy_buy) . " {$l_tdr_energy}<br>"; } } $playerinfo['ship_energy'] -= $energy_buy; } $free_holds = NUM_HOLDS($playerinfo['hull']) - $playerinfo['ship_ore'] - $playerinfo['ship_organics'] - $playerinfo['ship_goods'] - $playerinfo['ship_colonists']; // Time to buy if ($source['port_type'] == 'ore') { $ore_price1 = $ore_price - $ore_delta * $source['port_ore'] / $ore_limit * $inventory_factor; $ore_buy = $free_holds; if ($playerinfo['credits'] + $sourcecost < $ore_buy * $ore_price1) { $ore_buy = ($playerinfo['credits'] + $sourcecost) / $ore_price1; } if ($source['port_ore'] < $ore_buy) { $ore_buy = $source['port_ore']; if ($source['port_ore'] == 0) { echo "{$l_tdr_bought} " . NUMBER($ore_buy) . " {$l_tdr_ore} ({$l_tdr_portisempty})<br>"; } } if ($ore_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($ore_buy) . " {$l_tdr_ore}<br>"; } $playerinfo['ship_ore'] += $ore_buy; $sourcecost -= $ore_buy * $ore_price1; $resc = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $source['sector_id'])); db_op_result($db, $resc, __LINE__, __FILE__, $db_logging); } if ($source['port_type'] == 'goods') { $goods_price1 = $goods_price - $goods_delta * $source['port_goods'] / $goods_limit * $inventory_factor; $goods_buy = $free_holds; if ($playerinfo['credits'] + $sourcecost < $goods_buy * $goods_price1) { $goods_buy = ($playerinfo['credits'] + $sourcecost) / $goods_price1; } if ($source['port_goods'] < $goods_buy) { $goods_buy = $source['port_goods']; if ($source['port_goods'] == 0) { echo "{$l_tdr_bought} " . NUMBER($goods_buy) . " {$l_tdr_goods} ({$l_tdr_portisempty})<br>"; } } if ($goods_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($goods_buy) . " {$l_tdr_goods}<br>"; } $playerinfo['ship_goods'] += $goods_buy; $sourcecost -= $goods_buy * $goods_price1; $resd = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $source['sector_id'])); db_op_result($db, $resd, __LINE__, __FILE__, $db_logging); } if ($source['port_type'] == 'organics') { $organics_price1 = $organics_price - $organics_delta * $source['port_organics'] / $organics_limit * $inventory_factor; $organics_buy = $free_holds; if ($playerinfo['credits'] + $sourcecost < $organics_buy * $organics_price1) { $organics_buy = ($playerinfo['credits'] + $sourcecost) / $organics_price1; } if ($source['port_organics'] < $organics_buy) { $organics_buy = $source['port_organics']; if ($source['port_organics'] == 0) { echo "{$l_tdr_bought} " . NUMBER($organics_buy) . " {$l_tdr_organics} ({$l_tdr_portisempty})<br>"; } } if ($organics_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($organics_buy) . " {$l_tdr_organics}<br>"; } $playerinfo['ship_organics'] += $organics_buy; $sourcecost -= $organics_buy * $organics_price1; $rese = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $source['sector_id'])); db_op_result($db, $rese, __LINE__, __FILE__, $db_logging); } if ($source['port_type'] == 'energy') { $energy_price1 = $energy_price - $energy_delta * $source['port_energy'] / $energy_limit * $inventory_factor; $energy_buy = NUM_ENERGY($playerinfo['power']) - $playerinfo['ship_energy'] - $dist['scooped1']; if ($playerinfo['credits'] + $sourcecost < $energy_buy * $energy_price1) { $energy_buy = ($playerinfo['credits'] + $sourcecost) / $energy_price1; } if ($source['port_energy'] < $energy_buy) { $energy_buy = $source['port_energy']; if ($source['port_energy'] == 0) { echo "{$l_tdr_bought} " . NUMBER($energy_buy) . " {$l_tdr_energy} ({$l_tdr_portisempty})<br>"; } } if ($energy_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($energy_buy) . " {$l_tdr_energy}<br>"; } $playerinfo['ship_energy'] += $energy_buy; $sourcecost -= $energy_buy * $energy_price1; $resf = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $source['sector_id'])); db_op_result($db, $resf, __LINE__, __FILE__, $db_logging); } if ($dist['scooped1'] > 0) { $playerinfo['ship_energy'] += $dist['scooped1']; if ($playerinfo['ship_energy'] > NUM_ENERGY($playerinfo['power'])) { $playerinfo['ship_energy'] = NUM_ENERGY($playerinfo['power']); } } if ($ore_buy == 0 && $goods_buy == 0 && $energy_buy == 0 && $organics_buy == 0) { echo "{$l_tdr_nothingtotrade}<br>"; } if ($traderoute['circuit'] == '1') { $resf = $db->Execute("UPDATE {$db->prefix}ships SET ship_ore=?, ship_goods=?, ship_organics=?, ship_energy=? WHERE ship_id=?;", array($playerinfo['ship_ore'], $playerinfo['ship_goods'], $playerinfo['ship_organics'], $playerinfo['ship_energy'], $playerinfo['ship_id'])); db_op_result($db, $resf, __LINE__, __FILE__, $db_logging); } } } elseif ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') { $free_holds = NUM_HOLDS($playerinfo['hull']) - $playerinfo['ship_ore'] - $playerinfo['ship_organics'] - $playerinfo['ship_goods'] - $playerinfo['ship_colonists']; if ($traderoute['dest_type'] == 'P') { // Pick stuff up to sell at port if ($playerinfo['ship_id'] == $source['owner'] || $playerinfo['team'] == $source['corp']) { if ($source['goods'] > 0 && $free_holds > 0 && $dest['port_type'] != 'goods') { if ($source['goods'] > $free_holds) { $goods_buy = $free_holds; } else { $goods_buy = $source['goods']; } $free_holds -= $goods_buy; $playerinfo['ship_goods'] += $goods_buy; echo "{$l_tdr_loaded} " . NUMBER($goods_buy) . " {$l_tdr_goods}<br>"; } else { $goods_buy = 0; } if ($source['ore'] > 0 && $free_holds > 0 && $dest['port_type'] != 'ore') { if ($source['ore'] > $free_holds) { $ore_buy = $free_holds; } else { $ore_buy = $source['ore']; } $free_holds -= $ore_buy; $playerinfo['ship_ore'] += $ore_buy; echo "{$l_tdr_loaded} " . NUMBER($ore_buy) . " {$l_tdr_ore}<br>"; } else { $ore_buy = 0; } if ($source['organics'] > 0 && $free_holds > 0 && $dest['port_type'] != 'organics') { if ($source['organics'] > $free_holds) { $organics_buy = $free_holds; } else { $organics_buy = $source['organics']; } $free_holds -= $organics_buy; $playerinfo['ship_organics'] += $organics_buy; echo "{$l_tdr_loaded} " . NUMBER($organics_buy) . " {$l_tdr_organics}<br>"; } else { $organics_buy = 0; } if ($ore_buy == 0 && $goods_buy == 0 && $organics_buy == 0) { echo "{$l_tdr_nothingtoload}<br>"; } if ($traderoute['circuit'] == '1') { $resg = $db->Execute("UPDATE {$db->prefix}ships SET ship_ore=?, ship_goods=?, ship_organics=? WHERE ship_id=?;", array($playerinfo['ship_ore'], $playerinfo['ship_goods'], $playerinfo['ship_organics'], $playerinfo['ship_id'])); db_op_result($db, $resg, __LINE__, __FILE__, $db_logging); } } else { } $resh = $db->Execute("UPDATE {$db->prefix}planets SET ore=ore-?, goods=goods-?, organics=organics-? WHERE planet_id=?;", array($ore_buy, $goods_buy, $organics_buy, $source['planet_id'])); db_op_result($db, $resh, __LINE__, __FILE__, $db_logging); } elseif ($traderoute['dest_type'] == 'L' || $traderoute['dest_type'] == 'C') { if ($source['colonists'] > 0 && $free_holds > 0 && $playerinfo['trade_colonists'] == 'Y') { if ($source['colonists'] > $free_holds) { $colonists_buy = $free_holds; } else { $colonists_buy = $source['colonists']; } $free_holds -= $colonists_buy; $playerinfo['ship_colonists'] += $colonists_buy; echo "{$l_tdr_loaded} " . NUMBER($colonists_buy) . " {$l_tdr_colonists}<br>"; } else { $colonists_buy = 0; } $free_torps = NUM_TORPEDOES($playerinfo['torp_launchers']) - $playerinfo['torps']; if ($source['torps'] > 0 && $free_torps > 0 && $playerinfo['trade_torps'] == 'Y') { if ($source['torps'] > $free_torps) { $torps_buy = $free_torps; } else { $torps_buy = $source['torps']; } $free_torps -= $torps_buy; $playerinfo['torps'] += $torps_buy; echo "{$l_tdr_loaded} " . NUMBER($torps_buy) . " {$l_tdr_torps}<br>"; } else { $torps_buy = 0; } $free_fighters = NUM_FIGHTERS($playerinfo['computer']) - $playerinfo['ship_fighters']; if ($source['fighters'] > 0 && $free_fighters > 0 && $playerinfo['trade_fighters'] == 'Y') { if ($source['fighters'] > $free_fighters) { $fighters_buy = $free_fighters; } else { $fighters_buy = $source['fighters']; } $free_fighters -= $fighters_buy; $playerinfo['ship_fighters'] += $fighters_buy; echo "{$l_tdr_loaded} " . NUMBER($fighters_buy) . " {$l_tdr_fighters}<br>"; } else { $fighters_buy = 0; } if ($fighters_buy == 0 && $torps_buy == 0 && $colonists_buy == 0) { echo "{$l_tdr_nothingtoload}<br>"; } if ($traderoute['circuit'] == '1') { $resi = $db->Execute("UPDATE {$db->prefix}ships SET torps=?, ship_fighters=?, ship_colonists=? WHERE ship_id=?;", array($playerinfo['torps'], $playerinfo['ship_fighters'], $playerinfo['ship_colonists'], $playerinfo['ship_id'])); db_op_result($db, $resi, __LINE__, __FILE__, $db_logging); } $resj = $db->Execute("UPDATE {$db->prefix}planets SET colonists=colonists-?, torps=torps-?, fighters=fighters-? WHERE planet_id=?;", array($colonists_buy, $torps_buy, $fighters_buy, $source['planet_id'])); db_op_result($db, $resj, __LINE__, __FILE__, $db_logging); } } if ($dist['scooped1'] != 0) { echo "{$l_tdr_scooped} " . NUMBER($dist['scooped1']) . " {$l_tdr_energy}<br>"; } traderoute_results_close_cell(); if ($traderoute['circuit'] == '2') { $playerinfo['credits'] += $sourcecost; $destcost = 0; if ($traderoute['dest_type'] == 'P') { // Added the below for traderoute bug $ore_buy = 0; $goods_buy = 0; $organics_buy = 0; $energy_buy = 0; // Sells commodities $portfull = 0; if ($dest['port_type'] != 'ore') { $ore_price1 = $ore_price + $ore_delta * $dest['port_ore'] / $ore_limit * $inventory_factor; if ($dest['port_ore'] - $playerinfo['ship_ore'] < 0) { $ore_buy = $dest['port_ore']; $portfull = 1; } else { $ore_buy = $playerinfo['ship_ore']; } $destcost += $ore_buy * $ore_price1; if ($ore_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($ore_buy) . " {$l_tdr_ore} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($ore_buy) . " {$l_tdr_ore}<br>"; } } $playerinfo['ship_ore'] -= $ore_buy; } $portfull = 0; if ($dest['port_type'] != 'goods') { $goods_price1 = $goods_price + $goods_delta * $dest['port_goods'] / $goods_limit * $inventory_factor; if ($dest['port_goods'] - $playerinfo['ship_goods'] < 0) { $goods_buy = $dest['port_goods']; $portfull = 1; } else { $goods_buy = $playerinfo['ship_goods']; } $destcost += $goods_buy * $goods_price1; if ($goods_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($goods_buy) . " {$l_tdr_goods} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($goods_buy) . " {$l_tdr_goods}<br>"; } } $playerinfo['ship_goods'] -= $goods_buy; } $portfull = 0; if ($dest['port_type'] != 'organics') { $organics_price1 = $organics_price + $organics_delta * $dest['port_organics'] / $organics_limit * $inventory_factor; if ($dest['port_organics'] - $playerinfo['ship_organics'] < 0) { $organics_buy = $dest['port_organics']; $portfull = 1; } else { $organics_buy = $playerinfo['ship_organics']; } $destcost += $organics_buy * $organics_price1; if ($organics_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($organics_buy) . " {$l_tdr_organics} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($organics_buy) . " {$l_tdr_organics}<br>"; } } $playerinfo['ship_organics'] -= $organics_buy; } $portfull = 0; if ($dest['port_type'] != 'energy' && $playerinfo['trade_energy'] == 'Y') { $energy_price1 = $energy_price + $energy_delta * $dest['port_energy'] / $energy_limit * $inventory_factor; if ($dest['port_energy'] - $playerinfo['ship_energy'] < 0) { $energy_buy = $dest['port_energy']; $portfull = 1; } else { $energy_buy = $playerinfo['ship_energy']; } $destcost += $energy_buy * $energy_price1; if ($energy_buy != 0) { if ($portfull == 1) { echo "{$l_tdr_sold} " . NUMBER($energy_buy) . " {$l_tdr_energy} ({$l_tdr_portisfull})<br>"; } else { echo "{$l_tdr_sold} " . NUMBER($energy_buy) . " {$l_tdr_energy}<br>"; } } $playerinfo['ship_energy'] -= $energy_buy; } else { $energy_buy = 0; } $free_holds = NUM_HOLDS($playerinfo['hull']) - $playerinfo['ship_ore'] - $playerinfo['ship_organics'] - $playerinfo['ship_goods'] - $playerinfo['ship_colonists']; // Time to buy if ($dest['port_type'] == 'ore') { $ore_price1 = $ore_price - $ore_delta * $dest['port_ore'] / $ore_limit * $inventory_factor; if ($traderoute['source_type'] == 'L') { $ore_buy = 0; } else { $ore_buy = $free_holds; if ($playerinfo['credits'] + $destcost < $ore_buy * $ore_price1) { $ore_buy = ($playerinfo['credits'] + $destcost) / $ore_price1; } if ($dest['port_ore'] < $ore_buy) { $ore_buy = $dest['port_ore']; if ($dest['port_ore'] == 0) { echo "{$l_tdr_bought} " . NUMBER($ore_buy) . " {$l_tdr_ore} ({$l_tdr_portisempty})<br>"; } } if ($ore_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($ore_buy) . " {$l_tdr_ore}<br>"; } $playerinfo['ship_ore'] += $ore_buy; $destcost -= $ore_buy * $ore_price1; } $resk = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); db_op_result($db, $resk, __LINE__, __FILE__, $db_logging); } if ($dest['port_type'] == 'goods') { $goods_price1 = $goods_price - $goods_delta * $dest['port_goods'] / $goods_limit * $inventory_factor; if ($traderoute['source_type'] == 'L') { $goods_buy = 0; } else { $goods_buy = $free_holds; if ($playerinfo['credits'] + $destcost < $goods_buy * $goods_price1) { $goods_buy = ($playerinfo['credits'] + $destcost) / $goods_price1; } if ($dest['port_goods'] < $goods_buy) { $goods_buy = $dest['port_goods']; if ($dest['port_goods'] == 0) { echo "{$l_tdr_bought} " . NUMBER($goods_buy) . " {$l_tdr_goods} ({$l_tdr_portisempty})<br>"; } } if ($goods_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($goods_buy) . " {$l_tdr_goods}<br>"; } $playerinfo['ship_goods'] += $goods_buy; $destcost -= $goods_buy * $goods_price1; } $resl = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); db_op_result($db, $resl, __LINE__, __FILE__, $db_logging); } if ($dest['port_type'] == 'organics') { $organics_price1 = $organics_price - $organics_delta * $dest['port_organics'] / $organics_limit * $inventory_factor; if ($traderoute['source_type'] == 'L') { $organics_buy = 0; } else { $organics_buy = $free_holds; if ($playerinfo['credits'] + $destcost < $organics_buy * $organics_price1) { $organics_buy = ($playerinfo['credits'] + $destcost) / $organics_price1; } if ($dest['port_organics'] < $organics_buy) { $organics_buy = $dest['port_organics']; if ($dest['port_organics'] == 0) { echo "{$l_tdr_bought} " . NUMBER($organics_buy) . " {$l_tdr_organics} ({$l_tdr_portisempty})<br>"; } } if ($organics_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($organics_buy) . " {$l_tdr_organics}<br>"; } $playerinfo['ship_organics'] += $organics_buy; $destcost -= $organics_buy * $organics_price1; } $resm = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); db_op_result($db, $resm, __LINE__, __FILE__, $db_logging); } if ($dest['port_type'] == 'energy') { $energy_price1 = $energy_price - $energy_delta * $dest['port_energy'] / $energy_limit * $inventory_factor; if ($traderoute['source_type'] == 'L') { $energy_buy = 0; } else { $energy_buy = NUM_ENERGY($playerinfo['power']) - $playerinfo['ship_energy'] - $dist['scooped1']; if ($playerinfo['credits'] + $destcost < $energy_buy * $energy_price1) { $energy_buy = ($playerinfo['credits'] + $destcost) / $energy_price1; } if ($dest['port_energy'] < $energy_buy) { $energy_buy = $dest['port_energy']; if ($dest['port_energy'] == 0) { echo "{$l_tdr_bought} " . NUMBER($energy_buy) . " {$l_tdr_energy} ({$l_tdr_portisempty})<br>"; } } if ($energy_buy != 0) { echo "{$l_tdr_bought} " . NUMBER($energy_buy) . " {$l_tdr_energy}<br>"; } $playerinfo['ship_energy'] += $energy_buy; $destcost -= $energy_buy * $energy_price1; } if ($ore_buy == 0 && $goods_buy == 0 && $energy_buy == 0 && $organics_buy == 0) { echo "{$l_tdr_nothingtotrade}<br>"; } $resn = $db->Execute("UPDATE {$db->prefix}universe SET port_ore=port_ore-?, port_energy=port_energy-?, port_goods=port_goods-?, port_organics=port_organics-? WHERE sector_id=?;", array($ore_buy, $energy_buy, $goods_buy, $organics_buy, $dest['sector_id'])); db_op_result($db, $resn, __LINE__, __FILE__, $db_logging); } if ($dist['scooped2'] > 0) { $playerinfo['ship_energy'] += $dist['scooped2']; if ($playerinfo['ship_energy'] > NUM_ENERGY($playerinfo['power'])) { $playerinfo['ship_energy'] = NUM_ENERGY($playerinfo['power']); } } $reso = $db->Execute("UPDATE {$db->prefix}ships SET ship_ore=?, ship_goods=?, ship_organics=?, ship_energy=? WHERE ship_id=?;", array($playerinfo['ship_ore'], $playerinfo['ship_goods'], $playerinfo['ship_organics'], $playerinfo['ship_energy'], $playerinfo['ship_id'])); db_op_result($db, $reso, __LINE__, __FILE__, $db_logging); } else { if ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') { $colonists_buy = 0; $fighters_buy = 0; $torps_buy = 0; } $setcol = 0; if ($playerinfo['trade_colonists'] == 'Y') { $colonists_buy += $playerinfo['ship_colonists']; $col_dump = $playerinfo['ship_colonists']; if ($dest['colonists'] + $colonists_buy >= $colonist_limit) { $exceeding = $dest['colonists'] + $colonists_buy - $colonist_limit; $col_dump = $exceeding; $setcol = 1; $colonists_buy -= $exceeding; if ($colonists_buy < 0) { $colonists_buy = 0; } } } else { $col_dump = 0; } if ($colonists_buy != 0) { if ($setcol == 1) { echo "{$l_tdr_dumped} " . NUMBER($colonists_buy) . " {$l_tdr_colonists} ({$l_tdr_planetisovercrowded})<br>"; } else { echo "{$l_tdr_dumped} " . NUMBER($colonists_buy) . " {$l_tdr_colonists}<br>"; } } if ($playerinfo['trade_fighters'] == 'Y') { $fighters_buy += $playerinfo['ship_fighters']; $fight_dump = $playerinfo['ship_fighters']; } else { $fight_dump = 0; } if ($fighters_buy != 0) { echo "{$l_tdr_dumped} " . NUMBER($fighters_buy) . " {$l_tdr_fighters}<br>"; } if ($playerinfo['trade_torps'] == 'Y') { $torps_buy += $playerinfo['torps']; $torps_dump = $playerinfo['torps']; } else { $torps_dump = 0; } if ($torps_buy != 0) { echo "{$l_tdr_dumped} " . NUMBER($torps_buy) . " {$l_tdr_torps}<br>"; } if ($torps_buy == 0 && $fighters_buy == 0 && $colonists_buy == 0) { echo "{$l_tdr_nothingtodump}<br>"; } if ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') { if ($playerinfo['trade_colonists'] == 'Y') { if ($setcol != 1) { $col_dump = 0; } } else { $col_dump = $playerinfo['ship_colonists']; } if ($playerinfo['trade_fighters'] == 'Y') { $fight_dump = 0; } else { $fight_dump = $playerinfo['ship_fighters']; } if ($playerinfo['trade_torps'] == 'Y') { $torps_dump = 0; } else { $torps_dump = $playerinfo['torps']; } } $resp = $db->Execute("UPDATE {$db->prefix}planets SET colonists=colonists+?, fighters=fighters+?, torps=torps+? WHERE planet_id=?;", array($colonists_buy, $fighters_buy, $torps_buy, $traderoute['dest_id'])); db_op_result($db, $resp, __LINE__, __FILE__, $db_logging); if ($traderoute['source_type'] == 'L' || $traderoute['source_type'] == 'C') { $resq = $db->Execute("UPDATE {$db->prefix}ships SET ship_colonists=?, ship_fighters=?, torps=?, ship_energy=ship_energy+? WHERE ship_id=?;", array($col_dump, $fight_dump, $torps_dump, $dist['scooped'], $playerinfo['ship_id'])); db_op_result($db, $resq, __LINE__, __FILE__, $db_logging); } else { if ($setcol == 1) { $resr = $db->Execute("UPDATE {$db->prefix}ships SET ship_colonists=?, ship_fighters=ship_fighters-?, torps=torps-?, ship_energy=ship_energy+? WHERE ship_id=?;", array($col_dump, $fight_dump, $torps_dump, $dist['scooped'], $playerinfo['ship_id'])); db_op_result($db, $resr, __LINE__, __FILE__, $db_logging); } else { $ress = $db->Execute("UPDATE {$db->prefix}ships SET ship_colonists=ship_colonists-?, ship_fighters=ship_fighters-?, torps=torps-?, ship_energy=ship_energy+? WHERE ship_id=?;", array($col_dump, $fight_dump, $torps_dump, $dist['scooped'], $playerinfo['ship_id'])); db_op_result($db, $ress, __LINE__, __FILE__, $db_logging); } } } if ($dist['scooped2'] != 0) { echo "{$l_tdr_scooped} " . NUMBER($dist['scooped1']) . " {$l_tdr_energy}<br>"; } } else { echo $l_tdr_onlyonewaytdr; $destcost = 0; } traderoute_results_show_cost(); if ($sourcecost > 0) { echo "{$l_tdr_profit} : " . NUMBER(abs($sourcecost)); } else { echo "{$l_tdr_cost} : " . NUMBER(abs($sourcecost)); } traderoute_results_close_cost(); if ($destcost > 0) { echo "{$l_tdr_profit} : " . NUMBER(abs($destcost)); } else { echo "{$l_tdr_cost} : " . NUMBER(abs($destcost)); } traderoute_results_close_table(); $total_profit = $sourcecost + $destcost; traderoute_results_display_totals($total_profit); if ($traderoute['circuit'] == '1') { $newsec = $destport['sector_id']; } else { $newsec = $sourceport['sector_id']; } $rest = $db->Execute("UPDATE {$db->prefix}ships SET turns=turns-?, credits=credits+?, turns_used=turns_used+?, sector=? WHERE ship_id=?;", array($dist['triptime'], $total_profit, $dist['triptime'], $newsec, $playerinfo['ship_id'])); db_op_result($db, $rest, __LINE__, __FILE__, $db_logging); $playerinfo['credits'] += $total_profit - $sourcecost; $playerinfo['turns'] -= $dist['triptime']; $tdr_display_creds = NUMBER($playerinfo['credits']); traderoute_results_display_summary($tdr_display_creds); // echo $j." -- "; if ($traderoute['circuit'] == 2) { $l_tdr_engageagain = str_replace("[here]", "<a href=\"traderoute.php?engage=[tdr_engage]\">" . $l_here . "</a>", $l_tdr_engageagain); $l_tdr_engageagain = str_replace("[five]", "<a href=\"traderoute.php?engage=[tdr_engage]&tr_repeat=5\">" . $l_tdr_five . "</a>", $l_tdr_engageagain); $l_tdr_engageagain = str_replace("[ten]", "<a href=\"traderoute.php?engage=[tdr_engage]&tr_repeat=10\">" . $l_tdr_ten . "</a>", $l_tdr_engageagain); $l_tdr_engageagain = str_replace("[fifty]", "<a href=\"traderoute.php?engage=[tdr_engage]&tr_repeat=50\">" . $l_tdr_fifty . "</a>", $l_tdr_engageagain); $l_tdr_engageagain = str_replace("[tdr_engage]", $engage, $l_tdr_engageagain); if ($j == 1) { echo $l_tdr_engageagain . "\n"; traderoute_results_show_repeat(); } } if ($j == 1) { traderoute_die(""); } }
$syllables = "er,in,tia,wol,fe,pre,vet,jo,nes,al,len,son,cha,ir,ler,bo,ok,tio,nar,sim,ple,bla,ten,toe,cho,co,lat,spe,ak,er,po,co,lor,pen,cil,li,ght,wh,at,the,he,ck,is,mam,bo,no,fi,ve,any,way,pol,iti,cs,ra,dio,sou,rce,sea,rch,pa,per,com,bo,sp,eak,st,fi,rst,gr,oup,boy,ea,gle,tr,ail,bi,ble,brb,pri,dee,kay,en,be,se"; $syllable_array = explode(",", $syllables); for ($count = 1; $count <= 4; $count++) { if (mt_rand() % 10 == 1) { $makepass .= sprintf("%0.0f", mt_rand() % 50 + 1); } else { $makepass .= sprintf("%s", $syllable_array[mt_rand() % 62]); } } if ($xenlevel == '') { $xenlevel = 0; } $maxenergy = NUM_ENERGY($xenlevel); $maxarmor = NUM_ARMOR($xenlevel); $maxfighters = NUM_FIGHTERS($xenlevel); $maxtorps = NUM_TORPEDOES($xenlevel); $stamp = date("Y-m-d H:i:s"); // ***************************************************************************** // *** ADD Xenobe RECORD TO ships table ... MODIFY IF ships SCHEMA CHANGES *** // ***************************************************************************** $thesql = "INSERT INTO {$db->prefix}ships ( `ship_id` , `ship_name` , `ship_destroyed` , `character_name` , `password` , `email` , `hull` , `engines` , `power` , `computer` , `sensors` , `beams` , `torp_launchers` , `torps` , `shields` , `armor` , `armor_pts` , `cloak` , `credits` , `sector` , `ship_ore` , `ship_organics` , `ship_goods` , `ship_energy` , `ship_colonists` , `ship_fighters` , `ship_damage` , `turns` , `on_planet` , `dev_warpedit` , `dev_genesis` , `dev_beacon` , `dev_emerwarp` , `dev_escapepod` , `dev_fuelscoop` , `dev_minedeflector` , `turns_used` , `last_login` , `last_kami` , `last_sofa` , `ship_kills` , `ship_deaths` , `rating` , `score` , `points` , `team` , `team_invite` , `ip_address` , `planet_id` , `preset1` , `preset2` , `preset3` , `preset4` , `preset5` , `trade_colonists` , `trade_fighters` , `trade_torps` , `trade_energy` , `cleared_defences` , `lang` , `dev_lssd` )\n values (NULL,'{$shipname}','N','{$character}','{$makepass}','{$emailname}',{$xenlevel},{$xenlevel},{$xenlevel},{$xenlevel},{$xenlevel},{$xenlevel},{$xenlevel},{$maxtorps},{$xenlevel},{$xenlevel},{$maxarmor},{$xenlevel},{$start_credits},{$sector},0,0,0,{$maxenergy},0,{$maxfighters},0,{$start_turns},'N',0,0,0,0,'N','N',0,0, '{$stamp}','0000-00-00 00:00:00','0000-00-00 00:00:00',0,0,0,0,0,0,0,'127.0.0.1',0,0,0,0,0,0,'Y','N','N','Y',NULL,'{$default_lang}','Y')"; $result2 = $db->Execute($thesql); db_op_result($db, $result2, __LINE__, __FILE__, $db_logging); if (!$result2) { echo $db->ErrorMsg() . "<br>"; } else { echo "Xenobe has been created.<br><br>"; echo "password has been set.<br><br>"; echo "Ship Records have been updated.<br><br>"; } $result3 = $db->Execute("INSERT INTO {$db->prefix}xenobe (xenobe_id,active,aggression,orders) valueS('{$emailname}','{$_active}','{$aggression}','{$orders}')");
$fighter_number = 0; $fighter_number = round(abs($fighter_number)); $fighter_max = NUM_FIGHTERS($shipinfo[computer]) - $shipinfo[ship_fighters]; if($fighter_max < 0) { $fighter_max = 0; } if($fighter_number > $fighter_max) { $fighter_number = $fighter_max; } $fighter_cost = $fighter_number * $fighter_price; if($torpedo_number < 0) $torpedo_number = 0; $torpedo_number = round(abs($torpedo_number)); $torpedo_max = NUM_TORPEDOES($shipinfo[torp_launchers]) - $shipinfo[torps]; if($torpedo_max < 0) { $torpedo_max = 0; } if($torpedo_number > $torpedo_max) { $torpedo_number = $torpedo_max; } $torpedo_cost = $torpedo_number * $torpedo_price; if($armour_number < 0) $armour_number = 0; $armour_number = round(abs($armour_number)); $armour_max = NUM_ARMOUR($shipinfo[armour]) - $shipinfo[armour_pts]; if($armour_max < 0) {
function furangeeregen() { // ******************************* // *** SETUP GENERAL VARIABLES *** // ******************************* global $playerinfo; global $shipinfo; global $furangeeisdead; global $db, $dbtables; // ******************************* // *** LETS REGENERATE ENERGY **** // ******************************* $maxenergy = NUM_ENERGY($shipinfo[power]); if ($shipinfo[ship_energy] <= ($maxenergy - 50)) // *** STOP REGEN WHEN WITHIN 50 OF MAX *** { // *** REGEN HALF OF REMAINING ENERGY *** $shipinfo[ship_energy] = $shipinfo[ship_energy] + round(($maxenergy - $shipinfo[ship_energy])/2); $gene = "regenerated Energy to $shipinfo[ship_energy] units,"; } // ******************************* // *** LETS REGENERATE ARMOUR **** // ******************************* $maxarmour = NUM_ARMOUR($shipinfo[armour]); if ($shipinfo[armour_pts] <= ($maxarmour - 50)) // *** STOP REGEN WHEN WITHIN 50 OF MAX *** { // *** REGEN HALF OF REMAINING ARMOUR *** $shipinfo[armour_pts] = $shipinfo[armour_pts] + round(($maxarmour - $shipinfo[armour_pts])/2); $gena = "regenerated Armour to $shipinfo[armour_pts] points,"; } // ******************************* // *** LETS BUY FIGHTERS/TORPS *** // ******************************* // ******************************* // *** FURANGEE PAY 6/FIGHTER **** // ******************************* if ($shipinfo[ship_fighters] < 0) { playerlog($playerinfo[player_id], LOG_RAW, "Furangee had ".NUMBER($shipinfo[ship_fighters])." FIGHTERS!"); $shipinfo[ship_fighters] = 0; } $available_fighters = NUM_FIGHTERS($shipinfo[computer]) - $shipinfo[ship_fighters]; if ($available_fighters > 100000) { $available_fighters = round($available_fighters/6); } if (($playerinfo[credits]>5) && ($available_fighters>0)) { if (round($playerinfo[credits]/50)>$available_fighters) { $purchase = ($available_fighters*50); $playerinfo[credits] = $playerinfo[credits] - $purchase; $shipinfo[ship_fighters] = $shipinfo[ship_fighters] + $available_fighters; $genf = "purchased $available_fighters fighters for $purchase credits,"; } if (round($playerinfo[credits]/50)<=$available_fighters) { $purchase = round($playerinfo[credits]/50); $shipinfo[ship_fighters] = $shipinfo[ship_fighters] + $purchase/50; $genf = "purchased $purchase fighters for $playerinfo[credits] credits,"; $playerinfo[credits] = 0; } } // ******************************* // *** FURANGEE PAY 3/TORPEDO **** // ******************************* $available_torpedoes = (NUM_TORPEDOES($shipinfo[torp_launchers]) - $shipinfo[torps]); if ($available_torpedoes > 10000) { $available_torpedoes = round($available_torpedoes/6); } if (($playerinfo[credits]>24) && ($available_torpedoes>0)) { if (round($playerinfo[credits]/25)>$available_torpedoes) { $purchase = $available_torpedoes*25; $playerinfo[credits] = $playerinfo[credits] - $purchase; $shipinfo[torps] = $shipinfo[torps] + $available_torpedoes; $gent = "purchased $available_torpedoes torpedoes for $purchase credits,"; } if (round($playerinfo[credits]/25)<=$available_torpedoes) { $purchase = (round($playerinfo[credits]/25)); $shipinfo[torps] = $shipinfo[torps] + $purchase; $gent = "purchased $purchase torpedoes for $playerinfo[credits] credits,"; $playerinfo[credits] = 0; } } // ********************************* // *** UPDATE FURANGEE RECORD ****** // ********************************* $db->Execute ("UPDATE $dbtables[players] SET credits=$playerinfo[credits] WHERE player_id=$playerinfo[player_id]"); $db->Execute ("UPDATE $dbtables[ships] SET ship_energy=$shipinfo[ship_energy], armour_pts=$shipinfo[armour_pts], ship_fighters=$shipinfo[ship_fighters], torps=$shipinfo[torps] WHERE player_id=$playerinfo[player_id] AND ship_id=$playerinfo[currentship]"); if (!$genf=='' || !$gent=='') { playerlog($playerinfo[player_id], LOG_RAW, "Furangee $genf $gent and has been updated."); } }