From f92b4a9e62531bcd131216de93d18948b91d29ea Mon Sep 17 00:00:00 2001 From: otta8634 Date: Mon, 16 Dec 2024 00:47:58 +0800 Subject: [PATCH] Add entity fields to store average handicap over a match 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 | 2 ++ qcsrc/server/handicap.qh | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 8d0db75da..acad8cbe2 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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; } diff --git a/qcsrc/server/handicap.qh b/qcsrc/server/handicap.qh index 39a00e1a5..99c25705a 100644 --- a/qcsrc/server/handicap.qh +++ b/qcsrc/server/handicap.qh @@ -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; -- 2.39.2