// hud_show_lock_indicator() will display the lock indicator for homing missiles
void hud_show_lock_indicator(float frametime)
{
	int			target_objnum, sx, sy;
	object		*targetp;

	if (!Players[Player_num].lock_indicator_visible){
		return;
	}

	target_objnum = Player_ai->target_objnum;
	Assert(target_objnum != -1);
	targetp = &Objects[target_objnum];

	// check to see if there are any missile to fire.. we don't want to show the 
	// lock indicator if there are missiles to fire.
	if ( !ship_secondary_bank_has_ammo(Player_obj->instance) ) {
		return;
	}
	
	hud_set_iff_color(targetp);
//	nprintf(("Alan","lockx: %d, locky: %d TargetX: %d, TargetY: %d\n", Players[Player_num].lock_indicator_x, Players[Player_num].lock_indicator_y, Player->current_target_sx, Player->current_target_sy));

	if (Player_ai->current_target_is_locked) {
		sx = Player->current_target_sx;
		sy = Player->current_target_sy;
		// show the rotating triangles if target is locked
		hud_draw_lock_triangles(sx, sy, frametime);
	} else {
		sx = Players[Player_num].lock_indicator_x;
		sy = Players[Player_num].lock_indicator_y;
	}

	// show locked indicator
	/*
	if ( Lock_gauge.first_frame >= 0 ) {
		gr_set_bitmap(Lock_gauge.first_frame);
		gr_aabitmap(sx - Lock_gauge_half_w[gr_screen.res], sy - Lock_gauge_half_h[gr_screen.res]);
	} else {
		hud_draw_diamond(sx, sy, Lock_target_box_width[gr_screen.res], Lock_target_box_height[gr_screen.res]);
	}
	*/
	Lock_gauge.sx = sx - Lock_gauge_half_w[gr_screen.res];
	Lock_gauge.sy = sy - Lock_gauge_half_h[gr_screen.res];
	if(Player_ai->current_target_is_locked){
		Lock_gauge.time_elapsed = 0.0f;			
		hud_anim_render(&Lock_gauge, 0.0f, 1);		
	} else {
		hud_anim_render(&Lock_gauge, frametime, 1);
	}
}
Exemple #2
0
// hud_show_lock_indicator() will display the lock indicator for homing missiles.
// lock_point_pos should be the world coordinates of the target being locked. Assuming all the 
// necessary locking calculations are done for this frame, this function will compute 
// where the indicator should be relative to the player's viewpoint and will render accordingly.
void hud_show_lock_indicator(float frametime, vec3d* lock_point_pos)
{
	int target_objnum, sx, sy;
	object* targetp;
	vertex lock_point;

	if (!Players[Player_num].lock_indicator_visible)
	{
		return;
	}

	target_objnum = Player_ai->target_objnum;
	Assert(target_objnum != -1);
	targetp = &Objects[target_objnum];

	// check to see if there are any missile to fire.. we don't want to show the 
	// lock indicator if there are missiles to fire.
	if (!ship_secondary_bank_has_ammo(Player_obj->instance))
	{
		return;
	}

	// Get the target's current position on the screen. If he's not on there,
	// we're not going to draw the lock indicator even if he's in front 
	// of our ship, so bail out. 
	g3_rotate_vertex(&lock_point, lock_point_pos);
	g3_project_vertex(&lock_point);
	if (lock_point.codes & PF_OVERFLOW)
		return;

	hud_set_iff_color(targetp);
	//	nprintf(("Alan","lockx: %d, locky: %d TargetX: %d, TargetY: %d\n", Players[Player_num].lock_indicator_x, Players[Player_num].lock_indicator_y, Player->current_target_sx, Player->current_target_sy));

	// We have the coordinates of the lock indicator relative to the target in our "virtual frame" 
	// so, we calculate where it should be drawn based on the player's viewpoint.
	if (Player_ai->current_target_is_locked)
	{
		sx = fl2i(lock_point.sx);
		sy = fl2i(lock_point.sy);
		gr_unsize_screen_pos(&sx, &sy);

		// show the rotating triangles if target is locked
		hud_draw_lock_triangles(sx, sy, frametime);
	}
	else
	{
		sx = fl2i(lock_point.sx) - (Player->current_target_sx - Players[Player_num].lock_indicator_x);
		sy = fl2i(lock_point.sy) - (Player->current_target_sy - Players[Player_num].lock_indicator_y);
		gr_unsize_screen_pos(&sx, &sy);
	}

	// show locked indicator
	/*
	if ( Lock_gauge.first_frame >= 0 ) {
		gr_set_bitmap(Lock_gauge.first_frame);
		gr_aabitmap(sx - Lock_gauge_half_w[gr_screen.res], sy - Lock_gauge_half_h[gr_screen.res]);
	} else {
		hud_draw_diamond(sx, sy, Lock_target_box_width[gr_screen.res], Lock_target_box_height[gr_screen.res]);
	}
	*/
	Lock_gauge.sx = sx - Lock_gauge_half_w[Hud_reticle_style][gr_screen.res];
	Lock_gauge.sy = sy - Lock_gauge_half_h[gr_screen.res];
	if (Player_ai->current_target_is_locked)
	{
		Lock_gauge.time_elapsed = 0.0f;
		hud_anim_render(&Lock_gauge, 0.0f, 1);
	}
	else
	{
		hud_anim_render(&Lock_gauge, frametime, 1);
	}
}