]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into LegendaryGuard/armorizing_and_dark_nades
authorLegendaryGuard <rootuser999@gmail.com>
Fri, 7 May 2021 23:33:07 +0000 (01:33 +0200)
committerLegendaryGuard <rootuser999@gmail.com>
Fri, 7 May 2021 23:33:07 +0000 (01:33 +0200)
1  2 
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/stats.qh

index 4cab4fe2957e75a9fc27a4ae10a35d048e607156,e71c61855fc7f749692e7af12cfed3052590f8fd..6f9e8912810388d188c7e15f049229ed4d2b814e
@@@ -1835,57 -1339,64 +1841,73 @@@ MUTATOR_HOOKFUNCTION(nades, PlayerPreTh
                        else
                                player.alpha = player.nade_veil_prevalpha;
                }
 +              //LegendGuard adds nade if STAT DARK_ORB 08-02-2021
 +              if(STAT(DARK_ORB, player) && STAT(DARK_ORB, player) <= time)
 +              {
 +                      STAT(DARK_ORB, player) = 0;
 +                      if(player.vehicle)
 +                              player.vehicle.alpha = player.vehicle.nade_dark_prevalpha;
 +                      else
 +                              player.alpha = player.nade_dark_prevalpha;
 +              }
        }
  
-       if (frametime && IS_PLAYER(player))
-       {
-               int n = 0;
+       if (!(frametime && IS_PLAYER(player)))
+               return true;
  
-               IntrusiveList reviving_players = NULL;
+       entity revivers_last = NULL;
+       entity revivers_first = NULL;
  
-               if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
-                       n = -1;
-               else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
+       bool player_is_reviving = false;
+       int n = 0;
+       vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
+       FOREACH_CLIENT(IS_PLAYER(it) && IN_REVIVING_RANGE(player, it, revive_extra_size), {
+               // check if player is reviving anyone
+               if (STAT(FROZEN, it) == FROZEN_TEMP_DYING)
                {
-                       vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
-                       n = 0;
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
-                               if (!reviving_players)
-                                       reviving_players = IL_NEW();
-                               IL_PUSH(reviving_players, it);
-                               ++n;
-                       });
+                       if ((STAT(FROZEN, player) == FROZEN_TEMP_DYING))
+                               continue;
+                       if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
+                               continue;
+                       player_is_reviving = true;
+                       break;
                }
  
-               if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
-               {
-                       STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
-                       SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
+               if (!(STAT(FROZEN, player) == FROZEN_TEMP_DYING))
+                       continue; // both player and it are NOT frozen
+               if (revivers_last)
+                       revivers_last.chain = it;
+               revivers_last = it;
+               if (!revivers_first)
+                       revivers_first = it;
+               ++n;
+       });
+       if (revivers_last)
+               revivers_last.chain = NULL;
  
-                       if(STAT(REVIVE_PROGRESS, player) >= 1)
-                       {
-                               Unfreeze(player, false);
+       if (!n) // no teammate nearby
+       {
+               // freezetag already resets revive progress
+               if (!g_freezetag && !STAT(FROZEN, player) && !player_is_reviving)
+                       STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody
+       }
+       else if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
+       {
+               STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
+               // undo what PlayerPreThink did
+               STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * player.revive_speed, 1);
+               SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
  
-                               entity first = IL_FIRST(reviving_players);
-                               Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname);
-                               Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
-                       }
+               if(STAT(REVIVE_PROGRESS, player) >= 1)
+               {
+                       Unfreeze(player, false);
  
-                       IL_EACH(reviving_players, true, {
-                               STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
-                       });
+                       Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
+                       Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
                }
-               if (reviving_players)
-                       IL_DELETE(reviving_players);
+               for(entity it = revivers_first; it; it = it.chain)
+                       STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
        }
  }
  
index 4b382a2d2292f02250b0a70b2dfaff09738f082c,e5621c29ec97ecc80a2ef740ba4061aaec48aa77..554bd25765ce82992cb39ac58fbdb9d9ead5f451
@@@ -138,15 -138,9 +138,15 @@@ REGISTER_STAT(ITEMSTIME, int, autocvar_
  REGISTER_STAT(KILL_TIME, float)
  REGISTER_STAT(VEIL_ORB, float)
  REGISTER_STAT(VEIL_ORB_ALPHA, float)
 +REGISTER_STAT(ARMORIZING_ORB, float) //LegendGuard registers new STAT 11-02-2021
 +REGISTER_STAT(ARMORIZING_ORB_ALPHA, float)
 +REGISTER_STAT(AMMUNITIONING_ORB, float) //LegendGuard registers new STAT 11-02-2021
 +REGISTER_STAT(AMMUNITIONING_ORB_ALPHA, float)
 +REGISTER_STAT(DARK_ORB, float) //LegendGuard registers new STAT 08-02-2021
 +REGISTER_STAT(DARK_ORB_ALPHA, float)
  
  #ifdef SVQC
- float autocvar_sv_showfps = 5;
+ float autocvar_sv_showfps = 0;
  #endif
  REGISTER_STAT(SHOWFPS, float, autocvar_sv_showfps)