]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/sbar.qc
Value based color for the stomach board capacity indicator
[voretournament/voretournament.git] / data / qcsrc / client / sbar.qc
index 7785aa8540b99692ef885b0adfb3499987f6271f..cb86bf750d3790a53a52e3382a2d87df17f21e16 100644 (file)
@@ -122,39 +122,39 @@ void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, fl
        drawstring(pos, final_num, vsize, rgb, alpha, dflags);\r
 }\r
 \r
-void Sbar_DrawXNum_Colored (vector pos, float x, float lettersize, float alpha)\r
+vector Sbar_NumColor (float x, float center)\r
 {\r
-       if(x > 200) {\r
+       if(x > center*2) {\r
                color_x = 0;\r
                color_y = 1;\r
                color_z = 0;\r
        }\r
-       else if(x > 150) {\r
-               color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0\r
-               color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1\r
+       else if(x > center*1.5) {\r
+               color_x = 0.4 - (x-center*1.5)*0.02 * 0.4; //red value between 0.4 -> 0\r
+               color_y = 0.9 + (x-center*1.5)*0.02 * 0.1; // green value between 0.9 -> 1\r
                color_z = 0;\r
        }\r
-       else if(x > 100) {\r
-               color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4\r
-               color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9\r
-               color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0\r
+       else if(x > center*1) {\r
+               color_x = 1 - (x-center*1)*0.02 * 0.6; //red value between 1 -> 0.4\r
+               color_y = 1 - (x-center*1)*0.02 * 0.1; // green value between 1 -> 0.9\r
+               color_z = 1 - (x-center*1)*0.02; // blue value between 1 -> 0\r
        }\r
-       else if(x > 50) {\r
+       else if(x > center*0.5) {\r
                color_x = 1;\r
                color_y = 1;\r
-               color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1\r
+               color_z = 0.2 + (x-center*0.5)*0.02 * 0.8; // blue value between 0.2 -> 1\r
        }\r
-       else if(x > 20) {\r
+       else if(x > center*0.25) {\r
                color_x = 1;\r
-               color_y = (x-20)*90/27/100; // green value between 0 -> 1\r
-               color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2\r
+               color_y = (x-center*0.25)*90/27/100; // green value between 0 -> 1\r
+               color_z = (x-center*0.25)*90/27/100 * 0.2; // blue value between 0 -> 0.2\r
        }\r
        else {\r
                color_x = 1;\r
                color_y = 0;\r
                color_z = 0;\r
        }\r
-       Sbar_DrawXNum(pos, x, 3, 0, lettersize, color, alpha, DRAWFLAG_NORMAL);\r
+       return color;\r
 }\r
 \r
 void Cmd_Sbar_SetFields(float argc);\r
@@ -932,7 +932,7 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl)
                {\r
                        if(getstati(STAT_VORE_EATEN))\r
                        {\r
-                               if(teamplay && GetPlayerColor(pl.entnum - 1) == GetPlayerColor(player_localentnum - 1)) // same team\r
+                               if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team\r
                                        hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
                                else\r
                                        hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
@@ -1986,7 +1986,7 @@ void Sbar_Ring()
        string text1_msg, text2_msg;\r
 \r
        ring_pos_x = vid_conwidth / 2;\r
-       ring_pos_y = vid_conheight / 1.375;\r
+       ring_pos_y = vid_conheight - vid_conheight / 3.5;\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
@@ -2001,22 +2001,16 @@ void Sbar_Ring()
                        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
@@ -2031,15 +2025,11 @@ void Sbar_Ring()
                        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 = "Being swallowed...";\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
@@ -2220,8 +2210,8 @@ void centerprint(string strMessage)
        havail = vid_conheight;\r
        if(cvar("con_chatpos") < 0)\r
                havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat\r
-       if(havail > vid_conheight - 70)\r
-               havail = vid_conheight - 70; // avoid overlapping HUD\r
+       if(havail > vid_conheight / 4)\r
+               havail = vid_conheight / 4; // avoid overlapping HUD\r
 \r
        centerprint_start_x = 0;\r
 \r
@@ -3023,7 +3013,7 @@ void Sbar_Draw (void)
                        string hl_string;\r
                        if(getstati(STAT_VORE_EATEN))\r
                        {\r
-                               if(teamplay && GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1)) // same team\r
+                               if(teamplay && (GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(player_localentnum - 1) || GetPlayerColor(getstati(STAT_VORE_EATEN) - 1) == GetPlayerColor(spectatee_status - 1))) // same team\r
                                        hl_color = stov(cvar_string("sbar_stomachboard_color2"));\r
                                else\r
                                        hl_color = stov(cvar_string("sbar_stomachboard_color3"));\r
@@ -3037,27 +3027,38 @@ void Sbar_Draw (void)
                        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
+                       float stomach_load, stomach_maxload; // shows the predator's stomach load when we are eaten, and ours otherwise\r
+                       stomach_load = getstati(STAT_VORE_LOAD);\r
+                       stomach_maxload = getstati(STAT_VORE_MAXLOAD);\r
 \r
                        vector status_pos;\r
-                       string status_text;\r
-                       status_text = strcat(ftos(bound(0, stomach_load, 9)), "/", ftos(bound(0, g_balance_vore_swallow_limit, 9)));\r
-                       status_pos = bottomleft - '-43 171 0';\r
-                       status_pos -= '1 0 0' * stringwidth(status_text, FALSE, '22 22 0') * 0.5;\r
-                       drawstring(status_pos, status_text, '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-\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
-                       else if(!stomach_load)\r
-                               drawstring(bottomleft - '-76 142 0', "stomach empty", '12 12 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       string status_text, status_color;\r
+                       float status_size;\r
+                       status_color = rgb_to_hexcolor(Sbar_NumColor(stomach_maxload, cvar("g_balance_vore_load_pred_capacity")));\r
+                       if(stomach_load)\r
+                       {\r
+                               status_text = strcat(ftos(stomach_load), "^8/", status_color, ftos(stomach_maxload), "%");\r
+                               status_pos = bottomleft - '-44 168 0';\r
+                               status_size = 16;\r
+                       }\r
                        else\r
-                               drawstring(bottomleft - '-76 142 0', "stomach has prey", '12 12 0', '0.75 1 0.75', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       {\r
+                               status_text = strcat(status_color, ftos(stomach_maxload), "%");\r
+                               status_pos = bottomleft - '-44 170 0';\r
+                               status_size = 20;\r
+                       }\r
+                       status_pos -= '1 0 0' * stringwidth(status_text, TRUE, '1 0 0' * status_size) * 0.5;\r
+                       drawcolorcodedstring(status_pos, status_text, '1 1 0' * status_size, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+\r
+                       if(getstati(STAT_VORE_DIGESTING)) // we are currently digesting\r
+                               drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       else if(stomach_load) // we can digest at this time\r
+                               drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0.25 0.25 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       else // we cannot digest at this time\r
+                               drawpic(bottomleft - '-35 149 0', "gfx/hud/sb_digestion", '16 16 0', '0.25 0 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                        // draw the stomach board player list\r
-                       entity pl;\r
+                       entity pl, pred;\r
                        float f;\r
 \r
                        pos = bottomleft;\r
@@ -3082,10 +3083,18 @@ void Sbar_Draw (void)
                                        pos_y += 1.1 * sbar_fontsize_y;\r
                                }\r
 \r
+                               // set the predator's name\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
+                                       if(pl.sv_entnum == getstati(STAT_VORE_EATEN) - 1)\r
+                                               pred = pl;\r
+                               }\r
+                               else if(pl.sv_entnum == player_localentnum - 1 || pl.sv_entnum == spectatee_status - 1)\r
+                                       pred = pl; // show us or the spectated player\r
                        }\r
+\r
+                       // draw the predator's name\r
+                       Sbar_PrintStomachboardItemPred(bottomleft - '-76 150 0', pred);\r
                }\r
 \r
                if (cvar("viewsize") <= 100) {\r
@@ -3111,14 +3120,14 @@ void Sbar_Draw (void)
                {\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_Colored(armor_pos, x, 12, sbar_alpha_fg);\r
+                       Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x, 100), 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_Colored(health_pos, x, 22, sbar_alpha_fg);\r
+               Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x, 100), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                // ammo\r
                pos_x = bottom_x + 140;\r