function send_auctioned_ship($ship_id, $dest) { global $db, $ACTUAL_TICK; $sql = 'SELECT s.ship_id, s.user_id, -s.fleet_id AS start, st.value_10 AS max_warp_speed, s1.system_id AS start_system_id, s1.system_global_x AS start_x, s1.system_global_y AS start_y, s2.system_id AS dest_system_id, s2.system_global_x AS dest_x, s2.system_global_y AS dest_y FROM (ships s) INNER JOIN (ship_templates st) ON st.id = s.template_id INNER JOIN (planets p1) ON p1.planet_id = -s.fleet_id INNER JOIN (starsystems s1) ON s1.system_id = p1.system_id INNER JOIN (planets p2) ON p2.planet_id = ' . $dest . ' INNER JOIN (starsystems s2) ON s2.system_id = p2.system_id WHERE s.ship_id = ' . $ship_id; if (($ship = $db->queryrow($sql)) === false) { message(DATABASE_ERROR, 'Could not query ship data'); } if (empty($ship['ship_id'])) { message(GENERAL, 'Ship for auction does not exist', '$ship[\'ship_id\'] = empty'); } if ($ship['max_warp_speed'] > 9.99) { $ship['max_warp_speed'] = 9.99; } if ($ship['start_system_id'] == $ship['dest_system_id']) { $distance = $velocity = 0; $min_time = 6; } else { $distance = get_distance(array($ship['start_x'], $ship['start_y']), array($ship['dest_x'], $ship['dest_y'])); $velocity = warpf($ship['max_warp_speed']); $min_time = ceil($distance / $velocity / TICK_DURATION); } if ($min_time < 1) { $min_time = 1; } $sql = 'INSERT INTO scheduler_shipmovement (user_id, move_status, move_exec_started, start, dest, total_distance, remaining_distance, tick_speed, move_begin, move_finish, n_ships, action_code, action_data) VALUES (' . $ship['user_id'] . ', 0, 0, ' . $ship['start'] . ', ' . $dest . ', ' . $distance . ', ' . $distance . ', ' . $velocity * TICK_DURATION . ', ' . $ACTUAL_TICK . ', ' . ($ACTUAL_TICK + $min_time) . ', 1, 33, "")'; if (!$db->query($sql)) { message(DATABASE_ERROR, 'Could not insert new movement data'); } $new_move_id = $db->insert_id(); if (empty($new_move_id)) { message(GENERAL, 'Could not send auction fleet', '$new_move_id = empty'); } $sql = 'INSERT INTO ship_fleets (fleet_name, user_id, planet_id, move_id, n_ships) VALUES ("Auction ' . $ship_id . '", ' . $ship['user_id'] . ', 0, ' . $new_move_id . ', 1)'; if (!$db->query($sql)) { message(DATABASE_ERROR, 'Could not insert new auction fleet data'); } $new_fleet_id = $db->insert_id(); if (empty($new_fleet_id)) { message(GENERAL, 'Could not find new auction fleet', '$new_fleet_id = empty'); } $sql = 'UPDATE ships SET fleet_id = ' . $new_fleet_id . ' WHERE ship_id = ' . $ship_id; if (!$db->query($sql)) { message(DATABASE_ERROR, 'Could not update ships data'); } return true; }
$planets[$coordinates['tmp4']]['system_global_x'] = $coordinates['system_global_x']; $planets[$coordinates['tmp4']]['system_global_y'] = $coordinates['system_global_y']; } // 5. Sort the array: foreach ($planets as $key => $row) { $sort[$key] = $row['numerate']; } array_multisort($sort, SORT_ASC, $planets); unset($sort); // 6. Output data: foreach ($planets as $key => $planet) { /* 21/03/08 - AC: Add distance from currently selected planet */ if ($planet['planet_id'] != $game->planet['planet_id']) { $distance = get_distance(array($game->planet['system_global_x'], $game->planet['system_global_y']), array($planet['system_global_x'], $planet['system_global_y'])); $distance = round($distance, 2); $min_time = ceil($distance / warpf(6) / TICK_DURATION); $min_stardate = sprintf('%.1f', $game->config['stardate'] + $min_time / 10); $min_stardate_int = str_replace('.', '', $min_stardate); if ($distance > 0) { $arrival_minutes = ($min_stardate_int - (int) str_replace('.', '', $game->config['stardate'])) * TICK_DURATION; $arrival_hours = 0; $arrival_days = floor($arrival_minutes / 1440); $arrival_minutes -= $arrival_days * 1440; while ($arrival_minutes > 59) { $arrival_hours++; $arrival_minutes -= 60; } } else { $arrival_minutes = 20; $arrival_hours = 0; $arrival_days = 0;
} if ($in_orb) { message(NOTICE, constant($game->sprache("TEXT13"))); } if ($starter_atkptc && $free_planet) { message(NOTICE, constant($game->sprache("TEXT14"))); } $distance = $velocity = 0; if ($game->player['user_auth_level'] == STGC_DEVELOPER) { $min_time = 1; } elseif ($inter_system) { $min_time = 6; } else { include_once 'include/libs/moves.php'; $distance = get_distance(array($start_planet['system_global_x'], $start_planet['system_global_y']), array($dest_planet['system_global_x'], $dest_planet['system_global_y'])); $velocity = warpf($max_warp_speed); $min_time = ceil($distance / $velocity / TICK_DURATION); } $cur_istardate = (int) str_replace('.', '', $game->config['stardate']); $min_istardate = $cur_istardate + $min_time; $des_istardate = $min_istardate; if ($des_istardate < $min_istardate) { message(NOTICE, constant($game->sprache("TEXT15")) . ' ' . ($game->config['stardate'] + $min_time / 10)); } $move_time = $des_istardate - $cur_istardate; $sql = 'SELECT COUNT(ship_id) AS n_ships FROM ships WHERE fleet_id = ' . $fleet['fleet_id']; //IN ('.implode(',', $fleet_ids).')'; if (($_nships = $db->queryrow($sql)) === false) { message(DATABASE_ERROR, 'Could not query real n_ships data');
function SendBorgFleet($ACTUAL_TICK, $fleet_id, $dest, $action = 46) { if ($action == 0) { $action = 11; } $sql = 'SELECT f.fleet_id, f.user_id, f.n_ships, f.planet_id AS start, s1.system_id AS start_system_id, s1.system_global_x AS start_x, s1.system_global_y AS start_y, s2.system_id AS dest_system_id, s2.system_global_x AS dest_x, s2.system_global_y AS dest_y FROM (ship_fleets f) INNER JOIN (planets p1) ON p1.planet_id = f.planet_id INNER JOIN (starsystems s1) ON s1.system_id = p1.system_id INNER JOIN (planets p2) ON p2.planet_id = ' . $dest . ' INNER JOIN (starsystems s2) ON s2.system_id = p2.system_id WHERE f.fleet_id = ' . $fleet_id; if (($fleet = $this->db->queryrow($sql)) === false) { $this->sdl->log('Could not query fleet ' . $fleet_id . ' data', TICK_LOG_FILE_NPC); return false; } if (empty($fleet['fleet_id'])) { $this->sdl->log('Borg fleet for mission does not exist, already moving?', TICK_LOG_FILE_NPC); return false; } if ($fleet['start_system_id'] == $fleet['dest_system_id']) { $distance = $velocity = 0; $min_time = 6; } else { $distance = get_distance(array($fleet['start_x'], $fleet['start_y']), array($fleet['dest_x'], $fleet['dest_y'])); $velocity = warpf(10); $min_time = ceil($distance / $velocity / TICK_DURATION); } if ($min_time < 1) { $min_time = 1; } $sql = 'INSERT INTO scheduler_shipmovement (user_id, move_status, move_exec_started, start, dest, total_distance, remaining_distance, tick_speed, move_begin, move_finish, n_ships, action_code, action_data) VALUES (' . $fleet['user_id'] . ', 0, 0, ' . $fleet['start'] . ', ' . $dest . ', ' . $distance . ', ' . $distance . ', ' . $velocity * TICK_DURATION . ', ' . $ACTUAL_TICK . ', ' . ($ACTUAL_TICK + $min_time) . ', ' . $fleet['n_ships'] . ', ' . $action . ', "")'; if (!$this->db->query($sql)) { $this->sdl->log('Could not insert new movement data', TICK_LOG_FILE_NPC); return false; } $new_move_id = $this->db->insert_id(); if (empty($new_move_id)) { $this->sdl->log('Could not send Borg fleet $new_move_id = empty', TICK_LOG_FILE_NPC); return false; } if ($action == 46) { $sql = 'UPDATE ship_fleets SET planet_id = 0, move_id = ' . $new_move_id . ', npc_last_action = ' . ($ACTUAL_TICK + $min_time + 60) . ' WHERE fleet_id = ' . $fleet['fleet_id']; } else { $sql = 'UPDATE ship_fleets SET planet_id = 0, move_id = ' . $new_move_id . ' WHERE fleet_id = ' . $fleet['fleet_id']; } if (!$this->db->query($sql)) { $this->sdl->log('Could not update Borg fleet data', TICK_LOG_FILE_NPC); return false; } return true; }
$log_title = 'Ferengisteuer'; break; case 'ITA': $log_title = 'Tasse Ferengi'; break; } /* */ add_logbook_entry($user['user_id'], LOGBOOK_FERENGITAX, $log_title, $log_data); $sdl->log('3'); $res = $resource[0] + $resource[1] + $resource[2]; $ships = ceil($res / MAX_TRANSPORT_RESOURCES); if (1 == $user['planet_system']) { $distance = 6; } else { $distance = get_distance(array(5, 7), array($user['system_global_x'], $user['system_global_y'])); $velocity = warpf(6); $distance = ceil($distance / $velocity / TICK_DURATION); } $db->query('INSERT INTO scheduler_resourcetrade (planet,resource_1,resource_2,resource_3,arrival_time) VALUES ("' . $user['user_capital'] . '","' . $resource[0] . '","' . $resource[1] . '","' . $resource[2] . '","' . ($ACTUAL_TICK + $distance) . '")'); //send_fake_transporter(array(FERENGI_TRADESHIP_ID=>$ships), FERENGI_USERID,5 ,$user['user_capital']); $sdl->log('4: ' . $distance); $sdl->log('5'); $sdl->log('Paid ' . $user['user_name'] . ' (' . $user['user_id'] . ')!'); } } } $sdl->finish_job('Ferengi Taxes'); // ######################################################################################## // ######################################################################################## // Remove old Resourcetrade $sdl->start_job('Remove old Resourcetrade');
function display_ferengi_transfer($planet_id, $planet_system, $system_x, $system_y, $build_11) { global $game, $db; $game->out('<br><br> <table class="style_outer" width="400" align="center" border="0" cellpadding="2" cellspacing="2"><tr><td> <table class="style_inner" wisth0"400" align="center" border="0" cellpadding="2" cellspacing="2">'); if ($game->option_retr('show_trade') == 0) { $game->out(' <tr> <td><b>' . constant($game->sprache("TEXT15")) . ' <b>[<a href="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id'] . '&strade=1') . '"><i>' . constant($game->sprache("TEXT16")) . '</i></a>]</b></td></tr>'); } elseif ($build_11 < 1 || $game->planet['building_11'] < 1) { $game->out(' <tr> <td><b>' . constant($game->sprache("TEXT15")) . ' <b>[<a href="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id'] . '"&strade=0') . '"><i>' . constant($game->sprache("TEXT17")) . '</i></a>]</b><br><b><br>' . constant($game->sprache("TEXT18")) . '</b></td></tr>'); } else { $game->out(' <script language="JavaScript"> function UpdateValues() { var i; var res_1=eval(document.tradeform.res_1.value); var res_2=eval(document.tradeform.res_2.value); var res_3=eval(document.tradeform.res_3.value); '); for ($x = 0; $x < 6; $x++) { $game->out(' if (document.tradeform.unit_' . ($x + 1) . '.value>0) { res_1+=eval("' . UnitPrice($x, 0, $game->player['user_race']) . '")*eval(document.tradeform.unit_' . ($x + 1) . '.value); res_2+=eval("' . UnitPrice($x, 1, $game->player['user_race']) . '")*eval(document.tradeform.unit_' . ($x + 1) . '.value); res_3+=eval("' . UnitPrice($x, 2, $game->player['user_race']) . '")*eval(document.tradeform.unit_' . ($x + 1) . '.value); } '); } if ($game->planet['system_id'] == $planet_system) { $distance = 6; } else { $distance = get_distance(array($game->planet['system_global_x'], $game->planet['system_global_y']), array($system_x, $system_y)); $velocity = warpf(6); $distance = ceil($distance / $velocity / TICK_DURATION); } $game->out(' var ttax_set=' . (0.18 - 0.01 * $game->planet['building_11']) . '; document.getElementById( "res1" ).firstChild.nodeValue = Math.round(res_1*ttax_set); document.getElementById( "res2" ).firstChild.nodeValue = Math.round(res_2*ttax_set); document.getElementById( "res3" ).firstChild.nodeValue = Math.round(res_3*ttax_set); window.setTimeout( \'UpdateValues()\', 500 ); } </script> <form name="tradeform" method="post" action="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id']) . '"> <tr> <td colspan=3 align="center"><b>' . constant($game->sprache("TEXT19")) . '<br>(' . constant($game->sprache("TEXT22")) . ' ' . Zeit($distance * TICK_DURATION) . ')</b><br><br> </td> </tr> <tr> <td><img src=' . $game->GFX_PATH . 'menu_metal_small.gif> <input class="field" style="width: 60px;" type="text" name="res_1" value="0" onFocus="UpdateValues();">  </td> <td><img src=' . $game->GFX_PATH . 'menu_unit1_small.gif> <input class="field" style="width: 60px;" type="text" name="unit_1" value="0" onFocus="UpdateValues();">  </td> <td><img src=' . $game->GFX_PATH . 'menu_unit4_small.gif> <input class="field" style="width: 60px;" type="text" name="unit_4" value="0" onFocus="UpdateValues();">  </td> </tr> <tr> <td><img src=' . $game->GFX_PATH . 'menu_mineral_small.gif> <input class="field" style="width: 60px;" type="text" name="res_2" value="0" onFocus="UpdateValues();">  </td> <td><img src=' . $game->GFX_PATH . 'menu_unit2_small.gif> <input class="field" style="width: 60px;" type="text" name="unit_2" value="0" onFocus="UpdateValues();">  </td> <td><img src=' . $game->GFX_PATH . 'menu_unit5_small.gif> <input class="field" style="width: 60px;" type="text" name="unit_5" value="0" onFocus="UpdateValues();">  </td> </tr> <tr> <td><img src=' . $game->GFX_PATH . 'menu_latinum_small.gif> <input class="field" style="width: 60px;" type="text" name="res_3" value="0" onFocus="UpdateValues();">  </td> <td><img src=' . $game->GFX_PATH . 'menu_unit3_small.gif> <input class="field" style="width: 60px;" type="text" name="unit_3" value="0" onFocus="UpdateValues();">  </td> <td><img src=' . $game->GFX_PATH . 'menu_unit6_small.gif> <input class="field" style="width: 60px;" type="text" name="unit_6" value="0" onFocus="UpdateValues();">  </td> </tr> <tr> <td colspan=3 align="center"> <b>' . constant($game->sprache("TEXT20")) . '</b> <img src=' . $game->GFX_PATH . 'menu_metal_small.gif> <b id="res1">0</b> <img src=' . $game->GFX_PATH . 'menu_mineral_small.gif> <b id="res2">0</b> <img src=' . $game->GFX_PATH . 'menu_latinum_small.gif> <b id="res3">0</b> </td> </tr> <tr> <td colspan=3 align="center"> <input class="button" type="submit" name="trade" value="' . constant($game->sprache("TEXT21")) . '"><br><br><b> [<a href="' . parse_link('a=tactical_cartography&planet_id=' . $_GET['planet_id'] . '&strade=0') . '"><i>' . constant($game->sprache("TEXT17")) . '</i></a>]</b> </td> </tr> </form>'); } $game->out('</table></td></tr></table><br>'); }