]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Rename minstanex to vaporizer
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 2ec7db0623025d7bc813afae95a299956a0fd63c..980a8ab4a34e6397276d7e447459e7197ac0e6b2 100644 (file)
@@ -9,7 +9,7 @@ float scoreboard_alpha_name_self;
 void drawstringright(vector, string, vector, vector, float, float);
 void drawstringcenter(vector, string, vector, vector, float, float);
 
-float SCOREBOARD_OFFSET = 50;
+const float SCOREBOARD_OFFSET = 50;
 
 // wrapper to put all possible scores titles through gettext
 string TranslateScoresLabel(string l)
@@ -36,6 +36,7 @@ string TranslateScoresLabel(string l)
                case "lives": return CTX(_("SCO^lives"));
                case "losses": return CTX(_("SCO^losses"));
                case "name": return CTX(_("SCO^name"));
+               case "sum": return CTX(_("SCO^sum"));
                case "nick": return CTX(_("SCO^nick"));
                case "objectives": return CTX(_("SCO^objectives"));
                case "pickups": return CTX(_("SCO^pickups"));
@@ -263,6 +264,7 @@ void Cmd_HUD_Help()
        print(_("^3suicides^7                 Number of suicides\n"));
        print(_("^3frags^7                    kills - suicides\n"));
        print(_("^3kd^7                       The kill-death ratio\n"));
+       print(_("^3sum^7                      frags - deaths\n"));
        print(_("^3caps^7                     How often a flag (CTF) or a key (KeyHunt) was captured\n"));
        print(_("^3pickups^7                  How often a flag (CTF) or a key (KeyHunt) or a ball (Keepaway) was picked up\n"));
        print(_("^3captime^7                  Time of fastest cap (CTF)\n"));
@@ -304,6 +306,7 @@ string HUD_DefaultColumnLayout()
        return strcat( // fteqcc sucks
                "ping pl name | ",
                "-teams,race,lms/kills +freezetag/kills -teams,lms/deaths +freezetag/deaths -teams,lms,race,ka/suicides +freezetag/suicides -race,dm,tdm,ka,freezetag/frags ", // tdm already has this in "score"
+               "+tdm/kills +tdm/deaths +tdm/suicides ",
                "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
                "+lms/lives +lms/rank ",
                "+kh/caps +kh/pushes +kh/destroyed ",
@@ -372,7 +375,7 @@ void Cmd_HUD_SetFields(float argc)
                        pattern = substring(str, 0, slash);
                        str = substring(str, slash + 1, strlen(str) - (slash + 1));
 
-                       if not(isGametypeInFilter(gametype, teamplay, FALSE, pattern))
+                       if (!isGametypeInFilter(gametype, teamplay, FALSE, pattern))
                                continue;
                }
 
@@ -387,6 +390,8 @@ void Cmd_HUD_SetFields(float argc)
                        hud_field[hud_num_fields] = SP_PL;
                } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
                        hud_field[hud_num_fields] = SP_KDRATIO;
+               } else if(str == "sum" || str == "diff" || str == "f-d") {
+                       hud_field[hud_num_fields] = SP_SUM;
                } else if(str == "name" || str == "nick") {
                        hud_field[hud_num_fields] = SP_NAME;
                        have_name = 1;
@@ -404,7 +409,7 @@ void Cmd_HUD_SetFields(float argc)
                        }
                        else
                        {
-                               if not(nocomplain)
+                               if (!nocomplain)
                                        print(sprintf("^1Error:^7 Unknown score field: '%s'\n", str));
                                continue;
                        }
@@ -442,7 +447,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_title[0] = strzone(TranslateScoresLabel("name"));
                        hud_field[0] = SP_NAME;
                        ++hud_num_fields;
-                       print(sprintf(_("fixed missing field '%s'\n"), "name"));
+                       print("fixed missing field 'name'\n");
 
                        if(!have_separator)
                        {
@@ -457,7 +462,7 @@ void Cmd_HUD_SetFields(float argc)
                                hud_field[1] = SP_SEPARATOR;
                                hud_size[1] = stringwidth("|", FALSE, hud_fontsize);
                                ++hud_num_fields;
-                               print(sprintf(_("fixed missing field '%s'\n"), "|"));
+                               print("fixed missing field '|'\n");
                        }
                }
                else if(!have_separator)
@@ -467,7 +472,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_size[hud_num_fields] = stringwidth("|", FALSE, hud_fontsize);
                        hud_field[hud_num_fields] = SP_SEPARATOR;
                        ++hud_num_fields;
-                       print(sprintf(_("fixed missing field '%s'\n"), "|"));
+                       print("fixed missing field '|'\n");
                }
                if(!have_secondary)
                {
@@ -476,7 +481,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], FALSE, hud_fontsize);
                        hud_field[hud_num_fields] = ps_secondary;
                        ++hud_num_fields;
-                       print(sprintf(_("fixed missing field '%s'\n"), scores_label[ps_secondary]));
+                       print(sprintf("fixed missing field '%s'\n", scores_label[ps_secondary]));
                }
                if(!have_primary)
                {
@@ -485,7 +490,7 @@ void Cmd_HUD_SetFields(float argc)
                        hud_size[hud_num_fields] = stringwidth(hud_title[hud_num_fields], FALSE, hud_fontsize);
                        hud_field[hud_num_fields] = ps_primary;
                        ++hud_num_fields;
-                       print(sprintf(_("fixed missing field '%s'\n"), scores_label[ps_primary]));
+                       print(sprintf("fixed missing field '%s'\n", scores_label[ps_primary]));
                }
        }
 
@@ -521,7 +526,7 @@ string HUD_GetField(entity pl, float field)
        switch(field)
        {
                case SP_PING:
-                       if not(pl.gotscores)
+                       if (!pl.gotscores)
                                return "\xEE\x82\x8D\xEE\x82\x8D\xEE\x82\x8D"; // >>> sign
                        //str = getplayerkeyvalue(pl.sv_entnum, "ping");
                        f = pl.ping;
@@ -532,7 +537,7 @@ string HUD_GetField(entity pl, float field)
                        return ftos(f);
 
                case SP_PL:
-                       if not(pl.gotscores)
+                       if (!pl.gotscores)
                                return _("N/A");
                        f = pl.ping_packetloss;
                        tmp = pl.ping_movementloss;
@@ -582,6 +587,19 @@ string HUD_GetField(entity pl, float field)
                                str = sprintf("%.1f", num/denom);
                        return str;
 
+               case SP_SUM:
+                       f = pl.(scores[SP_KILLS]);
+                       f -= pl.(scores[SP_DEATHS]);
+
+                       if(f > 0) {
+                               hud_field_rgb = '0 1 0';
+                       } else if(f == 0) {
+                               hud_field_rgb = '1 1 1';
+                       } else {
+                               hud_field_rgb = '1 0 0';
+                       }
+                       return ftos(f);
+
                default:
                        tmp = pl.(scores[field]);
                        f = scores_flags[field];
@@ -947,12 +965,11 @@ float HUD_WouldDrawScoreboard() {
        return 0;
 }
 
-float g_minstagib;
 float average_accuracy;
 vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
 {
        float i;
-       float weapon_cnt = WEP_COUNT - 3; // either minstanex/nex are hidden, no port-o-launch, no tuba
+       float weapon_cnt = WEP_COUNT - 3; // either vaporizer/nex are hidden, no port-o-launch, no tuba
        float rows;
        if(autocvar_scoreboard_accuracy_doublerows)
                rows = 2;
@@ -962,6 +979,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        float fontsize = height * 1/3;
        float weapon_height = height * 2/3;
        float weapon_width = sbwidth / weapon_cnt;
+       float g_minstagib = 0;
 
        drawstring(pos, sprintf(_("Accuracy stats (average %d%%)"), average_accuracy), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness;
@@ -994,7 +1012,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        if(rows == 2)
                pos_x += weapon_width / 2;
 
-       if(switchweapon == WEP_MINSTANEX)
+       if(switchweapon == WEP_VAPORIZER)
                g_minstagib = 1; // TODO: real detection for minstagib?
 
        float weapon_stats;
@@ -1006,9 +1024,9 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
                self = get_weaponinfo(i);
-               if not(self.weapon)
+               if (!self.weapon)
                        continue;
-               if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA) // skip port-o-launch, nex || minstanex and tuba
+               if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_VAPORIZER && !g_minstagib) || i == WEP_TUBA) // skip port-o-launch, nex || vaporizer and tuba
                        continue;
                weapon_stats = weapon_accuracy[i-WEP_FIRST];
 
@@ -1063,7 +1081,7 @@ vector HUD_DrawKeyValue(vector pos, string key, string value) {
        drawstring(pos, value, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos_x = px;
        pos_y+= hud_fontsize_y;
-       
+
        return pos;
 }
 
@@ -1080,14 +1098,14 @@ vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) {
        rows = (stat_secrets_total ? 1 : 0);
 
        // if no rows, return
-       if not(rows)
+       if (!rows)
                return pos;
 
        //  draw table header
        drawstring(pos, _("Map stats:"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness;
-       
-       // draw table   
+
+       // draw table
        vector tmp = '0 0 0';
        tmp_x = sbwidth;
        tmp_y = hud_fontsize_y * rows;
@@ -1101,7 +1119,7 @@ vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) {
        // draw secrets
        val = sprintf("%d/%d", stat_secrets_found, stat_secrets_total);
        pos = HUD_DrawKeyValue(pos, _("Secrets found:"), val);
-       
+
        // update position
        pos_y += 1.25 * hud_fontsize_y;
        return pos;
@@ -1189,7 +1207,7 @@ void HUD_DrawScoreboard()
                        scoreboard_fade_alpha = 0;
        }
 
-       if not(scoreboard_fade_alpha)
+       if (!scoreboard_fade_alpha)
                return;
 
        HUD_UpdatePlayerTeams();
@@ -1298,7 +1316,7 @@ void HUD_DrawScoreboard()
                        pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
        }
 
-               
+
        if(teamplay)
                pos = HUD_DrawMapStats(pos, Team_ColorRGB(myteam), bg_size);
        else
@@ -1346,14 +1364,14 @@ void HUD_DrawScoreboard()
                                str = strcat(str, _(" or"));
                        if(teamplay)
                        {
-                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], fl), 
+                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], fl),
                                        (teamscores_label[ts_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (teamscores_label[ts_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(teamscores_label[ts_primary])));
                        }
                        else
                        {
-                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags[ps_primary], fl), 
+                               str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags[ps_primary], fl),
                                        (scores_label[ps_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (scores_label[ps_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(scores_label[ps_primary])));
@@ -1365,14 +1383,14 @@ void HUD_DrawScoreboard()
                                str = strcat(str, _(" or"));
                        if(teamplay)
                        {
-                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], ll), 
+                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags[ts_primary], ll),
                                        (teamscores_label[ts_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (teamscores_label[ts_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(teamscores_label[ts_primary])));
                        }
                        else
                        {
-                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags[ps_primary], ll), 
+                               str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags[ps_primary], ll),
                                        (scores_label[ps_primary] == "score")   ? CTX(_("SCO^points")) :
                                        (scores_label[ps_primary] == "fastest") ? CTX(_("SCO^is beaten")) :
                                        TranslateScoresLabel(scores_label[ps_primary])));
@@ -1392,7 +1410,7 @@ void HUD_DrawScoreboard()
                        // a negative number means we are awaiting respawn, time value is still the same
                        respawn_time *= -1; // remove mark now that we checked it
                        respawn_time = max(time, respawn_time); // don't show a negative value while the server is respawning the player (lag)
-                       
+
                        str = sprintf(_("^1Respawning in ^3%s^1..."),
                                (autocvar_scoreboard_respawntime_decimals ?
                                        count_seconds_decs(respawn_time - time, autocvar_scoreboard_respawntime_decimals)