]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add entity fields to store average handicap over a match k9er/handicap-features
authorotta8634 <k9wolf@pm.me>
Sun, 15 Dec 2024 16:47:58 +0000 (00:47 +0800)
committerotta8634 <k9wolf@pm.me>
Sun, 15 Dec 2024 16:47:58 +0000 (00:47 +0800)
Added .handicap_avg_taken_sum and .handicap_avg_given_sum.
Currently it doesn't include self-damage which *is* influenced by handicap.
- Including this would require minimum 2 but probably 4 more entity fields, so I'm not sure it's really necessary.
These can be networked to XonStat in future.

qcsrc/server/client.qc
qcsrc/server/handicap.qh

index 8d0db75dac1d04da1fa33703ecdf0a4ce30aa520..acad8cbe2314074d6d9e9c75d07a106db24661a4 100644 (file)
@@ -2776,11 +2776,13 @@ void PlayerFrame (entity this)
 
        if (this.score_frame_dmg)
        {
+               this.handicap_avg_given_sum += this.score_frame_dmg * Handicap_GetTotalHandicap(this, false);
                GameRules_scoring_add(this, DMG, this.score_frame_dmg);
                this.score_frame_dmg = 0;
        }
        if (this.score_frame_dmgtaken)
        {
+               this.handicap_avg_taken_sum += this.score_frame_dmgtaken * Handicap_GetTotalHandicap(this, true);
                GameRules_scoring_add(this, DMGTAKEN, this.score_frame_dmgtaken);
                this.score_frame_dmgtaken = 0;
        }
index 39a00e1a5c4f15c0d5334d35f98e2a072fde094a..99c25705a527662e71154fe5e7268f7700f8a33a 100644 (file)
@@ -50,11 +50,17 @@ float Handicap_GetTotalHandicap(entity player, bool receiving);
 /// \param[in] player Player to check.
 void Handicap_UpdateHandicapLevel(entity player);
 
-#define HANDICAP_MAX_LEVEL_EQUIVALENT  2.0
-
-.int handicap_level;
 // This int ranges 0 to 16, 0 meaning no handicap, 1 to 16 representing handicap "levels" mapped
 // from 1.0 to HANDICAP_MAX_LEVEL_EQUIVALENT, using (given + taken)/2 (i.e. both-ways handicap).
 // It is networked to the client.
 // The levels are mostly meaningless, just used to determine the player_handicap icon color.
+.int handicap_level;
+
+#define HANDICAP_MAX_LEVEL_EQUIVALENT  2.0
+
+// These store the player's total "average-sum" given/taken damage handicaps respectively.
+// average-sum refers to the arithmetic sum of damage taken/given, weighted by respective handicap.
+// To calculate the average handicap, divide by damage taken/given.
+.float handicap_avg_given_sum;
+.float handicap_avg_taken_sum;