static void update_client (entity *en) { helicopter *raw; int loop; aircraft_damage_types damage_type; raw = get_local_entity_data (en); update_local_entity_view_interest_level (en); update_local_helicopter_rotor_sounds (en); damage_type = aircraft_critically_damaged (en); if (raw->ac.mob.alive) { switch (raw->player) { //////////////////////////////////////// case ENTITY_PLAYER_AI: //////////////////////////////////////// { //////////////////////////////////////// for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { if ((damage_type == AIRCRAFT_DAMAGE_CRITICAL) || (get_local_entity_int_value (en, INT_TYPE_EJECTED))) { helicopter_death_movement (en); } else { if (!get_local_entity_int_value (en, INT_TYPE_LANDED)) { get_3d_terrain_point_data (raw->ac.mob.position.x, raw->ac.mob.position.z, &raw->ac.terrain_info); } helicopter_movement (en); } } //////////////////////////////////////// //////////////////////////////////////// // // ORDER IS CRITICAL // if (raw->ac.mob.alive) { update_rotors (en); update_aircraft_loading_doors (en); update_aircraft_cargo_doors (en); update_aircraft_undercarriage (en); update_aircraft_weapon_system_ready (en); update_entity_weapon_systems (en); update_entity_weapon_system_weapon_and_target_vectors (en); } // //////////////////////////////////////// break; } //////////////////////////////////////// case ENTITY_PLAYER_LOCAL: //////////////////////////////////////// { if (en != get_gunship_entity ()) { // // Client might be waiting for server to set old gunship to AI controlled. // return; } if (raw->invulnerable_timer > 0.0) { raw->invulnerable_timer -= get_delta_time (); } update_current_flight_dynamics_fuel_weight (); if ((!fire_continuous_weapon) && (get_local_entity_sound_type_valid (en, weapon_database [raw->ac.selected_weapon].launch_sound_effect_sub_type))) { pause_client_server_continuous_weapon_sound_effect (en, raw->ac.selected_weapon); } //helicopter_death_movement (en); //////////////////////////////////////// if ((!get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) && (!get_local_entity_int_value (en, INT_TYPE_EJECTED))) { update_flight_dynamics (); transmit_entity_comms_message (ENTITY_COMMS_UPDATE, en); } else { if (get_local_entity_int_value (en, INT_TYPE_LANDED)) { if (get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) { set_current_flight_dynamics_rotor_brake (TRUE); set_current_flight_dynamics_auto_pilot (FALSE); current_flight_dynamics->input_data.collective.value = 0.0; } } if ((damage_type == AIRCRAFT_DAMAGE_CRITICAL) || (get_local_entity_int_value (en, INT_TYPE_EJECTED)) || (get_local_entity_int_value (en, INT_TYPE_LANDED))) { set_current_flight_dynamics_auto_pilot (FALSE); } for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { if ((damage_type == AIRCRAFT_DAMAGE_CRITICAL) || (get_local_entity_int_value (en, INT_TYPE_EJECTED))) { helicopter_death_movement (en); } else { if (!get_local_entity_int_value (en, INT_TYPE_LANDED)) { get_3d_terrain_point_data (raw->ac.mob.position.x, raw->ac.mob.position.z, &raw->ac.terrain_info); } helicopter_movement (en); if (get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) { set_dynamics_entity_values (get_gunship_entity ()); } } } } //////////////////////////////////////// // // ORDER IS CRITICAL // if (raw->ac.mob.alive) { update_aircraft_loading_doors (en); update_aircraft_cargo_doors (en); update_aircraft_undercarriage (en); update_aircraft_weapon_system_ready (en); update_entity_weapon_systems (en); update_entity_weapon_system_weapon_and_target_vectors (en); update_avionics (); update_cockpits (); update_aircraft_decoy_release (en); } // //////////////////////////////////////// // // Check if gunship has a task - if not then set gunship entity to NULL // if (!get_local_entity_parent (en, LIST_TYPE_FOLLOWER)) { if (!get_local_entity_int_value (en, INT_TYPE_EJECTED)) { if (en == get_gunship_entity ()) { set_gunship_entity (NULL); } } } break; } //////////////////////////////////////// case ENTITY_PLAYER_REMOTE: //////////////////////////////////////// { //////////////////////////////////////// // // ORDER IS CRITICAL // if (raw->ac.mob.alive) { update_aircraft_loading_doors (en); update_aircraft_cargo_doors (en); update_aircraft_undercarriage (en); update_aircraft_weapon_system_ready (en); update_entity_weapon_systems (en); update_entity_weapon_system_weapon_and_target_vectors (en); } if ((get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) || (get_local_entity_int_value (en, INT_TYPE_EJECTED))) { for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { // no need for death_movement as if the remote_player is damaged it will default back to manual flight. if (get_local_entity_int_value (en, INT_TYPE_EJECTED)) { helicopter_death_movement (en); } else { if (!get_local_entity_int_value (en, INT_TYPE_LANDED)) { get_3d_terrain_point_data (raw->ac.mob.position.x, raw->ac.mob.position.z, &raw->ac.terrain_info); } helicopter_movement (en); } } } else { interpolate_entity_position (en); } // //////////////////////////////////////// break; } } } else { if (get_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE) == OPERATIONAL_STATE_DEAD) { } else { for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { helicopter_death_movement (en); } } } }
void play_aircraft_shot_at_speech (entity *victim, entity *aggressor) { entity_sides victim_side, aggressor_side; int val, array_type, speech_index, *last_index; ASSERT (victim); ASSERT (aggressor); victim_side = (entity_sides) get_local_entity_int_value (victim, INT_TYPE_SIDE); aggressor_side = (entity_sides) get_local_entity_int_value (aggressor, INT_TYPE_SIDE); last_index = NULL; if (aggressor_side == victim_side) { // // FRIENDLY FIRE // //////////////////////////////////// // // victims speech // //////////////////////////////////// //////////////////////////////////// // // Aggressors speech // //////////////////////////////////// if (get_local_entity_int_value (aggressor, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { if (aggressor != victim) { // PLAY_SPEECH (CPG) // // (Hold your fire, we're hitting friendlies) | (Cease fire, we're hitting our own guys) if (rand16 () & 1) { speech_index = SPEECH_CPG_FRIENDLY_FIRE1; } else { speech_index = SPEECH_CPG_FRIENDLY_FIRE2; } play_client_server_cpg_message ( aggressor, 1.0, 3.0, SPEECH_CATEGORY_ATTACKING_TARGETS, 8.0, speech_index ); } } } else { if (aircraft_critically_damaged (victim)) { //////////////////////////////////// // // victims speech // //////////////////////////////////// if (get_local_entity_int_value (victim, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { // PLAY_SPEECH (CPG) // // (Where did that come from) | (We're french fries) | etc } else { // PLAY_SPEECH (WINGMAN) // // [This is..] // [callsign + number] // (Mayday, Mayday, we are going down) | (I've been hit, I'm going down, repeat going down) speech_index = SPEECH_WINGMAN_GOING_DOWN; play_client_server_wingman_message ( victim, 0.5, 4.0, SPEECH_CATEGORY_UNDER_ATTACK, 10.0, SPEECH_INTRODUCTION_ALWAYS, SPEECH_ARRAY_WINGMAN_MESSAGES, speech_index ); } //////////////////////////////////// // // Aggressors speech // //////////////////////////////////// play_aircraft_destroyed_speech (victim, aggressor); } else { //////////////////////////////////// // // victims speech // //////////////////////////////////// if (get_local_entity_int_value (victim, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { } else { // PLAY_SPEECH (WINGMAN) // // [This is..] // [callsign + number] // (We're taking hits) | (Things are heating up out here) | (It's too dangerous up here etc..) val = get_speech_random_value ( aircraft_hit_victim_wingman_comments, num_ac_hit_victim_wingman_comments [victim_side], last_ac_hit_victim_wingman_comment [victim_side] ); array_type = aircraft_hit_victim_wingman_comments [val].array_type; speech_index = aircraft_hit_victim_wingman_comments [val].speech_index; play_client_server_wingman_message ( victim, 0.8, 8.0, SPEECH_CATEGORY_UNDER_ATTACK, 16.0, aircraft_hit_victim_wingman_comments [val].introduction, (speech_array_types) array_type, speech_index ); } //////////////////////////////////// // // Aggressors speech // //////////////////////////////////// if (get_local_entity_int_value (aggressor, INT_TYPE_IDENTIFY_AIRCRAFT)) { if (get_local_entity_int_value (aggressor, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI) { // PLAY_SPEECH (CPG) // // (Target Hit) | (Turkey shoot) | (Fish in a barrel) | (They can run, etc) val = get_speech_random_value ( aircraft_hit_aggressor_cpg_comments, num_ac_hit_aggressor_cpg_comments [aggressor_side], last_ac_hit_aggressor_cpg_comment [aggressor_side] ); array_type = aircraft_hit_aggressor_cpg_comments [val].array_type; speech_index = aircraft_hit_aggressor_cpg_comments [val].speech_index; play_client_server_cpg_message ( aggressor, 0.6, 5.0, SPEECH_CATEGORY_ATTACKING_TARGETS, 15.0, speech_index ); } else { // PLAY_SPEECH (WINGMAN) // // [This is..] // [callsign + number] // (Target Hit) | (Turkey shoot) | (Fish in a barrel) | (They can run, etc) val = get_speech_random_value ( aircraft_hit_aggressor_wingman_comments, num_ac_hit_aggressor_wingman_comments [aggressor_side], last_ac_hit_aggressor_wingman_comment [aggressor_side] ); array_type = aircraft_hit_aggressor_wingman_comments [val].array_type; speech_index = aircraft_hit_aggressor_wingman_comments [val].speech_index; play_client_server_wingman_message ( aggressor, 0.6, 5.0, SPEECH_CATEGORY_ATTACKING_TARGETS, 16.0, aircraft_hit_aggressor_wingman_comments [val].introduction, (speech_array_types) array_type, speech_index ); } } } } }
static void update_server (entity *en) { entity *group; helicopter *raw; int loop; aircraft_damage_types damage_type; raw = get_local_entity_data (en); update_local_entity_view_interest_level (en); update_local_helicopter_rotor_sounds (en); damage_type = aircraft_critically_damaged (en); if (raw->ac.mob.alive) { switch (raw->player) { //////////////////////////////////////// case ENTITY_PLAYER_AI: //////////////////////////////////////// { //////////////////////////////////////// for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { if ((damage_type == AIRCRAFT_DAMAGE_CRITICAL) || (get_local_entity_int_value (en, INT_TYPE_EJECTED))) { helicopter_death_movement (en); } else { if (!get_local_entity_int_value (en, INT_TYPE_LANDED)) { get_3d_terrain_point_data (raw->ac.mob.position.x, raw->ac.mob.position.z, &raw->ac.terrain_info); } helicopter_movement (en); } } // provide resync for AI wingmen group = get_local_entity_parent (en, LIST_TYPE_MEMBER); if (group) { if ((get_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE) != OPERATIONAL_STATE_LANDED) && (get_local_entity_int_value (group, INT_TYPE_MULTIPLAYER_GROUP))) { transmit_entity_comms_message (ENTITY_COMMS_UPDATE, en); } } //////////////////////////////////////// // // ORDER IS CRITICAL // if (raw->ac.mob.alive) { update_rotors (en); update_aircraft_loading_doors (en); update_aircraft_cargo_doors (en); update_aircraft_undercarriage (en); update_aircraft_rudder (en); update_aircraft_target_scan (en); update_aircraft_weapon_system_ready (en); update_entity_weapon_systems (en); update_entity_weapon_system_weapon_and_target_vectors (en); update_aircraft_weapon_fire (en); update_aircraft_decoy_release (en); } // //////////////////////////////////////// break; } //////////////////////////////////////// case ENTITY_PLAYER_LOCAL: //////////////////////////////////////// { ASSERT (en == get_gunship_entity ()); if (raw->invulnerable_timer > 0.0) { raw->invulnerable_timer -= get_delta_time (); } update_current_flight_dynamics_fuel_weight (); update_current_flight_dynamics_flight_time (); //////////////////////////////////////// if ((!get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) && (!get_local_entity_int_value (en, INT_TYPE_EJECTED))) { update_flight_dynamics (); update_player_helicopter_waypoint_distance (en); } else { if ((damage_type == AIRCRAFT_DAMAGE_CRITICAL) || (get_local_entity_int_value (en, INT_TYPE_EJECTED)) || (get_local_entity_int_value (en, INT_TYPE_LANDED))) { set_current_flight_dynamics_auto_pilot (FALSE); if (get_local_entity_int_value (en, INT_TYPE_LANDED)) { set_current_flight_dynamics_rotor_brake (TRUE); current_flight_dynamics->input_data.collective.value = 0.0; } } for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { if (get_local_entity_int_value (en, INT_TYPE_EJECTED)) { helicopter_death_movement (en); } else { get_3d_terrain_point_data (raw->ac.mob.position.x, raw->ac.mob.position.z, &raw->ac.terrain_info); helicopter_movement (en); if (get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) { set_dynamics_entity_values (en); } } } } //////////////////////////////////////// transmit_entity_comms_message (ENTITY_COMMS_UPDATE, en); //////////////////////////////////////// // // ORDER IS CRITICAL // if (raw->ac.mob.alive) { update_aircraft_loading_doors (en); update_aircraft_cargo_doors (en); update_aircraft_undercarriage (en); update_aircraft_weapon_system_ready (en); update_entity_weapon_systems (en); update_entity_weapon_system_weapon_and_target_vectors (en); update_avionics (); update_cockpits (); update_aircraft_decoy_release (en); } // //////////////////////////////////////// // // Check if gunship has a task - if not then set gunship entity to NULL // if (!get_local_entity_parent (en, LIST_TYPE_FOLLOWER)) { if (!get_local_entity_int_value (en, INT_TYPE_EJECTED)) { if (en == get_gunship_entity ()) { set_gunship_entity (NULL); } } } break; } //////////////////////////////////////// case ENTITY_PLAYER_REMOTE: //////////////////////////////////////// { //////////////////////////////////////// if (raw->invulnerable_timer > 0.0) { raw->invulnerable_timer -= get_delta_time (); } if ((get_local_entity_int_value (en, INT_TYPE_AUTO_PILOT)) || (get_local_entity_int_value (en, INT_TYPE_EJECTED))) { for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { if ((damage_type == AIRCRAFT_DAMAGE_CRITICAL) || (get_local_entity_int_value (en, INT_TYPE_EJECTED))) { helicopter_death_movement (en); } else { if (!get_local_entity_int_value (en, INT_TYPE_LANDED)) { get_3d_terrain_point_data (raw->ac.mob.position.x, raw->ac.mob.position.z, &raw->ac.terrain_info); } helicopter_movement (en); } } #if DEBUG_MODULE debug_log ("HC_UPDT: SERVER: moving client %d using AUTO PILOT", get_local_entity_index (en)); #endif } else { interpolate_entity_position (en); update_player_helicopter_waypoint_distance (en); } //////////////////////////////////////// // // ORDER IS CRITICAL // if (raw->ac.mob.alive) { update_aircraft_loading_doors (en); update_aircraft_cargo_doors (en); update_aircraft_undercarriage (en); update_aircraft_weapon_system_ready (en); update_entity_weapon_systems (en); update_entity_weapon_system_weapon_and_target_vectors (en); } // //////////////////////////////////////// break; } } } else { if (get_local_entity_int_value (en, INT_TYPE_OPERATIONAL_STATE) == OPERATIONAL_STATE_DEAD) { raw->ac.death_timer -= get_delta_time (); if (raw->ac.death_timer <= 0.0) { if (get_local_entity_int_value (en, INT_TYPE_PLAYER) == ENTITY_PLAYER_AI) { // // don't destroy helicopters while they are still occupied by players (otherwise avionics / pilot-entity etc. don't get deinitialised) // destroy_client_server_entity_family (en); } else { raw->ac.death_timer = 0.0; } } } else { for (loop = 0; loop < get_entity_movement_iterations (); loop ++) { helicopter_death_movement (en); } } } }