示例#1
0
// Decide which point lock should be homing on
void hud_lock_determine_lock_point(vector *lock_world_pos_out)
{
	vector	lock_world_pos;
	vertex	lock_point;
	object	*target_objp;

	Assert(Player_ai->target_objnum >= 0);
	target_objp = &Objects[Player_ai->target_objnum];

	Player->current_target_sx = -1;
	Player->current_target_sx = -1;

	// If subsystem is targeted, we must try to lock on that
	if ( Player_ai->targeted_subsys ) {
		hud_lock_update_lock_pos(target_objp, &lock_world_pos);
		Player->locking_on_center=0;
		Player->locking_subsys=NULL;
		Player->locking_subsys_parent=-1;
	} else {
		// See if we already have a successful locked point
		if ( hud_lock_has_homing_point() ) {
			hud_lock_update_lock_pos(target_objp, &lock_world_pos);
		} else {
			hud_lock_get_new_lock_pos(target_objp, &lock_world_pos);
		}
	}

	*lock_world_pos_out=lock_world_pos;

	g3_rotate_vertex(&lock_point,&lock_world_pos);
	g3_project_vertex(&lock_point);

	if (!(lock_point.flags & PF_OVERFLOW)) {  // make sure point projected
		Player->current_target_sx = (int)lock_point.sx;
		Player->current_target_sy = (int)lock_point.sy;
	}
}
示例#2
0
// Decide which point lock should be homing on
void hud_lock_determine_lock_point(vec3d *lock_world_pos_out)
{
	object		*target_objp;
	ship_weapon	*swp;
	weapon_info	*wip;

	vec3d vec_to_lock_pos;
	vec3d lock_local_pos;

	Assert(Player_ai->target_objnum >= 0);
	target_objp = &Objects[Player_ai->target_objnum];

	Player->current_target_sx = -1;
	Player->current_target_sy = -1;

	swp = &Player_ship->weapons;
	wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]];

	// If subsystem is targeted, we must try to lock on that
	if ( Player_ai->targeted_subsys && !(wip->wi_flags[Weapon::Info_Flags::Homing_javelin]) ) {
		hud_lock_update_lock_pos(target_objp);
		Player->locking_on_center=0;
		Player->locking_subsys=Player_ai->targeted_subsys;
		Player->locking_subsys_parent=Player_ai->target_objnum;
	} else if ( (wip->wi_flags[Weapon::Info_Flags::Homing_javelin]) && (target_objp->type == OBJ_SHIP)) {
		if (!Player->locking_subsys ||
			Player->locking_subsys->system_info->type != SUBSYSTEM_ENGINE) {
				Player->locking_subsys = ship_get_closest_subsys_in_sight(&Ships[target_objp->instance], SUBSYSTEM_ENGINE, &Player_obj->pos);
		}
		if (Player->locking_subsys != NULL) {
			get_subsystem_world_pos(target_objp, Player->locking_subsys, &lock_world_pos);
			Player->locking_on_center=0;
			Player->locking_subsys_parent=Player_ai->target_objnum;
		} else {
			hud_lock_reset();
			return;
		}
	} else {
		// See if we already have a successful locked point
		if ( hud_lock_has_homing_point() ) {
			hud_lock_update_lock_pos(target_objp);
		} else {
			hud_lock_get_new_lock_pos(target_objp);
		}
	}

	*lock_world_pos_out=lock_world_pos;

	vm_vec_sub(&vec_to_lock_pos,&lock_world_pos,&Player_obj->pos);
	vm_vec_rotate(&lock_local_pos,&vec_to_lock_pos,&Player_obj->orient);

	if ( lock_local_pos.xyz.z > 0.0f ) {
		// Get the location of our target in the "virtual frame" where the locking computation will be done
		float w = 1.0f / lock_local_pos.xyz.z;
		// Let's force our "virtual frame" to be 640x480. -MageKing17
		float sx = gr_screen.clip_center_x + (lock_local_pos.xyz.x * VIRTUAL_FRAME_HALF_WIDTH * w);
		float sy = gr_screen.clip_center_y - (lock_local_pos.xyz.y * VIRTUAL_FRAME_HALF_HEIGHT * w);

		Player->current_target_sx = (int)sx;
		Player->current_target_sy = (int)sy;
	}
}
示例#3
0
// Decide which point lock should be homing on
void hud_lock_determine_lock_point(vec3d* lock_world_pos_out)
{
	vec3d lock_world_pos;
	object* target_objp;
	ship_weapon* swp;
	weapon_info* wip;

	vec3d vec_to_lock_pos;
	vec3d lock_local_pos;

	Assert(Player_ai->target_objnum >= 0);
	target_objp = &Objects[Player_ai->target_objnum];

	Player->current_target_sx = -1;
	Player->current_target_sx = -1;

	swp = &Player_ship->weapons;
	wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]];

	// If subsystem is targeted, we must try to lock on that
	if (Player_ai->targeted_subsys && !(wip->wi_flags & WIF_HOMING_JAVELIN))
	{
		hud_lock_update_lock_pos(target_objp, &lock_world_pos);
		Player->locking_on_center = 0;
		Player->locking_subsys = Player_ai->targeted_subsys;
		Player->locking_subsys_parent = Player_ai->target_objnum;
	}
	else if (wip->wi_flags & WIF_HOMING_JAVELIN && target_objp->type == OBJ_SHIP)
	{
		if (!Player->locking_subsys ||
			Player->locking_subsys->system_info->type != SUBSYSTEM_ENGINE)
		{
			Player->locking_subsys = ship_get_closest_subsys_in_sight(&Ships[target_objp->instance],
				SUBSYSTEM_ENGINE, &Player_obj->pos);
		}
		if (Player->locking_subsys != NULL)
		{
			get_subsystem_world_pos(target_objp, Player->locking_subsys, &lock_world_pos);
			Player->locking_on_center = 0;
			Player->locking_subsys_parent = Player_ai->target_objnum;
		}
		else
		{
			hud_lock_reset();
			return;
		}
	}
	else
	{
		// See if we already have a successful locked point
		if (hud_lock_has_homing_point())
		{
			hud_lock_update_lock_pos(target_objp, &lock_world_pos);
		}
		else
		{
			hud_lock_get_new_lock_pos(target_objp, &lock_world_pos);
		}
	}

	*lock_world_pos_out = lock_world_pos;

	vm_vec_sub(&vec_to_lock_pos, &lock_world_pos, &Player_obj->pos);
	vm_vec_rotate(&lock_local_pos, &vec_to_lock_pos, &Player_obj->orient);

	if (lock_local_pos.xyz.z > 0.0f)
	{
		// Get the location of our target in the "virtual frame" where the locking computation will be done
		float w = 1.0f / lock_local_pos.xyz.z;
		float sx = ((gr_screen.clip_center_x * 2.0f) + (lock_local_pos.xyz.x * (gr_screen.clip_center_x * 2.0f) * w)) *
			0.5f;
		float sy = ((gr_screen.clip_center_y * 2.0f) - (lock_local_pos.xyz.y * (gr_screen.clip_center_y * 2.0f) * w)) *
			0.5f;

		Player->current_target_sx = (int)sx;
		Player->current_target_sy = (int)sy;
	}
}