]> icculus.org git repositories - taylor/freespace2.git/blob - include/hudtarget.h
Initial revision
[taylor/freespace2.git] / include / hudtarget.h
1 /*
2  * $Logfile: /Freespace2/code/Hud/HUDtarget.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Header file for HUD targeting functions
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 8     9/07/99 11:26p Andsager
15  * Fix "r" targeting key, making evaluate_ship_as_closest_target() and
16  * hud_target_live_turret() consider if turret is targeting player
17  * 
18  * 7     8/24/99 2:55p Andsager
19  * Add new prioritized turret selection code.
20  * 
21  * 6     7/09/99 12:00a Andsager
22  * Added target box with distance for remote detonate weapons
23  * 
24  * 5     5/28/99 10:00a Andsager
25  * Make player hud target affected by Nebula range
26  * 
27  * 4     2/26/99 6:01p Andsager
28  * Add sexp has-been-tagged-delay and cap-subsys-cargo-known-delay
29  * 
30  * 3     12/21/98 5:03p Dave
31  * Modified all hud elements to be multi-resolution friendly.
32  * 
33  * 2     10/07/98 10:53a Dave
34  * Initial checkin.
35  * 
36  * 1     10/07/98 10:49a Dave
37  * 
38  * 101   8/25/98 1:48p Dave
39  * First rev of EMP effect. Player side stuff basically done. Next comes
40  * AI code.
41  * 
42  * 100   5/15/98 8:36p Lawrance
43  * Add 'target ship that last sent transmission' target key
44  * 
45  * 99    5/04/98 6:12p Lawrance
46  * Write generic function hud_end_string_at_first_hash_symbol(), to use in
47  * various spots on the HUD
48  * 
49  * 98    4/13/98 5:06p Lawrance
50  * truncate secondary weapons names at the '#' char
51  * 
52  * 97    4/08/98 1:18a Lawrance
53  * Externalize function to find distance between two objects.
54  * 
55  * 96    4/07/98 5:30p Lawrance
56  * Player can't send/receive messages when comm is destroyed.  Garble
57  * messages when comm is damaged.
58  * 
59  * 95    3/30/98 12:20a Lawrance
60  * remove CARGO_REVEAL time, it is now in ship_info
61  * 
62  * 94    3/20/98 5:40p Lawrance
63  * Change targeting of uninspected cargo to select the next closest.
64  * 
65  * 93    3/12/98 5:36p John
66  * Took out any unused shaders.  Made shader code take rgbc instead of
67  * matrix and vector since noone used it like a matrix and it would have
68  * been impossible to do in hardware.   Made Glide implement a basic
69  * shader for online help.  
70  * 
71  * 92    3/11/98 12:14a Lawrance
72  * Added hud_target_auto_target_next()
73  * 
74  * 91    3/10/98 4:19p John
75  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
76  * & Glide have popups and print screen.  Took out all >8bpp software
77  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
78  * support Fred.  Made zbuffering key off of functions rather than one
79  * global variable.
80  * 
81  * 90    3/07/98 3:50p Lawrance
82  * Add lead indicator for asteroids
83  * 
84  * 89    3/04/98 3:44p Lawrance
85  * Only flash docking text for a couple of seconds
86  * 
87  * 88    3/02/98 11:32p Lawrance
88  * Allow asteroids about to impact ships to be bracketed
89  * 
90  * 87    2/26/98 12:33a Lawrance
91  * Added back slew mode,  lots of changes to external and chase views.
92  * 
93  * 86    2/24/98 2:49p Lawrance
94  * Enable cheat key to disable 'hidden from sensors' targeting
95  * 
96  * 85    2/06/98 4:33p Lawrance
97  * extern hud_get_best_primary_bank()
98  * 
99  * 84    2/02/98 7:00p Lawrance
100  * Adding new targeting keys (bomb, uninspected cargo, new ship, live
101  * turrets).
102  * 
103  * 83    1/29/98 11:53p Lawrance
104  * Change repair ship targeting to favor support ships that are headed for
105  * the player.
106  * 
107  * 82    1/20/98 9:30p Lawrance
108  * Have lead indicator, offscreen indicator and distance be relative to
109  * targeted subsystem when possible.
110  * 
111  * 81    1/17/98 1:30a Lawrance
112  * Add countermeasure gauge
113  * 
114  * 80    1/10/98 12:42a Lawrance
115  * make cargo inspection more realistic
116  * 
117  * 79    1/08/98 11:34p Lawrance
118  * change cargo reveal formula to max(150,1.5*radius)
119  * 
120  * 78    1/02/98 9:10p Lawrance
121  * Big changes to how colors get set on the HUD.
122  * 
123  * 77    12/16/97 9:13p Lawrance
124  * Integrate new gauges into HUD config.
125  * 
126  * 76    12/09/97 8:12a Allender
127  * changes to hotkey stuff.  Don't allow mission defined hotkeys to
128  * override user defined ones once the mission starts
129  * 
130  * 75    12/04/97 10:23a Lawrance
131  * don't allow matching speed unless target speed is above
132  * MATCH_SPEED_THRESHOLD
133  * 
134  * 74    12/01/97 5:12p Lawrance
135  * have minimial targeting gauges shown in chase and external view 
136  * 
137  * 73    12/01/97 12:27a Lawrance
138  * redo default alpha color for HUD, make it easy to modify in the future
139  * 
140  * 72    11/27/97 4:23p Lawrance
141  * add subsys_in_view to the player struct, which indicates that the
142  * player has a line of sight to his targeted subsystem
143  * 
144  * 71    11/20/97 5:40p Lawrance
145  * Make cargo revealing work so that anyone (including AI) on your team
146  * can reveal cargo for everyone else on the team.
147  * 
148  * 70    11/20/97 1:09a Lawrance
149  * add support for 'target closest friendly repair ship'
150  * 
151  * 69    11/11/97 12:58a Lawrance
152  * implement new target monitor view
153  * 
154  * 68    10/30/97 12:33a Lawrance
155  * update to show AIM_STRAFE debug output
156  * 
157  * 67    10/27/97 10:48p Lawrance
158  * get previous hostile/friendly targeting working.. simplify code a lot
159  * 
160  * 66    10/22/97 5:53p Lawrance
161  * move out subsystem_in_sight function
162  * 
163  * 65    10/12/97 3:44p Lawrance
164  * use target lists to cycle through closest hostile and friendly ships
165  * 
166  * 64    10/11/97 6:38p Lawrance
167  * having damage affect targeting
168  * 
169  * 63    10/10/97 6:15p Hoffoss
170  * Implemented a training objective list display.
171  * 
172  * 62    10/08/97 5:07p Lawrance
173  * make sensors and communication subsystem damage affect player
174  * 
175  * 61    9/22/97 4:55p Hoffoss
176  * Added a training message window display thingy.
177  * 
178  * 60    8/31/97 6:40p Lawrance
179  * make auto-target always target fighters/bombers first
180  * 
181  * 59    8/25/97 12:24a Lawrance
182  * implemented HUD shield management
183  * 
184  * 58    8/19/97 11:46p Lawrance
185  * adding new hud gauges for shileds, escort view, and weapons
186  * 
187  * 57    8/15/97 9:26a Lawrance
188  * split off target box code into HUDtargetbox.cpp
189  * 
190  * 56    8/14/97 5:29p Lawrance
191  * restructure target monitor code... support missile view and red shading
192  * 
193  * 55    8/12/97 5:51p Lawrance
194  * allow targeting of missiles
195  * 
196  * 54    7/13/97 5:54p Lawrance
197  * fix bug with restore game and the keyed targets
198  * 
199  * 53    7/01/97 11:53a Lawrance
200  * allow cycling through targets in the reticle
201  * 
202  * 52    5/14/97 8:55a Lawrance
203  * fix autotargeting so it switches to a new target as soon as current
204  * target is dying
205  * 
206  * 51    5/02/97 2:11p Lawrance
207  * added hud_prune_hotkeys()
208  * 
209  * 50    4/28/97 2:18p Lawrance
210  * made hotkey_add_remove more generic
211  * 
212  * 49    4/22/97 4:53p Lawrance
213  * allow auto-targeting to not play target fail sound when searching for
214  * the closest target
215  * 
216  * 48    4/15/97 4:00p Mike
217  * Intermediate checkin caused by getting other files.  Working on camera
218  * slewing system.
219  * 
220  * 47    4/13/97 3:53p Lawrance
221  * separate out the non-rendering dependant portions of the HUD ( sounds,
222  * updating lock position, changing targets, etc) and put into
223  * hud_update_frame()
224  * 
225  * 46    4/12/97 4:29p Lawrance
226  * get missle locking and offscreen indicator working properly with
227  * different sized screens
228  * 
229  * 45    4/10/97 5:29p Lawrance
230  * hud rendering split up into hud_render_3d(), hud_render_2d() and
231  * hud_render_target_model()
232  * 
233  * 44    4/08/97 10:55a Allender
234  * draw purple brackets on ship sending a message
235  * 
236  * 43    4/07/97 3:50p Allender
237  * ability to assign > 1 ship to a hotkey.  Enabled use of hotkeys in
238  * squadmate messaging
239  * 
240  * 42    3/27/97 3:58p Lawrance
241  * modified target_closest() to allow targeting closest ship that is
242  * attacking a given objnum
243  * 
244  * 41    3/27/97 9:29a Lawrance
245  * If reach maximum bounding box size, use radius targeting box method
246  * 
247  * 40    3/26/97 6:43p Lawrance
248  * implemented new method for detecting target in reticle, that doesn't
249  * require center point of target to be in reticle
250  * 
251  * 39    3/26/97 12:44p Lawrance
252  * modified targeting functions to take team into accout for Target
253  * Next/Prev/Closest
254  * 
255  * 38    3/19/97 5:53p Lawrance
256  * integrating new Misc_sounds[] array (replaces old Game_sounds
257  * structure)
258  * 
259  * 37    3/17/97 3:47p Mike
260  * Homing missile lock sound.
261  * More on AI ships firing missiles.
262  * 
263  * 36    3/10/97 8:53a Lawrance
264  * using hud_stop_looped_locking_sounds() in place of
265  * hud_stop_looped_sounds()
266  * 
267  * 35    1/02/97 10:32a Lawrance
268  * fixed some bugs related to stopping looped sounds when targets die and
269  * going to menus
270  * 
271  * 34    12/24/96 4:31p Lawrance
272  * Target bracket drawing code moved to separate files
273  * 
274  * 33    12/23/96 7:53p Lawrance
275  * took out missile lock code and moved to HUDlock.cpp and HUDlock.h
276  * 
277  * 32    12/17/96 11:10a Lawrance
278  * added targeting of subsystem in reticle
279  * 
280 */
281
282 #ifndef _HUDTARGET_H
283 #define _HUDTARGET_H
284
285 #include "object.h"
286 #include "ailocal.h"
287 #include "ship.h"
288 #include "2d.h"
289 #include "weapon.h"
290
291 #define INCREASING      0
292 #define DECREASING      1
293 #define NO_CHANGE               2       
294
295 #define MATCH_SPEED_THRESHOLD                           0.1f            // minimum speed target must be moving for match speed to apply
296 #define CARGO_RADIUS_DELTA                                      100             // distance added to radius required for cargo scanning
297 #define CAPITAL_CARGO_RADIUS_DELTA              250             // distance added to radius required for cargo scanning
298 #define CARGO_REVEAL_MIN_DIST                           150             // minimum distance for reveal cargo (used if radius+CARGO_RADIUS_DELTA < CARGO_REVEAL_MIN_DIST)
299 #define CAP_CARGO_REVEAL_MIN_DIST               300             // minimum distance for reveal cargo (used if radius+CARGO_RADIUS_DELTA < CARGO_REVEAL_MIN_DIST)
300 #define CARGO_MIN_DOT_TO_REVEAL                 0.95            // min dot to proceed to have cargo scanning take place
301
302 // structure and defines used for hotkey targeting
303 #define MAX_HOTKEY_TARGET_ITEMS         50              // maximum number of ships that can be targeted on *all* keys
304 #define SELECTION_SET                                   0x5000  // variable used for drawing brackets.  The bracketinng code uses
305                                                                                                                         // TEAM_* values.  I picked this value to be totally out of that
306                                                                                                                         // range.  Only used for drawing selection sets
307 #define MESSAGE_SENDER                                  0x5001  // variable used for drawing brackets around a message sender.
308                                                                                                                         // See above comments for SELECTION_SET
309
310 // defines used to tell how a particular hotkey was added
311 #define HOTKEY_USER_ADDED                               1
312 #define HOTKEY_MISSION_FILE_ADDED       2
313
314 typedef struct htarget_list {
315         struct htarget_list     *next, *prev;           // for linked lists
316         int                                             how_added;                      // determines how this hotkey was added (mission default or player)
317         object                                  *objp;                          // the actual object
318 } htarget_list;
319
320 extern htarget_list htarget_free_list;
321 extern int Hud_target_w, Hud_target_h;
322
323 extern shader Training_msg_glass;
324
325 extern char *Ai_class_names[];
326 extern char *Submode_text[];
327 extern char *Strafe_submode_text[];
328
329 extern void hud_init_targeting_colors();
330
331 void    hud_init_targeting();
332 void    hud_target_next(int team = -1);
333 void    hud_target_prev(int team = -1);
334 int     hud_target_closest(int team = -1, int attacked_objnum = -1, int play_fail_sound = TRUE, int filter = 0, int turret_attacking_target = 0);
335 void    hud_target_in_reticle_old();
336 void    hud_target_in_reticle_new();
337 void    hud_target_subsystem_in_reticle();
338 void    hud_show_targeting_gauges(float frametime, int in_cockpit=1);
339 void    hud_target_targets_target();
340 void    hud_check_reticle_list();
341 void    hud_target_closest_locked_missile(object *A);
342 void    hud_target_missile(object *source_obj, int next_flag);
343 void    hud_target_next_list(int hostile=1, int next_flag=1);
344 int     hud_target_closest_repair_ship(int goal_objnum=-1);
345 void    hud_target_auto_target_next();
346 void hud_show_remote_detonate_missile();
347
348 void    hud_target_uninspected_object(int next_flag);
349 void    hud_target_newest_ship();
350 void    hud_target_live_turret(int next_flag, int auto_advance=0, int turret_attacking_target=0);
351
352 void hud_target_last_transmit_level_init();
353 void hud_target_last_transmit();
354 void hud_target_last_transmit_add(int ship_num);
355
356 void hud_target_random_ship();
357
358 void    hud_target_next_subobject();
359 void    hud_target_prev_subobject();
360 void    hud_cease_subsystem_targeting(int print_message=1);
361 void    hud_cease_targeting();
362 void    hud_restore_subsystem_target(ship* shipp);
363 int     subsystem_in_sight(object* objp, ship_subsys* subsys, vector *eye, vector* subsystem);
364 vector* get_subsystem_world_pos(object* parent_obj, ship_subsys* subsys, vector* world_pos);
365 void    hud_target_change_check();
366
367 void hud_show_target_triangle_indicator(vertex *projected_v);
368 void hud_show_lead_indicator(vector *target_world_pos);
369 void hud_show_orientation_tee();
370 void hud_show_hostile_triangle();
371 void hud_show_target_data();
372 void hud_show_afterburner_gauge();
373 void hud_show_weapons();
374 void hud_start_flash_weapon(int index);
375 void hud_show_auto_icons();
376 void hud_show_weapon_energy_gauge();
377 void hud_show_cmeasure_gague();
378 void hud_show_brackets(object *targetp, vertex *projected_v);
379 void hud_draw_offscreen_indicator(vertex* target_point, vector *tpos, float distance=0.0f);
380 void hud_show_homing_missiles(void);
381
382 int hud_sensors_ok(ship *sp, int show_msg = 1);
383 int hud_communications_state(ship *sp, int show_msg = 0);
384
385 int hud_get_best_primary_bank(float *range);
386 void hud_target_toggle_hidden_from_sensors();
387 void hud_maybe_flash_docking_text(object *objp);
388 int hud_target_invalid_awacs(object *objp);
389
390 // functions for hotkey selection sets
391
392 extern void hud_target_hotkey_select( int k );
393 extern void hud_target_hotkey_clear( int k );
394
395 extern void hud_target_hotkey_add_remove( int k, object *objp, int how_to_add);
396 extern void hud_show_selection_set();
397 extern void hud_show_message_sender();
398 void                    hud_prune_hotkeys();
399 void                    hud_keyed_targets_clear();
400
401 // Code to draw filled triangles
402 void hud_tri(float x1,float y1,float x2,float y2,float x3,float y3);
403 // Code to draw empty triangles.
404 void hud_tri_empty(float x1,float y1,float x2,float y2,float x3,float y3);
405
406 float hud_find_target_distance( object *targetee, object *targeter );
407
408 #endif
409