]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Count damage caused by suicide (with the kill command) as damage taken except in...
authorterencehill <piuntn@gmail.com>
Thu, 27 May 2021 22:28:45 +0000 (00:28 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 27 May 2021 22:28:45 +0000 (00:28 +0200)
qcsrc/server/damage.qc
qcsrc/server/player.qc

index 7e052de046ebbbd5f93dc6ef2f071b306f85623f..83252c00d86676ff4f9bf951e17c29e8d5da987d 100644 (file)
@@ -611,9 +611,12 @@ void Damage(entity targ, entity inflictor, entity attacker, float damage, int de
                // These are ALWAYS lethal
                // No damage modification here
                // Instead, prepare the victim for his death...
-               SetResourceExplicit(targ, RES_ARMOR, 0);
+               if(deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id)
+               {
+                       SetResourceExplicit(targ, RES_ARMOR, 0);
+                       SetResourceExplicit(targ, RES_HEALTH, 0.9); // this is < 1
+               }
                targ.spawnshieldtime = 0;
-               SetResourceExplicit(targ, RES_HEALTH, 0.9); // this is < 1
                targ.flags -= targ.flags & FL_GODMODE;
                damage = 100000;
        }
index 0a7dd86cb32aec451ec87a824473248507aff0f3..bd1bc6d684f2636951cd313ca00cbacdc611fb06 100644 (file)
@@ -389,12 +389,15 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                        }
 
                        float realdmg = damage - excess;
-                       if (this != attacker && realdmg && !STAT(FROZEN, this)
+                       if ((this != attacker || deathtype == DEATH_KILL.m_id) && realdmg && !STAT(FROZEN, this)
                                && (!(round_handler_IsActive() && !round_handler_IsRoundStarted()) && time >= game_starttime))
                        {
-                               if (IS_PLAYER(attacker) && DIFF_TEAM(attacker, this)) {
+                               if (IS_PLAYER(attacker) && DIFF_TEAM(attacker, this) && deathtype != DEATH_KILL.m_id) {
                                        GameRules_scoring_add(attacker, DMG, realdmg);
                                }
+                               // don't count DEATH_KILL damage in game modes where suicide is for respawning
+                               // TODO mutator hook?
+                               if (deathtype != DEATH_KILL.m_id || !(IS_GAMETYPE(RACE) || IS_GAMETYPE(CTS)))
                                if (IS_PLAYER(this)) {
                                        GameRules_scoring_add(this, DMGTAKEN, realdmg);
                                }