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; }
void radar_plot_object( object *objp ) { vector pos, tempv; float dist, rscale, zdist, max_radar_dist; int xpos, ypos, color=0; vector *world_pos = &objp->pos; float awacs_level; // don't process anything here. Somehow, a jumpnode object caused this function // to get entered on server side. if( Game_mode & GM_STANDALONE_SERVER ){ return; } // multiplayer clients ingame joining should skip this function if ( MULTIPLAYER_CLIENT && (Net_player->flags & NETINFO_FLAG_INGAME_JOIN) ){ return; } // get team-wide awacs level for the object if not ship int ship_is_visible = 0; if (objp->type == OBJ_SHIP) { if (Player_ship != NULL) { if (ship_is_visible_by_team(objp->instance, Player_ship->team)) { ship_is_visible = 1; } } } // only check awacs level if ship is not visible by team awacs_level = 1.5f; if (Player_ship != NULL && !ship_is_visible) { awacs_level = awacs_get_level(objp, Player_ship); } // if the awacs level is unviewable - bail if(awacs_level < 0.0f && !See_all){ return; } // Apply object type filters switch ( objp->type ) { case OBJ_SHIP: // Place to cull ships, such as NavBuoys break; case OBJ_JUMP_NODE: // filter jump nodes here if required break; case OBJ_WEAPON: { // if not a bomb, return if ( !(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags & WIF_BOMB) ) { return; } // if bomb is on same team as player, return if ( (obj_team(objp) == Player_ship->team) && (Player_ship->team != TEAM_TRAITOR) ) { return; } break; } default: return; // if any other kind of object, don't want to show on radar break; } // end switch // JAS -- new way of getting the rotated point that doesn't require this to be // in a g3_start_frame/end_frame block. vm_vec_sub(&tempv,world_pos,&Player_obj->pos); vm_vec_rotate( &pos, &tempv, &Player_obj->orient ); // Apply range filter dist = vm_vec_dist(world_pos, &Player_obj->pos); max_radar_dist = Radar_ranges[HUD_config.rp_dist]; if ( dist > max_radar_dist ){ return; } if ( dist < pos.xyz.z ) { rscale = 0.0f; } else { rscale = (float) acos( pos.xyz.z/dist ) / 3.14159f; //2.0f; } zdist = fl_sqrt( (pos.xyz.x*pos.xyz.x)+(pos.xyz.y*pos.xyz.y) ); float new_x_dist, clipped_x_dist; float new_y_dist, clipped_y_dist; if (zdist < 0.01f ) { new_x_dist = 0.0f; new_y_dist = 0.0f; } else { new_x_dist = (pos.xyz.x/zdist) * rscale * radx; new_y_dist = (pos.xyz.y/zdist) * rscale * rady; // force new_x_dist and new_y_dist to be inside the radar float hypotenuse; float max_radius; hypotenuse = (float)_hypot(new_x_dist, new_y_dist); max_radius = i2fl(Radar_radius[gr_screen.res][0] - 5); if (hypotenuse >= (max_radius) ) { clipped_x_dist = max_radius * (new_x_dist / hypotenuse); clipped_y_dist = max_radius * (new_y_dist / hypotenuse); new_x_dist = clipped_x_dist; new_y_dist = clipped_y_dist; } } xpos = fl2i( Radar_center[gr_screen.res][0] + new_x_dist ); ypos = fl2i( Radar_center[gr_screen.res][1] - new_y_dist ); color = radar_blip_color(objp); // Determine the distance at which we will dim the radar blip if ( timestamp_elapsed(Radar_calc_dim_dist_timer) ) { Radar_calc_dim_dist_timer=timestamp(1000); Radar_dim_range = player_farthest_weapon_range(); if ( Radar_dim_range <= 0 ) { Radar_dim_range=1500.0f; } } blip *b; int blip_dim=0; if ( dist > Radar_dim_range ) { blip_dim=1; } if ( N_blips >= MAX_BLIPS ) { // out of blips, don't plot Int3(); return; } b = &Blips[N_blips]; b->flags=0; // flag the blip as a current target if it is if (OBJ_INDEX(objp) == Player_ai->target_objnum) { b->flags |= BLIP_CURRENT_TARGET; blip_dim = 0; } if ( blip_dim ) { list_append( &Blip_dim_list[color], b ); } else { list_append( &Blip_bright_list[color], b ); } b->x = xpos; b->y = ypos; // see if blip should be drawn distorted if (objp->type == OBJ_SHIP) { // ships specifically hidden from sensors if ( Ships[objp->instance].flags & SF_HIDDEN_FROM_SENSORS ) { b->flags |= BLIP_DRAW_DISTORTED; } // determine if its AWACS distorted if ( awacs_level < 1.0f ){ b->flags |= BLIP_DRAW_DISTORTED; } } N_blips++; }
/** * @brief Return if the specified object is visible on the radar * * @param objp The object which should be checked * @return A RadarVisibility enum specifying the visibility of the specified object */ RadarVisibility radar_is_visible( object *objp ) { Assert( objp != NULL ); if (objp->flags & OF_SHOULD_BE_DEAD) { return NOT_VISIBLE; } vec3d pos, tempv; float awacs_level, dist, max_radar_dist; vec3d world_pos = objp->pos; SCP_list<CJumpNode>::iterator jnp; // get team-wide awacs level for the object if not ship int ship_is_visible = 0; if (objp->type == OBJ_SHIP) { if (Player_ship != NULL) { if (ship_is_visible_by_team(objp, Player_ship)) { ship_is_visible = 1; } } } // only check awacs level if ship is not visible by team awacs_level = 1.5f; if (Player_ship != NULL && !ship_is_visible) { awacs_level = awacs_get_level(objp, Player_ship); } // if the awacs level is unviewable - bail if(awacs_level < 0.0f && !See_all){ return NOT_VISIBLE; } // Apply object type filters switch (objp->type) { case OBJ_SHIP: if (Ships[objp->instance].flags & SIF_STEALTH) return NOT_VISIBLE; // Ships that are warp in in are not visible on the radar if (Ships[objp->instance].flags & SF_ARRIVING_STAGE_1) return NOT_VISIBLE; break; case OBJ_JUMP_NODE: { for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) { if(jnp->GetSCPObject() == objp) break; } // don't plot hidden jump nodes if ( jnp->IsHidden() ) return NOT_VISIBLE; // filter jump nodes here if required break; } case OBJ_WEAPON: { // if not a bomb, return if ( !(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags2 & WIF2_SHOWN_ON_RADAR) ) if ( !(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags & WIF_BOMB) ) return NOT_VISIBLE; // if explicitly hidden, return if (Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags2 & WIF2_DONT_SHOW_ON_RADAR) return NOT_VISIBLE; // if we don't attack the bomb, return if ( (!(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags2 & WIF2_SHOW_FRIENDLY)) && (!iff_x_attacks_y(Player_ship->team, obj_team(objp)))) return NOT_VISIBLE; // if a local ssm is in subspace, return if (Weapons[objp->instance].lssm_stage == 3) return NOT_VISIBLE; break; } // if any other kind of object, don't show it on radar default: return NOT_VISIBLE; } vm_vec_sub(&tempv, &world_pos, &Player_obj->pos); vm_vec_rotate(&pos, &tempv, &Player_obj->orient); // Apply range filter dist = vm_vec_dist(&world_pos, &Player_obj->pos); max_radar_dist = Radar_ranges[HUD_config.rp_dist]; if (dist > max_radar_dist) { return NOT_VISIBLE; } if (objp->type == OBJ_SHIP) { // ships specifically hidden from sensors if (Ships[objp->instance].flags & SF_HIDDEN_FROM_SENSORS) return DISTORTED; // determine if its AWACS distorted if (awacs_level < 1.0f) return DISTORTED; } return VISIBLE; }
void radar_plot_object( object *objp ) { vec3d pos, tempv; float awacs_level, dist, max_radar_dist; vec3d world_pos = objp->pos; SCP_list<CJumpNode>::iterator jnp; // don't process anything here. Somehow, a jumpnode object caused this function // to get entered on server side. if( Game_mode & GM_STANDALONE_SERVER ){ return; } // multiplayer clients ingame joining should skip this function if ( MULTIPLAYER_CLIENT && (Net_player->flags & NETINFO_FLAG_INGAME_JOIN) ){ return; } // get team-wide awacs level for the object if not ship int ship_is_visible = 0; if (objp->type == OBJ_SHIP) { if (Player_ship != NULL) { if (ship_is_visible_by_team(objp, Player_ship)) { ship_is_visible = 1; } } } // only check awacs level if ship is not visible by team awacs_level = 1.5f; if (Player_ship != NULL && !ship_is_visible) { awacs_level = awacs_get_level(objp, Player_ship); } // if the awacs level is unviewable - bail if(awacs_level < 0.0f && !See_all){ return; } // Apply object type filters switch (objp->type) { case OBJ_SHIP: // Place to cull ships, such as NavBuoys break; case OBJ_JUMP_NODE: { for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) { if(jnp->GetSCPObject() == objp) break; } // don't plot hidden jump nodes if ( jnp->IsHidden() ) return; // filter jump nodes here if required break; } case OBJ_WEAPON: { // if not a bomb, return if ( !(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags2 & WIF2_SHOWN_ON_RADAR) ) if ( !(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags & WIF_BOMB) ) return; // if explicitly hidden, return if (Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags2 & WIF2_DONT_SHOW_ON_RADAR) return; // if we don't attack the bomb, return if ( (!(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags2 & WIF2_SHOW_FRIENDLY)) && (!iff_x_attacks_y(Player_ship->team, obj_team(objp)))) return; // if a local ssm is in subspace, return if (Weapons[objp->instance].lssm_stage == 3) return; // if corkscrew missile use last frame pos for pos if ( (Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags & WIF_CORKSCREW) ) world_pos = objp->last_pos; break; } // if any other kind of object, don't show it on radar default: return; } // Retrieve the eye orientation so we can position the blips relative to it matrix eye_orient; if (Player_obj->type == OBJ_SHIP) ship_get_eye(&tempv, &eye_orient, Player_obj, false , false); else eye_orient = Player_obj->orient; // JAS -- new way of getting the rotated point that doesn't require this to be // in a g3_start_frame/end_frame block. vm_vec_sub(&tempv, &world_pos, &Player_obj->pos); vm_vec_rotate(&pos, &tempv, &eye_orient); // Apply range filter dist = vm_vec_dist(&world_pos, &Player_obj->pos); max_radar_dist = Radar_ranges[HUD_config.rp_dist]; if (dist > max_radar_dist) { return; } // determine the range within which the radar blip is bright if (timestamp_elapsed(Radar_calc_bright_dist_timer)) { Radar_calc_bright_dist_timer = timestamp(1000); Radar_bright_range = player_farthest_weapon_range(); if (Radar_bright_range <= 0) Radar_bright_range = 1500.0f; } blip *b; int blip_bright = 0; int blip_type = 0; if (N_blips >= MAX_BLIPS) { return; } b = &Blips[N_blips]; b->flags = 0; // bright if within range blip_bright = (dist <= Radar_bright_range); // flag the blip as a current target if it is if (OBJ_INDEX(objp) == Player_ai->target_objnum) { b->flags |= BLIP_CURRENT_TARGET; blip_bright = 1; } radar_stuff_blip_info(objp, blip_bright, &b->blip_color, &blip_type); if (blip_bright) list_append(&Blip_bright_list[blip_type], b); else list_append(&Blip_dim_list[blip_type], b); b->position = pos; b->dist = dist; b->objp = objp; b->radar_image_2d = -1; b->radar_color_image_2d = -1; b->radar_image_size = -1; b->radar_projection_size = 1.0f; // see if blip should be drawn distorted // also determine if alternate image was defined for this ship if (objp->type == OBJ_SHIP) { // ships specifically hidden from sensors if (Ships[objp->instance].flags & SF_HIDDEN_FROM_SENSORS) b->flags |= BLIP_DRAW_DISTORTED; // determine if its AWACS distorted if (awacs_level < 1.0f) b->flags |= BLIP_DRAW_DISTORTED; ship_info *Iff_ship_info = &Ship_info[Ships[objp->instance].ship_info_index]; if (Iff_ship_info->radar_image_2d_idx >= 0 || Iff_ship_info->radar_color_image_2d_idx >= 0) { b->radar_image_2d = Iff_ship_info->radar_image_2d_idx; b->radar_color_image_2d = Iff_ship_info->radar_color_image_2d_idx; b->radar_image_size = Iff_ship_info->radar_image_size; b->radar_projection_size = Iff_ship_info->radar_projection_size_mult; } } // don't distort the sensor blips if the player has primitive sensors and the nebula effect // is not active if (Player_ship->flags2 & SF2_PRIMITIVE_SENSORS) { if (!(The_mission.flags & MISSION_FLAG_FULLNEB)) b->flags &= ~BLIP_DRAW_DISTORTED; } N_blips++; }
void radar_plot_object_std( object *objp ) { vec3d pos, tempv; float dist, rscale, zdist, max_radar_dist; int xpos, ypos; vec3d *world_pos = &objp->pos; float awacs_level; // don't process anything here. Somehow, a jumpnode object caused this function // to get entered on server side. if( Game_mode & GM_STANDALONE_SERVER ){ return; } // multiplayer clients ingame joining should skip this function if ( MULTIPLAYER_CLIENT && (Net_player->flags & NETINFO_FLAG_INGAME_JOIN) ){ return; } // get team-wide awacs level for the object if not ship int ship_is_visible = 0; if (objp->type == OBJ_SHIP) { if (Player_ship != NULL) { if (ship_is_visible_by_team(objp, Player_ship)) { ship_is_visible = 1; } } } // only check awacs level if ship is not visible by team awacs_level = 1.5f; if (Player_ship != NULL && !ship_is_visible) { awacs_level = awacs_get_level(objp, Player_ship); } // if the awacs level is unviewable - bail if(awacs_level < 0.0f && !See_all){ return; } // Apply object type filters switch (objp->type) { case OBJ_SHIP: // Place to cull ships, such as NavBuoys break; case OBJ_JUMP_NODE: { // don't plot hidden jump nodes if ( objp->jnp->is_hidden() ) return; // filter jump nodes here if required break; } case OBJ_WEAPON: { // if not a bomb, return if ( !(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags & WIF_BOMB) ) return; // if we don't attack the bomb, return if ( !iff_x_attacks_y(Player_ship->team, obj_team(objp)) ) return; // if a local ssm is in subspace, return if (Weapons[objp->instance].lssm_stage == 3) return; break; } // if any other kind of object, don't show it on radar default: return; } // JAS -- new way of getting the rotated point that doesn't require this to be // in a g3_start_frame/end_frame block. vm_vec_sub(&tempv, world_pos, &Player_obj->pos); vm_vec_rotate(&pos, &tempv, &Player_obj->orient); // Apply range filter dist = vm_vec_dist(world_pos, &Player_obj->pos); max_radar_dist = Radar_ranges[HUD_config.rp_dist]; if (dist > max_radar_dist) { return; } if (dist < pos.xyz.z) { rscale = 0.0f; } else { rscale = (float) acos(pos.xyz.z / dist) / 3.14159f; //2.0f; } zdist = fl_sqrt((pos.xyz.x * pos.xyz.x) + (pos.xyz.y * pos.xyz.y)); float new_x_dist, clipped_x_dist; float new_y_dist, clipped_y_dist; if (zdist < 0.01f) { new_x_dist = 0.0f; new_y_dist = 0.0f; } else { new_x_dist = (pos.xyz.x / zdist) * rscale * radx; new_y_dist = (pos.xyz.y / zdist) * rscale * rady; // force new_x_dist and new_y_dist to be inside the radar float hypotenuse; float max_radius; hypotenuse = (float) _hypot(new_x_dist, new_y_dist); max_radius = i2fl(Current_radar_global->Radar_radius[gr_screen.res][0] - 5); if (hypotenuse >= max_radius) { clipped_x_dist = max_radius * (new_x_dist / hypotenuse); clipped_y_dist = max_radius * (new_y_dist / hypotenuse); new_x_dist = clipped_x_dist; new_y_dist = clipped_y_dist; } } xpos = fl2i(Current_radar_global->Radar_center[gr_screen.res][0] + new_x_dist); ypos = fl2i(Current_radar_global->Radar_center[gr_screen.res][1] - new_y_dist); // determine the range within which the radar blip is bright if (timestamp_elapsed(Radar_calc_bright_dist_timer)) { Radar_calc_bright_dist_timer = timestamp(1000); Radar_bright_range = player_farthest_weapon_range(); if (Radar_bright_range <= 0) Radar_bright_range = 1500.0f; } blip *b; int blip_bright = 0; int blip_type = 0; if (N_blips >= MAX_BLIPS) { // out of blips, don't plot //Gahhh, this is bloody annoying -WMC //Int3(); return; } b = &Blips[N_blips]; b->flags = 0; // bright if within range blip_bright = (dist <= Radar_bright_range); // flag the blip as a current target if it is if (OBJ_INDEX(objp) == Player_ai->target_objnum) { b->flags |= BLIP_CURRENT_TARGET; blip_bright = 1; } radar_stuff_blip_info_std(objp, blip_bright, &b->blip_color, &blip_type); if (blip_bright) list_append(&Blip_bright_list[blip_type], b); else list_append(&Blip_dim_list[blip_type], b); b->x = xpos; b->y = ypos; // see if blip should be drawn distorted if (objp->type == OBJ_SHIP) { // ships specifically hidden from sensors if (Ships[objp->instance].flags & SF_HIDDEN_FROM_SENSORS) b->flags |= BLIP_DRAW_DISTORTED; // determine if its AWACS distorted if (awacs_level < 1.0f) b->flags |= BLIP_DRAW_DISTORTED; } // don't distort the sensor blips if the player has primitive sensors and the nebula effect // is not active if (Player_ship->flags2 & SF2_PRIMITIVE_SENSORS) { if (!(The_mission.flags & MISSION_FLAG_FULLNEB)) b->flags &= ~BLIP_DRAW_DISTORTED; } N_blips++; }
// ******************************************************************************************** bool CanAutopilot(vec3d targetPos, bool send_msg) { if (CurrentNav == -1) { if (send_msg) send_autopilot_msgID(NP_MSG_FAIL_NOSEL); return false; } if (object_get_gliding(Player_obj)) { if (send_msg) send_autopilot_msgID(NP_MSG_FAIL_GLIDING); return false; } // You cannot autopilot if you're within 1000 meters of your destination nav point if (vm_vec_dist_quick(&targetPos, Navs[CurrentNav].GetPosition()) < 1000) { if (send_msg) send_autopilot_msgID(NP_MSG_FAIL_TOCLOSE); return false; } if ( AutopilotMinEnemyDistance > 0 ) { // see if any hostiles are nearby for (ship_obj *so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so)) { object *other_objp = &Objects[so->objnum]; // attacks player? if (iff_x_attacks_y(obj_team(other_objp), obj_team(Player_obj)) && !(Ship_info[Ships[other_objp->instance].ship_info_index].flags & SIF_CARGO)) // ignore cargo { // Cannot autopilot if enemy within AutopilotMinEnemyDistance meters if (vm_vec_dist_quick(&targetPos, &other_objp->pos) < AutopilotMinEnemyDistance) { if (send_msg) send_autopilot_msgID(NP_MSG_FAIL_HOSTILES); return false; } } } } if ( AutopilotMinAsteroidDistance > 0 ) { //check for asteroids for (int n=0; n<MAX_ASTEROIDS; n++) { // asteroid if (Asteroids[n].flags & AF_USED) { // Cannot autopilot if asteroid within AutopilotMinAsteroidDistance meters if (vm_vec_dist_quick(&targetPos, &Objects[Asteroids[n].objnum].pos) < AutopilotMinAsteroidDistance) { if (send_msg) send_autopilot_msgID(NP_MSG_FAIL_HAZARD); return false; } } } } // check for support ships // cannot autopilot if support ship present if ( ship_find_repair_ship(Player_obj) != 0 ) { if (send_msg) send_autopilot_msgID(NP_MSG_FAIL_SUPPORT_PRESENT); return false; } return true; }