Patches #1720

Merge in xonotic/xonotic-data.pk3dir.git: debugger/scoreboard_damage

Added by git-manager about 1 year ago. Updated 12 months ago.

Status:ClosedStart date:07/10/2013
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:-

Description

Purpose of the branch:

Adding 'damage', 'damage taken' and 'net damage' to the scoreboard (disabled by default).
The values will be displayed in thousands so its not too easy to guess the dealt damage;
e.g. 1200 damage will be displayed as 1.2 k damage.

Repository: xonotic/xonotic-data.pk3dir.git
Commit: 804a6e21c0edb4eb4e2e2238534fca03cd9aaac6
Branch: debugger/scoreboard_damage

Merge commands:

cd data/xonotic-data.pk3dir
git checkout master
git reset --hard origin/master
git pull && git diff '804a6e21c0edb4eb4e2e2238534fca03cd9aaac6'..'origin/debugger/scoreboard_damage'

# please check that the diff you just saw did not contain anything complex that
# needs a new merge request, and review these changes

git merge --no-ff 'origin/debugger/scoreboard_damage'

# please make sure this merge worked, and if not, fix merge conflicts and git
# commit BEFORE the next command
#
# also, THIS is the point to do final pre-merge testing
#
# use git reset --hard origin/master to bail out

git push && git push --delete origin 'debugger/scoreboard_damage'

Diffstat:

 qcsrc/client/main.qh         |    2 ++
 qcsrc/client/scoreboard.qc   |   33 +++++++++++++++++++++++++++++++++
 qcsrc/common/constants.qh    |    4 +++-
 qcsrc/server/cl_player.qc    |   17 +++++++++++++++--
 qcsrc/server/scores_rules.qc |    4 ++++
 5 files changed, 57 insertions(+), 3 deletions(-)

Revision log:

commit 804a6e21c0edb4eb4e2e2238534fca03cd9aaac6
Author: Debugger <pyngot@hotmail.com>
Commit: Debugger <pyngot@hotmail.com>

    bugfixes and some optimisation, works properly now

commit 53039a95273cad98cf219414c0d30378f45ceb3f
Author: Debugger <pyngot@hotmail.com>
Commit: Debugger <pyngot@hotmail.com>

    adding some more stuff to the scoreboard (dmg, dmgtaken, netdmg). Current version is broken

commit 881cd4b12ef75301d05edc6b2374da5c55001b07
Author: Debugger <pyngot@hotmail.com>
Commit: Debugger <pyngot@hotmail.com>

    remove weird files (?)

commit 645f2c3c4f1776fc7f1fbcb315687b91e4de3230
Author: Debugger <pyngot@hotmail.com>
Commit: Debugger <pyngot@hotmail.com>

    dmg on the scoreboard works now (but still has a bug)

commit 783ef38de692a86e62b2d75c3516222a0a661803
Author: Debugger <pyngot@hotmail.com>
Commit: Debugger <pyngot@hotmail.com>

    first attempt of adding 'dmg' to scoreboard

User agreed to the GPLv2+.

Diff:

diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh
index 10a3b16..f6185d6 100644
--- a/qcsrc/client/main.qh
+++ b/qcsrc/client/main.qh
@@ -55,6 +55,8 @@ float gametype;
 #define SP_PL -6
 #define SP_FRAGS -7

+#define SP_NETDMG -9 //SP_NET has value -8
+
 #define SP_SEPARATOR -100

 float hud_field[MAX_HUD_FIELDS + 1];
diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc
index 743e4b7..5edc247 100644
--- a/qcsrc/client/scoreboard.qc
+++ b/qcsrc/client/scoreboard.qc
@@ -22,6 +22,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"));
@@ -36,6 +38,7 @@ string TranslateScoresLabel(string l)
         case "lives": return CTX(_("SCO^lives"));
         case "losses": return CTX(_("SCO^losses"));
         case "name": return CTX(_("SCO^name"));
+        case "netdmg": return CTX(_("SCO^netdmg"));
         case "nick": return CTX(_("SCO^nick"));
         case "objectives": return CTX(_("SCO^objectives"));
         case "pickups": return CTX(_("SCO^pickups"));
@@ -263,6 +266,9 @@ 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(_("^3dmg^7                      The total damage done\n"));
+    print(_("^3dmgtaken^7                 The total damage taken\n"));
+    print(_("^3netdmg^7                   Damage done - damage taken\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"));
@@ -393,6 +399,12 @@ void Cmd_HUD_SetFields(float argc)
         } else if(str == "|") {
             hud_field[hud_num_fields] = SP_SEPARATOR;
             have_separator = 1;
+        } else if(str == "dmg") {
+            hud_field[hud_num_fields] = SP_DMG;
+        } else if(str == "dmgtaken") {
+            hud_field[hud_num_fields] = SP_DMGTAKEN;
+        } else if(str == "netdmg") {
+            hud_field[hud_num_fields] = SP_NETDMG;
         } else {
             for(j = 0; j < MAX_SCORE; ++j)
                 if(str == strtolower(scores_label[j]))
@@ -582,6 +594,27 @@ string HUD_GetField(entity pl, float field)
                 str = sprintf("%.1f", num/denom);
             return str;

+        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; 
+        
+        case SP_NETDMG:
+            num = pl.(scores[SP_DMG]);
+            denom = pl.(scores[SP_DMGTAKEN]);
+            
+            str = sprintf("%.1f k", (num-denom)/1000);
+            return str;
+
         default:
             tmp = pl.(scores[field]);
             f = scores_flags[field];
diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh
index b399f38..796f8e5 100644
--- a/qcsrc/common/constants.qh
+++ b/qcsrc/common/constants.qh
@@ -265,7 +265,7 @@ const vector eZ = '0 0 1';
 /**
  * Score indices
  */
-#define MAX_SCORE 10
+#define MAX_SCORE 12
 #define MAX_TEAMSCORE 2

 #define ST_SCORE 0
@@ -273,6 +273,8 @@ const vector eZ = '0 0 1';
 #define SP_DEATHS 1
 #define SP_SUICIDES 2
 #define SP_SCORE 3
+#define SP_DMG 10
+#define SP_DMGTAKEN 11
 // game mode specific indices are not in common/, but in server/scores_rules.qc!

 #ifdef COMPAT_XON010_CHANNELS
diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc
index 68a2de3..aabdcb9 100644
--- a/qcsrc/server/cl_player.qc
+++ b/qcsrc/server/cl_player.qc
@@ -498,8 +498,21 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
     self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
     self.dmg_inflictor = inflictor;

-    if(g_ca && self != attacker && IS_PLAYER(attacker))
-        PlayerTeamScore_Add(attacker, SP_SCORE, ST_SCORE, (damage - excess) * autocvar_g_ca_damage2score_multiplier);
+    if(self != attacker)
+    {
+        float realdmg = damage - excess;
+        
+        if(IS_PLAYER(attacker))
+        {
+            if(g_ca)
+                PlayerTeamScore_Add(attacker, SP_SCORE, ST_SCORE, realdmg * autocvar_g_ca_damage2score_multiplier);
+
+            PlayerScore_Add(attacker, SP_DMG, realdmg);
+        }
+        
+        if(IS_PLAYER(frag_target))
+            PlayerScore_Add(frag_target, SP_DMGTAKEN, realdmg);
+    }

     float abot, vbot, awep;
     abot = (IS_BOT_CLIENT(attacker));
diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc
index d60f456..8b2531c 100644
--- a/qcsrc/server/scores_rules.qc
+++ b/qcsrc/server/scores_rules.qc
@@ -27,6 +27,10 @@ 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_NETDMG, "netdamage", 0);
+    ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "damagetaken", SFL_LOWER_IS_BETTER);
 }
 void ScoreRules_basics_end()
 {

History

#1 Updated by Debugger about 1 year ago

  • Assignee set to Samual
  • Target version set to 0.8

#2 Updated by Debugger 12 months ago

  • Status changed from New to Closed
  • Assignee deleted (Samual)
  • Target version deleted (0.8)
  • % Done changed from 0 to 100

Outdated.

Also available in: Atom PDF