void setup_campaign (void) { entity *force; ASSERT (get_comms_model () == COMMS_MODEL_SERVER); ASSERT (get_session_entity ()); // // Create force overall campaign objectives // force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); ASSERT (force); while (force) { create_force_campaign_objectives (force); force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } // // Setup Order Of Battle // initialise_order_of_battle (); }
int get_session_pilot_count (void) { entity *force, *pilot; int count; ASSERT (get_session_entity ()); count = 0; force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { pilot = get_local_entity_first_child (force, LIST_TYPE_PILOT); while (pilot) { count ++; pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } return count; }
entity *get_local_force_entity (entity_sides side) { entity *force; if (!get_session_entity ()) { return NULL; } force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { debug_assert (get_local_entity_type (force) == ENTITY_TYPE_FORCE); if (get_local_entity_int_value (force, INT_TYPE_SIDE) == side) { return force; } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } return NULL; }
void update_dynamics_shared_mem () { if (gPtrSharedMemory == 0) return; gPtrSharedMemory->time_of_day = get_local_entity_float_value (get_session_entity (), FLOAT_TYPE_TIME_OF_DAY); gPtrSharedMemory->pitch = current_flight_dynamics->pitch.value; gPtrSharedMemory->roll = current_flight_dynamics->roll.value; gPtrSharedMemory->heading = current_flight_dynamics->heading.value; gPtrSharedMemory->indicated_airspeed = current_flight_dynamics->indicated_airspeed.value; gPtrSharedMemory->indicated_slip = current_flight_dynamics->indicated_slip.value; gPtrSharedMemory->vertical_speed = current_flight_dynamics->world_velocity_y.value; gPtrSharedMemory->barometric_altitude = current_flight_dynamics->barometric_altitude.value; gPtrSharedMemory->radar_altitude = current_flight_dynamics->radar_altitude.value; gPtrSharedMemory->g_force = current_flight_dynamics->g_force.value; gPtrSharedMemory->left_engine_rpm = current_flight_dynamics->left_engine_rpm.value; gPtrSharedMemory->left_engine_n1_rpm = current_flight_dynamics->left_engine_n1_rpm.value; gPtrSharedMemory->left_engine_torque = current_flight_dynamics->left_engine_torque.value; gPtrSharedMemory->left_engine_temp = current_flight_dynamics->left_engine_temp.value; gPtrSharedMemory->right_engine_rpm = current_flight_dynamics->right_engine_rpm.value; gPtrSharedMemory->right_engine_n1_rpm = current_flight_dynamics->right_engine_n1_rpm.value; gPtrSharedMemory->right_engine_torque = current_flight_dynamics->right_engine_torque.value; gPtrSharedMemory->right_engine_temp = current_flight_dynamics->right_engine_temp.value; gPtrSharedMemory->combined_engine_rpm = current_flight_dynamics->combined_engine_rpm.value; gPtrSharedMemory->combined_engine_torque = current_flight_dynamics->combined_engine_torque.value; gPtrSharedMemory->fuel_weight = current_flight_dynamics->fuel_weight.value; }
entity *get_group_at_road_node (int node) { entity *force, *group; force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { group = get_local_entity_first_child (force, LIST_TYPE_GROUND_REGISTRY); while (group) { if ((get_local_entity_int_value (group, INT_TYPE_ROUTE_NODE) == node) && (get_local_entity_int_value (group, INT_TYPE_ALIVE))) { #if DEBUG_MODULE debug_log ("GP_MSGS: found retreat group %d side %s at node %d", group, entity_side_names [get_local_entity_int_value (group, INT_TYPE_SIDE)], node); #endif return group; } group = get_local_entity_child_succ (group, LIST_TYPE_GROUND_REGISTRY); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } return NULL; }
void update_apache_upfront_display (void) { char s1[80], s2[80]; float time_of_day, hours, minutes, seconds; // if (!electrical_system_active()) // return; time_of_day = get_local_entity_float_value (get_session_entity (), FLOAT_TYPE_TIME_OF_DAY); get_digital_clock_values (time_of_day, &hours, &minutes, &seconds); sprintf (s1, "%02d:%02d:%02d", (int) hours, (int) minutes, (int) seconds); sprintf (s2, "FUEL %04d LBS", (int) (bound (kilograms_to_pounds (current_flight_dynamics->fuel_weight.value), 0.0, 2500.0))); set_apache_upfront_display_text (NULL, NULL, s1, s2); }
void play_entity_weapon_low_speech (entity *en, entity_sub_types weapon_type) { int speech_index; // // only play speech for players // speech_index = weapon_database [weapon_type].weapon_low_cpg_speech; if (speech_index != -1) { if (get_local_entity_int_value (en, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { if (!get_local_entity_int_value (get_session_entity (), INT_TYPE_INFINITE_WEAPONS)) { play_client_server_cpg_message ( en, 1.0, 5.0, SPEECH_CATEGORY_AMMO_LOW, -1.0, speech_index ); } } } }
static void set_eo_view_params(target_acquisition_systems system, int x_min, int y_min, int x_max, int y_max, float xfov, float yfov) { display_3d_light_levels light_level; display_3d_noise_levels noise_level; vec3d *position; weathermodes weather_mode; day_segment_types day_segment_type; display_3d_tints tint; position = get_local_entity_vec3d_ptr (get_gunship_entity (), VEC3D_TYPE_POSITION); weather_mode = get_simple_session_weather_at_point (position); ASSERT ((weather_mode > WEATHERMODE_INVALID) && (weather_mode < WEATHERMODE_LAST)); day_segment_type = (day_segment_types) get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE); ASSERT ((day_segment_type >= 0) && (day_segment_type < NUM_DAY_SEGMENT_TYPES)); switch (system) { case TARGET_ACQUISITION_SYSTEM_FLIR: { light_level = flir_light_levels[weather_mode][day_segment_type]; noise_level = flir_noise_levels[weather_mode][day_segment_type]; tint = DISPLAY_3D_TINT_AMBER; break; } case TARGET_ACQUISITION_SYSTEM_LLLTV: { light_level = llltv_light_levels[weather_mode][day_segment_type]; noise_level = llltv_noise_levels[weather_mode][day_segment_type]; tint = DISPLAY_3D_TINT_AMBER_VISUAL; break; } default: { debug_fatal ("Invalid target acquisition system = %d", system); break; } } set_main_3d_params (tint, light_level, noise_level, x_min, y_min, x_max, y_max, xfov, yfov); }
static void get_clock_hand_values (float *hours, float *minutes, float *seconds) { float time_of_day, hour_hand_value, minute_hand_value, second_hand_value; if (test_cockpit_instruments) { static float hour_value = 0.0, minute_value = 30.0, second_value = 0.0; hour_value += 0.1; if (hour_value >= 12.0) { hour_value = 0.0; } minute_value += 0.5; if (minute_value >= 60.0) { minute_value = 0.0; } second_value += 1.0; if (second_value >= 60.0) { second_value = 0.0; } hour_hand_value = hour_value; minute_hand_value = minute_value; second_hand_value = second_value; } else { time_of_day = get_local_entity_float_value (get_session_entity (), FLOAT_TYPE_TIME_OF_DAY); get_analogue_clock_values (time_of_day, &hour_hand_value, &minute_hand_value, &second_hand_value); } *hours = hour_hand_value; *minutes = minute_hand_value; *seconds = second_hand_value; }
void dedicated_screen_update_function (ui_object *obj, void *arg) { float time; int hours, minutes, seconds; char s [64]; ASSERT (command_line_comms_dedicated_server); if (get_session_entity ()) { if (get_local_entity_int_value (get_session_entity (), INT_TYPE_SESSION_COMPLETE)) { if (!get_connection_list_head ()) { debug_log ("DEDI_SC: Exiting game as no clients left"); exit_apache_havoc (NULL); } } time = get_local_entity_float_value (get_session_entity (), FLOAT_TYPE_ELAPSED_TIME); get_digital_countdown_values (time, NULL, &hours, &minutes, &seconds); sprintf (s, "Day %d, %02d:%02d:%02d", get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY), hours, minutes, seconds); set_ui_object_text (dedicated_server_time_text, s); dedicated_server_build_player_list (); } }
void campaign_screen_update_chat_page_pilot (entity *en) { entity *current_target; current_target = get_local_entity_safe_ptr (get_ui_object_item_number (chat_send_button)); if (current_target == en) { set_ui_object_item_number (chat_send_button, get_local_entity_safe_index (get_session_entity ())); } build_chat_target_list (); }
static void draw_local_3d_object (entity *en, float range) { site_updatable *raw; object_3d_instance *inst3d; vec3d face_normal; day_segment_types day_segment_type; raw = (site_updatable *) get_local_entity_data (en); inst3d = construct_temporary_3d_object (raw->fix.object_3d_shape, raw->fix.alive); if (inst3d) { if (raw->fix.alive) { animate_site_radar (en, inst3d); animate_site_loading_doors (en, inst3d); } memcpy (&inst3d->vp.position, &raw->fix.position, sizeof (vec3d)); if (fixed_database[raw->fix.sub_type].align_with_terrain) { get_3d_terrain_face_normal (&face_normal, raw->fix.position.x, raw->fix.position.z); get_3d_transformation_matrix_from_face_normal_and_heading (inst3d->vp.attitude, &face_normal, raw->fix.heading); } else { get_3d_transformation_matrix (inst3d->vp.attitude, raw->fix.heading, 0.0, 0.0); } day_segment_type = (day_segment_types) get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE); inst3d->object_sprite_lights = ((day_segment_type == DAY_SEGMENT_TYPE_NIGHT) || (day_segment_type == DAY_SEGMENT_TYPE_DUSK)); inst3d->object_has_shadow = FALSE; insert_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_OBJECT, inst3d); } }
int object_internal_lighting_valid (entity *en) { day_segment_types day_segment_type; if (get_local_entity_int_value (en, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { return (get_local_entity_int_value (en, INT_TYPE_LIGHTS_ON)); } else { day_segment_type = get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE); return ((day_segment_type == DAY_SEGMENT_TYPE_NIGHT) || (day_segment_type == DAY_SEGMENT_TYPE_DUSK)); } }
void set_default_instrument_colours (void) { switch (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE)) { case DAY_SEGMENT_TYPE_DAWN: { white_needle_colour = white_needle_colour_level2; red_needle_colour = red_needle_colour_level2; white_digit_colour = white_digit_colour_level2; break; } case DAY_SEGMENT_TYPE_DAY: { white_needle_colour = white_needle_colour_level1; red_needle_colour = red_needle_colour_level1; white_digit_colour = white_digit_colour_level1; break; } case DAY_SEGMENT_TYPE_DUSK: { white_needle_colour = white_needle_colour_level2; red_needle_colour = red_needle_colour_level2; white_digit_colour = white_digit_colour_level2; break; } case DAY_SEGMENT_TYPE_NIGHT: { white_needle_colour = white_needle_colour_level3; red_needle_colour = red_needle_colour_level3; white_digit_colour = white_digit_colour_level3; break; } } #if DEMO_VERSION white_needle_colour = white_needle_colour_level1; red_needle_colour = red_needle_colour_level1; white_digit_colour = white_digit_colour_level1; #endif }
static void draw_local_3d_object (entity *en, float range) { ship_vehicle *raw; day_segment_types day_segment_type; raw = get_local_entity_data (en); // // update viewpoint // raw->vh.inst3d->vp.position = raw->vh.mob.position; memcpy (&raw->vh.inst3d->vp.attitude, &raw->vh.mob.attitude, sizeof (matrix3x3)); // // animate // animate_ship_rotors (en); animate_vehicle_loading_doors (en); animate_vehicle_radar (en); animate_vehicle_weapon_system_ready (en); day_segment_type = get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE); raw->vh.inst3d->object_internal_lighting = ((day_segment_type == DAY_SEGMENT_TYPE_NIGHT) || (day_segment_type == DAY_SEGMENT_TYPE_DUSK)); raw->vh.inst3d->object_sprite_lights = raw->vh.inst3d->object_internal_lighting; // // draw // animate_and_draw_entity_muzzle_flash_effect (en); raw->vh.inst3d->object_has_shadow = FALSE; insert_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_OBJECT, raw->vh.inst3d); }
static void save_session (ui_object *obj, void *arg) { char *filename; ASSERT (get_current_game_session ()); ASSERT (get_session_entity ()); filename = get_ui_object_text (save_current_filename); if (filename) { if (strlen (filename) > 0) { store_session (current_session, filename); } } pop_campaign_history (NULL, NULL); }
static void dedicated_server_build_player_list (void) { entity *force, *pilot; entity_sides side; rgb_colour col; ui_object_destroy_list_items (player_list); force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { pilot = get_local_entity_first_child (force, LIST_TYPE_PILOT); while (pilot) { if (pilot != get_pilot_entity ()) { side = (entity_sides) get_local_entity_int_value (pilot, INT_TYPE_SIDE); col.r = 255; col.g = 255; col.b = 255; col.a = 255; add_to_pop_up_list (get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME), player_list, NULL, 0, UI_FONT_ARIAL_16, col); } pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } }
void initialise_campaign_screen_chat_page_objects (void) { // // Set Window Mode // set_ui_object_drawable (chat_target_list_area, TRUE); set_ui_object_drawable (chat_message_list_area, FALSE); set_ui_object_state (chat_window_destination_button, UI_OBJECT_STATE_ON); // // Set Target to ALL // set_ui_object_item_number (chat_send_button, get_local_entity_safe_index (get_session_entity ())); // // Clear Text Input Area // set_ui_object_drawable (chat_input, FALSE); set_ui_object_text (chat_input, ""); set_ui_object_state (chat_input, UI_OBJECT_STATE_OFF); // // Clear Current Text Area // set_ui_object_text (chat_current_text, ""); set_ui_object_drawable (chat_current_text, TRUE); }
static void set_local_int_value (entity *en, int_types type, int value) { vehicle *raw; #if DEBUG_MODULE debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_INT_VALUE, en, type, value); #endif raw = (vehicle *) get_local_entity_data (en); switch (type) { //////////////////////////////////////// case INT_TYPE_CPG_IDENTIFIED: //////////////////////////////////////// { raw->cpg_identified = value; break; } //////////////////////////////////////// case INT_TYPE_DAMAGE_LEVEL: //////////////////////////////////////// { raw->damage_level = value; break; } //////////////////////////////////////// case INT_TYPE_FORMATION_POSITION: //////////////////////////////////////// { raw->formation_position = value; break; } //////////////////////////////////////// case INT_TYPE_GROUP_MEMBER_NUMBER: //////////////////////////////////////// { ASSERT (value >= 0); ASSERT (value < (1 << NUM_GROUP_MEMBER_NUMBER_BITS)); raw->group_member_number = value; break; } //////////////////////////////////////// case INT_TYPE_GUNSHIP_RADAR_LOS_CLEAR: //////////////////////////////////////// { raw->gunship_radar_los_clear = value; break; } //////////////////////////////////////// case INT_TYPE_ID_NUMBER: //////////////////////////////////////// { raw->id_number = value; break; } //////////////////////////////////////// case INT_TYPE_ID_NUMBER_SIGNIFICANT_DIGITS: //////////////////////////////////////// { raw->id_number_significant_digits = value; break; } //////////////////////////////////////// case INT_TYPE_LIGHTS_ON: //////////////////////////////////////// { raw->lights_on = value; break; } //////////////////////////////////////// case INT_TYPE_LOS_TO_TARGET: //////////////////////////////////////// { raw->los_to_target = value; break; } //////////////////////////////////////// case INT_TYPE_OBJECT_3D_SHAPE: //////////////////////////////////////// { raw->object_3d_shape = value; break; } //////////////////////////////////////// case INT_TYPE_OPERATIONAL_STATE: //////////////////////////////////////// { int state1, state2; day_segment_types day_segment_type; state1 = get_local_entity_int_value (en, INT_TYPE_MOBILE_MOVING); raw->operational_state = value; state2 = get_local_entity_int_value (en, INT_TYPE_MOBILE_MOVING); if ((state1 == FALSE) && (state2 == TRUE)) { // // wasn't moving, but is now // // vehicle wakes set_infinite_smoke_list_generating_state (en, ENTITY_SUB_TYPE_EFFECT_SMOKE_LIST_VEHICLE_WAKE, INFINITE_SMOKE_ON); // lights day_segment_type = (day_segment_types) get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE); if ((day_segment_type == DAY_SEGMENT_TYPE_NIGHT) || (day_segment_type == DAY_SEGMENT_TYPE_DUSK)) { set_vehicle_headlight_state (en, ON); } // weapons if (get_comms_model () == COMMS_MODEL_SERVER) { set_client_server_entity_int_value (en, INT_TYPE_SELECTED_WEAPON, ENTITY_SUB_TYPE_WEAPON_NO_WEAPON); } // sound effects pause_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING1, 0.5); resume_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING2); } else if ((state1 == TRUE) && (state2 == FALSE)) { // // was moving, but isn't anymore // set_infinite_smoke_list_generating_state (en, ENTITY_SUB_TYPE_EFFECT_SMOKE_LIST_VEHICLE_WAKE, INFINITE_SMOKE_OFF); set_vehicle_headlight_state (en, OFF); pause_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING2, 0.5); resume_local_entity_sound_type (en, ENTITY_SUB_TYPE_EFFECT_SOUND_ENGINE_LOOPING1); } break; } //////////////////////////////////////// case INT_TYPE_SELECTED_WEAPON: //////////////////////////////////////// { // // stop continuous sound effect // if (raw->selected_weapon != value) { pause_local_continuous_weapon_sound_effect (en, raw->selected_weapon); } raw->selected_weapon = value; raw->weapon_burst_timer = 0.0; break; } //////////////////////////////////////// case INT_TYPE_SELECTED_WEAPON_SYSTEM_READY: //////////////////////////////////////// { raw->selected_weapon_system_ready = value; break; } //////////////////////////////////////// case INT_TYPE_WEAPON_AND_TARGET_VECTORS_VALID: //////////////////////////////////////// { raw->weapon_and_target_vectors_valid = value; break; } //////////////////////////////////////// case INT_TYPE_WEAPON_CONFIG_TYPE: //////////////////////////////////////// { raw->weapon_config_type = (weapon_config_types) value; load_local_entity_weapon_config (en); break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal_invalid_int_type (en, type); break; } } }
static void draw_local_3d_object (entity *en, float range) { fixed_wing *raw; day_segment_types day_segment_type; raw = (fixed_wing *) get_local_entity_data (en); // // update viewpoint // raw->ac.inst3d->vp.position = raw->ac.mob.position; memcpy (&raw->ac.inst3d->vp.attitude, &raw->ac.mob.attitude, sizeof (matrix3x3)); // // animate // animate_fixed_wing_afterburners (en); animate_fixed_wing_airbrakes (en); animate_fixed_wing_flaps (en); animate_fixed_wing_propellors (en); animate_aircraft_loading_doors (en); animate_aircraft_cargo_doors (en); animate_aircraft_undercarriage (en); animate_aircraft_weapon_system_ready (en); animate_aircraft_shadow (en); animate_aircraft_rudder (en); // // draw // day_segment_type = (day_segment_types) get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE); raw->ac.inst3d->object_internal_lighting = ((day_segment_type == DAY_SEGMENT_TYPE_NIGHT) || (day_segment_type == DAY_SEGMENT_TYPE_DUSK)); raw->ac.inst3d->object_sprite_lights = (raw->ac.inst3d->object_internal_lighting && sprite_light_valid (en)); animate_and_draw_entity_muzzle_flash_effect (en); insert_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_OBJECT, raw->ac.inst3d); #if DEBUG_MODULE if (en == get_external_view_entity ()) { vec3d *pos, wp_pos; draw_mobile_entity_debug_info (en); if (get_local_entity_primary_task (en)) { fixed_wing_movement_get_waypoint_position (en, &wp_pos); pos = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION); create_debug_3d_line (pos, &wp_pos, sys_col_dark_green, 0.0); } } #endif }
void create_force_campaign_objectives (entity *force) { entity *keysite, *target_force, **list; int loop, count, side, target_side; float highest, *rating; ASSERT (get_comms_model () == COMMS_MODEL_SERVER); ASSERT (get_session_entity ()); ASSERT (force); side = get_local_entity_int_value (force, INT_TYPE_SIDE); // // count up potential objective keysites // count = 0; target_force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (target_force) { if (target_force != force) { keysite = get_local_entity_first_child (target_force, LIST_TYPE_KEYSITE_FORCE); while (keysite) { if (get_local_entity_int_value (keysite, INT_TYPE_POTENTIAL_CAMPAIGN_OBJECTIVE)) { if (get_local_entity_int_value (keysite, INT_TYPE_IN_USE)) { count ++; } } keysite = get_local_entity_child_succ (keysite, LIST_TYPE_KEYSITE_FORCE); } } target_force = get_local_entity_child_succ (target_force, LIST_TYPE_FORCE); } if (count == 0) { debug_fatal ("SETUP: No potential campaign objectives for side %s", entity_side_short_names [side]); } // // construct the list and rate each keysite according to sector importance // list = malloc_heap_mem (sizeof (entity *) * count); rating = malloc_heap_mem (sizeof (float) * count); highest = 0.0; count = 0; target_force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (target_force) { if (target_force != force) { target_side = get_local_entity_int_value (target_force, INT_TYPE_SIDE); keysite = get_local_entity_first_child (target_force, LIST_TYPE_KEYSITE_FORCE); while (keysite) { if (get_local_entity_int_value (keysite, INT_TYPE_POTENTIAL_CAMPAIGN_OBJECTIVE)) { if (get_local_entity_int_value (keysite, INT_TYPE_IN_USE)) { float actual_range; vec3d *pos; list [count] = keysite; pos = get_local_entity_vec3d_ptr (keysite, VEC3D_TYPE_POSITION); get_closest_keysite (NUM_ENTITY_SUB_TYPE_KEYSITES, target_side, pos, 1.0 * KILOMETRE, &actual_range, keysite); rating [count] = actual_range; highest = max (highest, rating [count]); count ++; } } keysite = get_local_entity_child_succ (keysite, LIST_TYPE_KEYSITE_FORCE); } } target_force = get_local_entity_child_succ (target_force, LIST_TYPE_FORCE); } // // Normalise ratings // if (highest == 0.0) { debug_fatal ("SETUP: No sector importance for side %s", entity_side_short_names [side]); } for (loop = 0; loop < count; loop ++) { rating [loop] = rating [loop] / highest; } // // obligatory random factor // for (loop = 0; loop < count; loop ++) { rating [loop] += frand1 (); } // // sort the list // quicksort_entity_list (list, count, rating); // // now find the best N targets and link them into the force // count = min (count, NUMBER_OF_CAMPAIGN_OBJECTIVES_PER_SIDE); for (loop = 0; loop < count; loop ++) { insert_local_entity_into_parents_child_list (list [loop], LIST_TYPE_CAMPAIGN_OBJECTIVE, force, NULL); debug_log ("Side %s Objective :- %s (%s)", entity_side_short_names [side], get_local_entity_string (list [loop], STRING_TYPE_KEYSITE_NAME), get_local_entity_string (list [loop], STRING_TYPE_FULL_NAME)); } free_mem (list); free_mem (rating); }
int resume_local_entity_sound_type (entity *en, entity_sub_types type) { entity *spec; sound_effect *raw; int count; count = 0; spec = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT); while (spec) { if (get_local_entity_type (spec) == ENTITY_TYPE_SOUND_EFFECT) { raw = get_local_entity_data (spec); if (raw->eff.sub_type == type) { // // "unpause" sound // if (!raw->valid_sound_effect) { // // set flag and start playing // raw->valid_sound_effect = TRUE; if (en == get_session_entity ()) { play_local_entity_sound (en, &main_vp, 0); } else { vec3d *position; viewpoint *vp; float range; vp = &main_vp; position = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION); range = get_approx_3d_range (&vp->position, position); play_local_entity_sound (en, vp, range); } if (!get_local_entity_parent (spec, LIST_TYPE_UPDATE)) { insert_local_entity_into_parents_child_list (spec, LIST_TYPE_UPDATE, get_update_entity (), NULL); } count ++; } } } spec = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT); } return count; }
void display_campaign_criteria_time_remaining (void) { #if 0 entity *force_en; force *force_raw; //session //*session_raw; //campaign_criteria_type //*this_campaign_criteria; //float //elapsed_hours, //elapsed_minutes, //elapsed_seconds; //int //remaining_hours, //remaining_minutes, //remaining_seconds; //int //x, y; //char //s [20]; // // display count down timer until campaign completiion (NOT "tour of duty" timer) // // // currently used only for special games, so I have tailored it to suit :- // only displays minutes and seconds, // doesn't display on the clients until after first time-of-day resync // if ((get_game_type () != GAME_TYPE_SPECIAL) && (get_game_type () != GAME_TYPE_MAGAZINE_DEMO)) { return; } ASSERT (get_session_entity ()); force_en = get_local_force_entity (get_global_gunship_side ()); ASSERT (force_en); force_raw = (force *) get_local_entity_data (force_en); /* this_campaign_criteria = force_raw->campaign_criteria; while (this_campaign_criteria) { if (this_campaign_criteria->criteria_type == CAMPAIGN_CRITERIA_TIME_DURATION) { break; } this_campaign_criteria = this_campaign_criteria->next; } if (this_campaign_criteria) { if (this_campaign_criteria->valid) { session_raw = (force *) get_local_entity_data (get_session_entity ()); // // clients don't display until AFTER first resync (otherwise time will be wrong) // if (get_comms_model () == COMMS_MODEL_CLIENT) { if (!display_timer_valid) { return; } } // // get time remaining // get_digital_clock_values (session_raw->elapsed_time_of_day, &elapsed_hours, &elapsed_minutes, &elapsed_seconds); remaining_seconds = (this_campaign_criteria->days - session_raw->elapsed_days) * ONE_DAY; remaining_seconds += (this_campaign_criteria->hours - elapsed_hours) * ONE_HOUR; remaining_seconds += (this_campaign_criteria->minutes - elapsed_minutes) * ONE_MINUTE; remaining_seconds += (this_campaign_criteria->seconds - elapsed_seconds) * ONE_SECOND; if ((remaining_seconds > 0.0) && (remaining_seconds < ONE_HOUR)) { if (remaining_seconds < ONE_MINUTE) { if (remaining_seconds < 10.0) { // // flash if < 10 seconds // if (frac (session_raw->elapsed_time_of_day) < 0.5) { return; } } set_ui_font (UI_FONT_ADS_15_ORANGE); } else { set_ui_font (UI_FONT_ADS_15_WHITE); } get_digital_clock_int_values (remaining_seconds, &remaining_hours, &remaining_minutes, &remaining_seconds); if (lock_screen (active_screen)) { set_full_screen_viewport (); sprintf (s, "T-%02d:%02d", remaining_minutes, remaining_seconds); // string WAS right-justified, but looked bad due to proportional fonts changing the width every second ! // x = get_screen_width (active_screen) - ui_get_string_length (s); x = get_screen_width (active_screen) - 62; y = ui_get_font_height () + 2; ui_display_text (s, x, y); unlock_screen (active_screen); } } } } */ #endif }
void build_chat_target_list (void) { ui_object *new_item; entity *force, *pilot, *current_target; static char s [128]; current_target = get_local_entity_safe_ptr (get_ui_object_item_number (chat_send_button)); ui_object_destroy_list_items (chat_target_list); sprintf (s, "%s", get_trans ("Side")); new_item = add_to_pop_up_list (s, chat_target_list, NULL, ENTITY_INDEX_DONT_CARE, UI_FONT_ARIAL_16, ui_ingame_dead_text_colour); // // All // ASSERT (get_session_entity ()); sprintf (s, "%s", get_trans ("CHAT_TARGET_ALL")); new_item = add_to_pop_up_list (s, chat_target_list, NULL, get_local_entity_safe_index (get_session_entity ()), UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); if (get_session_entity () == current_target) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); } // // Sides // force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { sprintf (s, "%s", get_local_entity_string (force, STRING_TYPE_FORCE_NAME)); new_item = add_to_pop_up_list (s, chat_target_list, NULL, get_local_entity_safe_index (force), UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); if (force == current_target) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } // // Sides // sprintf (s, "%s", get_trans ("UI_PILOTS")); new_item = add_to_pop_up_list (s, chat_target_list, NULL, ENTITY_INDEX_DONT_CARE, UI_FONT_ARIAL_16, ui_ingame_dead_text_colour); force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { pilot = get_local_entity_first_child (force, LIST_TYPE_PILOT); while (pilot) { if (pilot != get_pilot_entity ()) { sprintf (s, "%s", get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME)); new_item = add_to_pop_up_list (s, chat_target_list, NULL, get_local_entity_safe_index (pilot), UI_FONT_ARIAL_16, ui_ingame_live_text_colour); set_ingame_ui_object_mouse_over_properties (new_item); if (pilot == current_target) { set_ui_object_state (new_item, UI_OBJECT_STATE_ON); } } pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } }
void dynamics_damage_model (unsigned int damage, int random) { dynamics_damage_types damage_array [NUM_DYNAMIC_DAMAGES]; int count; dynamics_damage_types this_damage; if (!get_session_entity ()) { return; } if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_INVULNERABLE_FROM_COLLISIONS)) { // if invulnerable only allow damage/use of fire extinguisher damage = damage & DYNAMICS_DAMAGE_FIRE_EXTINGUISHER; } if (random) { damage_array [0] = DYNAMICS_DAMAGE_NONE; this_damage = DYNAMICS_DAMAGE_NONE; count = 1; while (this_damage < NUM_DYNAMICS_DAMAGE_TYPES) { if (damage & this_damage) { damage_array [count] = this_damage; count ++; } this_damage = this_damage << 1; } damage = damage_array [rand16 () % count]; #if DYNAMICS_DEBUG debug_log ("DYNAMICS: randomly selecting damage %d", damage); #endif } notify_avionics_of_dynamics_fault (damage); this_damage = DYNAMICS_DAMAGE_NONE; while (this_damage < NUM_DYNAMICS_DAMAGE_TYPES) { if ((damage & this_damage) && (!(current_flight_dynamics->dynamics_damage & this_damage))) { switch (this_damage) { case DYNAMICS_DAMAGE_NONE: { #if DYNAMICS_DEBUG debug_log ("DYNAMICS: no damage"); #endif current_flight_dynamics->dynamics_damage = DYNAMICS_DAMAGE_NONE; current_flight_dynamics->main_blade_pitch.damaged = FALSE; current_flight_dynamics->main_rotor_roll_angle.damaged = FALSE; current_flight_dynamics->main_rotor_pitch_angle.damaged = FALSE; current_flight_dynamics->main_rotor_rpm.damaged = FALSE; current_flight_dynamics->tail_blade_pitch.damaged = FALSE; current_flight_dynamics->tail_rotor_rpm.damaged = FALSE; current_flight_dynamics->left_engine_torque.damaged = FALSE; current_flight_dynamics->left_engine_rpm.damaged = FALSE; current_flight_dynamics->right_engine_torque.damaged = FALSE; current_flight_dynamics->right_engine_rpm.damaged = FALSE; current_flight_dynamics->cross_coupling_effect.damaged = FALSE; current_flight_dynamics->input_data.cyclic_x.damaged = FALSE; current_flight_dynamics->input_data.cyclic_y.damaged = FALSE; current_flight_dynamics->input_data.cyclic_x_trim.damaged = FALSE; current_flight_dynamics->input_data.cyclic_y_trim.damaged = FALSE; break; } case DYNAMICS_DAMAGE_MAIN_ROTOR: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: main rotor damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_MAIN_ROTOR; current_flight_dynamics->main_blade_pitch.damaged = TRUE; current_flight_dynamics->main_rotor_roll_angle.damaged = TRUE; current_flight_dynamics->main_rotor_pitch_angle.damaged = TRUE; current_flight_dynamics->main_rotor_rpm.damaged = TRUE; set_client_server_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED, TRUE); play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_MAIN_ROTOR_DAMAGED); set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_TAIL_ROTOR: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: tail rotor damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_TAIL_ROTOR; current_flight_dynamics->tail_blade_pitch.damaged = TRUE; current_flight_dynamics->tail_rotor_rpm.damaged = TRUE; current_flight_dynamics->cross_coupling_effect.damaged = TRUE; set_client_server_entity_int_value (get_gunship_entity (), INT_TYPE_TAIL_ROTOR_DAMAGED, TRUE); play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_TAIL_ROTOR_DAMAGED); set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_LEFT_ENGINE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: left engine damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_LEFT_ENGINE; current_flight_dynamics->left_engine_torque.damaged = TRUE; current_flight_dynamics->left_engine_rpm.damaged = TRUE; play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_LEFT_ENGINE_FAILURE); set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_RIGHT_ENGINE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: right engine damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_RIGHT_ENGINE; current_flight_dynamics->right_engine_torque.damaged = TRUE; current_flight_dynamics->right_engine_rpm.damaged = TRUE; play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_RIGHT_ENGINE_FAILURE); set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_LEFT_ENGINE_FIRE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: left engine fire damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_LEFT_ENGINE_FIRE; play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_LEFT_ENGINE_FIRE); set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_RIGHT_ENGINE_FIRE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: right engine fire damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_RIGHT_ENGINE_FIRE; play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_RIGHT_ENGINE_FIRE); set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_LOW_HYDRAULICS: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: LOW HYDRAULICS damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_LOW_HYDRAULICS; current_flight_dynamics->input_data.cyclic_x.damaged = TRUE; current_flight_dynamics->input_data.cyclic_y.damaged = TRUE; if (sfrand1 () < 0.0) { play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_HYDRAULIC_PRESSURE_FAILURE); } else { play_client_server_cpg_message (get_gunship_entity (), 0.5, 1.0, SPEECH_CATEGORY_CPG_SYSTEMS, 1.0, SPEECH_CPG_CONTROL_SYSTEMS_DAMAGED); } set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_STABILISER: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: STABILISER damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_STABILISER; set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); if (sfrand1 () < 0.0) { play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_STABILISER_DAMAGED); } else { play_client_server_cpg_message (get_gunship_entity (), 0.5, 1.0, SPEECH_CATEGORY_CPG_SYSTEMS, 1.0, SPEECH_CPG_CONTROL_SYSTEMS_DAMAGED); } break; } case DYNAMICS_DAMAGE_FUEL_LEAK: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: FUEL_LEAK damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_FUEL_LEAK; play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_FUEL_LEAK); break; } case DYNAMICS_DAMAGE_LOW_OIL_PRESSURE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: LOW_OIL_PRESSURE damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_LOW_OIL_PRESSURE; current_flight_dynamics->input_data.cyclic_y.damaged = TRUE; if (sfrand1 () < 0.0) { play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_LOW_ENGINE_OIL_PRESSURE); } else { play_client_server_cpg_message (get_gunship_entity (), 0.5, 1.0, SPEECH_CATEGORY_CPG_SYSTEMS, 1.0, SPEECH_CPG_CONTROL_SYSTEMS_DAMAGED); } set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_HIGH_OIL_PRESSURE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: HIGH_OIL_PRESSURE damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_HIGH_OIL_PRESSURE; current_flight_dynamics->input_data.collective.damaged = TRUE; if (sfrand1 () < 0.0) { play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_HIGH_ENGINE_OIL_TEMPERATURE); } else { play_client_server_cpg_message (get_gunship_entity (), 0.5, 1.0, SPEECH_CATEGORY_CPG_SYSTEMS, 1.0, SPEECH_CPG_CONTROL_SYSTEMS_DAMAGED); } set_current_flight_dynamics_auto_hover (HOVER_HOLD_NONE); set_current_flight_dynamics_auto_pilot (FALSE); break; } case DYNAMICS_DAMAGE_AVIONICS: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: AVIONICS damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_AVIONICS; break; } case DYNAMICS_DAMAGE_FIRE_EXTINGUISHER: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: FIRE_EXTINGUISHER damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_FIRE_EXTINGUISHER; break; } case DYNAMICS_DAMAGE_UNDERCARRIAGE: { //#if DYNAMICS_DEBUG debug_log ("DYNAMICS: UNDERCARRIAGE damage"); //#endif current_flight_dynamics->dynamics_damage |= DYNAMICS_DAMAGE_UNDERCARRIAGE; current_flight_dynamics->undercarriage_state.damaged = TRUE; play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_GEAR_DAMAGED); break; } default: { debug_fatal ("DYNAMICS: unknown damage %d", this_damage); } } } this_damage = this_damage << 1; } }
entity *create_engage_task (entity *group, entity *objective, entity *originator, int expire) { entity *force_en, *new_task; force *force_raw; vec3d *pos; entity_sides side; float expire_time; formation_types original_formation; ASSERT (group); ASSERT (get_local_entity_int_value (group, INT_TYPE_ENGAGE_ENEMY)); ASSERT (objective); #if DEBUG_MODULE debug_log ("ENGAGE: Trying to engage against %s (%d)", get_local_entity_string (objective, STRING_TYPE_FULL_NAME), get_local_entity_index (objective)); #endif ASSERT ((get_local_entity_int_value (objective, INT_TYPE_IDENTIFY_AIRCRAFT)) || (get_local_entity_int_value (objective, INT_TYPE_IDENTIFY_VEHICLE)) || (get_local_entity_int_value (objective, INT_TYPE_IDENTIFY_FIXED))); if (get_local_entity_int_value (get_session_entity (), INT_TYPE_SUPPRESS_AI_FIRE)) { return NULL; } force_en = get_local_force_entity ((entity_sides)get_local_entity_int_value (group, INT_TYPE_SIDE)); force_raw = (force*) get_local_entity_data (force_en); if (expire) { expire_time = (2.0 * ONE_MINUTE) + (frand1 () * ONE_MINUTE); } else { // // Max time for ENGAGE - stops attackers hanging around target area for too long (especially if they can NEVER get to their target) // expire_time = (15.0 * ONE_MINUTE) + (frand1 () * 5.0 * ONE_MINUTE); } new_task = NULL; // // Create engage task to expire in task_time seconds - debug // side = (entity_sides) get_local_entity_int_value (group, INT_TYPE_SIDE); pos = get_local_entity_vec3d_ptr (objective, VEC3D_TYPE_POSITION); ASSERT (get_local_entity_first_child (group, LIST_TYPE_MEMBER)); original_formation = FORMATION_ROW_LEFT; new_task = create_task (ENTITY_SUB_TYPE_TASK_ENGAGE, side, (movement_types) get_local_entity_int_value (group, INT_TYPE_MOVEMENT_TYPE), NULL, NULL, originator, TRUE, expire_time, 0.0, objective, task_database [ENTITY_SUB_TYPE_TASK_ENGAGE].task_priority, pos, objective, ENTITY_SUB_TYPE_WAYPOINT_TARGET, original_formation, &terminator_point, NULL, NUM_ENTITY_SUB_TYPE_WAYPOINTS, FORMATION_NONE); #if DEBUG_MODULE debug_log ("ENGAGE: Created Engage task against %s (%d)", get_local_entity_string (objective, STRING_TYPE_FULL_NAME), get_local_entity_index (objective)); #endif return new_task; }
void draw_hokum_virtual_cockpit (void) { int draw_main_rotors; float theta; object_3d_instance *inst3d; object_3d_sub_object_search_data search; switch (get_view_mode ()) { case VIEW_MODE_VIRTUAL_COCKPIT_CREW: case VIEW_MODE_VIRTUAL_COCKPIT_HUD: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: { break; } default: { if (!get_global_draw_cockpit_graphics ()) { draw_external_hokum_hud (); return; } break; } } // // lamps and instruments // draw_hokum_virtual_cockpit_lamps (); draw_hokum_virtual_cockpit_instruments (); // // crew animation // set_hokum_crew_head_positions (); // // animate main rotors // if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED)) { animate_damaged_helicopter_main_rotors (get_gunship_entity (), TRUE); } else { animate_helicopter_main_rotors (get_gunship_entity (), TRUE, FALSE); } inst3d = get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); theta = get_rotation_angle_of_helicopter_main_rotors (inst3d); set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d, theta); animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d); draw_main_rotors = TRUE; if (get_global_glass_cockpit ()) { draw_main_rotors = FALSE; } else { if (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW) { if (get_helicopter_main_rotors_blurred (get_gunship_entity ())) { if (!get_global_blurred_main_rotors_visible_from_cockpit ()) { draw_main_rotors = FALSE; } } } } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_MAIN_ROTOR_SHAFT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_main_rotors; } search.search_depth = 1; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_MAIN_ROTOR_SHAFT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_main_rotors; } // // animate electro-optics // animate_hokum_virtual_cockpit_eo (virtual_cockpit_inst3d); // // animate wipers // animate_hokum_wipers (virtual_cockpit_inst3d); // // draw 3D scene // set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // light direction is in world coordinates // light_3d_source *display_backlight, *cockpit_light; vec3d direction; matrix3x3 m1, m2; if (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE) == DAY_SEGMENT_TYPE_DAY) { //////////////////////////////////////// // // DAY LIGHTING // //////////////////////////////////////// if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.5000, 0.4000, 0.0000); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (cockpit_light); } else { // // inactive night vision system // insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); } } else { //////////////////////////////////////// // // NIGHT LIGHTING // //////////////////////////////////////// direction.x = virtual_cockpit_inst3d->vp.zv.x; direction.y = virtual_cockpit_inst3d->vp.zv.y; direction.z = virtual_cockpit_inst3d->vp.zv.z; display_backlight = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.2500, 0.0980, 0.0000); if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.5000, 0.4000, 0.0000); } else { // // inactive night vision system // direction.x = virtual_cockpit_inst3d->vp.yv.x; direction.y = virtual_cockpit_inst3d->vp.yv.y; direction.z = virtual_cockpit_inst3d->vp.yv.z; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0666, 0.1098, 0.6431); } insert_light_3d_source_into_3d_scene (display_backlight); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); remove_light_3d_source_from_3d_scene (display_backlight); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (display_backlight); destroy_light_3d_source (cockpit_light); } } #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
aircraft_fire_result aircraft_fire_weapon (entity *en, unsigned int check_flags) { entity *target; aircraft *raw; vec3d *target_pos, en_pos; ASSERT (en); raw = get_local_entity_data (en); // // Fire suppressed // if (check_flags & AIRCRAFT_FIRE_SUPPRESSED) { if (get_local_entity_int_value (get_session_entity (), INT_TYPE_SUPPRESS_AI_FIRE)) { return AIRCRAFT_FIRE_SUPPRESSED; } } // // check weapon // if (check_flags & AIRCRAFT_FIRE_NO_WEAPON) { if (get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON) == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON) { debug_log ("AC_WPN: Fire Weapon Error - NO WEAPON"); return AIRCRAFT_FIRE_NO_WEAPON; } } // // weapon system_ready // if (check_flags & AIRCRAFT_FIRE_WEAPON_SYSTEM_NOT_READY) { if (!get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON_SYSTEM_READY)) { debug_log ("AC_WPN: Fire Weapon Error - WEAPON SYSTEM NOT READY"); return AIRCRAFT_FIRE_WEAPON_SYSTEM_NOT_READY; } } // // find target // if (check_flags & AIRCRAFT_FIRE_NO_TARGET) { target = get_local_entity_parent (en, LIST_TYPE_TARGET); if (!target) { debug_log ("AC_WPN: Fire Weapon Error - NO TARGET"); return AIRCRAFT_FIRE_NO_TARGET; } } // // line of sight checks // if (check_flags & AIRCRAFT_FIRE_NO_LOS) { int criteria; if (get_local_entity_int_value (target, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { criteria = MOBILE_LOS_CHECK_ALL; } else { criteria = MOBILE_LOS_CHECK_COURSE_TERRAIN; } get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &en_pos); target_pos = get_local_entity_vec3d_ptr (target, VEC3D_TYPE_POSITION); en_pos.y -= (get_local_entity_float_value (en, FLOAT_TYPE_CENTRE_OF_GRAVITY_TO_GROUND_DISTANCE) + 2.0); if (!check_position_line_of_sight (en, target, &en_pos, target_pos, criteria)) { debug_log ("AC_WPN: Fire Weapon Error - NO LOS (Aircraft %s (%d), Target %s (%d))", get_local_entity_string (en, STRING_TYPE_FULL_NAME), get_local_entity_index (en), get_local_entity_string (target, STRING_TYPE_FULL_NAME), get_local_entity_index (target)); return AIRCRAFT_FIRE_NO_LOS; } } // // Play Speech // play_aircraft_weapon_launched_speech (en, raw->selected_weapon); // // Fire weapon // launch_client_server_weapon (en, raw->selected_weapon); return AIRCRAFT_FIRE_OK; }
aircraft_fire_result aircraft_fire_weapon (entity *en, unsigned int check_flags) { entity *target; aircraft *raw; vec3d *target_pos, en_pos; int loal_mode = FALSE; ASSERT (en); raw = (aircraft *) get_local_entity_data (en); // // Fire suppressed // if (check_flags & AIRCRAFT_FIRE_SUPPRESSED) { if (get_local_entity_int_value (get_session_entity (), INT_TYPE_SUPPRESS_AI_FIRE)) { return AIRCRAFT_FIRE_SUPPRESSED; } } // // check weapon // if (check_flags & AIRCRAFT_FIRE_NO_WEAPON) { if (get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON) == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON) { debug_log ("AC_WPN: Fire Weapon Error - NO WEAPON"); return AIRCRAFT_FIRE_NO_WEAPON; } } // // weapon system_ready // if (check_flags & AIRCRAFT_FIRE_WEAPON_SYSTEM_NOT_READY) { if (!get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON_SYSTEM_READY)) { debug_log ("AC_WPN: Fire Weapon Error - WEAPON SYSTEM NOT READY"); return AIRCRAFT_FIRE_WEAPON_SYSTEM_NOT_READY; } } // debug_log("%s: %d", get_sub_type_name(en), get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON)); // // find target // if (check_flags & AIRCRAFT_FIRE_NO_TARGET) { target = get_local_entity_parent (en, LIST_TYPE_TARGET); if (!target) { debug_log ("AC_WPN: Fire Weapon Error - NO TARGET"); return AIRCRAFT_FIRE_NO_TARGET; } } // // line of sight checks // if (check_flags & AIRCRAFT_FIRE_NO_LOS) { int criteria; if (get_local_entity_int_value (target, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { criteria = MOBILE_LOS_CHECK_ALL; } else { criteria = MOBILE_LOS_CHECK_COURSE_TERRAIN; } get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &en_pos); target_pos = get_local_entity_vec3d_ptr (target, VEC3D_TYPE_POSITION); en_pos.y -= (get_local_entity_float_value (en, FLOAT_TYPE_CENTRE_OF_GRAVITY_TO_GROUND_DISTANCE) + 2.0); if (!check_position_line_of_sight (en, target, &en_pos, target_pos, (mobile_los_check_criteria) criteria)) { if (get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON) == ENTITY_SUB_TYPE_WEAPON_AGM114L_LONGBOW_HELLFIRE && get_2d_range(&en_pos, target_pos) > weapon_database[ENTITY_SUB_TYPE_WEAPON_AGM114L_LONGBOW_HELLFIRE].min_range_loal) { debug_log("AC_WPN: Switching to LOAL mode to fire at target without LOS ((Aircraft %s (%d), Target %s (%d))", get_local_entity_string (en, STRING_TYPE_FULL_NAME), get_local_entity_index (en), get_local_entity_string (target, STRING_TYPE_FULL_NAME), get_local_entity_index (target)); loal_mode = TRUE; } else { debug_log ("AC_WPN: Fire Weapon Error - NO LOS (Aircraft %s (%d), Target %s (%d))", get_local_entity_string (en, STRING_TYPE_FULL_NAME), get_local_entity_index (en), get_local_entity_string (target, STRING_TYPE_FULL_NAME), get_local_entity_index (target)); return AIRCRAFT_FIRE_NO_LOS; } } } // // Play Speech // play_aircraft_weapon_launched_speech (en, raw->selected_weapon); // // Fire weapon // set_local_entity_int_value(en, INT_TYPE_LOCK_ON_AFTER_LAUNCH, loal_mode); launch_client_server_weapon (en, raw->selected_weapon); return AIRCRAFT_FIRE_OK; }
void draw_kiowa_virtual_cockpit (void) { int draw_main_rotors; float theta; object_3d_instance *inst3d; object_3d_sub_object_search_data search; switch (get_view_mode ()) { case VIEW_MODE_VIRTUAL_COCKPIT_CREW: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: { break; } default: { if (!get_global_draw_cockpit_graphics ()) { return; } break; } } // // lamps // draw_kiowa_virtual_cockpit_lamps (); // // crew animation // set_kiowa_crew_head_positions (); // // animate main rotors // if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED)) { animate_damaged_helicopter_main_rotors (get_gunship_entity (), TRUE); } else { animate_helicopter_main_rotors (get_gunship_entity (), TRUE, FALSE); } inst3d = (object_3d_instance *) get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); theta = get_rotation_angle_of_helicopter_main_rotors (inst3d); set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d, theta); animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d); draw_main_rotors = TRUE; if (get_global_glass_cockpit ()) { draw_main_rotors = FALSE; } else { if (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW) { if (get_helicopter_main_rotors_blurred (get_gunship_entity ())) { if (!get_global_blurred_main_rotors_visible_from_cockpit ()) { draw_main_rotors = FALSE; } } } } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_MAIN_ROTOR_SHAFT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_main_rotors; } // // draw 3D scene // set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // light direction is in world coordinates // light_3d_source *display_backlight, *cockpit_light; vec3d direction; matrix3x3 m1, m2; //VJ 050131 update on wideview mod, much better movement if (get_global_wide_cockpit () && ( get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY ) ) { get_kiowa_crew_viewpoint (); virtual_cockpit_inst3d->vp.x += wide_cockpit_position[wide_cockpit_nr].c.x; virtual_cockpit_inst3d->vp.y += wide_cockpit_position[wide_cockpit_nr].c.y; virtual_cockpit_inst3d->vp.z += wide_cockpit_position[wide_cockpit_nr].c.z; //ataribaby 27/12/2008 //virtual_cockpit_inst3d->vp.x += bound(current_flight_dynamics->model_acceleration_vector.x * ONE_OVER_G, -3.0, 3.0) * 0.025 * command_line_g_force_head_movment_modifier; //virtual_cockpit_inst3d->vp.y += bound(current_flight_dynamics->g_force.value - 1.0, -1.5, 5.0) * 0.025 * command_line_g_force_head_movment_modifier; if (wide_cockpit_nr == WIDEVIEW_KIOWA_PILOT) pilot_head_pitch_datum = rad ( wide_cockpit_position[wide_cockpit_nr].c.p ); if (wide_cockpit_nr == WIDEVIEW_KIOWA_COPILOT) co_pilot_head_pitch_datum = rad ( wide_cockpit_position[wide_cockpit_nr].c.p ); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); } //ataribaby 27/12/2008 new head g-force movement and vibration from main rotor if (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY) { if (get_time_acceleration() != TIME_ACCELERATION_PAUSE) { random_vibration_x = (frand1() * (current_flight_dynamics->main_rotor_rpm.value * 0.00002)) * command_line_g_force_head_movment_modifier; random_vibration_y = (frand1() * (current_flight_dynamics->main_rotor_rpm.value * 0.00002)) * command_line_g_force_head_movment_modifier; } x_head_g_movement = move_by_rate(x_head_g_movement, random_vibration_x + (bound(current_flight_dynamics->model_acceleration_vector.x * ONE_OVER_G, -3.0, 3.0) * 0.025 * command_line_g_force_head_movment_modifier), 0.05); y_head_g_movement = move_by_rate(y_head_g_movement, random_vibration_y + (bound(current_flight_dynamics->g_force.value - 1.0, -1.5, 5.0) * 0.025 * command_line_g_force_head_movment_modifier), 0.05); virtual_cockpit_inst3d->vp.x -= x_head_g_movement; //if (!current_flight_dynamics->auto_hover) // arneh - auto hover has some weird dynamics which cause lots of g-forces, so disable head movement when auto hover is enabled virtual_cockpit_inst3d->vp.y -= y_head_g_movement; } { // // ADI // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { float heading, pitch, roll; get_kiowa_virtual_cockpit_adi_angles (virtual_cockpit_inst3d->vp.attitude, &heading, &pitch, &roll); search.result_sub_object->relative_heading = -heading; search.result_sub_object->relative_pitch = pitch; search.result_sub_object->relative_roll = -roll; } // // ADI slip // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI_SIDE_SLIP; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_kiowa_virtual_cockpit_adi_slip_indicator_needle_value (); } // // airspeed // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_AIRSPEED; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_kiowa_virtual_cockpit_airspeed_indicator_needle_value (); } // // altimeter // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ALTIMETER; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_kiowa_virtual_cockpit_barometric_altimeter_needle_value (); } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_COMPASS_HEADING_NULL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_heading = -current_flight_dynamics->heading.value; } // // clock // { float hours, minutes, seconds; // // only read clock values if drawing virtual cockpit needles to prevent speeding up clock debug values // get_kiowa_virtual_cockpit_clock_hand_values (&hours, &minutes, &seconds); // // hour hand // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_HOUR_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = hours; } // // minute hand // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_MINUTE_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = minutes; } // // second hand // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_SECOND_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = seconds; } } } if (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE) == DAY_SEGMENT_TYPE_DAY) { //////////////////////////////////////// // // DAY LIGHTING // //////////////////////////////////////// if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0000, 0.5000, 0.0000); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (cockpit_light); } else { // // inactive night vision system // insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); print_edit_wide_cockpit (); end_3d_scene (); } } else { //////////////////////////////////////// // // NIGHT LIGHTING // //////////////////////////////////////// direction.x = virtual_cockpit_inst3d->vp.zv.x; direction.y = virtual_cockpit_inst3d->vp.zv.y; direction.z = virtual_cockpit_inst3d->vp.zv.z; display_backlight = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0627, 0.2039, 0.0392); if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0000, 0.5000, 0.0000); } else { // // inactive night vision system // direction.x = virtual_cockpit_inst3d->vp.yv.x; direction.y = virtual_cockpit_inst3d->vp.yv.y; direction.z = virtual_cockpit_inst3d->vp.yv.z; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0666, 0.1098, 0.6431); } insert_light_3d_source_into_3d_scene (display_backlight); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); print_edit_wide_cockpit (); end_3d_scene (); remove_light_3d_source_from_3d_scene (display_backlight); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (display_backlight); destroy_light_3d_source (cockpit_light); } } move_edit_wide_cockpit (); #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }