FS2_Open
Open source remastering of the Freespace 2 engine
hudreticle.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 
13 #include "gamesnd/gamesnd.h"
14 #include "hud/hudreticle.h"
15 #include "hud/hudtargetbox.h"
16 #include "io/timer.h"
17 #include "localization/localize.h"
18 #include "network/multi.h"
19 #include "playerman/player.h"
20 #include "ship/ship.h"
21 #include "weapon/emp.h"
22 #include "weapon/weapon.h"
23 
24 #define NUM_RETICLE_ANIS 11 // keep up to date when modifying the number of reticle ani files
25 
26 #define RETICLE_TOP_ARC 0
27 #define RETICLE_LASER_WARN 1
28 #define RETICLE_LOCK_WARN 2
29 #define RETICLE_LEFT_ARC 3
30 #define RETICLE_RIGHT_ARC 4
31 #define RETICLE_ONE_PRIMARY 5
32 #define RETICLE_TWO_PRIMARY 6
33 #define RETICLE_ONE_SECONDARY 7
34 #define RETICLE_TWO_SECONDARY 8
35 #define RETICLE_THREE_SECONDARY 9
36 //#define RETICLE_LAUNCH_LABEL 5
37 #define RETICLE_CENTER 10
38 
40  49,
41  78
42 };
44  50, 80
45 };
47  { 309, 494 },
48  { 307, 491 }
49 };
51  17,
52  27
53 };
55  259,
56  414
57 };
58 
60  104,
61  166
62 };
63 
65 {
66  { // GR_640
67  320, 242
68  },
69  { // GR_1024
70  512, 387
71  }
72 };
73 
75 {
76 //XSTR:OFF
77  {
78  { // GR_640
79  "toparc1_fs1",
80  "toparc2_fs1",
81  "toparc3_fs1",
82  "leftarc_fs1",
83  "rightarc1_fs1",
84  "rightarc2_fs1",
85  "rightarc3_fs1",
86  "rightarc4_fs1",
87  "rightarc5_fs1",
88  "rightarc6_fs1",
89 // "toparc4_fs1",
90  "reticle1_fs1",
91  },
92  { // GR_1024
93  "2_toparc1_fs1",
94  "2_toparc2_fs1",
95  "2_toparc3_fs1",
96  "2_leftarc_fs1",
97  "2_rightarc1_fs1",
98  "2_rightarc2_fs1",
99  "2_rightarc3_fs1",
100  "2_rightarc4_fs1",
101  "2_rightarc5_fs1",
102  "2_rightarc6_fs1",
103 // "2_toparc4_fs1",
104  "2_reticle1_fs1",
105  }
106  },
107  {
108  { // GR_640
109  "toparc1",
110  "toparc2",
111  "toparc3",
112  "leftarc",
113  "rightarc1",
114  "<none>",
115  "<none>",
116  "<none>",
117  "<none>",
118  "<none>",
119 // "<none>",
120  "reticle1",
121  },
122  { // GR_1024
123  "2_toparc1",
124  "2_toparc2",
125  "2_toparc3",
126  "2_leftarc",
127  "2_rightarc1",
128  "<none>",
129  "<none>",
130  "<none>",
131  "<none>",
132  "<none>",
133 // "<none>",
134  "2_reticle1",
135  }
136  }
137 //XSTR:ON
138 };
139 
140 // reticle frame coords
142 {
143  {
144  { // GR_640
145  {241, 137},
146  {300, 137},
147  {320, 137},
148  {217, 244},
149  {374, 242},
150  {406, 253},
151  {406, 253},
152  {391, 276},
153  {391, 276},
154  {391, 276},
155 // {297, 162},
156  {308, 235}
157  },
158  { // GR_1024
159  {386, 219},
160  {480, 219},
161  {512, 219},
162  {347, 390},
163  {598, 387},
164  {650, 405},
165  {650, 405},
166  {626, 442},
167  {626, 442},
168  {626, 442},
169 // {475, 259},
170  {493, 376}
171  },
172  },
173  {
174  { // GR_640
175  {241, 137},
176  {400, 245},
177  {394, 261},
178  {216, 168},
179  {359, 168},
180  {406, 253},
181  {406, 253},
182  {391, 276},
183  {391, 276},
184  {391, 276},
185 // {297, 161},
186  {308, 235}
187  },
188  { // GR_1024
189  {386, 219},
190  {640, 393},
191  {631, 419},
192  {346, 269},
193  {574, 269},
194  {649, 401},
195  {649, 401},
196  {625, 438},
197  {625, 438},
198  {625, 438},
199 // {475, 258},
200  {493, 370}
201  }
202  }
203 };
204 
205 // "launch" gauge coords
207  { // GR_640
208  297, 161
209  },
210  { // GR_1024
211  475, 258
212  }
213 };
214 
215 #define THREAT_DUMBFIRE (1<<0)
216 #define THREAT_ATTEMPT_LOCK (1<<1)
217 #define THREAT_LOCK (1<<2)
218 
219 #define THREAT_UPDATE_DUMBFIRE_TIME 1000 // time between checking for dumbfire threats
220 #define THREAT_UPDATE_LOCK_TIME 500 // time between checking for lock threats
221 
222 #define THREAT_DUMBFIRE_FLASH 180
223 #define THREAT_LOCK_FLASH 180
224 static int Threat_lock_timer; // timestamp for when to show next flashing frame for lock threat
225 static int Threat_lock_frame; // frame offset of current lock flashing warning
226 
227 
230 {
231 }
232 
234 {
236  if (crosshair.first_frame < 0) {
237  mprintf(("Cannot load hud ani: %s\n", fname));
238  }
239 }
240 
241 void HudGaugeReticle::initFirepointDisplay(bool firepoint, int scaleX, int scaleY, int size) {
242  firepoint_display = firepoint;
243  firepoint_scale_x = scaleX;
244  firepoint_scale_y = scaleY;
246 }
247 
248 void HudGaugeReticle::render(float frametime)
249 {
251 
253 
254  if (firepoint_display) {
255  fp.clear();
257 
258  if (fp.size() > 0) {
259  int ax, ay;
260  bm_get_info(crosshair.first_frame, &ax, &ay);
261  int centerX = position[0] + (ax / 2);
262  int centerY = position[1] + (ay / 2);
263 
264  for (SCP_vector<firepoint>::iterator fpi = fp.begin(); fpi != fp.end(); ++fpi) {
265  if (fpi->active == 2)
267  else if (fpi->active == 1)
269  else
271 
272  renderCircle((int) (centerX + (fpi->xy.x * firepoint_scale_x)), (int) (centerY + (fpi->xy.y * firepoint_scale_y)), firepoint_size);
273  }
274  }
275  }
276 }
277 
279  //First, get the player ship
280  ship_info* sip;
281  ship* shipp;
282  polymodel* pm;
283 
285 
286  if (Objects[Player->objnum].type == OBJ_SHIP) {
287  shipp = &Ships[Objects[Player->objnum].instance];
288  sip = &Ship_info[shipp->ship_info_index];
289 
290  //Get the player eyepoint
291  pm = model_get(sip->model_num);
292 
293  if (pm->n_view_positions == 0) {
294  mprintf(("Model %s does not have a defined eyepoint. Firepoint display could not be generated\n", pm->filename));
295  } else {
296  if (pm->n_guns > 0) {
297  eye eyepoint = pm->view_positions[shipp->current_viewpoint];
298  vec2d ep = { eyepoint.pnt.xyz.x, eyepoint.pnt.xyz.y };
299 
300  for (int i = 0; i < pm->n_guns; i++) {
301  int bankactive = 0;
302  ship_weapon *swp = &shipp->weapons;
303 
305  bankactive = 1;
307  bankactive = 1;
308  else if (i == shipp->weapons.current_primary_bank || shipp->flags & SF_PRIMARY_LINKED)
309  bankactive = 2;
310 
311  int num_slots = pm->gun_banks[i].num_slots;
312  for (int j = 0; j < num_slots; j++) {
313  int fpactive = bankactive;
314 
315  if (sip->flags2 & SIF2_DYN_PRIMARY_LINKING) {
316  // If this firepoint is not among the next shot(s) to be fired, dim it one step
317  if ( !( (j >= (shipp->last_fired_point[i]+1) % num_slots) && (j <= (shipp->last_fired_point[i]+swp->primary_bank_slot_count[i]) % num_slots) ) ) {
318  fpactive--;
319  }
320  } else if (Weapon_info[swp->primary_bank_weapons[i]].wi_flags2 & WIF2_CYCLE) {
321  // If this firepoint is not the next one to be fired, dim it one step
322  if (j != (shipp->last_fired_point[i]+1) % num_slots) {
323  fpactive--;
324  }
325  }
326 
327  vec3d fpfromeye;
328 
329  matrix eye_orient, player_transpose;
330 
331  vm_copy_transpose(&player_transpose, &Objects[Player->objnum].orient);
332  vm_matrix_x_matrix(&eye_orient, &player_transpose, &Eye_matrix);
333  vm_vec_rotate(&fpfromeye, &pm->gun_banks[i].pnt[j], &eye_orient);
334 
335  firepoint tmp = { { fpfromeye.xyz.x - ep.x, ep.y - fpfromeye.xyz.y }, fpactive };
336  fp.push_back(tmp);
337  }
338  }
339  }
340  }
341  }
342 }
343 
345 {
347 }
348 
351 {
352 
353 }
355 {
356  Bottom_offset_y = y;
357 }
358 
360 {
361  throttle_w = w;
362  throttle_h = h;
363 }
364 
366 {
368 }
369 
370 void HudGaugeThrottle::initMaxSpeedOffsets(int x, int y, bool show)
371 {
372  Max_speed_offsets[0] = x;
373  Max_speed_offsets[1] = y;
374  Show_max_speed = show;
375 }
376 
377 void HudGaugeThrottle::initZeroSpeedOffsets(int x, int y, bool show)
378 {
379  Zero_speed_offsets[0] = x;
380  Zero_speed_offsets[1] = y;
381  Show_min_speed = show;
382 }
383 
384 void HudGaugeThrottle::initOrbitCenterOffsets(int x, int y, bool orbiting)
385 {
386  Orbit_center_offsets[0] = x;
387  Orbit_center_offsets[1] = y;
388  orbit = orbiting;
389 }
390 
392 {
393  orbit_radius = radius;
394 }
395 
396 void HudGaugeThrottle::initTargetSpeedOffsets(int x, int y, bool show, bool percent)
397 {
398  Target_speed_offsets[0] = x;
399  Target_speed_offsets[1] = y;
400  Show_target_speed = show;
401  Show_percent = percent;
402 }
403 
405 {
406  Show_background = show;
407 }
408 
409 void HudGaugeThrottle::initGlideOffsets(int x, int y, bool custom)
410 {
411  Glide_offsets[0] = x;
412  Glide_offsets[1] = y;
413  Use_custom_glide = custom;
414 }
415 
416 void HudGaugeThrottle::initMatchSpeedOffsets(int x, int y, bool custom)
417 {
418  Match_speed_offsets[0] = x;
419  Match_speed_offsets[1] = y;
420  Use_custom_match_speed = custom;
421 
423  // NOTE: default to normal m because either
424  // a) the german font has no special m (its an a)
425  // b) the font has no special characters
426  if (sc == 0 || Lcl_gr) {
427  Match_speed_icon = ubyte ('m');
428  } else {
429  Match_speed_icon = sc + 3;
430  }
431 }
432 
434 {
436 
437  if (throttle_frames.first_frame < 0) {
438  mprintf(("Cannot load hud ani: %s\n", fname));
439  }
440 }
441 
443 {
445 }
446 
447 void HudGaugeThrottle::render(float frametime)
448 {
449  float desired_speed, max_speed, current_speed, absolute_speed, absolute_displayed_speed, max_displayed_speed, percent_max, percent_aburn_max;
450  int desired_y_pos, y_end;
451 
452  ship_info *sip;
454 
455  current_speed = Player_obj->phys_info.fspeed;
456  if ( current_speed < 0.0f){
457  current_speed = 0.0f;
458  }
459 
461  if ( max_speed <= 0 ) {
462  max_speed = sip->max_vel.xyz.z;
463  }
464 
465  absolute_speed = Player_obj->phys_info.speed;
466 
467  // scale by distance modifier from hud_guages.tbl for display purposes
468  absolute_displayed_speed = absolute_speed * Hud_speed_multiplier;
469  max_displayed_speed = max_speed * Hud_speed_multiplier;
470 
471  desired_speed = Player->ci.forward * max_speed;
472  if ( desired_speed < 0.0f ){ // so ships that go backwards don't force the indicators below where they can go
473  desired_speed = 0.0f;
474  }
475 
476  desired_y_pos = position[1] + Bottom_offset_y - fl2i(throttle_h*desired_speed/max_speed+0.5f) - 1;
477 
478  if (max_speed <= 0) {
479  percent_max = 0.0f;
480  } else {
481  percent_max = current_speed / max_speed;
482  }
483 
484  percent_aburn_max = 0.0f;
485  if ( percent_max > 1 ) {
486  percent_max = 1.0f;
487  percent_aburn_max = (current_speed - max_speed) / (sip->afterburner_max_vel.xyz.z - max_speed);
488  if ( percent_aburn_max > 1.0f ) {
489  percent_aburn_max = 1.0f;
490  }
491  if ( percent_aburn_max < 0 ) {
492  percent_aburn_max = 0.0f;
493  }
494  }
495 
496  y_end = position[1] + Bottom_offset_y - fl2i(throttle_h*percent_max+0.5f);
497  if ( percent_aburn_max > 0 ) {
498  y_end -= fl2i(percent_aburn_max * throttle_aburn_h + 0.5f);
499  }
500 
502  // default value is 240 when afterburner is on.
503  //I'm assuming that this value is basically Bottom_offset_y - throttle_aburn_h - throttle_h
504  desired_y_pos = position[1] + Bottom_offset_y - throttle_aburn_h - throttle_h;
505  }
506 
507  setGaugeColor();
508 
509  if(Show_background) {
511  } else {
513  }
514 
515  // draw throttle speed number
516  //hud_render_throttle_speed(current_speed, y_end);
517  // Absolute speed, not forward speed, for hud speed reticle - fixes the guage for sliding -- kazan
518  renderThrottleSpeed(absolute_displayed_speed, y_end);
519 
520  // draw target speed if necessary
521  if ( Show_target_speed ) {
522  char buf[32];
523  int w, h;
524 
525  if ( Show_percent ) {
527  strcpy_s(buf, "A/B");
528  } else {
529  sprintf(buf, XSTR( "%d%%", 326), fl2i( (desired_speed/max_speed)*100 + 0.5f ));
530  }
531  } else {
532  sprintf(buf, "%d", fl2i(desired_speed * Hud_speed_multiplier + 0.5f));
533  }
534 
536  gr_get_string_size(&w, &h, buf);
537 
539  }
540 
541  // draw the "desired speed" bar on the throttle
542  renderThrottleLine(desired_y_pos);
543 
544  // draw left arc (the bright portion of the throttle gauge)
546 
547  if ( Show_max_speed ) {
548  renderPrintf(position[0] + Max_speed_offsets[0], position[1] + Max_speed_offsets[1], "%d",fl2i(max_displayed_speed+0.5f));
549  }
550 
551  if ( Show_min_speed ) {
553  }
554 }
555 
556 void HudGaugeThrottle::renderThrottleSpeed(float current_speed, int y_end)
557 {
558  char buf[32];
559  int sx, sy, x_pos, y_pos, w, h;
560 
561  //setGaugeColor();
562  sprintf(buf, "%d", fl2i(current_speed+0.5f));
564  gr_get_string_size(&w, &h, buf);
565 
566  if ( orbit ) {
567  // y_end is the y-coordinate of the current throttle setting, calc x-coordinate for edge of
568  // circle (x^2 + y^2 = r^2)
569  y_pos = position[1] + Orbit_center_offsets[1] - y_end;
570  x_pos = (int)sqrt(double(orbit_radius * orbit_radius - y_pos * y_pos) );
571  x_pos = position[0] + Orbit_center_offsets[0] - x_pos;
572 
573  // draw current speed at (x_pos, y_end);
574  sx = x_pos - w - 2;
575  sy = fl2i(y_end - h/2.0f + 1.5);
576  } else {
577  sx = position[0] + Orbit_center_offsets[0] - w;
578  sy = position[1] + Orbit_center_offsets[1];
579  }
580 
581  renderPrintf(sx, sy, buf);
582 
583  if ( object_get_gliding(Player_obj) ) {
584  if ( Use_custom_glide ) {
585  renderString(position[0] + Glide_offsets[0], position[1] + Glide_offsets[1], "GLIDE");
586  } else {
587  int offset;
588  if ( current_speed <= 9.5 ) {
589  offset = -31;
590  } else if ( current_speed <= 99.5 ) {
591  offset = -22;
592  } else {
593  offset = -13;
594  }
595 
596  renderString(sx+offset, sy + h, "GLIDE");
597  }
599  if ( Use_custom_match_speed ) {
601  } else {
602  int offset;
603  if ( current_speed <= 9.5 ) {
604  offset = 0;
605  } else {
606  offset = 3;
607  }
608 
609  renderPrintf(sx+offset, sy + h, "%c", Match_speed_icon);
610  }
611  }
612 }
613 
615 {
616  // hud_set_bright_color();
617  //setGaugeColor(HUD_C_BRIGHT);
618 
620  position[0], y_line,
621  throttle_w, 1,
622  0,
623  y_line-position[1]);
624 }
625 
627 {
628  int w,h;
629 
630  //setGaugeColor();
631 
633 
634  if ( y_end < (position[1] + h - 1) ) {
635  renderBitmapEx(throttle_frames.first_frame + 2, position[0], y_end, w, h - (y_end - position[1]), 0, y_end - position[1]);
636  }
637 }
638 
640 {
641  int w,h;
642 
643  //setGaugeColor();
644 
646 
647  if ( y_end > position[1] ) {
648  renderBitmapEx(throttle_frames.first_frame+1, position[0], position[1], w, y_end-position[1]+1, 0, 0);
649  }
650 }
651 
654 {
655 }
656 
658 {
659  Laser_warn_offsets[0] = x;
660  Laser_warn_offsets[1] = y;
661 }
662 
664 {
665  Lock_warn_offsets[0] = x;
666  Lock_warn_offsets[1] = y;
667 }
668 
669 void HudGaugeThreatIndicator::initBitmaps(char *fname_arc, char *fname_laser, char *fname_lock)
670 {
672  if (threat_arc.first_frame < 0) {
673  mprintf(("Cannot load hud ani: %s\n", fname_arc));
674  }
675 
677  if (laser_warn.first_frame < 0) {
678  mprintf(("Cannot load hud ani: %s\n", fname_laser));
679  }
680 
682  if (lock_warn.first_frame < 0) {
683  mprintf(("Cannot load hud ani: %s\n", fname_lock));
684  }
685 }
686 
688 {
690  laser_warn_frame = 0;
691 
693  lock_warn_frame = 0;
694 
696 }
697 
699 {
703 }
704 
705 void HudGaugeThreatIndicator::render(float frametime)
706 {
707  setGaugeColor();
709 
712 }
713 
715 {
716  int frame_offset, num_frames;
717 
718  //Check how many frames the ani actually has
719  num_frames = laser_warn.num_frames;
720  //We need at least two frames here
721  Assert( num_frames >= 2 );
722 
727  if ( laser_warn_frame > (num_frames - 1) ) { //The first frame being the default "off" setting, we need to cycle through all the other frames
728  laser_warn_frame = 1;
729  }
730  }
731  frame_offset = laser_warn_frame;
732  } else {
733  frame_offset = 0;
734  }
735 
737 }
738 
740 {
741  int frame_offset, num_frames;
742 
743  //Let's find out how many frames our ani has, and adjust accordingly
744  num_frames = lock_warn.num_frames;
745  //We need at least two frames here
746  Assert( num_frames >= 2 );
747 
750  if ( Player->threat_flags & THREAT_LOCK ) {
752  } else {
754  }
755  lock_warn_frame++;
756  if ( lock_warn_frame > (num_frames - 1) ) { //The first frame being the default "off" setting, we need to cycle through all the other frames
757  lock_warn_frame = 1;
758  }
759  }
760  frame_offset = lock_warn_frame;
761  } else {
762  frame_offset = 0;
763  }
764 
766 }
767 
770 {
771 }
772 
774 {
777 }
778 
780 {
783 }
784 
786 {
789 }
790 
792 {
795 }
796 
798 {
801 }
802 
804  char *fname_primary_link_1,
805  char *fname_primary_link_2,
806  char *fname_secondary_link_1,
807  char *fname_secondary_link_2,
808  char *fname_secondary_link_3)
809 {
811  if (arc.first_frame < 0) {
812  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_arc);
813  }
814 
816  if (weapon_linking_modes[LINK_ONE_PRIMARY].first_frame < 0) {
817  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_primary_link_1);
818  }
819 
821  if (weapon_linking_modes[LINK_TWO_PRIMARY].first_frame < 0) {
822  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_primary_link_2);
823  }
824 
826  if (weapon_linking_modes[LINK_ONE_SECONDARY].first_frame < 0) {
827  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_secondary_link_1);
828  }
829 
831  if (weapon_linking_modes[LINK_TWO_SECONDARY].first_frame < 0) {
832  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_secondary_link_2);
833  }
834 
836  if (weapon_linking_modes[LINK_THREE_SECONDARY].first_frame < 0) {
837  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_secondary_link_3);
838  }
839 }
840 
841 
843 {
845 
846  for(int i = 0; i < NUM_WEAPON_LINK_MODES; i++) {
848  }
849 }
850 
851 void HudGaugeWeaponLinking::render(float frametime)
852 {
853  int gauge_index=0, frame_offset=0;
854  ship_weapon *swp;
855 
856  setGaugeColor();
857 
858  if (arc.first_frame >= 0) {
860  }
861 
862  swp = &Player_ship->weapons;
863 
864  switch( swp->num_primary_banks ) {
865  case 0:
866  gauge_index = -1;
867  break;
868 
869  case 1:
870  gauge_index = LINK_ONE_PRIMARY;
872  frame_offset = 0;
873  } else {
874  frame_offset = 1;
875  }
876  break;
877 
878  case 2:
879  gauge_index = LINK_TWO_PRIMARY;
880  if ( swp->current_primary_bank == -1 ) {
881  frame_offset = 0;
882  } else {
884  frame_offset = 3;
885  } else {
886  if ( swp->current_primary_bank == 0 ) {
887  frame_offset = 1;
888  } else {
889  frame_offset = 2;
890  }
891  }
892  }
893  break;
894 
895  default:
896  Int3(); // shouldn't happen (get Alan if it does)
897  return;
898  break;
899  }
900 
901  if ( gauge_index != -1 ) {
902  if (weapon_linking_modes[gauge_index].first_frame >= 0) {
903  renderBitmap(weapon_linking_modes[gauge_index].first_frame+frame_offset, position[0] + Weapon_link_offsets[gauge_index][0], position[1] + Weapon_link_offsets[gauge_index][1]);
904  }
905  }
906 
907  int num_banks = swp->num_secondary_banks;
908  if ( num_banks <= 0 ) {
909  num_banks = Ship_info[Player_ship->ship_info_index].num_secondary_banks;
910  }
911 
912  switch( num_banks ) {
913  case 0:
914  Int3();
915  gauge_index = -1;
916  break;
917 
918  case 1:
919  gauge_index = LINK_ONE_SECONDARY;
920  break;
921 
922  case 2:
923  gauge_index = LINK_TWO_SECONDARY;
924  break;
925 
926  case 3:
927  gauge_index = LINK_THREE_SECONDARY;
928  break;
929 
930  default:
931  Int3(); // shouldn't happen (get Alan if it does)
932  return;
933  break;
934  }
935 
936  if ( gauge_index != -1 ) {
937  if ( swp->num_secondary_banks <= 0 ) {
938  frame_offset = 0;
939  } else {
940  frame_offset = swp->current_secondary_bank+1;
941  }
942  if (weapon_linking_modes[gauge_index].first_frame >= 0) {
943  renderBitmap(weapon_linking_modes[gauge_index].first_frame+frame_offset, position[0] + Weapon_link_offsets[gauge_index][0], position[1] + Weapon_link_offsets[gauge_index][1]);
944  }
945  }
946 }
947 
948 // Called at the start of each level.. use Reticle_inited so we only load frames once
950 {
951  Threat_lock_timer = timestamp(0);
952  Threat_lock_frame = 1;
953  Player->threat_flags = 0;
956 }
957 
958 // called once per frame to update the reticle gauges. Makes calls to
959 // ship_dumbfire_threat() and ship_lock_threat() and updates Threat_flags.
961 {
962  int rval;
963  ship *shipp;
964 
965  // multiplayer clients won't call this routine
967  return;
968 
969  shipp = &Ships[Objects[pp->objnum].instance];
970 
971  if ( ship_dumbfire_threat(shipp) ) {
974  }
975 
979  }
980 
981  if ( timestamp_elapsed(pp->update_lock_time) ) {
984  rval = ship_lock_threat(shipp);
985  if ( rval == 1 ) {
987  } else if ( rval == 2 ) {
988  pp->threat_flags |= THREAT_LOCK;
989  }
990  }
991 
993  // a less hacked up version of the missile launch warning
995  }
996 
998  if ( timestamp_elapsed(Threat_lock_timer) ) {
999  Threat_lock_timer = timestamp(THREAT_LOCK_FLASH);
1000 
1001  Threat_lock_frame++;
1002  if ( Threat_lock_frame > 2 ) {
1003  Threat_lock_frame = 1;
1004  }
1005  if ( (Threat_lock_frame == 2) && (Player->threat_flags & THREAT_ATTEMPT_LOCK ) ) {
1007  }
1008  }
1009  }
1010 }
bool Use_custom_glide
Definition: hudreticle.h:79
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
virtual void initialize()
Definition: hud.cpp:1049
int Orbit_center_offsets[2]
Definition: hudreticle.h:70
int timestamp(int delta_ms)
Definition: timer.cpp:226
#define PLAYER_FLAGS_MATCH_TARGET
Definition: player.h:36
#define MULTIPLAYER_CLIENT
Definition: multi.h:132
#define MY_NET_PLAYER_NUM
Definition: multi.h:127
int i
Definition: multi_pxo.cpp:466
void init1PrimaryOffsets(int x, int y)
Definition: hudreticle.cpp:773
void renderBitmapEx(int frame, int x, int y, int w, int h, int sx, int sy)
Definition: hud.cpp:818
int primary_bank_weapons[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:103
void initGlideOffsets(int x, int y, bool custom)
Definition: hudreticle.cpp:409
control_info ci
Definition: player.h:126
#define HUD_C_BRIGHT
Definition: hud.h:162
matrix * vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1)
Definition: vecmat.cpp:1006
#define LINK_THREE_SECONDARY
Definition: hudreticle.h:28
#define LINK_TWO_SECONDARY
Definition: hudreticle.h:27
int num_primary_banks
Definition: ship.h:99
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
#define HUD_THREAT_GAUGE
Definition: hudgauges.h:37
void initFirepointDisplay(bool firepoint, int scaleX, int scaleY, int size)
Definition: hudreticle.cpp:241
polymodel * model_get(int model_num)
Definition: modelread.cpp:3134
weapon_info Weapon_info[MAX_WEAPON_TYPES]
Definition: weapons.cpp:79
ship_weapon weapons
Definition: ship.h:658
SCP_vector< game_snd > Snds
Definition: gamesnd.cpp:19
#define LINK_ONE_SECONDARY
Definition: hudreticle.h:26
#define WIF2_CYCLE
Definition: weapon.h:89
void hud_num_make_mono(char *num_str, int font_num)
Convert a number string to use mono-spaced 1 character.
Definition: hud.cpp:2275
#define VM_WARP_CHASE
Definition: systemvars.h:37
physics_info phys_info
Definition: object.h:157
missile threat indicator flashes
Definition: gamesnd.h:122
int n_view_positions
Definition: model.h:752
bool Show_target_speed
Definition: hudreticle.h:75
void setGaugeColor(int bright_index=-4)
Definition: hud.cpp:445
int model_num
Definition: ship.h:1189
int next_primary_fire_stamp[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:113
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
Assert(pm!=NULL)
Definition: pstypes.h:88
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
#define mprintf(args)
Definition: pstypes.h:238
int Outer_circle_radius[GR_NUM_RESOLUTIONS]
Definition: hudreticle.cpp:59
#define THREAT_ATTEMPT_LOCK
Definition: hudreticle.cpp:216
w_bank * gun_banks
Definition: model.h:772
SCP_vector< firepoint > fp
Definition: hudreticle.h:40
#define VM_EXTERNAL
Definition: systemvars.h:31
void render(float frametime)
Definition: hudreticle.cpp:851
matrix Eye_matrix
Definition: 3dsetup.cpp:26
int bm_get_info(int handle, int *w, int *h, ubyte *flags, int *nframes, int *fps)
Gets info on the bitmap indexed by handle.
Definition: bmpman.cpp:769
struct vec3d::@225::@227 xyz
#define SIF2_DYN_PRIMARY_LINKING
Definition: ship.h:933
GLclampf f
Definition: Glext.h:7097
int update_lock_time
Definition: player.h:188
float y
Definition: pstypes.h:107
hud_frames throttle_frames
Definition: hudreticle.h:57
#define THREAT_LOCK_FLASH
Definition: hudreticle.cpp:223
matrix * vm_copy_transpose(matrix *dest, const matrix *src)
Definition: vecmat.cpp:984
vec3d * vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m)
Definition: vecmat.cpp:933
int Hud_throttle_h[GR_NUM_RESOLUTIONS]
Definition: hudreticle.cpp:43
bool Use_custom_match_speed
Definition: hudreticle.h:82
int update_dumbfire_time
Definition: player.h:187
int current_primary_bank
Definition: ship.h:106
int Max_speed_offsets[2]
Definition: hudreticle.h:64
int firepoint_scale_y
Definition: hudreticle.h:44
uint flags
Definition: ship.h:644
void renderThrottleLine(int y)
Definition: hudreticle.cpp:614
hud_frames crosshair
Definition: hudreticle.h:38
int current_secondary_bank
Definition: ship.h:107
GLsizeiptr size
Definition: Glext.h:5496
#define Int3()
Definition: pstypes.h:292
#define LINK_ONE_PRIMARY
Definition: hudreticle.h:24
Definition: model.h:594
ship * shipp
Definition: lua.cpp:9162
#define VM_TOPDOWN
Definition: systemvars.h:43
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
int Hud_reticle_center[GR_NUM_RESOLUTIONS][2]
Definition: hudreticle.cpp:64
void renderThrottleSpeed(float current_speed, int y_end)
Definition: hudreticle.cpp:556
vec3d pnt[MAX_SLOTS]
Definition: model.h:434
int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
Loads a bitmap sequance so we can draw with it.
Definition: bmpman.cpp:1420
void initBitmaps(char *fname_arc, char *fname_primary_link_1, char *fname_primary_link_2, char *fname_secondary_link_1, char *fname_secondary_link_2, char *fname_secondary_link_3)
Definition: hudreticle.cpp:803
Definition: hud.h:201
#define NUM_RETICLE_ANIS
Definition: hudreticle.cpp:24
void initAburnHeight(int h)
Definition: hudreticle.cpp:365
int Reticle_frame_coords[NUM_HUD_RETICLE_STYLES][GR_NUM_RESOLUTIONS][NUM_RETICLE_ANIS][2]
Definition: hudreticle.cpp:141
vec3d pnt
Definition: model.h:596
player Players[MAX_PLAYERS]
void renderThrottleBackground(int y_end)
Definition: hudreticle.cpp:639
void render(float frametime)
Definition: hudreticle.cpp:447
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
#define THREAT_UPDATE_LOCK_TIME
Definition: hudreticle.cpp:220
int instance
Definition: object.h:150
GLintptr offset
Definition: Glext.h:5497
Definition: player.h:85
#define VM_DEAD_VIEW
Definition: systemvars.h:33
void initThrottleSizes(int w, int h)
Definition: hudreticle.cpp:359
void initLaserWarnOffsets(int x, int y)
Definition: hudreticle.cpp:657
int font_num
Definition: hud.h:210
#define HUD_OBJECT_CENTER_RETICLE
Definition: hudparse.h:160
void init2SecondaryOffsets(int x, int y)
Definition: hudreticle.cpp:791
hud_frames weapon_linking_modes[NUM_WEAPON_LINK_MODES]
Definition: hudreticle.h:143
bool object_get_gliding(object *objp)
Definition: object.cpp:2059
int num_frames
Definition: hud.h:34
int ship_get_sound(object *objp, GameSoundsIndex id)
Returns a ship-specific sound index.
Definition: ship.cpp:18614
float speed
Definition: physics.h:79
int num_secondary_banks
Definition: ship.h:100
int primary_animation_done_time[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:153
#define w(p)
Definition: modelsinc.h:68
void initOrbitRadius(int radius)
Definition: hudreticle.cpp:391
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
float forward
Definition: physics.h:105
#define NUM_WEAPON_LINK_MODES
Definition: hudreticle.h:23
#define MULTI_OBSERVER(np)
Definition: multi.h:140
float current_max_speed
Definition: ship.h:641
int threat_flags
Definition: player.h:189
int snd_play(game_snd *gs, float pan, float vol_scale, int priority, bool is_voice_msg)
Definition: sound.cpp:517
#define SF_PRIMARY_LINKED
Definition: ship.h:458
#define THREAT_UPDATE_DUMBFIRE_TIME
Definition: hudreticle.cpp:219
int current_viewpoint
Definition: ship.h:756
matrix eye_orient
Definition: fredrender.cpp:112
#define HUD_OBJECT_THREAT
Definition: hudparse.h:166
int flags2
Definition: ship.h:1228
Definition: ship.h:534
int num_slots
Definition: model.h:433
#define LINK_TWO_PRIMARY
Definition: hudreticle.h:25
void renderString(int x, int y, const char *str)
Definition: hud.cpp:665
int Zero_speed_offsets[2]
Definition: hudreticle.h:67
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
object Objects[MAX_OBJECTS]
Definition: object.cpp:62
unsigned char ubyte
Definition: pstypes.h:62
uint flags
Definition: physics.h:37
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
int objnum
Definition: player.h:124
ship * Player_ship
Definition: ship.cpp:124
int wi_flags2
Definition: weapon.h:385
void init2PrimaryOffsets(int x, int y)
Definition: hudreticle.cpp:779
#define OBJ_SHIP
Definition: object.h:32
int Target_speed_offsets[2]
Definition: hudreticle.h:74
ubyte lcl_get_font_index(int font_num)
Definition: localize.cpp:495
GLbitfield flags
Definition: Glext.h:6722
void hud_init_reticle()
Definition: hudreticle.cpp:949
int first_frame
Definition: hud.h:33
float x
Definition: pstypes.h:107
void render(float frametime)
Definition: hudreticle.cpp:248
int firepoint_scale_x
Definition: hudreticle.h:43
float fspeed
Definition: physics.h:80
void initLockWarnOffsets(int x, int y)
Definition: hudreticle.cpp:663
ship Ships[MAX_SHIPS]
Definition: ship.cpp:122
int Reticle_launch_coords[GR_NUM_RESOLUTIONS][2]
Definition: hudreticle.cpp:206
#define HUD_C_NORMAL
Definition: hud.h:164
void initMatchSpeedOffsets(int x, int y, bool custom)
Definition: hudreticle.cpp:416
void init3SecondaryOffsets(int x, int y)
Definition: hudreticle.cpp:797
int ship_dumbfire_threat(ship *sp)
Definition: ship.cpp:15078
void init1SecondaryOffsets(int x, int y)
Definition: hudreticle.cpp:785
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
int Match_speed_offsets[2]
Definition: hudreticle.h:81
int position[2]
Definition: hud.h:204
Definition: pstypes.h:106
void bm_page_in_aabitmap(int bitmapnum, int nframes)
Marks a texture as being used for this level, and is anti-aliased.
Definition: bmpman.cpp:2354
#define fl2i(fl)
Definition: floating.h:33
player * Player
void hud_start_text_flash(char *txt, int t, int interval)
ubyte Match_speed_icon
Definition: hudreticle.h:83
bool Show_background
Definition: hudreticle.h:85
float Hud_speed_multiplier
Definition: hudparse.cpp:41
void initZeroSpeedOffsets(int x, int y, bool show)
Definition: hudreticle.cpp:377
int last_fired_point[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:771
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
#define THREAT_LOCK
Definition: hudreticle.cpp:217
void initBitmaps(char *fname)
Definition: hudreticle.cpp:233
int Hud_throttle_aburn_h[GR_NUM_RESOLUTIONS]
Definition: hudreticle.cpp:50
int Hud_throttle_frame_w[GR_NUM_RESOLUTIONS]
Definition: hudreticle.cpp:39
int ship_info_index
Definition: ship.h:539
void getFirepointStatus()
Definition: hudreticle.cpp:278
SCP_vector< ship_info > Ship_info
Definition: ship.cpp:164
#define LOCATION
Definition: pstypes.h:245
#define HUD_OBJECT_THROTTLE
Definition: hudparse.h:163
vec3d afterburner_max_vel
Definition: ship.h:1281
#define VM_PADLOCK_ANY
Definition: systemvars.h:46
#define timestamp_elapsed(stamp)
Definition: timer.h:102
int n_guns
Definition: model.h:768
void renderPrintf(int x, int y, const char *format,...)
Definition: hud.cpp:724
int Weapon_link_offsets[NUM_WEAPON_LINK_MODES][2]
Definition: hudreticle.h:144
char Reticle_frame_names[NUM_HUD_RETICLE_STYLES][GR_NUM_RESOLUTIONS][NUM_RETICLE_ANIS][MAX_FILENAME_LEN]
Definition: hudreticle.cpp:74
eye view_positions[MAX_EYES]
Definition: model.h:753
object * Player_obj
Definition: object.cpp:56
void initBitmaps(char *fname_arc, char *fname_laser, char *fname_lock)
Definition: hudreticle.cpp:669
#define PF_AFTERBURNER_ON
Definition: physics.h:20
void renderThrottleForeground(int y_end)
Definition: hudreticle.cpp:626
void initOrbitCenterOffsets(int x, int y, bool orbiting)
Definition: hudreticle.cpp:384
polymodel * pm
Definition: lua.cpp:1598
void initBitmaps(char *fname)
Definition: hudreticle.cpp:433
#define HUD_OBJECT_WEAPON_LINKING
Definition: hudparse.h:178
#define VM_OTHER_SHIP
Definition: systemvars.h:35
#define HUD_CENTER_RETICLE
Definition: hudgauges.h:27
#define THREAT_DUMBFIRE_FLASH
Definition: hudreticle.cpp:222
bool firepoint_display
Definition: hudreticle.h:39
void hud_update_reticle(player *pp)
Definition: hudreticle.cpp:960
false
Definition: lua.cpp:6789
#define HUD_THROTTLE_GAUGE
Definition: hudgauges.h:24
int ship_lock_threat(ship *sp)
Definition: ship.cpp:15163
char type
Definition: object.h:146
int Hud_throttle_bottom_y[NUM_HUD_RETICLE_STYLES][GR_NUM_RESOLUTIONS]
Definition: hudreticle.cpp:46
void showBackground(bool show)
Definition: hudreticle.cpp:404
vec3d max_vel
Definition: ship.h:1196
void render(float frametime)
Definition: hudreticle.cpp:705
char filename[FILESPEC_LENGTH]
Definition: model.h:734
net_player Net_players[MAX_PLAYERS]
Definition: multi.cpp:93
#define HUD_C_DIM
Definition: hud.h:163
int primary_bank_slot_count[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:131
int Hud_throttle_aburn_button[GR_NUM_RESOLUTIONS]
Definition: hudreticle.cpp:54
int Lcl_gr
Definition: localize.cpp:48
void initMaxSpeedOffsets(int x, int y, bool show)
Definition: hudreticle.cpp:370
GLint y
Definition: Gl.h:1505
void initThrottleStartY(int y)
Definition: hudreticle.cpp:354
void renderCircle(int x, int y, int diameter)
Definition: hud.cpp:919
int Player_num
#define strcpy_s(...)
Definition: safe_strings.h:67
void initTargetSpeedOffsets(int x, int y, bool show, bool percent)
Definition: hudreticle.cpp:396
void renderBitmap(int x, int y)
Definition: hud.cpp:782
int Glide_offsets[2]
Definition: hudreticle.h:78
#define THREAT_DUMBFIRE
Definition: hudreticle.cpp:215
#define NUM_HUD_RETICLE_STYLES
Definition: hudparse.h:17