]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/sbar.qc
Change "Being swallowed..." to "Swallowed..." on the HUD ring.
[voretournament/voretournament.git] / data / qcsrc / client / sbar.qc
index c041ce66cfcb27663448985cf205035f3626e7c8..f8d7eefc002920842e0e5a6e91d46bc9e10bc9e6 100644 (file)
@@ -72,7 +72,7 @@ vector Sbar_AccuracyColor(float accuracy)
 void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags)\r
 {\r
        float l;\r
-       string str, tmp, l_length;\r
+       string str, tmp, l_length, final_num;\r
        float minus, plus;\r
        vector vsize;\r
 \r
@@ -114,16 +114,12 @@ void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, fl
        }\r
 \r
        if(minus)\r
-       {\r
-               drawstring(pos, "-", vsize, rgb, alpha, dflags);\r
-               pos_x += lettersize / 2;\r
-       } else if(plus)\r
-       {\r
-               drawstring(pos, "+", vsize, rgb, alpha, dflags);\r
-               pos_x += lettersize / 2;\r
-       }\r
+               final_num = "-";\r
+       else if(plus)\r
+               final_num = "+";\r
 \r
-       drawstring(pos, str, vsize, rgb, alpha, dflags);\r
+       final_num = strcat(final_num, str);\r
+       drawstring(pos, final_num, vsize, rgb, alpha, dflags);\r
 }\r
 \r
 void Sbar_DrawXNum_Colored (vector pos, float x, float lettersize, float alpha)\r
@@ -923,6 +919,7 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl)
 \r
        string str;\r
        float f, field, field_number;\r
+       vector hl_color;\r
        field_number = 3; // the number of components each row has\r
 \r
        for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
@@ -934,9 +931,15 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl)
                if(field == ST_HIGHLIGHT)\r
                {\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
+                       {\r
+                               if(teamplay && GetPlayerColor(pl.entnum - 1) == GetPlayerColor(player_localentnum - 1)) // same team\r
+                                       hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
+                               else\r
+                                       hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
+                       }\r
                        else\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
+                               hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
+                       drawfill(pos - '0 0 0', '193 11 0', hl_color, cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                if(field == ST_NAME) {\r
@@ -1653,7 +1656,7 @@ void Sbar_Score()
 {\r
        float score, distribution, leader;\r
        vector score_pos, secondary_score_pos, race_score_pos, distribution_color;\r
-       string racetime;\r
+       string racetime, secondary_racetime;\r
        entity tm, pl, me;\r
        me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];\r
 \r
@@ -1679,7 +1682,7 @@ void Sbar_Score()
                score = me.(scores[ps_primary]);\r
 \r
                float racemin, racesec, racemsec;\r
-               float distsec, distmsec, minusplus;\r
+               float distsec, distmsec;\r
                string s_racemin, s_racesec, s_racemsec;\r
                \r
                racemin = floor(score/(60 * TIME_FACTOR));\r
@@ -1700,28 +1703,29 @@ void Sbar_Score()
                        if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)\r
                                distmsec = fabs(distribution);\r
                        else {\r
-                               distsec = floor(fabs(distribution)/TIME_FACTOR);\r
-                               distmsec = fabs(distribution) - distsec*TIME_FACTOR;\r
-                               if (distribution < 0)\r
-                                       distsec = -distsec;\r
+                               distsec = floor(fabs(distribution) / TIME_FACTOR);\r
+                               distmsec = fabs(distribution) - distsec * TIME_FACTOR;\r
                        }\r
 \r
-                       if (distribution <= 0) {\r
+                       if (distribution < 0) {\r
                                distribution_color = '0 1 0';\r
-                               minusplus = 1; // minusplus 1: always prefix with minus sign\r
+                               secondary_racetime = "-"; // always prefix with minus sign\r
                        }\r
-                       else {\r
+                       else if (distribution > 0) {\r
                                distribution_color = '1 0 0';\r
-                               minusplus = 2; // minusplus 1: always prefix with plus sign\r
+                               secondary_racetime = "+"; // minusplus 1: always prefix with plus sign\r
                        }\r
-                       Sbar_DrawXNum(score_pos + '222 -6 0' - '14 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 14, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-                       Sbar_DrawXNum(score_pos + '222 6 0' - '14 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 14, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       else\r
+                               distribution_color = '1 1 1';\r
+\r
+                       secondary_racetime = strcat(secondary_racetime, ftos(distsec), ".", ftos(distmsec));\r
+                       drawstring(score_pos + '222 0 0' - '14 0 0', secondary_racetime, '14 14 0', distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                racetime = strcat(s_racemin, " : ", s_racesec, " . ", s_racemsec);\r
                race_score_pos = top + '0 0 0';\r
                race_score_pos -= '1 0 0' * stringwidth(racetime, FALSE, '30 30 0') * 0.5;\r
-               drawstring(race_score_pos, racetime, '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);\r
+               drawstring(race_score_pos, racetime, '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
        } else if (!teamplay) { // non-teamgames, except race/cts\r
                // me vector := [team/connected frags id]\r
@@ -1747,7 +1751,7 @@ void Sbar_Score()
                else\r
                        distribution_color = '1 0 0';\r
                \r
-               Sbar_DrawXNum(secondary_score_pos, distribution, 6, 0, 16, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               Sbar_DrawXNum(secondary_score_pos, distribution, 6, 3, 16, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                Sbar_DrawXNum(score_pos, score, 6, 0, 34, distribution_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
        } else { // teamgames\r
                float max_fragcount;\r
@@ -1765,11 +1769,11 @@ void Sbar_Score()
                        if(tm.team == myteam) {\r
                                if (max_fragcount == score)\r
                                        leader = 1;\r
-                               Sbar_DrawXNum(score_pos, score, 6, 0, 34, GetTeamRGB(tm.team) * 0.4 + '0.6 0.6 0.6', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               Sbar_DrawXNum(score_pos, score, 6, 0, 34, GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        } else {\r
                                if (max_fragcount == score)\r
                                        leader = 1;\r
-                               Sbar_DrawXNum(secondary_score_pos, score, 6, 0, 16, GetTeamRGB(tm.team) * 0.4 + '0.6 0.6 0.6', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               Sbar_DrawXNum(secondary_score_pos, score, 6, 3, 16, GetTeamRGB(tm.team), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                                secondary_score_pos = secondary_score_pos + '0 16 0';\r
                        }\r
                }\r
@@ -1940,14 +1944,12 @@ void Sbar_Timer()
        } else {\r
                minutes = minutesLeft;\r
                seconds = secondsLeft;\r
-               if (minutes == 0)\r
-                       bgpos_x = topright_x - (58 + 7 + 12) * scale;\r
-               else if (minutes < 10) // nudge the timer background left if more digits are drawn\r
-                       bgpos_x = topright_x - (66 + 17 + 12) * scale;\r
+               if (minutes < 10) // nudge the timer background left if more digits are drawn\r
+                       bgpos_x = topright_x - (54 + 17 + 12) * scale;\r
                else if (minutes < 100)\r
-                       bgpos_x = topright_x - (74 + 17 + 12) * scale;\r
+                       bgpos_x = topright_x - (62 + 17 + 12) * scale;\r
                else\r
-                       bgpos_x = topright_x - (82 + 17 + 12) * scale;\r
+                       bgpos_x = topright_x - (70 + 17 + 12) * scale;\r
                bgpos_y = 0;\r
                bgpos_z = 0;\r
        }\r
@@ -1965,9 +1967,7 @@ void Sbar_Timer()
        }\r
 \r
        drawpic(topright - ('19 0 0' + '3 0 0' - '0 2 0'), "gfx/hud/sb_time", '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-       if(minutesLeft >= 1 || cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {\r
-               finaltime = strcat(ftos(minutes), ":");\r
-       }\r
+       finaltime = strcat(ftos(minutes), ":");\r
        if(seconds < 10)\r
                finaltime = strcat(finaltime, "0", ftos(seconds));\r
        else\r
@@ -1978,6 +1978,94 @@ void Sbar_Timer()
        drawstring(pos, finaltime, 18 * scale * '1 1 0', timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 }\r
 \r
+void Sbar_Ring()\r
+{\r
+       vector ring_pos, ring1_color, ring2_color;\r
+       vector text_pos, text1_size, text2_size;\r
+       float ring1_alpha, ring2_alpha, ring1_size, ring1_clip, ring2_size, ring2_clip;\r
+       string text1_msg, text2_msg;\r
+\r
+       ring_pos_x = vid_conwidth / 2;\r
+       ring_pos_y = vid_conheight / 1.375;\r
+       ring1_size = cvar("sbar_ring1_scale");\r
+       ring2_size = cvar("sbar_ring2_scale");\r
+       ring1_alpha = sbar_alpha_fg * cvar("sbar_ring1_alpha");\r
+       ring2_alpha = sbar_alpha_fg * cvar("sbar_ring2_alpha");\r
+       text1_size = '1 1 0' * cvar("sbar_ring1_text_scale");\r
+       text2_size = '1 1 0' * cvar("sbar_ring2_text_scale");\r
+\r
+       switch(getstati(STAT_SBRING1_TYPE))\r
+       {\r
+               case 0:\r
+                       // ring disabled\r
+                       break;\r
+               case 1:\r
+                       // ring shows predator swallow progress, fills with progress\r
+                       if not(cvar("sbar_ring1_info_swallowprogress_pred"))\r
+                               break;\r
+                       ring1_color = '0.5 1 0.5';\r
+                       text1_msg = "Swallowing...";\r
+                       break;\r
+               case 2:\r
+                       // ring shows vore system delay, empties with progress\r
+                       if not(cvar("sbar_ring1_info_voredelay"))\r
+                               break;\r
+                       ring1_color = '0.5 0.5 1';\r
+                       text1_msg = "Vore delay";\r
+                       break;\r
+               case 3:\r
+                       // ring shows stomach kick delay, empties with progress\r
+                       if not(cvar("sbar_ring1_info_kickdelay"))\r
+                               break;\r
+                       ring1_color = '1 1 0.5';\r
+                       text1_msg = "Kick delay";\r
+                       break;\r
+               default:\r
+                       print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));\r
+                       break;\r
+       }\r
+       switch(getstati(STAT_SBRING2_TYPE))\r
+       {\r
+               case 0:\r
+                       // ring disabled\r
+                       break;\r
+               case 1:\r
+                       // ring shows prey swallow progress, fills with progress\r
+                       if not(cvar("sbar_ring2_info_swallowprogress_prey"))\r
+                               break;\r
+                       ring2_color = '1 0.5 0.5';\r
+                       text2_msg = "Swallowed...";\r
+                       break;\r
+               case 2:\r
+                       // ring shows regurgitation preparing, fills with progress\r
+                       if not(cvar("sbar_ring2_info_regurgitateprepare"))\r
+                               break;\r
+                       ring2_color = '1 0.5 1';\r
+                       text2_msg = "Regurgitating...";\r
+                       break;\r
+               default:\r
+                       print(strcat("^1Error:^7 Unknown ring type: ", ftos(getstati(STAT_SBRING1_TYPE)), "\n"));\r
+                       break;\r
+       }\r
+       ring1_clip = getstatf(STAT_SBRING1_CLIP);\r
+       ring2_clip = getstatf(STAT_SBRING2_CLIP);\r
+\r
+       if(text1_msg != "" && cvar("sbar_ring1"))\r
+       {\r
+               DrawCircleClippedPic(ring_pos, ring1_size, "gfx/hud/sb_ring.tga", ring1_clip, ring1_color, ring1_alpha, DRAWFLAG_ADDITIVE);\r
+               text_pos_x = ring_pos_x - stringwidth(text1_msg, FALSE, text1_size) / 2;\r
+               text_pos_y = ring_pos_y - ring1_size / 2;\r
+               drawstring(text_pos, text1_msg, text1_size, ring1_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+       }\r
+       if(text2_msg != "" && cvar("sbar_ring2"))\r
+       {\r
+               DrawCircleClippedPic(ring_pos, ring2_size, "gfx/hud/sb_ring.tga", ring2_clip, ring2_color, ring2_alpha, DRAWFLAG_ADDITIVE);\r
+               text_pos_x = ring_pos_x - stringwidth(text2_msg, FALSE, text2_size) / 2;\r
+               text_pos_y = ring_pos_y + ring1_size / 2;\r
+               drawstring(text_pos, text2_msg, text2_size, ring2_color, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+       }\r
+}\r
+\r
 void CSQC_Strength_Timer() {\r
        vector pos;\r
        vector bottomright;\r
@@ -2584,8 +2672,13 @@ string GetAmmoPicture(float i)
 {\r
        switch(i)\r
        {\r
-               case 0: return "gfx/hud/sb_fuel";\r
-               default: return "";\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
@@ -2926,16 +3019,23 @@ void Sbar_Draw (void)
                                }\r
                        }\r
 \r
+                       vector hl_color;\r
+                       string hl_string;\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") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-                               drawstring(bottomleft - '-80 173 0', "predator:", '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               if(teamplay && GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1)) // same team\r
+                                       hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
+                               else\r
+                                       hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
+                               hl_string = "predator:";\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") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-                               drawstring(bottomleft - '-80 173 0', "self:", '11 11 0', ' 1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               hl_color = stov(cvar_string("sbar_stomachboard_color1"));\r
+                               hl_string = "self:";\r
                        }\r
+                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(hl_color), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       drawstring(bottomleft - '-80 173 0', hl_string, '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                        float stomach_load;\r
                        stomach_load = getstati(STAT_VORE_LOAD); // shows the predator's stomach load when we are eaten, and ours otherwise\r
@@ -3078,9 +3178,10 @@ void Sbar_Draw (void)
                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
+               // draw scores, timer, and ring\r
                Sbar_Score();\r
                Sbar_Timer();\r
+               Sbar_Ring();\r
 \r
                // draw strength/invincibility icon and timer\r
                CSQC_Strength_Timer();\r