From: terencehill Date: Tue, 23 Apr 2024 15:23:49 +0000 (+0200) Subject: Fix damagetext not stopping damage accumulation after enemy's death X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=b828c282e1f5cb52638a461d09b29ba248e4e249;p=xonotic%2Fxonotic-data.pk3dir.git Fix damagetext not stopping damage accumulation after enemy's death --- diff --git a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc index 8383626fc..c49ebb7e5 100644 --- a/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qh b/qcsrc/common/mutators/mutator/damagetext/damagetext.qh index cc631c1c3..d6ba64098 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qh +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qh @@ -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); diff --git a/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc index d76ecee0e..b49cddd96 100644 --- a/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/sv_damagetext.qc @@ -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); +}