From: TimePath Date: Mon, 26 Oct 2015 06:33:58 +0000 (+1100) Subject: Rebase @Debugger's damage-on-scoreboard X-Git-Tag: xonotic-v0.8.2~1787^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cbd696f28d9038519ae6fccf39d76341036ce814;p=xonotic%2Fxonotic-data.pk3dir.git Rebase @Debugger's damage-on-scoreboard --- diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index adbac93c8..24cfe46ab 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -33,6 +33,8 @@ string TranslateScoresLabel(string l) case "captime": return CTX(_("SCO^captime")); case "deaths": return CTX(_("SCO^deaths")); case "destroyed": return CTX(_("SCO^destroyed")); + case "dmg": return CTX(_("SCO^dmg")); + case "dmgtaken": return CTX(_("SCO^dmgtaken")); case "drops": return CTX(_("SCO^drops")); case "faults": return CTX(_("SCO^faults")); case "fckills": return CTX(_("SCO^fckills")); @@ -260,6 +262,8 @@ void Cmd_HUD_Help() LOG_INFO(_("^3suicides^7 Number of suicides\n")); LOG_INFO(_("^3frags^7 kills - suicides\n")); LOG_INFO(_("^3kd^7 The kill-death ratio\n")); + LOG_INFO(_("^3dmg^7 The total damage done\n")); + LOG_INFO(_("^3dmgtaken^7 The total damage taken\n")); LOG_INFO(_("^3sum^7 frags - deaths\n")); LOG_INFO(_("^3caps^7 How often a flag (CTF) or a key (KeyHunt) was captured\n")); LOG_INFO(_("^3pickups^7 How often a flag (CTF) or a key (KeyHunt) or a ball (Keepaway) was picked up\n")); @@ -300,6 +304,7 @@ void Cmd_HUD_Help() #define HUD_DefaultColumnLayout() \ "ping pl name | " \ "-teams,rc,lms/kills +ft,tdm/kills -teams,lms/deaths +ft,tdm/deaths -teams,lms,rc,ka/suicides +ft,tdm/suicides -rc,dm,tdm,ka,ft/frags " /* tdm already has this in "score" */ \ +"dmg dmgtaken " \ "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns +ons/caps +ons/takes " \ "+lms/lives +lms/rank " \ "+kh/caps +kh/pushes +kh/destroyed " \ @@ -394,6 +399,8 @@ void Cmd_HUD_SetFields(float argc) case "sum": case "diff": case "k-d": hud_field[hud_num_fields] = SP_SUM; break; case "name": case "nick": hud_field[hud_num_fields] = SP_NAME; have_name = true; break; case "|": hud_field[hud_num_fields] = SP_SEPARATOR; have_separator = true; break; + case "dmg": hud_field[hud_num_fields] = SP_DMG; break; + case "dmgtaken": hud_field[hud_num_fields] = SP_DMGTAKEN; break; default: { for(j = 0; j < MAX_SCORE; ++j) @@ -598,6 +605,20 @@ string HUD_GetField(entity pl, int field) } return ftos(f); + case SP_DMG: + num = pl.(scores[SP_DMG]); + denom = 1000; + + str = sprintf("%.1f k", num/denom); + return str; + + case SP_DMGTAKEN: + num = pl.(scores[SP_DMGTAKEN]); + denom = 1000; + + str = sprintf("%.1f k", num/denom); + return str; + default: tmp = pl.(scores[field]); f = scores_flags[field]; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 254246bdf..47b07fc01 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -204,7 +204,7 @@ const int SFL_SORT_PRIO_MASK = 12; /** * Score indices */ -#define MAX_SCORE 10 +#define MAX_SCORE 12 #define MAX_TEAMSCORE 2 const int ST_SCORE = 0; @@ -212,6 +212,8 @@ const int SP_KILLS = 0; const int SP_DEATHS = 1; const int SP_SUICIDES = 2; const int SP_SCORE = 3; +const int SP_DMG = 10; +const int SP_DMGTAKEN = 11; // game mode specific indices are not in common/, but in server/scores_rules.qc! const int CH_INFO = 0; diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 01b9ab0d3..ecbafc40b 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -479,9 +479,18 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp self.dmg_take = self.dmg_take + take;//max(take - 10, 0); self.dmg_inflictor = inflictor; - float abot, vbot; - abot = (IS_BOT_CLIENT(attacker)); - vbot = (IS_BOT_CLIENT(self)); + if (self != attacker) { + float realdmg = damage - excess; + if (IS_PLAYER(attacker)) { + PlayerScore_Add(attacker, SP_DMG, realdmg); + } + if (IS_PLAYER(self)) { + PlayerScore_Add(self, SP_DMGTAKEN, realdmg); + } + } + + bool abot = (IS_BOT_CLIENT(attacker)); + bool vbot = (IS_BOT_CLIENT(self)); valid_damage_for_weaponstats = 0; Weapon awep = WEP_Null; diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc index 07d726791..2071b0c32 100644 --- a/qcsrc/server/scores_rules.qc +++ b/qcsrc/server/scores_rules.qc @@ -31,6 +31,9 @@ void ScoreRules_basics(float teams, float sprio, float stprio, float score_enabl if(score_enabled) ScoreInfo_SetLabel_PlayerScore(SP_SCORE, "score", sprio); + + ScoreInfo_SetLabel_PlayerScore(SP_DMG, "damage", 0); + ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "damagetaken", SFL_LOWER_IS_BETTER); } void ScoreRules_basics_end() {