sys_redirect('metamatter.php'); } lng_include('infos'); if (!$unit_id || !get_unit_param($unit_id) && !isset($lang['info'][$unit_id])) { sys_redirect('index.php?page=techtree'); } $template = gettemplate('novapedia', true); $unit_data = get_unit_param($unit_id); $unit_type = $unit_data['type']; if ($unit_type == UNIT_SHIPS) { $template_result['UNIT_IS_SHIP'] = true; $ship_data = get_ship_data($unit_id, $user); $template_result += array('BASE_SPEED' => pretty_number($ship_data['speed_base']), 'ACTUAL_SPEED' => pretty_number($ship_data['speed']), 'BASE_CONSUMPTION' => pretty_number($ship_data['consumption_base']), 'ACTUAL_CONSUMPTION' => pretty_number($ship_data['consumption']), 'BASE_CAPACITY' => pretty_number($unit_data['capacity']), 'ACTUAL_CAPACITY' => pretty_number($ship_data['capacity'])); $engine_template_info = array(); foreach ($unit_data['engine'] as $unit_engine_data) { $unit_engine_data = get_engine_data($user, $unit_engine_data); $engine_template_info[] = array('NAME' => $lang['tech'][$unit_engine_data['tech']], 'MIN_LEVEL' => $unit_engine_data['min_level'], 'USER_TECH_LEVEL' => mrc_get_level($user, null, $unit_engine_data['tech']), 'BASE_SPEED' => pretty_number($unit_engine_data['speed_base']), 'BASE_CONSUMPTION' => pretty_number($unit_engine_data['consumption_base']), 'ACTUAL_SPEED' => pretty_number($unit_engine_data['speed']), 'ACTUAL_CONSUMPTION' => pretty_number($unit_engine_data['consumption'])); } $template_result['.']['engine'] = $engine_template_info; } $sn_data_group_combat = sn_get_groups('combat'); if (in_array($unit_id, $sn_data_group_combat)) { $template_result['UNIT_IS_COMBAT'] = true; $unit_durability = $unit_data['shield'] + $unit_data['armor']; $volley_arr = $rapid_to = $rapid_from = array(); $str_rapid_from = ''; $str_rapid_to = ''; foreach ($sn_data_group_combat as $enemy_id) { $enemy_data = get_unit_param($enemy_id); $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability;
function get_ship_data($ship_id, $user) { $ship_data = array(); if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { foreach (get_unit_param($ship_id, 'engine') as $engine_info) { $tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { $ship_data = $engine_info; $ship_data['tech_level'] = $tech_level; } } $ship_data = get_engine_data($user, $ship_data); $ship_data['capacity'] = get_unit_param($ship_id, 'capacity'); } return $ship_data; }