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