]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/sbar.qc
Some improvements to the sbar ammo code and other fixes
[voretournament/voretournament.git] / data / qcsrc / client / sbar.qc
index 527276fc3ace448680868c3ad271b1867fa30bbf..110d674abb050e1641947921b1e58cabbb214e46 100644 (file)
@@ -2591,7 +2591,7 @@ float GetAmmoStat(float i)
 {\r
        switch(i)\r
        {\r
-               case 1: return STAT_FUEL;\r
+               case 0: return STAT_FUEL;\r
                default: return -1;\r
        }\r
 }\r
@@ -2600,7 +2600,7 @@ float GetAmmoItemCode(float i)
 {\r
        switch(i)\r
        {\r
-               case 1: return IT_FUEL;\r
+               case 0: return IT_FUEL;\r
                default: return -1;\r
        }\r
 }\r
@@ -2609,7 +2609,7 @@ string GetAmmoPicture(float i)
 {\r
        switch(i)\r
        {\r
-               case 1: return "gfx/hud/sb_fuel";\r
+               case 0: return "gfx/hud/sb_fuel";\r
                default: return "";\r
        }\r
 }\r
@@ -3036,18 +3036,30 @@ void Sbar_Draw (void)
                if(x < 10) health_pos_x -= 11; // always center\r
                Sbar_DrawXNum_Colored(health_pos, x, 22, sbar_alpha_fg);\r
 \r
-               // fuel ammo\r
-               a = getstati(GetAmmoStat(1)); // how much fuel do we have?\r
+               // ammo\r
+               pos_x = bottom_x + 140;\r
+               pos_y = bottom_y - 20;\r
 \r
-               if (a > 0) { // if we have fuel, draw the amount\r
-                       float invincibility_time, dt;\r
-                       invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);\r
-                       dt = invincibility_time - time;\r
-                       pos_x = bottom_x + 140;\r
-                       pos_y = bottom_y - 20;\r
-                       drawpic(pos - '98 18 0', GetAmmoPicture(1), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\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
                        Sbar_DrawXNum(pos - '144 16 0', a, 3, 0, 16, '1 1 1', 0, 0, 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
+                                       Sbar_DrawXNum(pos - '144 16 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               }\r
+                       }\r
+               }\r
 \r
                // weapon icon\r
                entity e;\r