int hud_abort_lock() { int target_team; target_team = obj_team(&Objects[Player_ai->target_objnum]); if ( Player_ship->weapons.num_secondary_banks <= 0 ) { return 1; } if ( Player_ship->weapons.current_secondary_bank < 0 ) { return 1; } // check to see if there are any missile to fire.. we don't want to show the // lock indicator if there are no missiles to fire. if ( !ship_secondary_bank_has_ammo(Player_obj->instance) ) { return 1; } // if the target is friendly, don't lock! if ( hud_team_matches_filter(Player_ship->team, target_team)) { // if we're in multiplayer dogfight, ignore this #ifndef NO_NETWORK if(!((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT))) #endif { return 1; } } return 0; }
int hud_abort_lock() { int target_team; target_team = obj_team(&Objects[Player_ai->target_objnum]); if ( Player_ship->weapons.num_secondary_banks <= 0 ) { return 1; } if ( Player_ship->weapons.current_secondary_bank < 0 ) { return 1; } // check to see if there are any missile to fire.. we don't want to show the // lock indicator if there are no missiles to fire. if ( !ship_secondary_bank_has_ammo(Player_obj->instance) ) { return 1; } if ( Player_ship->flags[Ship::Ship_Flags::No_secondary_lockon] ) { return 1; } // if we're on the same team and the team doesn't attack itself, then don't lock! if ((Player_ship->team == target_team) && (!iff_x_attacks_y(Player_ship->team, target_team))) { // if we're in multiplayer dogfight, ignore this if(!MULTI_DOGFIGHT) { return 1; } } return 0; }
int hud_abort_lock() { int target_team; target_team = obj_team(&Objects[Player_ai->target_objnum]); if (Player_ship->weapons.num_secondary_banks <= 0) { return 1; } if (Player_ship->weapons.current_secondary_bank < 0) { return 1; } // check to see if there are any missile to fire.. we don't want to show the // lock indicator if there are no missiles to fire. if (!ship_secondary_bank_has_ammo(Player_obj->instance)) { return 1; } // if we're on the same team and the team doesn't attack itself, then don't lock! if ((Player_ship->team == target_team) && (!iff_x_attacks_y(Player_ship->team, target_team))) { // if we're in multiplayer dogfight, ignore this if (!((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT))) { return 1; } } weapon_info* wip = &Weapon_info[Player_ship->weapons.secondary_bank_weapons[Player_ship->weapons. current_secondary_bank]]; object* target_obj = &Objects[Player_ai->target_objnum]; if (target_obj->type == OBJ_SHIP) { if (target_obj->instance >= 0 && Ships[target_obj->instance].ship_info_index >= 0) { ship_info* sip = &Ship_info[Ships[target_obj->instance].ship_info_index]; bool is_weapon_huge_or_bomb = ((wip->wi_flags & (WIF_HUGE | WIF_BOMB)) != 0); bool is_target_small_ship = ((sip->flags & (SIF_SMALL_SHIP)) != 0); if (is_weapon_huge_or_bomb && is_target_small_ship) { return 1; } } } return 0; }
// 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); } }
// 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 HudGaugeLock::render(float frametime) { int target_objnum, sx, sy; object *targetp; vertex lock_point; bool locked = Player_ai->current_target_is_locked ? true : false; bool reset_timers = false; if ( locked != Last_lock_status ) { // check if player lock status has changed since the last frame. reset_timers = true; Last_lock_status = locked; } if (Player_ai->target_objnum == -1) { return; } if (Player->target_is_dying) { return; } 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; } bool in_frame = g3_in_frame() > 0; if(!in_frame) g3_start_frame(0); gr_set_screen_scale(base_w, base_h); // 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_world_pos); g3_project_vertex(&lock_point); if (lock_point.codes & PF_OVERFLOW) { gr_reset_screen_scale(); if(!in_frame) g3_end_frame(); 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.screen.xyw.x); sy = fl2i(lock_point.screen.xyw.y); gr_unsize_screen_pos(&sx, &sy); // show the rotating triangles if target is locked renderLockTriangles(sx, sy, frametime); if ( reset_timers ) { Lock_gauge.time_elapsed = 0.0f; } } else { const float scaling_factor = (gr_screen.clip_center_x < gr_screen.clip_center_y) ? (gr_screen.clip_center_x / VIRTUAL_FRAME_HALF_WIDTH) : (gr_screen.clip_center_y / VIRTUAL_FRAME_HALF_HEIGHT); sx = fl2i(lock_point.screen.xyw.x) - fl2i(i2fl(Player->current_target_sx - Players[Player_num].lock_indicator_x) * scaling_factor); sy = fl2i(lock_point.screen.xyw.y) - fl2i(i2fl(Player->current_target_sy - Players[Player_num].lock_indicator_y) * scaling_factor); gr_unsize_screen_pos(&sx, &sy); if ( reset_timers ) { Lock_gauge_draw_stamp = -1; Lock_gauge_draw = 0; Lock_anim.time_elapsed = 0.0f; } } // show locked indicator Lock_gauge.sx = sx - Lock_gauge_half_w; Lock_gauge.sy = sy - Lock_gauge_half_h; if (Player_ai->current_target_is_locked) { hud_anim_render(&Lock_gauge, 0.0f, 1); } else { hud_anim_render(&Lock_gauge, frametime, 1); } gr_reset_screen_scale(); if(!in_frame) g3_end_frame(); }
// 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); } }