]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
get rid of br_PlayerDamage()
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sun, 23 Jan 2022 16:36:23 +0000 (17:36 +0100)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sun, 23 Jan 2022 16:36:23 +0000 (17:36 +0100)
qcsrc/common/gamemodes/gamemode/br/sv_br.qc
qcsrc/server/player.qc

index 70270f671299c391f6d7311605e9052802a68d70..a1f13beebdc950f11e19a6e0836afbdb71dbef3c 100644 (file)
@@ -12,7 +12,6 @@ void br_SetPlayerDropAngle(entity this);
 void br_LastPlayerForSquad_Notify(entity squad);
 void br_RemovePlayer(entity player);
 void br_Revive(entity player);
-void br_PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force);
 int br_WinningCondition();
 
 entity ring;
@@ -193,13 +192,6 @@ MUTATOR_HOOKFUNCTION(br, SpectatePrev)
     return MUT_SPECPREV_FOUND;
 }
 
-MUTATOR_HOOKFUNCTION(br, PlayerSpawn)
-{
-    entity player = M_ARGV(0, entity);
-
-    player.event_damage = br_PlayerDamage;
-}
-
 MUTATOR_HOOKFUNCTION(br, ForbidSpawn)
 {
     return (round_handler_IsActive() && round_handler_IsRoundStarted());
@@ -496,14 +488,30 @@ MUTATOR_HOOKFUNCTION(br, PM_Physics)
 MUTATOR_HOOKFUNCTION(br, Damage_Calculate)
 {
     entity target = M_ARGV(2, entity);
+    float deathtype = M_ARGV(3, float);
 
-    if(STAT(DROP, target) == DROP_FALLING)
+    if(STAT(DROP, target) != DROP_LANDED)
     {
-        // only take half of the usual damage
-        M_ARGV(4, float) /= 2;
-        M_ARGV(5, float) /= 2;
         // weapon impact has no push force while dropping
         M_ARGV(6, vector) = '0 0 0';
+
+        if(STAT(DROP, target) == DROP_TRANSPORT)
+            M_ARGV(4, float) = M_ARGV(5, float) = 0; // can't take damage while on the dropship
+        else if(STAT(DROP, target) == DROP_FALLING)
+        {
+            switch(deathtype)
+            {
+                case DEATH_FALL.m_id:
+                case DEATH_SHOOTING_STAR.m_id:
+                    // do not take fall damage when landing from dropship
+                    M_ARGV(4, float) = M_ARGV(5, float) = 0;
+                    break;
+                default:
+                    // only take half of the usual damage
+                    M_ARGV(4, float) /= 2;
+                    M_ARGV(5, float) /= 2;
+            }
+        }
     }
 }
 
@@ -599,13 +607,34 @@ MUTATOR_HOOKFUNCTION(br, PlayerDied)
 
 MUTATOR_HOOKFUNCTION(br, ClientObituary)
 {
+    entity frag_inflictor = M_ARGV(0, entity);
+    entity frag_attacker = M_ARGV(1, entity);
     entity frag_target = M_ARGV(2, entity);
     float frag_deathtype = M_ARGV(3, float); // float for some reason, breaks if changed to int
+    //entity frag_weaponentity = M_ARGV(4, entity);
 
-    if(BR_KILLS_INSTANTLY(frag_target, frag_deathtype))
-        return false;
-    else
-        return !STAT(BLEEDING, frag_target);
+    if(!STAT(BLEEDING, frag_target) && !BR_KILLS_INSTANTLY(frag_target, frag_deathtype))
+    {
+        frag_target.br_bleeding_inflictor = frag_inflictor;
+        frag_target.br_bleeding_attacker = frag_attacker;
+        frag_target.br_bleeding_deathtype = frag_deathtype;
+        //frag_target.br_bleeding_weaponentity = frag_weaponentity; // TODO: get entity field
+        return true;
+    }
+
+    if(STAT(BLEEDING, frag_target) && frag_target.br_bleeding_attacker)
+    {
+        entity new_inflictor = frag_target.br_bleeding_inflictor;
+        entity new_attacker = frag_target.br_bleeding_attacker;
+        int new_deathtype = frag_target.br_bleeding_deathtype;
+        .entity new_weaponentity = frag_target.br_bleeding_weaponentity;
+        frag_target.br_bleeding_attacker = frag_target.br_bleeding_inflictor = NULL;
+
+        Obituary(new_attacker, new_inflictor, frag_target, new_deathtype, new_weaponentity);
+        return true;
+    }
+
+    return false;
 }
 
 MUTATOR_HOOKFUNCTION(br, SetResource)
@@ -783,43 +812,6 @@ void br_Revive(entity player)
     br_SquadUpdateInfo();
 }
 
-void br_PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
-{
-    if(STAT(DROP, this) == DROP_TRANSPORT)
-        return; // can't take damage while on the dropship
-
-    // do not take fall damage when landing from dropship
-    if(STAT(DROP, this) == DROP_FALLING)
-    {
-        switch(deathtype)
-        {
-            case DEATH_FALL.m_id:
-            case DEATH_SHOOTING_STAR.m_id:
-                return;
-        }
-    }
-
-    if(STAT(BLEEDING, this) && this.br_bleeding_attacker)
-    {
-        inflictor = this.br_bleeding_inflictor;
-        attacker = this.br_bleeding_attacker;
-        deathtype = this.br_bleeding_deathtype;
-        weaponentity = this.br_bleeding_weaponentity;
-    }
-
-    PlayerDamage(this, inflictor, attacker, damage, deathtype, weaponentity, hitloc, force);
-
-    if(STAT(BLEEDING, this))
-    {
-        this.br_bleeding_inflictor = inflictor;
-        this.br_bleeding_attacker = attacker;
-        this.br_bleeding_deathtype = deathtype;
-        this.br_bleeding_weaponentity = weaponentity;
-
-        this.fixangle = false;
-    }
-}
-
 int br_WinningCondition()
 {
     int total_squads = br_SquadUpdateInfo();
index ad3ba94e4a21d18c9aa7c293a1c68cfa9a04edeb..6630d1df0163daa204589b69c989ddfcb4be23f1 100644 (file)
@@ -503,7 +503,8 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
 
                Portal_ClearAllLater(this);
 
-               this.fixangle = true;
+               if(!STAT(BLEEDING, this))
+                       this.fixangle = true;
 
                if(defer_ClientKill_Now_TeamChange)
                        ClientKill_Now_TeamChange(this); // can turn player into spectator