]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Rebase @Debugger's damage-on-scoreboard
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 26 Oct 2015 06:33:58 +0000 (17:33 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 26 Oct 2015 06:34:09 +0000 (17:34 +1100)
qcsrc/client/scoreboard.qc
qcsrc/common/constants.qh
qcsrc/server/cl_player.qc
qcsrc/server/scores_rules.qc

index adbac93c8fed9fd56b28bf2ffb2e25d5baba951b..24cfe46abdfe5dc0d6d49f3ac91f5b25c091827f 100644 (file)
@@ -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];
index 254246bdff54a896477a214d96686f5dd4ffb9ce..47b07fc01f786c9bcd7ca454d113fe013683d16a 100644 (file)
@@ -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;
index 01b9ab0d3411abcfd321026a8a14c176d4a8a71e..ecbafc40b8a058f0afee2ae134ab1647249d163a 100644 (file)
@@ -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;
index 07d7267910cc7391e3e79deccdd4a1416289b4ec..2071b0c3211e7a6db05a7d59081c0360d7a594b1 100644 (file)
@@ -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()
 {