示例#1
0
int set_entity_update_frame_rate (int frame_rate)
{

	int
		entity_update_iterations;

	float
		entity_update_delta_time;

	entity_update_iterations = 1;

	ASSERT ((frame_rate >= 1) && (frame_rate <= 100));

	entity_update_iterations = (int) (get_delta_time () * frame_rate + 1.0);

	entity_update_delta_time = get_delta_time () / entity_update_iterations;

	#if DEBUG_MODULE

	debug_log ("UPDATE: requested frame rate %d, delta time %f, iterations %d, set_delta_time %f", frame_rate, get_delta_time (), entity_update_iterations, entity_update_delta_time);

	#endif

	set_manual_delta_time (entity_update_delta_time);

	return entity_update_iterations;
}
示例#2
0
static int 
process_callback(jack_nframes_t nframes, void *notused)
{
#ifdef MEASURE_TIME
	if (get_delta_time() > MAX_TIME_BETWEEN_CALLBACKS) {
		warn_from_jack_thread_context("Had to wait too long for JACK callback; scheduling problem?");
	}
#endif

	/* Check for impossible condition that actually happened to me, caused by some problem between jackd and OSS4. */
	if (nframes <= 0) {
		warn_from_jack_thread_context("Process callback called with nframes = 0; bug in JACK?");
		return 0;
	}


	if (pthread_mutex_trylock(&mutex) == 0) {
		if ((smf = smf_vol) != NULL) {
			process_midi_output(nframes);
		}
		pthread_mutex_unlock(&mutex);
	}

#ifdef MEASURE_TIME
	if (get_delta_time() > MAX_PROCESSING_TIME) {
		warn_from_jack_thread_context("Processing took too long; scheduling problem?");
	}
#endif

	return 0;
}
示例#3
0
文件: ss_updt.c 项目: Comanche93/eech
static void update_time_of_day_resync (entity *en)
{
	session
		*raw;
		
	ASSERT (en);

	raw = (session *) get_local_entity_data (en);

	raw->time_of_day_resync += get_delta_time ();

	if (raw->time_of_day_resync > SESSION_RESYNC_FREQUENCY)
	{

		transmit_entity_comms_message (ENTITY_COMMS_UPDATE, en);

		raw->time_of_day_resync = 0.0;

		#if DEBUG_MODULE

		debug_log ("SS_UPDT : Weather at %f, %f - radius %f", raw->weather_position.x, raw->weather_position.z, raw->weather_radius);

		#endif
	}
}
示例#4
0
static void update_master_caution (void)
{
	//
	// monitor engine damage
	//

	engine_damage_imminent_status = get_current_flight_dynamics_engine_damage_imminent ();

	if ((!previous_engine_damage_imminent_status) && engine_damage_imminent_status)
	{
		play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_ENGINE_OVERTORQUE);

		activate_blackhawk_master_caution ();
	}

	previous_engine_damage_imminent_status = engine_damage_imminent_status;

	//
	// update master caution
	//

	master_caution_sound_timer -= get_delta_time ();

	if (master_caution_sound_timer <= 0.0)
	{
		master_caution_sound_timer = 0.0;

		pause_local_entity_sound_type (get_gunship_entity (), ENTITY_SUB_TYPE_EFFECT_SOUND_MCA, 0.5);
	}
}
/*
  return delta_time for the delta_angle
 */
float AP_InertialSensor::get_delta_angle_dt(uint8_t i) const
{
    if (_delta_angle_valid[i] && _delta_angle_dt[i] > 0) {
        return _delta_angle_dt[i];
    }
    return get_delta_time();
}
/*
  return delta_time for the delta_velocity
 */
float AP_InertialSensor::get_delta_velocity_dt(uint8_t i) const
{
    if (_delta_velocity_valid[i]) {
        return _delta_velocity_dt[i];
    }
    return get_delta_time();
}
/*
  return delta_time for the delta_angle
 */
float AP_InertialSensor::get_delta_angle_dt(uint8_t i) const
{
    if (_delta_angle_valid[i]) {
//        pilot_info("_delta_angle_dt[%d]=%f\n", i, _delta_angle_dt[i]);
        return _delta_angle_dt[i];
    }
    return get_delta_time();
}
示例#8
0
文件: cm_stat.c 项目: Comanche93/eech
void update_static_camera (camera *raw)
{
	float
		heading,
		pitch;

	ASSERT (raw);

	heading = get_heading_from_attitude_matrix (raw->attitude);

	pitch = get_pitch_from_attitude_matrix (raw->attitude);

	//
	// adjust camera heading
	//

	if (adjust_view_left_key || joystick_pov_left)
	{
		heading -= STATIC_CAMERA_ROTATE_RATE * get_delta_time ();
	}
	else if (adjust_view_right_key || joystick_pov_right)
	{
		heading += STATIC_CAMERA_ROTATE_RATE * get_delta_time ();
	}

	heading = wrap_angle (heading);

	//
	// adjust camera pitch
	//

	if (adjust_view_up_key || joystick_pov_up)
	{
		pitch += STATIC_CAMERA_ROTATE_RATE * get_delta_time ();

		pitch = min (STATIC_CAMERA_ROTATE_UP_LIMIT, pitch);
	}
	else if (adjust_view_down_key || joystick_pov_down)
	{
		pitch -= STATIC_CAMERA_ROTATE_RATE * get_delta_time ();

		pitch = max (STATIC_CAMERA_ROTATE_DOWN_LIMIT, pitch);
	}

	get_3d_transformation_matrix (raw->attitude, heading, pitch, 0.0);
}
bool CEnvironment::update_theatre_of_operations(eTimeType time_type)
{	
	for(m_logistics_operation_iter = mv_logistics_operation.begin(); m_logistics_operation_iter < mv_logistics_operation.end(); ++m_logistics_operation_iter)
	{	
		m_logistics_operation_iter->update_operation(get_delta_time());	
	}
	return true;
}
示例#10
0
文件: fw_draw.c 项目: Comanche93/eech
void update_fixed_wing_sprite_light_timers (void)
{
	sprite_light_timer += (get_delta_time () * SPRITE_LIGHT_TIMER_FREQUENCY);

	if (sprite_light_timer >= 1.0)
	{
		sprite_light_timer = frac (sprite_light_timer);
	}
}
示例#11
0
static void update_master_caution (void)
{
	//
	// monitor engine damage
	//

	engine_damage_imminent_status = get_current_flight_dynamics_engine_damage_imminent ();

	if ((!previous_engine_damage_imminent_status) && engine_damage_imminent_status)
	{
		play_client_server_warning_message (get_gunship_entity (), SPEECH_SYSTEM_ENGINE_OVERTORQUE);

		activate_hokum_master_caution ();
	}

	previous_engine_damage_imminent_status = engine_damage_imminent_status;

	//
	// update master caution lamp
	//

	if (master_caution_alert)
	{
		master_caution_flash_timer -= get_delta_time ();

		if (master_caution_flash_timer <= 0.0)
		{
			master_caution_flash_timer = MASTER_CAUTION_FLASH_RATE;

			hokum_lamps.master_caution ^= 1;
		}

		master_caution_sound_timer -= get_delta_time ();

		if (master_caution_sound_timer <= 0.0)
		{
			master_caution_sound_timer = 0.0;

			pause_local_entity_sound_type (get_gunship_entity (), ENTITY_SUB_TYPE_EFFECT_SOUND_MCA, 0.5);
		}
	}
}
/*
  get delta velocity if available
*/
bool AP_InertialSensor::get_delta_velocity(uint8_t i, Vector3f &delta_velocity) const
{
    if (_delta_velocity_valid[i]) {
        delta_velocity = _delta_velocity[i];
        return true;
    } else if (get_accel_health(i)) {
        delta_velocity = get_accel(i) * get_delta_time();
        return true;
    }
    return false;
}
/*
  get delta angles
 */
bool AP_InertialSensor::get_delta_angle(uint8_t i, Vector3f &delta_angle) const
{
    if (_delta_angle_valid[i]) {
        delta_angle = _delta_angle[i];
        return true;
    } else if (get_gyro_health(i)) {
        // provide delta angle from raw gyro, so we use the same code
        // at higher level
        delta_angle = get_gyro(i) * get_delta_time();
        return true;
    }
    return false;
}
示例#14
0
static void update_rotors (entity *en)
{
	helicopter
		*raw;

	raw = get_local_entity_data (en);

	if (!get_local_entity_parent (en, LIST_TYPE_FOLLOWER))
	{
		raw->main_rotor_rpm -= 5.0 * get_delta_time ();

		raw->main_rotor_rpm = bound (raw->main_rotor_rpm, 0.0, 100.0);

		raw->tail_rotor_rpm = raw->main_rotor_rpm;
	}
}
示例#15
0
void update_aircraft_damage_timers (void)
{

	if (send_damage_update_flag)
	{
		send_damage_update_flag = FALSE;
	}

	aircraft_damage_timer -= get_delta_time ();

	if (aircraft_damage_timer < 0.0)
	{
		aircraft_damage_timer = AIRCRAFT_DAMAGE_TIMER_MAX_VALUE;

		send_damage_update_flag = TRUE;
	}
}
示例#16
0
文件: mslider.c 项目: Comanche93/eech
void mslider_move_function (event *ev)
{

	float
		mouse_x,
		mouse_y;

	static ui_object
		*obj;

	if (current_object_to_slide)
	{

		mouse_x = get_mouse_x ();

		mouse_y = get_mouse_y ();

		if (mouse_y < get_ui_object_y (current_object_to_slide))
		{

			scroll = max (-1.0f, (get_ui_object_y (current_object_to_slide) - mouse_y) * get_delta_time ());

			set_ui_object_state (current_object_to_slide, UI_OBJECT_STATE_OFF);
		}
		else if (mouse_y > get_ui_object_y (current_object_to_slide) + get_ui_object_y_size (current_object_to_slide))
		{

			scroll = min (1.0f, (get_ui_object_y (current_object_to_slide) + get_ui_object_y_size (current_object_to_slide) - mouse_y) * get_delta_time ());

			set_ui_object_state (current_object_to_slide, UI_OBJECT_STATE_OFF);
		}
		else
		{

			scroll = 0.0;

			obj = check_ui_object_for_selection (current_object_to_slide, mouse_x, mouse_y);

			if (obj)
			{

				set_ui_object_state (obj, UI_OBJECT_STATE_ON);
			}
		}
	}
}
示例#17
0
void idleFunction() 
{
	long delta = get_delta_time();
	//receivePackets loops through all packets.
	std::string incMsg;
	switch (gameData.get_game_state()) {
	case CHAT_SCREEN:
		incMsg = receivePackets_ChatScreen();
		if (incMsg == "READY") {
			gameData.toggle_opponent_ready();
		}
		else {
			if (incMsg.size() > 0) {
				messages.push_back("Friend: " + incMsg);
				glutPostRedisplay();
			}
		}
		countDown((gameData.is_player_ready() && gameData.is_opponent_ready()), messages, gameData);
		// erase old messages that no longer fit.
		if (messages.size()*0.05 >= 1.49) {
			messages.pop_front();
			glutPostRedisplay();
		}
		break;
	case START_GAME:
		receivePackets_Game(gameData);
		decideOrder(gameData);
		//initialDraw();
		gameData.set_game_state(GAME);
		glutPostRedisplay();
		break;
	case GAME:
		receivePackets_Game(gameData);
		if (gameData.actions_remain())
			gameData.next_action()(delta);
		drawApproach(delta); // animated card-draw;
		if (cardGrabbed && hoverCard->getY() > -0.5f && hoverCard->getY() < 0.0f) {
			hoverCard->moveTo(hoverCard->getX(), hoverCard->getY(), 1.24f - 1.24f*((0.5f + hoverCard->getY())/0.5f));
			glutPostRedisplay();
		}
		break;
	}
	incMsg = "";
}
示例#18
0
文件: ss_updt.c 项目: Comanche93/eech
static void update_time_of_day (entity *en)
{
	session
		*raw;

	float
		time_of_day;

	ASSERT (en);

	raw = (session *) get_local_entity_data (en);

	//
	// Time of day
	//

	raw->elapsed_time += (get_delta_time () * raw->time_of_day_acceleration);

	time_of_day = calculate_session_time_of_day (en, NULL);

	//
	// skip night-time for demos
	//

	if (raw->skip_night_time)
	{
		if (time_of_day > get_segment_time_of_day (DAY_SEGMENT_TYPE_NIGHT))
		{
			raw->elapsed_time += (ONE_DAY - time_of_day) + get_segment_time_of_day (DAY_SEGMENT_TYPE_DAWN);

			time_of_day = calculate_session_time_of_day (en, NULL);
		}
		else if (time_of_day < get_segment_time_of_day (DAY_SEGMENT_TYPE_DAWN))
		{
			raw->elapsed_time += get_segment_time_of_day (DAY_SEGMENT_TYPE_DAWN) - time_of_day;

			time_of_day = calculate_session_time_of_day (en, NULL);
		}
	}

	raw->day_segment_type = get_day_segment_type (time_of_day);
}
示例#19
0
void update_local_entity_view_interest_level (entity *en)
{
    float
    level;

    ASSERT (en);

    level = get_local_entity_float_value (en, FLOAT_TYPE_VIEW_INTEREST_LEVEL);

    if (level > 0.0)
    {
        level -= get_delta_time ();

        if (level < 0.0)
        {
            level = 0.0;
        }

        set_local_entity_float_value (en, FLOAT_TYPE_VIEW_INTEREST_LEVEL, level);
    }
}
示例#20
0
文件: rg_updt.c 项目: Comanche93/eech
static void update_server (entity *en)
{

	regen
		*raw;

	raw = (regen *) get_local_entity_data (en);

	if (!raw->alive)
	{
		return;
	}

	raw->sleep -= get_delta_time ();

	if (raw->sleep <= 0.0)
	{
		regen_update (en);

		raw->sleep = regen_frequency [raw->side] * get_regen_frequency_difficulty_modifier ();
	}
}
示例#21
0
void update_good_tone (void)
{
	if (good_tone_delay > 0.0)
	{
		good_tone_delay -= get_delta_time ();

		if (good_tone_delay <= 0.0)
		{
			good_tone_delay = 0.0;

			play_client_server_cpg_message (get_gunship_entity (), 0.5, 1.0, SPEECH_CATEGORY_CPG_SYSTEMS, 1.0, SPEECH_CPG_GOOD_TONE);
		}
	}

	if (!good_tone)
	{
		if (frand1 () < 0.5)
		{
			good_tone_delay = 0.5 + (frand1 () * 0.5);
		}
	}

	good_tone = TRUE;
}
void update_game(Game* G)
{
    float delta_time = (float)get_delta_time(G->timer);
    int ii;

    _control_camera(G, delta_time);
    set_view_matrix(G->graphics, mat4_inverse(transform_get_matrix(G->camera)));

    /* Dynamic Lights */
    if(G->dynamic_lights) {
        G->sun_light.position = mat3_mul_vector(vec3_create(5,5,0), mat3_rotation_y((float)get_running_time(G->timer)*0.5f));
        G->light_transform += delta_time;
        for(ii=0;ii<NUM_LIGHTS;++ii) {
            if(ii % 2)
                G->lights[ii].position.z = sinf((G->light_transform + ii * 1.0f)/2.0f) * 10.0f;
            else
                G->lights[ii].position.x = sinf((G->light_transform + ii * 1.0f)/2.0f) * 10.0f;
        }
    }

    add_light(G->graphics, G->sun_light);
    for(ii=0;ii<NUM_LIGHTS;++ii) {
        add_light(G->graphics, G->lights[ii]);
    }
    render_scene(G->scene, G->graphics);

    G->tap_timer += delta_time;

    /* Calculate FPS */
    G->fps_time += delta_time;
    G->fps_count++;

    if(G->fps_time >= 1.0f) {
        G->fps = G->fps_count/G->fps_time;
        system_log("FPS: %f\n", G->fps);
        G->fps_time -= 1.0f;
        G->fps_count = 0;
    }
    {
        int width, height;
        float scale = 50.0f;
        float x = -G->width/2.0f;
        float y = G->height/2.0f-scale;
        char buffer[256] = {0};
        // FPS
        sprintf(buffer, "FPS: %.2f", G->fps);
        add_string(G->ui, x, y, scale, buffer);
        y -= scale;
        // Renderer
        switch(renderer_type(G->graphics)) {
        case kForward: add_string(G->ui, x, y, scale, "Forward renderer"); break;
        case kLightPrePass: add_string(G->ui, x, y, scale, "Deferred Lighting"); break;
        case kDeferred: add_string(G->ui, x, y, scale, "Deferred Shading"); break;
        default: assert(!"Invalid renderer"); break;
        }
        y -= scale;
        // Resolution
        graphics_size(G->graphics, &width, &height);
        sprintf(buffer, "%dx%d", width, height);
        add_string(G->ui, x, y, scale, buffer);
    }
}
示例#23
0
文件: ah_eo.c 项目: Comanche93/eech
void update_ah64a_eo (eo_params *eo)
{
	float
		fine_slew_rate,
		medium_slew_rate,
		mouse_slew_rate, // Jabberwock 030930 
		coarse_slew_rate;

	ASSERT (eo);

	////////////////////////////////////////
	//
	// field of view
	//
	////////////////////////////////////////

	while (single_target_acquisition_system_inc_range_key)
	{
		dec_eo_field_of_view (eo);

		single_target_acquisition_system_inc_range_key--;
	}

	while (single_target_acquisition_system_inc_range_fast_key)
	{
		fast_dec_eo_field_of_view (eo);

		single_target_acquisition_system_inc_range_fast_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_dec_range_key)
	{
		inc_eo_field_of_view (eo);

		single_target_acquisition_system_dec_range_key--;
	}

	while (single_target_acquisition_system_dec_range_fast_key)
	{
		fast_inc_eo_field_of_view (eo);

		single_target_acquisition_system_dec_range_fast_key--;
	}

	////////////////////////////////////////

	while (toggle_ground_stabilisation_key)
	{
		toggle_ground_stabilisation ();

		toggle_ground_stabilisation_key--;
	}

	////////////////////////////////////////

	////////////////////////////////////////
	//
	// slew optics
	//
	////////////////////////////////////////

	switch (eo->field_of_view)
	{
		////////////////////////////////////////
		case EO_FOV_ZOOM:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (0.1) * get_delta_time ();

			medium_slew_rate = rad (0.5) * get_delta_time ();

			mouse_slew_rate = rad (1.2) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (2.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		case EO_FOV_NARROW:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (0.25) * get_delta_time ();

			medium_slew_rate = rad (1.0) * get_delta_time ();

			mouse_slew_rate = rad (2.0) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (4.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		case EO_FOV_MEDIUM:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (0.5) * get_delta_time ();

			medium_slew_rate = rad (2.5) * get_delta_time ();

			mouse_slew_rate = rad (6) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (10.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		case EO_FOV_WIDE:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (4.0) * get_delta_time ();

			medium_slew_rate = rad (20.0) * get_delta_time ();

			mouse_slew_rate = rad (48) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (80.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal ("Invalid field of view = %d", eo->field_of_view);

			break;
		}
	}

	////////////////////////////////////////

	keyboard_slew_eo_system(fine_slew_rate, medium_slew_rate, coarse_slew_rate);

	////////////////////////////////////////

	while (single_target_acquisition_system_select_next_target_key)
	{
		select_next_eo_target ();

		single_target_acquisition_system_select_next_target_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_previous_target_key)
	{
		select_previous_eo_target ();

		single_target_acquisition_system_select_previous_target_key--;
	}


// Jabberwock 031107 Designated targets
	
	while (single_target_acquisition_system_select_next_designated_key)
	{
		select_next_designated_eo_target ();

		single_target_acquisition_system_select_next_designated_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_previous_designated_key)
	{
		select_previous_designated_eo_target ();

		single_target_acquisition_system_select_previous_designated_key--;
	}	

// Jabberwock 031107 ends	

	if ( command_line_eo_pan_joystick_index == -1 )
	{						
		float ROTATE_RATE = (float) command_line_mouse_look_speed / 5.0;

		eo_azimuth = get_eo_azimuth (ROTATE_RATE, coarse_slew_rate, eo_azimuth, eo_min_azimuth, eo_max_azimuth, mouse_slew_rate);
		eo_elevation = get_eo_elevation (ROTATE_RATE, coarse_slew_rate, eo_elevation, eo_min_elevation, eo_max_elevation, mouse_slew_rate);
	}
	
	eo->field_of_view = get_old_eo_zoom(eo->field_of_view, eo->max_field_of_view, eo->min_field_of_view);

	////////////////////////////////////////

	// Retro 31Oct2004 - copy+paste of loke's comanche EO slew code
	// loke 030315
	// added code to allow the user to slew the eo device using joystick axes

	joystick_slew_eo_system(coarse_slew_rate);

	////////////////////////////////////////

	// loke 030322
	// handle the ground stabilisation

	if (eo_ground_stabilised)
	{
		handle_ground_stabilisation();
	}

	////////////////////////////////////////
}
示例#24
0
文件: bh_eo.c 项目: Comanche93/eech
void update_blackhawk_eo (eo_params *eo)
{
	float
		fine_slew_rate,
		medium_slew_rate,
		mouse_slew_rate, // Jabberwock 030930 
		coarse_slew_rate;

	ASSERT (eo);

	////////////////////////////////////////
	//
	// field of view
	//
	////////////////////////////////////////

	while (single_target_acquisition_system_inc_range_key)
	{
		dec_eo_field_of_view (eo);

		single_target_acquisition_system_inc_range_key--;
	}

	while (single_target_acquisition_system_inc_range_fast_key)
	{
		fast_dec_eo_field_of_view (eo);

		single_target_acquisition_system_inc_range_fast_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_dec_range_key)
	{
		inc_eo_field_of_view (eo);

		single_target_acquisition_system_dec_range_key--;
	}

	while (single_target_acquisition_system_dec_range_fast_key)
	{
		fast_inc_eo_field_of_view (eo);

		single_target_acquisition_system_dec_range_fast_key--;
	}

	////////////////////////////////////////
	//
	// slew optics
	//
	////////////////////////////////////////

	switch (eo->field_of_view)
	{
		////////////////////////////////////////
		case EO_FOV_NARROW:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (0.05) * get_delta_time ();

			medium_slew_rate = rad (0.25) * get_delta_time ();

			mouse_slew_rate = rad (0.6) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (1.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		case EO_FOV_MEDIUM:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (0.5) * get_delta_time ();

			medium_slew_rate = rad (2.5) * get_delta_time ();

			mouse_slew_rate = rad (6) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (10.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		case EO_FOV_WIDE:
		////////////////////////////////////////
		{
			fine_slew_rate = rad (4.0) * get_delta_time ();

			medium_slew_rate = rad (20.0) * get_delta_time ();

			mouse_slew_rate = rad (48) * get_delta_time ();	// Jabberwock 030930
			
			coarse_slew_rate = rad (80.0) * get_delta_time ();

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal ("Invalid field of view = %d", eo->field_of_view);

			break;
		}
	}

	////////////////////////////////////////

	if (continuous_target_acquisition_system_steer_left_fast_key)
	{
		eo_azimuth -= coarse_slew_rate;

		eo_azimuth = max (eo_azimuth, eo_min_azimuth);
	}
	else if (continuous_target_acquisition_system_steer_left_fine_key)
	{
		eo_azimuth -= fine_slew_rate;

		eo_azimuth = max (eo_azimuth, eo_min_azimuth);
	}
	else if (continuous_target_acquisition_system_steer_left_key)
	{
		eo_azimuth -= medium_slew_rate;

		eo_azimuth = max (eo_azimuth, eo_min_azimuth);
	}

	////////////////////////////////////////

	if (continuous_target_acquisition_system_steer_right_fast_key)
	{
		eo_azimuth += coarse_slew_rate;

		eo_azimuth = min (eo_azimuth, eo_max_azimuth);
	}
	else if (continuous_target_acquisition_system_steer_right_fine_key)
	{
		eo_azimuth += fine_slew_rate;

		eo_azimuth = min (eo_azimuth, eo_max_azimuth);
	}
	else if (continuous_target_acquisition_system_steer_right_key)
	{
		eo_azimuth += medium_slew_rate;

		eo_azimuth = min (eo_azimuth, eo_max_azimuth);
	}

	////////////////////////////////////////

	if (continuous_target_acquisition_system_steer_up_fast_key)
	{
		eo_elevation += coarse_slew_rate;

		eo_elevation = min (eo_elevation, eo_max_elevation);
	}
	else if (continuous_target_acquisition_system_steer_up_fine_key)
	{
		eo_elevation += fine_slew_rate;

		eo_elevation = min (eo_elevation, eo_max_elevation);
	}
	else if (continuous_target_acquisition_system_steer_up_key)
	{
		eo_elevation += medium_slew_rate;

		eo_elevation = min (eo_elevation, eo_max_elevation);
	}

	////////////////////////////////////////

	if (continuous_target_acquisition_system_steer_down_fast_key)
	{
		eo_elevation -= coarse_slew_rate;

		eo_elevation = max (eo_elevation, eo_min_elevation);
	}
	else if (continuous_target_acquisition_system_steer_down_fine_key)
	{
		eo_elevation -= fine_slew_rate;

		eo_elevation = max (eo_elevation, eo_min_elevation);
	}
	else if (continuous_target_acquisition_system_steer_down_key)
	{
		eo_elevation -= medium_slew_rate;

		eo_elevation = max (eo_elevation, eo_min_elevation);
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_next_target_key)
	{
		select_next_eo_target ();

		single_target_acquisition_system_select_next_target_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_previous_target_key)
	{
		select_previous_eo_target ();

		single_target_acquisition_system_select_previous_target_key--;
	}

// Jabberwock 031107 Designated targets
	
	while (single_target_acquisition_system_select_next_designated_key)
	{
		select_next_designated_eo_target ();

		single_target_acquisition_system_select_next_designated_key--;
	}

	////////////////////////////////////////

	while (single_target_acquisition_system_select_previous_designated_key)
	{
		select_previous_designated_eo_target ();

		single_target_acquisition_system_select_previous_designated_key--;
	}	

// Jabberwock 031107 ends	

	if ( command_line_eo_pan_joystick_index == -1 )
	{						
		float ROTATE_RATE = (float) command_line_mouse_look_speed / 5.0;

		eo_azimuth = get_eo_azimuth (ROTATE_RATE, coarse_slew_rate, eo_azimuth, eo_min_azimuth, eo_max_azimuth, mouse_slew_rate);
		eo_elevation = get_eo_elevation (ROTATE_RATE, coarse_slew_rate, eo_elevation, eo_min_elevation, eo_max_elevation, mouse_slew_rate);
	}
	
	eo->field_of_view = get_old_eo_zoom(eo->field_of_view, eo->max_field_of_view, eo->min_field_of_view);

	////////////////////////////////////////

	// Retro 31Oct2004 - copy+paste of loke's comanche EO slew code
	// loke 030315
	// added code to allow the user to slew the eo device using joystick axes

	if (command_line_eo_pan_joystick_index != -1)
	{
		float
			panning_offset_horiz,
			panning_offset_vert;

		int
			horizontal_value,
			vertical_value;
		
		horizontal_value = get_joystick_axis (command_line_eo_pan_joystick_index, command_line_eo_pan_horizontal_joystick_axis);

		panning_offset_horiz = make_panning_offset_from_axis (horizontal_value);

		eo_azimuth += panning_offset_horiz * coarse_slew_rate;

		if (panning_offset_horiz > 0)
		{
			eo_azimuth = min (eo_azimuth, eo_max_azimuth);
		}
		else
		{
			eo_azimuth = max (eo_azimuth, eo_min_azimuth);
		}


		vertical_value = get_joystick_axis (command_line_eo_pan_joystick_index, command_line_eo_pan_vertical_joystick_axis);

		panning_offset_vert = make_panning_offset_from_axis (vertical_value);

		eo_elevation -= panning_offset_vert * coarse_slew_rate;

		if (panning_offset_vert < 0)
		{
			eo_elevation = min (eo_elevation, eo_max_elevation);
		}
		else
		{
			eo_elevation = max (eo_elevation, eo_min_elevation);
		}
	}
}
示例#25
0
void update_dynamics_damage (void)
{

	int
		damage;

	for (damage = 1; damage < NUM_DYNAMICS_DAMAGE_TYPES; damage = damage << 1)
	{

		if (current_flight_dynamics->dynamics_damage & damage)
		{

			switch (damage)
			{

				case DYNAMICS_DAMAGE_MAIN_ROTOR:
				case DYNAMICS_DAMAGE_TAIL_ROTOR:
				case DYNAMICS_DAMAGE_LEFT_ENGINE:
				case DYNAMICS_DAMAGE_RIGHT_ENGINE:
				case DYNAMICS_DAMAGE_LOW_HYDRAULICS:
				case DYNAMICS_DAMAGE_LOW_OIL_PRESSURE:
				case DYNAMICS_DAMAGE_HIGH_OIL_PRESSURE:
				case DYNAMICS_DAMAGE_AVIONICS:
				case DYNAMICS_DAMAGE_FIRE_EXTINGUISHER:
				case DYNAMICS_DAMAGE_UNDERCARRIAGE:
				{

					break;
				}
				case DYNAMICS_DAMAGE_LEFT_ENGINE_FIRE:
				{

					if (current_flight_dynamics->dynamics_damage & ~DYNAMICS_DAMAGE_LEFT_ENGINE)
					{

						current_flight_dynamics->left_engine_temp.value += 10.0 * get_delta_time ();

						if (current_flight_dynamics->left_engine_temp.value > current_flight_dynamics->left_engine_temp.max)
						{

							dynamics_damage_model (DYNAMICS_DAMAGE_LEFT_ENGINE, FALSE);
						}

						#if DEBUG_MODULE

						debug_log ("DYNAMICS: left engine fire temp %f", current_flight_dynamics->left_engine_temp.value);

						#endif
					}

					break;
				}
				case DYNAMICS_DAMAGE_RIGHT_ENGINE_FIRE:
				{

					if (current_flight_dynamics->dynamics_damage & ~DYNAMICS_DAMAGE_RIGHT_ENGINE)
					{

						current_flight_dynamics->right_engine_temp.value += 10.0 * get_delta_time ();

						if (current_flight_dynamics->right_engine_temp.value > current_flight_dynamics->right_engine_temp.max)
						{

							dynamics_damage_model (DYNAMICS_DAMAGE_RIGHT_ENGINE, FALSE);
						}

						#if DEBUG_MODULE

						debug_log ("DYNAMICS: right engine fire temp %f", current_flight_dynamics->right_engine_temp.value);

						#endif
					}

					break;
				}
				case DYNAMICS_DAMAGE_STABILISER:
				{

					//
					// move cog about ramdomly
					//

					if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_AIRBORNE_AIRCRAFT))
					{

						current_flight_dynamics->centre_of_gravity.x += current_flight_dynamics->roll.value * get_model_delta_time ();
						current_flight_dynamics->centre_of_gravity.z -= current_flight_dynamics->pitch.value * get_model_delta_time ();

						current_flight_dynamics->centre_of_gravity.x = bound (current_flight_dynamics->centre_of_gravity.x, -0.1, 0.1);
						current_flight_dynamics->centre_of_gravity.z = bound (current_flight_dynamics->centre_of_gravity.z, -0.1, 0.1);

						#if DEBUG_MODULE

						debug_log ("DYNAMICS: stabaliser damaged : cog %f, %f", current_flight_dynamics->centre_of_gravity.x, current_flight_dynamics->centre_of_gravity.z);

						#endif
					}

					break;
				}

				case DYNAMICS_DAMAGE_FUEL_LEAK:
				{

					current_flight_dynamics->fuel_weight.value -= FUEL_LEAK_RATE * get_delta_time ();

					current_flight_dynamics->fuel_weight.value = max (current_flight_dynamics->fuel_weight.value, 0.0);

					#if DEBUG_MODULE

					debug_log ("DYNAMICS: fuel leak, currently %f", current_flight_dynamics->fuel_weight.value);

					#endif

					break;
				}
			}
		}
	}
}
示例#26
0
void update_dynamics_at_keysite (void)
{

	unsigned int
		model_damage,
		damage_count,
		this_damage;

	if ((!get_keysite_currently_landed_at ()) || (!get_gunship_entity ()))
	{

		return;
	}

	//
	// Refuel, only set if inside keysite
	//

	#if !DEMO_VERSION

	if (current_flight_dynamics->refuelling)
	{
		entity
			*keysite;

		float
			max_fuel;

		if (!(current_flight_dynamics->dynamics_damage & DYNAMICS_DAMAGE_FUEL_LEAK))
		{

			//#if DYNAMICS_DEBUG

			debug_log ("DYNAMICS: refuelling, fuel = %f (max = %f)", current_flight_dynamics->fuel_weight.value, current_flight_dynamics->fuel_weight.max);

			//#endif

			max_fuel = current_flight_dynamics->fuel_weight.max;

			keysite = get_keysite_currently_landed_at ();

			if (keysite)
			{

				if (get_local_entity_float_value (keysite, FLOAT_TYPE_FUEL_SUPPLY_LEVEL) <= 0.0)
				{

					if (!get_connection_list_head ())
					{

						max_fuel *= 0.25;
					}
				}
			}

			if (current_flight_dynamics->fuel_weight.value >= max_fuel)
			{

				current_flight_dynamics->refuelling = FALSE;
			}
			else
			{

				current_flight_dynamics->fuel_weight.value += REFUELLING_RATE * get_delta_time ();
			}

			current_flight_dynamics->fuel_weight.value = bound (current_flight_dynamics->fuel_weight.value,
																				current_flight_dynamics->fuel_weight.min,
																				current_flight_dynamics->fuel_weight.max);
		}
		else
		{

			debug_log ("DYNAMICS: can't refuel till leak is fixed");
		}
	}

	#endif

	//
	// Repair, only set if inside keysite
	//

	if (current_flight_dynamics->repairing)
	{

		if (current_flight_dynamics->dynamics_damage != DYNAMICS_DAMAGE_NONE)
		{

			current_flight_dynamics->damage_repair_time -= get_delta_time ();

			current_flight_dynamics->damage_repair_time = max (current_flight_dynamics->damage_repair_time, 0.0);

			#if DYNAMICS_DEBUG

			debug_log ("DYNAMICS: repairing %d, repair time %f seconds", current_flight_dynamics->damage_repair_time, current_flight_dynamics->damage_repair_time);

			#endif

			//
			// set repair timer to time to repair each part in turn
			//

			if (current_flight_dynamics->damage_repair_time <= 0.0)
			{

				// clear repaired damage
				if ((current_flight_dynamics->repairing_damage != DYNAMICS_DAMAGE_NONE) &&
					(current_flight_dynamics->dynamics_damage & current_flight_dynamics->repairing_damage))
				{

					repair_damage_model (current_flight_dynamics->repairing_damage);
				}

				current_flight_dynamics->repairing_damage = DYNAMICS_DAMAGE_NONE;

				// start repairing next
				this_damage = DYNAMICS_DAMAGE_NONE;

				damage_count = 0;

				model_damage = current_flight_dynamics->dynamics_damage;

				while (this_damage < NUM_DYNAMICS_DAMAGE_TYPES)
				{

					if ((model_damage & this_damage) && (dynamics_damage_database [damage_count].repairable))
					{

						current_flight_dynamics->damage_repair_time = dynamics_damage_database [damage_count].repair_time;

						current_flight_dynamics->repairing_damage = this_damage;

						#if DEBUG_MODULE

						debug_log ("DYNAMICS: repairing %s, repair time %f seconds", dynamics_damage_database [damage_count].name, current_flight_dynamics->damage_repair_time);

						#endif

						break;
					}

					damage_count ++;

					this_damage = this_damage << 1;
				}

				if (current_flight_dynamics->repairing_damage == DYNAMICS_DAMAGE_NONE)
				{

					#if DEBUG_MODULE

					debug_log ("DYNAMICS: model fully repaired");

					#endif

					restore_helicopter_entity (get_gunship_entity (), NULL, get_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE));

					set_client_server_entity_int_value (get_gunship_entity (), INT_TYPE_DAMAGE_LEVEL, get_local_entity_int_value (get_gunship_entity (), INT_TYPE_INITIAL_DAMAGE_LEVEL));

					transmit_entity_comms_message (ENTITY_COMMS_RESTORE_ENTITY, get_gunship_entity (), get_local_entity_vec3d_ptr (get_gunship_entity (), VEC3D_TYPE_POSITION), get_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE));
				}
			}
		}
	}
}
示例#27
0
void update_client_server_entities (void)
{
	entity
		*en;

	float
		delta_time;

	int
		loop,
		iterations;

	ASSERT (get_update_entity ());

	/////////////////////////////////////////////////

	iterations = 1;

	if (!locked_frame_rate)
	{
	
		delta_time = get_delta_time ();
	
		iterations = set_entity_update_frame_rate (command_line_entity_update_frame_rate);
	}

	for (loop = 0; loop < iterations; loop ++)
	{
	
		////////////////////////////////////////

		//
		// update_entities is coded around the entity system to avoid spinning through
		// the update list twice (which Vtune shows up as slow). MB_INT sets and gets
		// the values. You may only set the value to true. It is set to false by the
		// memset below.
		//

		memset (updated_entities, 0, MAX_NUM_ENTITIES / (sizeof (unsigned int) * 8));

		//
		// replaces....
		//
		/*
		en = get_local_entity_first_child (get_update_entity (), LIST_TYPE_UPDATE);
	
		while (en)
		{

			set_local_entity_int_value (en, INT_TYPE_UPDATED, FALSE);
	
			en = get_local_entity_child_succ (en, LIST_TYPE_UPDATE);
		}
		*/
		////////////////////////////////////////

		en = get_local_entity_first_child (get_update_entity (), LIST_TYPE_UPDATE);
	
		while (en)
		{
			set_update_succ (get_local_entity_child_succ (en, LIST_TYPE_UPDATE));
	
			update_client_server_entity (en);
	
			set_local_entity_int_value (en, INT_TYPE_UPDATED, TRUE);
	
			en = get_update_succ ();
		}
	
		set_update_succ (NULL);

		////////////////////////////////////////
	}

	if (!locked_frame_rate)
	{

		set_manual_delta_time (delta_time);
	}

	/////////////////////////////////////////////////
}
示例#28
0
文件: sg_updt.c 项目: Comanche93/eech
static void update_server (entity *en)
{
	entity
		*parent,
		*next_segment,
		*prev_segment;

	entity_sub_types
		sub_type;

	vec3d
		*pos;

	float
		terrain_height;

	terrain_3d_point_data
		terrain_info;

	//
	// notify the segments neighbours as applicable
	//

	parent = get_local_entity_parent (en, LIST_TYPE_SEGMENT);

	ASSERT (parent);

	next_segment = get_local_entity_child_succ (en, LIST_TYPE_SEGMENT);

	if (next_segment)
	{
		notify_local_entity (ENTITY_MESSAGE_COLLISION, parent, next_segment);
	}

	prev_segment = get_local_entity_child_pred (en, LIST_TYPE_SEGMENT);

	if (prev_segment)
	{
		notify_local_entity (ENTITY_MESSAGE_COLLISION, parent, prev_segment);
	}

	sub_type = get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE);

	if (sub_type == ENTITY_SUB_TYPE_FIXED_BRIDGE_UNSUPPORTED_MID_SECTION)
	{
		//
		// make the segment drop to the floor ( removing it from the update list when it hits )
		//
	
		pos = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);
	
		pos->y -= ( 10.0 * get_delta_time() );
	
		memset (&terrain_info, 0, sizeof (terrain_3d_point_data));
	
		terrain_height = get_3d_terrain_point_data (pos->x, pos->z, &terrain_info);

		if (get_terrain_type_class (terrain_info.terrain_type) == TERRAIN_CLASS_WATER)
		{
			terrain_height -= 1.0;
		}
	
		if ( pos->y <= terrain_height )
		{
			pos->y = terrain_height;
	
			delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);
	
			if (get_comms_model () == COMMS_MODEL_SERVER)
			{
				create_client_server_object_hit_ground_explosion_effect (en, terrain_info.terrain_type);
			}
		}
	}
	else
	{
		//
		// segment is supported, and so should be instantly removed from the update list
		// ( only put there in the first place so that neighbours would be notified )
		//

		delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE);
	}
}
示例#29
0
文件: rv_anim.c 项目: Comanche93/eech
void animate_routed_vehicle_wheels (entity *en)
{
	routed_vehicle
		*raw;

	object_3d_instance
		*inst3d;

	float
		speed,
		delta_pitch;

	int
		blurred_flag;

	ASSERT (en);

	if (get_local_entity_int_value (en, INT_TYPE_OBJECT_DRAWN_ONCE_THIS_FRAME))
	{
		return;
	}

   if (get_time_acceleration () == TIME_ACCELERATION_PAUSE)
	{
		return;
	}

	if (!get_local_entity_int_value (en, INT_TYPE_MOBILE_MOVING))
	{
		return;
	}

	raw = (routed_vehicle *) get_local_entity_data (en);

	inst3d = raw->vh.inst3d;

	if ( ( in_flight_articulation_test ) && ( get_external_view_entity() == en ) )
	{
		//
		// debug articulation test
		//

		test_speed += ( test_speed_inc * get_delta_time() );

		if ( test_speed > TEST_SPEED_MAX )
		{
			test_speed_inc = -TEST_SPEED_INC;
		}
		else if ( test_speed <= 0.0 )
		{
			test_speed_inc = TEST_SPEED_INC;
		}

		test_speed = bound( test_speed, 0.0, TEST_SPEED_MAX );

		speed = test_speed;
	}
	else
	{
		//
		// normal operation
		//

		speed = get_local_entity_float_value( en, FLOAT_TYPE_VELOCITY );
	}

	blurred_flag = ( speed > BLURRED_WHEEL_THRESHOLD );

	if ( blurred_flag )
	{
		delta_pitch = PI / 20.0;
	}
	else
	{
		delta_pitch = 2 * speed * get_delta_time ();
	}

	//
	// rotate wheel objects
	//
	// if a blurred wheel type exists on the vehicle then set the correct wheel type visible status, and rotate it
	// otherwise just rotate the standard wheel type
	//

	// fixed
	if ( activate_and_modify_sub_object_type_heading_pitch_and_roll
					(
						inst3d,
						OBJECT_3D_SUB_OBJECT_FIXED_WHEEL_MOVING,
						blurred_flag,
						0.0, delta_pitch, 0.0
					) )
	{
		activate_and_modify_sub_object_type_heading_pitch_and_roll
					(
						inst3d,
						OBJECT_3D_SUB_OBJECT_FIXED_WHEEL,
						!blurred_flag,
						0.0, delta_pitch, 0.0
					);
	}
	else
	{
		activate_and_modify_sub_object_type_heading_pitch_and_roll
					(
						inst3d,
						OBJECT_3D_SUB_OBJECT_FIXED_WHEEL,
						TRUE,
						0.0, delta_pitch, 0.0
					);
	}

	// steerable
	if ( activate_and_modify_sub_object_type_heading_pitch_and_roll
					(
						inst3d,
						OBJECT_3D_SUB_OBJECT_STEERABLE_WHEEL_MOVING,
						blurred_flag,
						0.0, delta_pitch, 0.0
					) )
	{
		activate_and_modify_sub_object_type_heading_pitch_and_roll
					(
						inst3d,
						OBJECT_3D_SUB_OBJECT_STEERABLE_WHEEL,
						!blurred_flag,
						0.0, delta_pitch, 0.0
					);
	}
	else
	{
		activate_and_modify_sub_object_type_heading_pitch_and_roll
					(
						inst3d,
						OBJECT_3D_SUB_OBJECT_STEERABLE_WHEEL,
						TRUE,
						0.0, delta_pitch, 0.0
					);
	}

	//
	// animate track textures
	//

	if ( speed > 0.0 )
	{
		//
		// debug articulation test
		//

		advance_texture_animation_frame_on_object( inst3d, TEXTURE_ANIMATION_INDEX_TRAK0 );
	}
}
示例#30
0
void update_aircraft_decoy_release (entity *en)
{
	aircraft
		*raw;

	int
		chaff_available,
		flare_available,
		chaff_released,
		flare_released;

	float
		range,
		velocity,
		time_to_impact;

	entity_sub_types
		weapon_sub_type;

	entity
		*persuer;

	vec3d
		*target_position,
		*weapon_position;

	ASSERT (en);

	#ifdef DEBUG

	if (get_comms_model () == COMMS_MODEL_CLIENT)
	{
		ASSERT (en == get_gunship_entity ());
	}

	#endif

	raw = get_local_entity_data (en);

	////////////////////////////////////////
	//
	// update timer
	//
	////////////////////////////////////////

	raw->decoy_release_timer -= get_delta_time ();

	if (raw->decoy_release_timer >= 0.0)
	{
		return;
	}

	raw->decoy_release_timer = 2.0 + frand1 ();

	////////////////////////////////////////
	//
	// validate
	//
	////////////////////////////////////////

	if (en == get_gunship_entity ())
	{
		if (!get_global_auto_counter_measures ())
		{
			return;
		}
	}
	else if (get_local_entity_int_value (en, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI)
	{
		return;
	}

	if (!get_local_entity_int_value (en, INT_TYPE_AIRBORNE_AIRCRAFT))
	{
		return;
	}

	persuer = get_local_entity_first_child (en, LIST_TYPE_TARGET);

	if (!persuer)
	{
		return;
	}

	chaff_available = get_local_entity_weapon_available (en, ENTITY_SUB_TYPE_WEAPON_CHAFF);

	flare_available = get_local_entity_weapon_available (en, ENTITY_SUB_TYPE_WEAPON_FLARE);

	if (!(chaff_available || flare_available))
	{
		return;
	}

	////////////////////////////////////////
	//
	// check all persuers
	//
	////////////////////////////////////////

	target_position = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);

	chaff_released = FALSE;
	flare_released = FALSE;

	while (persuer)
	{
		if (get_local_entity_type (persuer) == ENTITY_TYPE_WEAPON)
		{
			if (get_local_entity_int_value (persuer, INT_TYPE_WEAPON_GUIDANCE_TYPE) != WEAPON_GUIDANCE_TYPE_NONE)
			{
				weapon_sub_type = get_decoy_type_for_weapon (persuer);

				if (weapon_sub_type == ENTITY_SUB_TYPE_WEAPON_CHAFF)
				{
					if (chaff_available)
					{
						if (!chaff_released)
						{
							weapon_position = get_local_entity_vec3d_ptr (persuer, VEC3D_TYPE_POSITION);

							range = get_approx_3d_range (weapon_position, target_position);

							velocity = get_local_entity_float_value (persuer, FLOAT_TYPE_VELOCITY);

							time_to_impact = range / max (velocity, 1.0);

							if (time_to_impact < 10.0)
							{
								launch_client_server_weapon (en, ENTITY_SUB_TYPE_WEAPON_CHAFF);

								chaff_released = TRUE;

								if (flare_released)
								{
									break;
								}
							}
						}
					}
				}
				else if (weapon_sub_type == ENTITY_SUB_TYPE_WEAPON_FLARE)
				{
					if (flare_available)
					{
						if (!flare_released)
						{
							weapon_position = get_local_entity_vec3d_ptr (persuer, VEC3D_TYPE_POSITION);

							range = get_approx_3d_range (weapon_position, target_position);

							velocity = get_local_entity_float_value (persuer, FLOAT_TYPE_VELOCITY);

							time_to_impact = range / max (velocity, 1.0);

							if (time_to_impact < 10.0)
							{
								launch_client_server_weapon (en, ENTITY_SUB_TYPE_WEAPON_FLARE);

								flare_released = TRUE;

								if (chaff_released)
								{
									break;
								}
							}
						}
					}
				}
			}
		}

		persuer = get_local_entity_child_succ (persuer, LIST_TYPE_TARGET);
	}
}