Open source remastering of the Freespace 2 engine
hudtarget.h File Reference
#include "hud/hud.h"

Go to the source code of this file.


struct  htarget_list
struct  esct
 An abbreviation for "Evaluate Ship as Closest Target", defines a data structure used to hold the required arguments for evaluating a prospective closest target to an attacked object. More...
struct  target_display_info
class  HudGaugeAutoTarget
class  HudGaugeAutoSpeed
class  HudGaugeCmeasures
class  HudGaugeAfterburner
class  HudGaugeWeaponEnergy
class  HudGaugeWeapons
class  HudGaugeWeaponList
class  HudGaugePrimaryWeapons
class  HudGaugeSecondaryWeapons
class  HudGaugeHardpoints
class  HudGaugeWarheadCount
class  HudGaugeOrientationTee
class  HudGaugeReticleTriangle
class  HudGaugeHostileTriangle
class  HudGaugeTargetTriangle
class  HudGaugeMissileTriangles
class  HudGaugeOffscreen
class  HudGaugeLeadIndicator
class  HudGaugeLeadSight


#define INCREASING   0
#define DECREASING   1
#define NO_CHANGE   2
#define CARGO_RADIUS_DELTA   100
#define CARGO_MIN_DOT_TO_REVEAL   0.95
#define SELECTION_SET   0x5000
#define MESSAGE_SENDER   0x5001
#define NUM_HUD_SETTINGS   2
#define TARGET_DISPLAY_DIST   (1<<0)
#define TARGET_DISPLAY_DOTS   (1<<1)
#define TARGET_DISPLAY_LEAD   (1<<2)
#define TARGET_DISPLAY_SUBSYS   (1<<3)
#define TARGET_DISPLAY_NAME   (1<<4)
#define TARGET_DISPLAY_CLASS   (1<<5)


typedef struct htarget_list htarget_list
typedef struct esct esct
 An abbreviation for "Evaluate Ship as Closest Target", defines a data structure used to hold the required arguments for evaluating a prospective closest target to an attacked object. More...
typedef struct target_display_info target_display_info


void hud_init_targeting_colors ()
bool evaluate_ship_as_closest_target (esct *esct)
 evaluate a ship (and maybe turrets) as a potential target More...
void hud_init_targeting ()
void hud_target_next (int team_mask=-1)
void hud_target_prev (int team_mask=-1)
int hud_target_closest (int team_mask=-1, int attacked_objnum=-1, int play_fail_sound=TRUE, int filter=0, int turret_attacking_target=0)
 Sets the Players[Player_num].current_target to the closest ship to the player that matches the team passed as a paramater. More...
void hud_target_in_reticle_old ()
void hud_target_in_reticle_new ()
void hud_target_subsystem_in_reticle ()
void hud_show_targeting_gauges (float frametime)
void hud_target_targets_target ()
void hud_check_reticle_list ()
void hud_target_closest_locked_missile (object *A)
void hud_target_missile (object *source_obj, int next_flag)
void hud_target_next_list (int hostile=1, int next_flag=1, int team_mask=-1, int attacked_objnum=-1, int play_fail_sound=TRUE, int filter=0, int turret_attacking_target=0)
int hud_target_closest_repair_ship (int goal_objnum=-1)
void hud_target_auto_target_next ()
void hud_process_remote_detonate_missile ()
void hud_target_uninspected_object (int next_flag)
void hud_target_newest_ship ()
void hud_target_live_turret (int next_flag, int auto_advance=0, int turret_attacking_target=0)
void hud_target_last_transmit_level_init ()
void hud_target_last_transmit ()
void hud_target_last_transmit_add (int ship_num)
void hud_target_random_ship ()
void hud_target_next_subobject ()
void hud_target_prev_subobject ()
void hud_cease_subsystem_targeting (int print_message=1)
void hud_cease_targeting ()
void hud_restore_subsystem_target (ship *shipp)
int subsystem_in_sight (object *objp, ship_subsys *subsys, vec3d *eye, vec3d *subsystem)
vec3dget_subsystem_world_pos (object *parent_obj, ship_subsys *subsys, vec3d *world_pos)
void hud_target_change_check ()
void hud_show_hostile_triangle ()
void hud_start_flash_weapon (int index)
void hud_update_weapon_flash ()
void hud_process_homing_missiles (void)
int hud_sensors_ok (ship *sp, int show_msg=1)
 Check if targeting is possible based on sensors strength. More...
int hud_communications_state (ship *sp)
int hud_get_best_primary_bank (float *range)
void hud_target_toggle_hidden_from_sensors ()
int hud_target_invalid_awacs (object *objp)
void hud_target_hotkey_select (int k)
void hud_target_hotkey_clear (int k)
void hud_target_hotkey_add_remove (int k, object *objp, int how_to_add)
void hud_show_selection_set ()
void hud_show_message_sender ()
void hud_prune_hotkeys ()
void hud_keyed_targets_clear ()
void hud_tri (float x1, float y1, float x2, float y2, float x3, float y3)
void hud_tri_empty (float x1, float y1, float x2, float y2, float x3, float y3)
float hud_find_target_distance (object *targetee, object *targeter)
void polish_predicted_target_pos (weapon_info *wip, object *targetp, vec3d *enemy_pos, vec3d *predicted_enemy_pos, float dist_to_enemy, vec3d *last_delta_vec, int num_polish_steps)
void hud_calculate_lead_pos (vec3d *lead_target_pos, vec3d *target_pos, object *targetp, weapon_info *wip, float dist_to_target, vec3d *rel_pos=NULL)
void hud_stuff_ship_name (char *ship_name_text, ship *shipp)
void hud_stuff_ship_callsign (char *ship_callsign_text, ship *shipp)
void hud_stuff_ship_class (char *ship_class_text, ship *shipp)
void hud_target_add_display_list (object *objp, vertex *target_point, vec3d *target_pos, int correction, color *bracket_clr, char *name, int flags)
void hud_target_clear_display_list ()


int Toggle_text_alpha
htarget_list htarget_free_list
int Hud_target_w
int Hud_target_h
shader Training_msg_glass
char ** Ai_class_names
char * Submode_text []
char * Strafe_submode_text []
SCP_vector< target_display_infotarget_display_list

Macro Definition Documentation


Definition at line 30 of file hudtarget.h.


Definition at line 28 of file hudtarget.h.

#define CARGO_MIN_DOT_TO_REVEAL   0.95

Definition at line 31 of file hudtarget.h.

#define CARGO_RADIUS_DELTA   100

Definition at line 27 of file hudtarget.h.


Definition at line 29 of file hudtarget.h.

#define DECREASING   1

Definition at line 23 of file hudtarget.h.


Definition at line 44 of file hudtarget.h.


Definition at line 43 of file hudtarget.h.

#define INCREASING   0

Definition at line 22 of file hudtarget.h.


Definition at line 26 of file hudtarget.h.


Definition at line 35 of file hudtarget.h.

#define MESSAGE_SENDER   0x5001

Definition at line 39 of file hudtarget.h.

#define NO_CHANGE   2

Definition at line 24 of file hudtarget.h.

#define NUM_HUD_SETTINGS   2

Definition at line 47 of file hudtarget.h.

#define SELECTION_SET   0x5000

Definition at line 36 of file hudtarget.h.

#define TARGET_DISPLAY_CLASS   (1<<5)

Definition at line 165 of file hudtarget.h.

#define TARGET_DISPLAY_DIST   (1<<0)

Definition at line 160 of file hudtarget.h.

#define TARGET_DISPLAY_DOTS   (1<<1)

Definition at line 161 of file hudtarget.h.

#define TARGET_DISPLAY_LEAD   (1<<2)

Definition at line 162 of file hudtarget.h.

#define TARGET_DISPLAY_NAME   (1<<4)

Definition at line 164 of file hudtarget.h.

#define TARGET_DISPLAY_SUBSYS   (1<<3)

Definition at line 163 of file hudtarget.h.


Definition at line 56 of file hudtarget.h.


Definition at line 57 of file hudtarget.h.

Typedef Documentation

typedef struct esct esct

An abbreviation for "Evaluate Ship as Closest Target", defines a data structure used to hold the required arguments for evaluating a prospective closest target to an attacked object.

typedef struct htarget_list htarget_list

Function Documentation

bool evaluate_ship_as_closest_target ( esct esct_p)

evaluate a ship (and maybe turrets) as a potential target

Check if shipp (or its turrets) is attacking attacked_objnum Provides a special case for player trying to select target (don't check if turrets are aimed at player)

[in,out]*esctThe Evaluate Ship as Closest Target (esct) that will be used to determine if a target is a valid, harmful target and, if so, sets the min_distance attribute to the distance of either the attacker or the closest attacker's turret. Otherwise, min_distance is set to FLT_MAX
true if either the ship or one of it's turrets are attacking the player. Otherwise, returns false.

Definition at line 2069 of file hudtarget.cpp.

vec3d* get_subsystem_world_pos ( object parent_obj,
ship_subsys subsys,
vec3d world_pos 

Definition at line 4395 of file hudtarget.cpp.

void hud_calculate_lead_pos ( vec3d lead_target_pos,
vec3d target_pos,
object targetp,
weapon_info wip,
float  dist_to_target,
vec3d rel_pos = NULL 

Definition at line 3682 of file hudtarget.cpp.

void hud_cease_subsystem_targeting ( int  print_message = 1)

Definition at line 4346 of file hudtarget.cpp.

void hud_cease_targeting ( )

Definition at line 4367 of file hudtarget.cpp.

void hud_check_reticle_list ( )

Definition at line 539 of file hudtarget.cpp.

int hud_communications_state ( ship sp)

Definition at line 4607 of file hudtarget.cpp.

float hud_find_target_distance ( object targetee,
object targeter 

Definition at line 2009 of file hudtarget.cpp.

int hud_get_best_primary_bank ( float range)

Definition at line 3719 of file hudtarget.cpp.

void hud_init_targeting ( )

Definition at line 1038 of file hudtarget.cpp.

void hud_init_targeting_colors ( )

Definition at line 973 of file hudtarget.cpp.

void hud_keyed_targets_clear ( )

Definition at line 982 of file hudtarget.cpp.

void hud_process_homing_missiles ( void  )

Definition at line 3098 of file hudtarget.cpp.

void hud_process_remote_detonate_missile ( )

Definition at line 3224 of file hudtarget.cpp.

void hud_prune_hotkeys ( )

Definition at line 3330 of file hudtarget.cpp.

void hud_restore_subsystem_target ( ship shipp)

Definition at line 4379 of file hudtarget.cpp.

int hud_sensors_ok ( ship sp,
int  show_msg = 1 

Check if targeting is possible based on sensors strength.

Definition at line 4578 of file hudtarget.cpp.

void hud_show_hostile_triangle ( )

Definition at line 3556 of file hudtarget.cpp.

void hud_show_message_sender ( )

Definition at line 3265 of file hudtarget.cpp.

void hud_show_selection_set ( )

Definition at line 3387 of file hudtarget.cpp.

void hud_show_targeting_gauges ( float  frametime)

Definition at line 3478 of file hudtarget.cpp.

void hud_start_flash_weapon ( int  index)

Definition at line 4534 of file hudtarget.cpp.

void hud_stuff_ship_callsign ( char *  ship_callsign_text,
ship shipp 

Definition at line 5290 of file hudtarget.cpp.

void hud_stuff_ship_class ( char *  ship_class_text,
ship shipp 

Definition at line 5325 of file hudtarget.cpp.

void hud_stuff_ship_name ( char *  ship_name_text,
ship shipp 

Definition at line 5269 of file hudtarget.cpp.

void hud_target_add_display_list ( object objp,
vertex target_point,
vec3d target_pos,
int  correction,
color bracket_clr,
char *  name,
int  flags 

Definition at line 6195 of file hudtarget.cpp.

void hud_target_auto_target_next ( )

Definition at line 1971 of file hudtarget.cpp.

void hud_target_change_check ( )

Definition at line 4407 of file hudtarget.cpp.

void hud_target_clear_display_list ( )

Definition at line 6221 of file hudtarget.cpp.

int hud_target_closest ( int  team_mask,
int  attacked_objnum,
int  play_fail_snd,
int  filter,
int  get_closest_turret_attacking_player 

Sets the Players[Player_num].current_target to the closest ship to the player that matches the team passed as a paramater.

The current algorithm is to simply iterate through the objects and calculate the magnitude of the vector that connects the player to the target. The smallest magnitude is tracked, and then used to locate the closest hostile ship. Note only the square of the magnitude is required, since we are only comparing magnitudes.

[in]team_maskteam of closest ship that should be targeted. Default value is -1, if team doesn't matter.
[in]attacked_objnumobject number of ship that is being attacked
[in]play_fail_sndboolean, whether to play SND_TARGET_FAIL (needed, since function called repeatedly when auto-targeting is enabled, and we don't want a string of fail sounds playing). This is a default parameter with a value of TRUE.
[in]filterOPTIONAL parameter (default value 0): when set to TRUE, only fighters and bombers are considered for new targets.
[in]get_closest_turret_attacking_playerFinds the closest turret attacking the player if true. Otherwise, only finds the closest attacking ship, targeting the turret closest to the player.
: true (non-zero) if a target was acquired. Returns false (zero) if no target was acquired.

Definition at line 2212 of file hudtarget.cpp.

void hud_target_closest_locked_missile ( object A)

Definition at line 1908 of file hudtarget.cpp.

int hud_target_closest_repair_ship ( int  goal_objnum = -1)

Definition at line 4858 of file hudtarget.cpp.

void hud_target_hotkey_add_remove ( int  k,
object objp,
int  how_to_add 

Definition at line 771 of file hudtarget.cpp.

void hud_target_hotkey_clear ( int  k)

Definition at line 835 of file hudtarget.cpp.

void hud_target_hotkey_select ( int  k)

Definition at line 855 of file hudtarget.cpp.

void hud_target_in_reticle_new ( )

Definition at line 2483 of file hudtarget.cpp.

void hud_target_in_reticle_old ( )

Definition at line 2602 of file hudtarget.cpp.

int hud_target_invalid_awacs ( object objp)

Definition at line 460 of file hudtarget.cpp.

void hud_target_last_transmit ( )

Definition at line 5127 of file hudtarget.cpp.

void hud_target_last_transmit_add ( int  ship_num)

Definition at line 5197 of file hudtarget.cpp.

void hud_target_last_transmit_level_init ( )

Definition at line 5099 of file hudtarget.cpp.

void hud_target_live_turret ( int  next_flag,
int  auto_advance = 0,
int  turret_attacking_target = 0 

Definition at line 1724 of file hudtarget.cpp.

void hud_target_missile ( object source_obj,
int  next_flag 

Definition at line 1425 of file hudtarget.cpp.

void hud_target_newest_ship ( )

Definition at line 1619 of file hudtarget.cpp.

void hud_target_next ( int  team_mask = -1)

Definition at line 1247 of file hudtarget.cpp.

void hud_target_next_list ( int  hostile = 1,
int  next_flag = 1,
int  team_mask = -1,
int  attacked_objnum = -1,
int  play_fail_sound = TRUE,
int  filter = 0,
int  turret_attacking_target = 0 

Definition at line 4637 of file hudtarget.cpp.

void hud_target_next_subobject ( )

Definition at line 1147 of file hudtarget.cpp.

void hud_target_prev ( int  team_mask = -1)

Definition at line 1252 of file hudtarget.cpp.

void hud_target_prev_subobject ( )

Definition at line 1142 of file hudtarget.cpp.

void hud_target_random_ship ( )

Definition at line 5221 of file hudtarget.cpp.

void hud_target_subsystem_in_reticle ( )

Definition at line 2673 of file hudtarget.cpp.

void hud_target_targets_target ( )

Definition at line 2388 of file hudtarget.cpp.

void hud_target_toggle_hidden_from_sensors ( )

Definition at line 4920 of file hudtarget.cpp.

void hud_target_uninspected_object ( int  next_flag)

Definition at line 4977 of file hudtarget.cpp.

void hud_tri ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3 

Definition at line 2803 of file hudtarget.cpp.

void hud_tri_empty ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3 

Definition at line 2886 of file hudtarget.cpp.

void hud_update_weapon_flash ( )

Definition at line 6152 of file hudtarget.cpp.

void polish_predicted_target_pos ( weapon_info wip,
object targetp,
vec3d enemy_pos,
vec3d predicted_enemy_pos,
float  dist_to_enemy,
vec3d last_delta_vec,
int  num_polish_steps 

Definition at line 3777 of file hudtarget.cpp.

int subsystem_in_sight ( object objp,
ship_subsys subsys,
vec3d eye,
vec3d subsystem 

Variable Documentation

char** Ai_class_names

Definition at line 268 of file aicode.cpp.

htarget_list htarget_free_list

Definition at line 98 of file hudtarget.cpp.

int Hud_target_h

Definition at line 52 of file hudtarget.cpp.

int Hud_target_w

Definition at line 52 of file hudtarget.cpp.

char* Strafe_submode_text[]

Definition at line 154 of file aicode.cpp.

char* Submode_text[]

Definition at line 133 of file aicode.cpp.

SCP_vector<target_display_info> target_display_list

Definition at line 72 of file hudtarget.cpp.

int Toggle_text_alpha

Definition at line 226 of file hudtarget.cpp.

shader Training_msg_glass

Definition at line 84 of file hudtarget.cpp.