]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix damagetext not stopping damage accumulation after enemy's death
authorterencehill <piuntn@gmail.com>
Tue, 23 Apr 2024 15:23:49 +0000 (17:23 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 2 May 2024 09:45:05 +0000 (11:45 +0200)
qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc
qcsrc/common/mutators/mutator/damagetext/damagetext.qh
qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc

index 8383626fc718733f0cfc76f0e5daa69b1166df76..c49ebb7e56ae62dcff1844e335278a33e5549965 100644 (file)
@@ -268,9 +268,11 @@ NET_HANDLE(damagetext, bool isNew)
                // disown the parent entity from this DamageText
                // and (likely) give the entity a new DT afterwards
                // this should only cancel damage accumulation for this DT
-               if ((autocvar_cl_damagetext_accumulate_lifetime >= 0) // negative never disowns
-               && (time - it.hit_time > autocvar_cl_damagetext_accumulate_lifetime)
-               && (current_alpha(it) > alphathreshold))
+
+               if (flags & DTFLAG_STOP_ACCUMULATION
+                       || ((autocvar_cl_damagetext_accumulate_lifetime >= 0) // negative never disowns
+                               && (time - it.hit_time > autocvar_cl_damagetext_accumulate_lifetime)
+                               && (current_alpha(it) > alphathreshold)))
                {
                        it.m_group = 0;
                }
index cc631c1c3ad9c9259ecf5a48181c1e10ea3639fa..d6ba640988e459a8c695eb8ba43cdc7b6cfa9b26 100644 (file)
@@ -9,3 +9,4 @@ const int DTFLAG_BIG_ARMOR = BIT(2);
 const int DTFLAG_BIG_POTENTIAL = BIT(3);
 const int DTFLAG_NO_ARMOR = BIT(4);
 const int DTFLAG_NO_POTENTIAL = BIT(5);
+const int DTFLAG_STOP_ACCUMULATION = BIT(6);
index d76ecee0effee63466f9d842e92c9b79ab73ebcc..b49cddd96012b6acb97077c5e84b9e2c3f0ed63a 100644 (file)
@@ -14,6 +14,7 @@ REGISTER_MUTATOR(damagetext, true);
 .float dent_net_health;
 .float dent_net_armor;
 .float dent_net_potential;
+.entity dent_attackers;
 
 bool write_damagetext(entity this, entity client, int sf)
 {
@@ -96,6 +97,13 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
                net_text_prev.dent_net_potential = potential_damage;
                return;
        }
+       else if (!IL_CONTAINS(hit.dent_attackers, attacker))
+       {
+               // player is hit for the first time after respawn by this attacker
+               IL_PUSH(hit.dent_attackers, attacker);
+               flags |= DTFLAG_STOP_ACCUMULATION; // forcedly stop client-side damage accumulation
+       }
+
        entity net_text = new_pure(net_damagetext);
        net_text.realowner = attacker;
        net_text.enemy = hit;
@@ -113,3 +121,25 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
 
        Net_LinkEntity(net_text, false, 0, write_damagetext);
 }
+
+MUTATOR_HOOKFUNCTION(damagetext, ClientDisconnect)
+{
+       entity player = M_ARGV(0, entity);
+       if (player.dent_attackers)
+               IL_DELETE(player.dent_attackers);
+
+       // NOTE this player is automatically removed from dent_attackers lists of other players
+       // by intrusive list's ONREMOVE
+}
+
+MUTATOR_HOOKFUNCTION(damagetext, PlayerSpawn)
+{
+       entity player = M_ARGV(0, entity);
+       if (player.dent_attackers == NULL)
+       {
+               player.dent_attackers = IL_NEW();
+               return true;
+       }
+
+       IL_CLEAR(player.dent_attackers);
+}