From: Samual Lenks Date: Thu, 6 Sep 2012 03:14:28 +0000 (-0400) Subject: Add "captime" score field for CTF, revealing captime to xonstat X-Git-Tag: xonotic-v0.7.0~240^2~49 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=a1bfb918e857adeb04648b349ba1f41d5f0fc688 Add "captime" score field for CTF, revealing captime to xonstat --- diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 69a296796..48a7217fc 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -19,6 +19,7 @@ string TranslateScoresLabel(string l) case "bckills": return CTX(_("SCO^bckills")); case "bctime": return CTX(_("SCO^bctime")); case "caps": return CTX(_("SCO^caps")); + case "captime": return CTX(_("SCO^captime")); case "deaths": return CTX(_("SCO^deaths")); case "destroyed": return CTX(_("SCO^destroyed")); case "drops": return CTX(_("SCO^drops")); @@ -254,6 +255,7 @@ void Cmd_HUD_Help() print(_("^3kd^7 The kill-death ratio\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")); print(_("^3fckills^7 Number of flag carrier kills\n")); print(_("^3returns^7 Number of flag returns\n")); print(_("^3drops^7 Number of flag drops\n")); diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 6cd8f95b5..a12b769f1 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -353,6 +353,7 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype) { entity enemy_flag = ((capturetype == CAPTURE_NORMAL) ? toucher.flagcarried : toucher); entity player = ((capturetype == CAPTURE_NORMAL) ? toucher : enemy_flag.ctf_dropper); + float old_time, new_time; if not(player) { return; } // without someone to give the reward to, we can't possibly cap @@ -371,6 +372,11 @@ void ctf_Handle_Capture(entity flag, entity toucher, float capturetype) PlayerTeamScore_AddScore(player, ctf_ReadScore("score_capture")); PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, 1); + old_time = PlayerScore_Add(player, SP_CTF_CAPTIME, 0); + new_time = TIME_ENCODE(time - enemy_flag.ctf_pickuptime); + if(!old_time || new_time < old_time) + PlayerScore_Add(player, SP_CTF_CAPTIME, new_time - old_time); + // effects if(autocvar_g_ctf_flag_capture_effects) { diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc index 806e24507..8266d4e3c 100644 --- a/qcsrc/server/scores_rules.qc +++ b/qcsrc/server/scores_rules.qc @@ -47,16 +47,18 @@ void ScoreRules_generic() // g_ctf #define ST_CTF_CAPS 1 #define SP_CTF_CAPS 4 -#define SP_CTF_PICKUPS 5 -#define SP_CTF_DROPS 6 -#define SP_CTF_FCKILLS 7 -#define SP_CTF_RETURNS 8 +#define SP_CTF_CAPTIME 5 +#define SP_CTF_PICKUPS 6 +#define SP_CTF_DROPS 7 +#define SP_CTF_FCKILLS 8 +#define SP_CTF_RETURNS 9 void ScoreRules_ctf() { CheckAllowedTeams(world); - ScoreRules_basics(2 + (c3>=0), SFL_SORT_PRIO_PRIMARY, 0, TRUE); // NOTE this assumes that the rogue team is team 3 + ScoreRules_basics(2, SFL_SORT_PRIO_PRIMARY, 0, TRUE); ScoreInfo_SetLabel_TeamScore (ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY); ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME); ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS, "pickups", 0); ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS, "fckills", 0); ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS, "returns", 0);