]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/sbar.qc
eater -> predator, because that's a more correct word
[voretournament/voretournament.git] / data / qcsrc / client / sbar.qc
index 03e5c04c43b4c22ab5fe11be439fa5b2837e545a..9b3db2e22a2bf0087c687e560758dfad1eaf43a1 100644 (file)
@@ -29,7 +29,6 @@ float ps_primary, ps_secondary;
 float ts_primary, ts_secondary;\r
 \r
 vector color;\r
-float SCOREBOARD_OFFSET = 50;\r
 \r
 void CSQC_kh_hudreset();\r
 void CSQC_kh_hud();\r
@@ -509,14 +508,15 @@ void Cmd_Sbar_SetFields(float argc)
                        sbar_field[sbar_num_fields] = SP_SEPARATOR;\r
                        have_separator = 1;\r
                } else {\r
+                       if(gametype == GAME_RPG)\r
+                               return;\r
+\r
                        for(j = 0; j < MAX_SCORE; ++j)\r
                                if(str == strtolower(scores_label[j]))\r
                                        goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"\r
 :notfound\r
-                       if(str == "frags" && !(gametype == GAME_RPG))\r
-                       {\r
+                       if(str == "frags")\r
                                j = SP_FRAGS;\r
-                       }\r
                        else\r
                        {\r
                                if not(nocomplain)\r
@@ -963,18 +963,15 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl)
        for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
        {\r
                field = -fieldcounter;\r
-               if(field == SP_SEPARATOR)\r
-                       break;\r
-\r
                str = Sbar_GetStomachField(pl, field);\r
 \r
                // row highlighting\r
                if(field == ST_HIGHLIGHT)\r
                {\r
-                       if(getstati(STAT_STOMACH_EATEN))\r
-                               drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color2")), cvar("sbar_stomachboard_highlight_alpha"), DRAWFLAG_NORMAL);\r
+                       if(getstati(STAT_VORE_EATEN))\r
+                               drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color2")), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        else\r
-                               drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color1")), cvar("sbar_stomachboard_highlight_alpha"), DRAWFLAG_NORMAL);\r
+                               drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color1")), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                if(field == ST_NAME) {\r
@@ -984,7 +981,7 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl)
                        drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                        pos_x += 24;\r
-                       drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       drawcolorcodedstring(pos, textShortenToWidth(str, 138, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                if(field == ST_HEALTH)\r
@@ -1006,7 +1003,7 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl)
 float fieldcounter2;\r
 void Sbar_PrintStomachboardItemPred(vector pos, entity pl)\r
 {\r
-       // shows the name of our eater\r
+       // shows the name of our predator\r
 \r
        string str;\r
        float f, field, field_number;\r
@@ -1015,9 +1012,6 @@ void Sbar_PrintStomachboardItemPred(vector pos, entity pl)
        for(fieldcounter2 = 1; fieldcounter2 <= field_number; ++fieldcounter2)\r
        {\r
                field = -fieldcounter2;\r
-               if(field == SP_SEPARATOR)\r
-                       break;\r
-\r
                str = Sbar_GetStomachFieldPred(pl, field);\r
 \r
                if(field == STP_NAME) {\r
@@ -1027,7 +1021,7 @@ void Sbar_PrintStomachboardItemPred(vector pos, entity pl)
                        drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                        pos_x += 24;\r
-                       drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       drawcolorcodedstring(pos, textShortenToWidth(str, 122, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
        }\r
 }\r
@@ -1390,7 +1384,7 @@ void Sbar_DrawScoreboard()
        sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);\r
 \r
        xmin = 0.5 * (vid_conwidth - sbwidth);\r
-       ymin = SCOREBOARD_OFFSET;\r
+       ymin = cvar("sbar_scoreboard_offset");\r
 \r
        xmax = vid_conwidth - xmin;\r
        ymax = vid_conheight - 0.2*vid_conheight;\r
@@ -2428,7 +2422,7 @@ void Sbar_DrawAccuracyStats()
 \r
        drawfont = sbar_bigfont;\r
        pos_x = 0;\r
-       pos_y = SCOREBOARD_OFFSET;\r
+       pos_y = cvar("sbar_scoreboard_offset");\r
        pos_z = 0;\r
        drawstringcenter(pos, "Weapon Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
@@ -2454,10 +2448,10 @@ void Sbar_DrawAccuracyStats()
                return;\r
        }\r
 \r
-       float top_border_hitscan = SCOREBOARD_OFFSET + 55;  // position where the hitscan row starts: pixels down the screen\r
+       float top_border_hitscan = cvar("sbar_scoreboard_offset") + 55;  // position where the hitscan row starts: pixels down the screen\r
        Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * top_border_hitscan);\r
 \r
-       float top_border_splash = SCOREBOARD_OFFSET + 175;  // position where the splash row starts: pixels down the screen\r
+       float top_border_splash = cvar("sbar_scoreboard_offset") + 175;  // position where the splash row starts: pixels down the screen\r
        Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * top_border_splash);\r
 \r
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)\r
@@ -2591,7 +2585,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 +2594,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 +2603,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
@@ -2637,7 +2631,7 @@ vector stomachstatus_colorfade_current;
 vector StomachStatus_ColorFade(vector target_color)\r
 {\r
        local float step;\r
-       step = cvar("sbar_stomachboard_status_fade");\r
+       step = cvar("sbar_stomachboard_status_fade") * frametime;\r
 \r
        if(stomachstatus_colorfade_current_x >= target_color_x + step)\r
                stomachstatus_colorfade_current_x -= step;\r
@@ -2955,25 +2949,25 @@ void Sbar_Draw (void)
                        }\r
                }\r
 \r
-               if(getstati(STAT_STOMACH_EATEN))\r
+               if(getstati(STAT_VORE_EATEN))\r
                {\r
-                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color2"))), cvar("sbar_stomachboard_status_alpha"), DRAWFLAG_NORMAL);\r
+                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color2"))), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        drawstring(bottomleft - '-80 172 0', "predator:", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
                else\r
                {\r
-                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color1"))), cvar("sbar_stomachboard_status_alpha"), DRAWFLAG_NORMAL);\r
+                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color1"))), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        drawstring(bottomleft - '-80 172 0', "self:", '10 10 0', ' 1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                float stomach_load;\r
-               stomach_load = getstati(STAT_STOMACH_LOAD); // shows the predator's stomach load when we are eaten, and ours otherwise\r
+               stomach_load = getstati(STAT_VORE_LOAD); // shows the predator's stomach load when we are eaten, and ours otherwise\r
 \r
                Sbar_DrawXNum(bottomleft - '-18 170 0', bound(0, stomach_load, 9), 1, 0, 22, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                drawstring(bottomleft - '-40 170 0', "/", '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                Sbar_DrawXNum(bottomleft - '-50 170 0', bound(0, g_balance_vore_swallow_limit, 9), 1, 0, 22, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
-               if(getstati(STAT_STOMACH_DIGESTING))\r
+               if(getstati(STAT_VORE_DIGESTING))\r
                        drawstring(bottomleft - '-76 142 0', "stomach digesting", '12 12 0', '1 0.5 0.5', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                else if(stomach_load == g_balance_vore_swallow_limit)\r
                        drawstring(bottomleft - '-76 142 0', "stomach full", '12 12 0', '0.5 1 0.5', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
@@ -2992,14 +2986,14 @@ void Sbar_Draw (void)
                        if(pl.team == COLOR_SPECTATOR)\r
                                continue;\r
 \r
-                       if(getstati(STAT_STOMACH_EATEN))\r
-                               f = pl.pleater == getstati(STAT_STOMACH_EATEN);\r
+                       if(getstati(STAT_VORE_EATEN))\r
+                               f = pl.plpredator == getstati(STAT_VORE_EATEN);\r
                        else\r
                        {\r
                                if(spectatee_status)\r
-                                       f = pl.pleater == spectatee_status;\r
+                                       f = pl.plpredator == spectatee_status;\r
                                else\r
-                                       f = pl.pleater == player_localentnum;\r
+                                       f = pl.plpredator == player_localentnum;\r
                        }\r
 \r
                        if(f)\r
@@ -3008,8 +3002,8 @@ void Sbar_Draw (void)
                                pos_y += 1.25 * sbar_fontsize_y;\r
                        }\r
 \r
-                       if(getstati(STAT_STOMACH_EATEN))\r
-                       if(pl.sv_entnum == getstati(STAT_STOMACH_EATEN) - 1)\r
+                       if(getstati(STAT_VORE_EATEN))\r
+                       if(pl.sv_entnum == getstati(STAT_VORE_EATEN) - 1)\r
                                Sbar_PrintStomachboardItemPred(bottomleft - '-76 156 0', pl);\r
                }\r
 \r
@@ -3036,24 +3030,36 @@ 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
                e = get_weaponinfo(activeweapon);\r
-               //if (e && e.netname != "")\r
-                       dprint(strcat("XX_", e.netname, "_YY\n"));\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 and timer\r
                Sbar_Score();\r
@@ -3069,6 +3075,16 @@ void Sbar_Draw (void)
                        CSQC_ctf_hud();\r
                else if(gametype == GAME_CTS || gametype == GAME_RACE)\r
                        CSQC_race_hud();\r
+\r
+               // draw the canleave message\r
+               if(getstati(STAT_VORE_CANLEAVE))\r
+               if not(spectatee_status) // this message doesn't address spectated players\r
+               {\r
+                       s = strcat("^7Press ^3", getcommandkey("jump", "+jump"), " ^7to exit");\r
+                       pos_x = bottom_x - stringwidth(s, TRUE, '0 0 0') * 16 / 2;\r
+                       pos_y = bottom_y - 120;\r
+                       drawcolorcodedstring(pos, s, '16 16 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               }\r
        }\r
        return;\r
 }\r