]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
HUD hit indicator: if dead remove all indicators; if an attacker dies or disconnects...
authorterencehill <piuntn@gmail.com>
Thu, 15 Feb 2024 15:01:35 +0000 (16:01 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 15 Feb 2024 15:20:29 +0000 (16:20 +0100)
qcsrc/client/view.qc

index 211076f8393ad4f811464070c8039e38cc6e2863..5294e99c67269275634011b3182419e4da6148e4 100644 (file)
@@ -788,14 +788,29 @@ void HitIndicatorUpdate(float dmg, entity attacker)
 
 void HitIndicatorShow()
 {
+       if (STAT(HEALTH) <= 0 && HitIndicator_time[0] >= 0)
+       {
+               // if dead remove all indicators
+               for (int i = 0; i < HITINDICATOR_MAX_COUNT; ++i)
+                       HitIndicator_attacker[i] = NULL;
+               HitIndicator_time[0] = -1; // this is to avoid removing indicators every frame
+               return;
+       }
+
        if (!autocvar_cl_hit_indicator || autocvar_cl_hit_indicator_size <= 0 || autocvar_chase_active)
                return;
 
        for (int i = 0; i < HITINDICATOR_MAX_COUNT; ++i)
        {
                entity attacker = HitIndicator_attacker[i];
-               if (!attacker || HITINDICATOR_EXPIRED(i))
+               if (!attacker)
                        continue;
+               if (HITINDICATOR_EXPIRED(i) || entcs_IsDead(attacker.sv_entnum) || wasfreed(attacker))
+               {
+                       // if the attacker dies or disconnects remove the related hit indicator
+                       HitIndicator_attacker[i] = NULL;
+                       continue;
+               }
 
                // hide indicator if attacker is not visible (check ported from shownames.qc)
                traceline(view_origin, attacker.origin, MOVE_NOMONSTERS, attacker);