31 #define NUM_SHIELD_LEVELS 8
33 #define SHIELD_TRANSFER_PERCENT 0.083f // 1/12 total shield strength
35 #define SHIELD_HIT_DURATION_SHORT 300 // time a shield quadrant flashes after being hit
36 #define SHIELD_FLASH_INTERVAL_FAST 200 // time between shield quadrant flashes
45 static int Hud_shield_inited = 0;
113 #define SHIELD_HIT_PLAYER 0
114 #define SHIELD_HIT_TARGET 1
128 if ( !Hud_shield_inited ) {
129 for ( i = 0; i < Hud_shield_filenames.size(); i++ ) {
130 Shield_gauges.push_back(temp);
131 Shield_gauges.at(i).first_frame = -1;
132 Shield_gauges.at(i).num_frames = 0;
135 Hud_shield_inited = 1;
151 shi = &Shield_hit_data[target_index];
189 if ( sgp->first_frame == -1 ) {
191 if ( sgp->first_frame == -1 ) {
198 for (i=0; i<sgp->num_frames; i++ ) {
233 for (idx = 0; idx < objp->
n_quadrants - 1; idx++) {
244 if (strength == 0.0
f)
284 float xfer_amount, energy_avail, percent_to_take,
delta;
285 float max_quadrant_val;
296 Assert(direction >= 0 && direction < objp->n_quadrants);
301 if ( (objp->
shield_quadrant[direction] + xfer_amount) > max_quadrant_val )
305 if ( xfer_amount == 0 ) {
315 if ( i == direction )
320 percent_to_take = xfer_amount/energy_avail;
321 if ( percent_to_take > 1.0
f )
322 percent_to_take = 1.0f;
325 if ( i == direction )
343 for ( i = 0; i < (
ubyte)Hud_shield_filenames.size(); i++ ) {
344 if ( !
stricmp(filename, Hud_shield_filenames.at(i).c_str()) ) {
352 Hud_shield_filenames.push_back((
SCP_string)filename);
357 char text_integrity[64];
358 int numeric_integrity;
359 float p_target_integrity;
364 numeric_integrity =
fl2i(p_target_integrity*100 + 0.5
f);
365 if(numeric_integrity > 100){
366 numeric_integrity = 100;
371 if ( numeric_integrity == 100 ) {
376 else if ( numeric_integrity < 10 ) {
386 if ( numeric_integrity == 0 ) {
387 if ( p_target_integrity > 0 ) {
388 numeric_integrity = 1;
392 sprintf(text_integrity,
"%d", numeric_integrity);
393 if ( numeric_integrity < 100 ) {
397 gr_string(final_pos[0], final_pos[1], text_integrity);
405 int hud_color_index,
range, frame_offset;
446 Assert(hud_color_index >= 0 && hud_color_index <= range);
448 if ( hud_color_index < 0 ) {
474 int n_quadrants = (objp != NULL) ? objp->
n_quadrants : 0;
476 shi->
members = n_quadrants + 1;
520 for ( i = 0; i <
limit; i++ ) {
521 for ( j = 0; j < Shield_hit_data[
i].
members; j++ ) {
549 Assertion(objp != NULL,
"hud_shield_quadrant_hit() called with a NULL objp; get a coder!\n");
568 if ( quadrant >= 0 ) {
600 int hud_color_index,
range;
655 angles rot_angles = {-1.570796327f,0.0f,0.0f};
752 Assert(hud_color_index >= 0 && hud_color_index <= range);
754 if ( hud_color_index < 0 ) {
773 if (framenum < sgp->first_frame+sgp->
num_frames)
779 static const int TRI_EDGE = 6;
780 static const int BAR_LENGTH = 112;
781 static const int BAR_HEIGHT = 54;
782 static const int BAR_WIDTH = 6;
783 static const int SHIELD_OFFSET = BAR_WIDTH + TRI_EDGE + 3;
789 shield_icon_coords[0].
x = sx; shield_icon_coords[0].
y = sy+BAR_WIDTH+TRI_EDGE;
790 shield_icon_coords[1].
x = sx; shield_icon_coords[1].
y = sy;
791 shield_icon_coords[2].
x = sx+TRI_EDGE; shield_icon_coords[2].
y = sy+BAR_WIDTH;
792 shield_icon_coords[3].
x = sx+BAR_LENGTH; shield_icon_coords[3].
y = sy;
793 shield_icon_coords[4].
x = sx+BAR_LENGTH-TRI_EDGE; shield_icon_coords[4].
y = sy+BAR_WIDTH;
794 shield_icon_coords[5].
x = sx+BAR_LENGTH; shield_icon_coords[5].
y = sy+BAR_WIDTH+TRI_EDGE;
800 shield_icon_coords[0].
x = sx+BAR_WIDTH+TRI_EDGE; shield_icon_coords[0].
y = sy+BAR_HEIGHT;
801 shield_icon_coords[1].
x = sx; shield_icon_coords[1].
y = sy+BAR_HEIGHT;
802 shield_icon_coords[2].
x = sx+BAR_WIDTH; shield_icon_coords[2].
y = sy+BAR_HEIGHT-TRI_EDGE;
803 shield_icon_coords[3].
x = sx; shield_icon_coords[3].
y = sy;
804 shield_icon_coords[4].
x = sx+BAR_WIDTH; shield_icon_coords[4].
y = sy+TRI_EDGE;
805 shield_icon_coords[5].
x = sx+BAR_WIDTH+TRI_EDGE; shield_icon_coords[5].
y = sy;
807 sy -= SHIELD_OFFSET + BAR_WIDTH + TRI_EDGE;
813 shield_icon_coords[0].
x = sx-BAR_WIDTH-TRI_EDGE; shield_icon_coords[0].
y = sy;
814 shield_icon_coords[1].
x = sx; shield_icon_coords[1].
y = sy;
815 shield_icon_coords[2].
x = sx-BAR_WIDTH; shield_icon_coords[2].
y = sy+TRI_EDGE;
816 shield_icon_coords[3].
x = sx; shield_icon_coords[3].
y = sy+BAR_HEIGHT;
817 shield_icon_coords[4].
x = sx-BAR_WIDTH; shield_icon_coords[4].
y = sy+BAR_HEIGHT-TRI_EDGE;
818 shield_icon_coords[5].
x = sx-BAR_WIDTH-TRI_EDGE; shield_icon_coords[5].
y = sy+BAR_HEIGHT;
825 sy += BAR_HEIGHT + SHIELD_OFFSET*2 - BAR_WIDTH - TRI_EDGE;
826 shield_icon_coords[0].
x = sx+BAR_LENGTH; shield_icon_coords[0].
y = sy;
827 shield_icon_coords[1].
x = sx+BAR_LENGTH; shield_icon_coords[1].
y = sy+BAR_WIDTH+TRI_EDGE;
828 shield_icon_coords[2].
x = sx+BAR_LENGTH-TRI_EDGE; shield_icon_coords[2].
y = sy+TRI_EDGE;
829 shield_icon_coords[3].
x = sx; shield_icon_coords[3].
y = sy+BAR_WIDTH+TRI_EDGE;
830 shield_icon_coords[4].
x = sx+TRI_EDGE; shield_icon_coords[4].
y = sy+TRI_EDGE;
831 shield_icon_coords[5].
x = sx; shield_icon_coords[5].
y = sy;
833 sy -= BAR_HEIGHT + SHIELD_OFFSET*2 - BAR_WIDTH - TRI_EDGE;
837 nprintf((
"HUD",
"Invalid shield quadrant %d specified!\n", i));
861 int nx = 0,
ny = 0,
i;
878 for (
i = 0;
i < 6; ++
i) {
892 shi = &Shield_hit_data[target_index];
969 Warning(
LOCATION,
"Could not load in the HUD shield ani: %s\n", fname);
997 int hud_color_index,
range, frame_offset;
1035 Assert(hud_color_index >= 0 && hud_color_index <= range);
1037 if ( hud_color_index < 0 ) {
1038 hud_color_index = 0;
1052 if (frame_offset < Shield_mini_gauge.
num_frames)
1061 char text_integrity[64];
1062 int numeric_integrity;
1065 numeric_integrity =
fl2i(p_target_integrity*100 + 0.5
f);
1066 if(numeric_integrity > 100){
1067 numeric_integrity = 100;
1072 if ( numeric_integrity == 100 ) {
1076 else if ( numeric_integrity < 10 ) {
1084 if ( numeric_integrity == 0 ) {
1085 if ( p_target_integrity > 0 ) {
1086 numeric_integrity = 1;
1093 sprintf(text_integrity,
"%d", numeric_integrity);
1094 if ( numeric_integrity < 100 ) {
1098 renderString(final_pos[0], final_pos[1], text_integrity);
1106 shi = &Shield_hit_data[target_index];
void hud_shield_equalize(object *objp, player *pl)
int Mini_2digit_offsets[2]
int timestamp(int delta_ms)
#define MULTIPLAYER_CLIENT
float get_max_shield_quad(object *objp)
void hud_ship_icon_page_in(ship_info *sip)
#define timestamp_elapsed_safe(_a, _b)
#define HUD_TARGET_SHIELD_ICON
void hud_gauge_popup_start(int gauge_index, int time)
Start a gauge to pop-up.
void showIntegrity(float p_target_integrity)
int maybeFlashShield(int target_index, int shield_offset)
int Hud_mini_3digit[GR_NUM_RESOLUTIONS][3]
float shield_get_strength(object *objp)
SCP_vector< game_snd > Snds
#define gr_end_view_matrix
void hud_num_make_mono(char *num_str, int font_num)
Convert a number string to use mono-spaced 1 character.
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
#define SIF2_GENERATE_HUD_ICON
void setGaugeColor(int bright_index=-4)
float ship_max_shield_strength
SCP_vector< int > shield_hit_next_flash
int Hud_mini_2digit[GR_NUM_RESOLUTIONS][3]
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
#define HUD_NUM_COLOR_LEVELS
#define GR_NUM_RESOLUTIONS
SCP_vector< SCP_string > Hud_shield_filenames
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
#define HUD_OBJECT_TARGET_SHIELD
void hud_escort_ship_hit(object *objp, int quadrant)
void set_flags(uint flags)
void model_render_immediate(model_render_params *render_info, int model_num, matrix *orient, vec3d *pos, int render, bool sort)
int maybeFlashShield(int target_index, int shield_offset)
#define Assertion(expr, msg,...)
void set_detail_level_lock(int detail_level_lock)
#define HUD_OBJECT_MINI_SHIELD
void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, int center_w, int center_h, bool force_stretch)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
#define gr_end_proj_matrix
void setClip(int x, int y, int w, int h)
#define HUD_COLOR_ALPHA_MAX
void hud_shield_show_mini(object *objp, int x_force, int y_force, int x_hull_offset, int y_hull_offset)
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.
void render(float frametime)
#define gr_set_view_matrix
int Shield_mini_coords[GR_NUM_RESOLUTIONS][2]
#define gr_set_proj_matrix
void shield_info_reset(object *objp, shield_hit_info *shi)
SCP_vector< hud_frames > Shield_gauges
#define HUD_TARGET_MINI_ICON
#define GR_AABITMAP(a, b, c)
SCP_vector< int > shield_hit_timers
int * ship_replacement_textures
#define SHIELD_HIT_PLAYER
void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom)
float get_hull_pct(object *objp)
int Mini_1digit_offsets[2]
void hud_shield_level_init()
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
void hud_shield_quadrant_hit(object *objp, int quadrant)
void gr_shield_icon(coord2d coords[6], int resize_mode)
ubyte Quadrant_xlate[DEFAULT_SHIELD_SECTIONS]
int snd_play(game_snd *gs, float pan, float vol_scale, int priority, bool is_voice_msg)
void init1DigitOffsets(int x, int y)
float max_shield_strength
void hud_set_gauge_color(int gauge_index, int bright_index)
Set the HUD color for the gauge, based on whether it is flashing or not.
#define DEFAULT_SHIELD_SECTIONS
int hud_shield_maybe_flash(int gauge, int target_index, int shield_offset)
void renderString(int x, int y, const char *str)
#define SHIELD_HIT_DURATION_SHORT
GLint GLint GLint GLint GLint x
object Objects[MAX_OBJECTS]
void render(float frametime)
void set_replacement_textures(int *textures)
virtual void render(float frametime)
void hud_shield_hit_update()
#define SHIELD_HIT_TARGET
#define GM_STANDALONE_SERVER
void renderShieldIcon(coord2d coords[6])
int shield_point_augment_ctrls[4]
int hud_gauge_maybe_flash(int gauge_index)
Set the color for a gauge that may be flashing.
#define HUD_PLAYER_SHIELD_ICON
bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
void init2DigitOffsets(int x, int y)
void hud_shield_assign_info(ship_info *sip, char *filename)
bool shield_ani_warning_displayed_already
hud_frames Shield_mini_gauge
void bm_page_in_aabitmap(int bitmapnum, int nframes)
Marks a texture as being used for this level, and is anti-aliased.
void hud_targetbox_start_flash(int index, int duration)
GLfloat GLfloat GLfloat GLfloat nx
void init3DigitOffsets(int x, int y)
#define SHIELD_FLASH_INTERVAL_FAST
void hud_augment_shield_quadrant(object *objp, int direction)
SCP_vector< ship_info > Ship_info
int Hud_mini_1digit[GR_NUM_RESOLUTIONS][3]
void gr_reset_screen_scale()
void initBitmaps(char *fname)
#define timestamp_elapsed(stamp)
SCP_vector< float > shield_quadrant
void render(float frametime)
bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
#define SIF2_MODEL_POINT_SHIELDS
void shield_set_strength(object *objp, float strength)
void hud_shield_hit_reset(object *objp, int player)
#define SHIELD_TRANSFER_PERCENT
#define HUD_OBJECT_PLAYER_SHIELD
int Hud_mini_base[GR_NUM_RESOLUTIONS][2]
#define SF2_PRIMITIVE_SENSORS
shield quadrant transfer successful
void hud_show_mini_ship_integrity(object *objp, int x_force, int y_force)
void set_object_number(int num)
int Mini_3digit_offsets[2]
void showShields(object *objp, int mode)
void showMiniShields(object *objp)
matrix vmd_identity_matrix
char ship_name[NAME_LENGTH]
void hud_save_restore_camera_data(int save)
Called to save and restore the 3D camera settings.
#define g3_start_frame(zbuffer_flag)
void renderBitmap(int x, int y)