From: MirceaKitsune Date: Sun, 31 Jul 2011 20:23:00 +0000 (+0300) Subject: Show HUD status when dead, if we are eaten X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aebf59178f4cbf92afb01044c80276a448e7b414;p=voretournament%2Fvoretournament.git Show HUD status when dead, if we are eaten --- diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 94c038e6..edda2244 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -1595,6 +1595,38 @@ float race_CheckName(string net_name) { // Does the name already exist in rankin return 0; } +float GetAmmoStat(float i) +{ + switch(i) + { + case 0: return STAT_FUEL; + default: return -1; + } +} + +float GetAmmoItemCode(float i) +{ + switch(i) + { + case 0: return IT_FUEL; + default: return -1; + } +} + +string GetAmmoPicture(float i) +{ + switch(i) + { + case 0: + if(getstati(STAT_ITEMS) & IT_FUEL_REGEN) + return "gfx/hud/sb_fuel_regen"; + else + return "gfx/hud/sb_fuel"; + default: + return ""; + } +} + float race_status_time; float race_status_prev; string race_status_name_prev; @@ -1891,6 +1923,110 @@ void Sbar_Score() } } +void Sbar_Status() +{ + vector bottom; + bottom_x = vid_conwidth/2; + bottom_y = vid_conheight; + bottom_z = 0; + + float armor, health, x, a; + armor = getstati(STAT_ARMOR); + health = getstati(STAT_HEALTH); + + float stat_items; + stat_items = getstati(STAT_ITEMS); + + vector health_pos, armor_pos, pos; + health_pos = bottom - '43 58 0'; + armor_pos = bottom - '43 68 0'; + + if (cvar("viewsize") <= 100) { + if (teamplay) + drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color + else { + // allow for custom HUD colors in non-teamgames + color_x = cvar("sbar_color_bg_r"); + color_y = cvar("sbar_color_bg_g"); + color_z = cvar("sbar_color_bg_b"); + + drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL); + } + } + + // armor + x = armor; + if (x > 0) + { + drawpic(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5; + Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + } + + // health + x = health; + drawpic(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5; + Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + + // ammo + pos_x = bottom_x + 140; + pos_y = bottom_y - 20; + + float weapon_clipload, weapon_clipsize; + vector ammo_pos_offset; + + // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon + if(stat_items & IT_JETPACK && button_jetpack) + { + a = getstati(GetAmmoStat(0)); // how much fuel do we have? + drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5; + Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + else + { + float i; + for (i = 0; i < 1; ++i) + { + if (stat_items & GetAmmoItemCode(i)) + { + a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i? + drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE); + // if the weapon we're holding is reloadable, show both its ammo and load + if(weapon_clipsize) + { + weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD); + if(weapon_clipload < 0) // we're reloading + { + ammo_pos_offset = '1 0 0' * stringwidth("- -", FALSE, '16 16 0') * 0.5; + drawstring(pos - '118 23 0' - ammo_pos_offset, "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + else + { + ammo_pos_offset = '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '16 16 0') * 0.5; + Sbar_DrawXNum(pos - '118 23 0' - ammo_pos_offset, weapon_clipload, 2, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '12 12 0') * 0.5; + Sbar_DrawXNum(pos - '118 7 0' - ammo_pos_offset, a, 3, 0, 12, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + else + { + ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5; + Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + } + } + } + + // weapon icon + entity e; + e = get_weaponinfo(activeweapon); + if (e && e.netname != "" && e.netname != "N/A") + drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); +} + void Sbar_Timer() { float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft; @@ -2639,38 +2775,6 @@ void drawstringcenter(vector position, string text, vector scale, vector rgb, fl drawstring(position, text, scale, rgb, alpha, flag); } -float GetAmmoStat(float i) -{ - switch(i) - { - case 0: return STAT_FUEL; - default: return -1; - } -} - -float GetAmmoItemCode(float i) -{ - switch(i) - { - case 0: return IT_FUEL; - default: return -1; - } -} - -string GetAmmoPicture(float i) -{ - switch(i) - { - case 0: - if(getstati(STAT_ITEMS) & IT_FUEL_REGEN) - return "gfx/hud/sb_fuel_regen"; - else - return "gfx/hud/sb_fuel"; - default: - return ""; - } -} - void Sbar_Reset (void) { // reset gametype specific icons @@ -2744,8 +2848,7 @@ void Sbar_Draw (void) sbar_color_bg_team = cvar("sbar_color_bg_team"); float weapon_stats; - float x, fade; - float stat_items, stat_weapons; + float fade; weapon_stats = getstati(STAT_DAMAGE_HITS); weapon_number = weapon_stats & 63; @@ -2971,6 +3074,8 @@ void Sbar_Draw (void) Sbar_DrawScoreboard(); Sbar_Score(); Sbar_Timer(); + if(getstati(STAT_VORE_EATEN)) + Sbar_Status(); Sbar_Reset(); @@ -2982,12 +3087,6 @@ void Sbar_Draw (void) Sbar_DrawAccuracyStats(); else Sbar_DrawScoreboard(); - float armor, health; - armor = getstati(STAT_ARMOR); - health = getstati(STAT_HEALTH); - - stat_items = getstati(STAT_ITEMS); - stat_weapons = getstati(STAT_WEAPONS); fade = 3.2 - 2 * (time - weapontime); fade = bound(0.7, fade, 1); @@ -3097,97 +3196,8 @@ void Sbar_Draw (void) Sbar_PrintStomachboardItemPred(bottomleft - '-76 150 0', pred); } - if (cvar("viewsize") <= 100) { - if (teamplay) - drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color - else { - // allow for custom HUD colors in non-teamgames - color_x = cvar("sbar_color_bg_r"); - color_y = cvar("sbar_color_bg_g"); - color_z = cvar("sbar_color_bg_b"); - - drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL); - } - } - - vector health_pos, armor_pos; - health_pos = bottom - '43 58 0'; - armor_pos = bottom - '43 68 0'; - - // armor - x = armor; - if (x > 0) - { - drawpic(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5; - Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); - } - - // health - x = health; - drawpic(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5; - Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); - - // ammo - pos_x = bottom_x + 140; - pos_y = bottom_y - 20; - - float weapon_clipload, weapon_clipsize; - vector ammo_pos_offset; - - // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon - if(stat_items & IT_JETPACK && button_jetpack) - { - a = getstati(GetAmmoStat(0)); // how much fuel do we have? - drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5; - Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } - else - { - float i; - for (i = 0; i < 1; ++i) - { - if (stat_items & GetAmmoItemCode(i)) - { - a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i? - drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE); - - // if the weapon we're holding is reloadable, show both its ammo and load - if(weapon_clipsize) - { - weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD); - if(weapon_clipload < 0) // we're reloading - { - ammo_pos_offset = '1 0 0' * stringwidth("- -", FALSE, '16 16 0') * 0.5; - drawstring(pos - '118 23 0' - ammo_pos_offset, "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } - else - { - ammo_pos_offset = '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '16 16 0') * 0.5; - Sbar_DrawXNum(pos - '118 23 0' - ammo_pos_offset, weapon_clipload, 2, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } - ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '12 12 0') * 0.5; - Sbar_DrawXNum(pos - '118 7 0' - ammo_pos_offset, a, 3, 0, 12, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } - else - { - ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5; - Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } - } - } - } - - // weapon icon - entity e; - e = get_weaponinfo(activeweapon); - if (e && e.netname != "" && e.netname != "N/A") - drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - - // draw scores, timer, and ring + // draw status, scores, timer, and ring + Sbar_Status(); Sbar_Score(); Sbar_Timer(); Sbar_Ring();