]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Freezetag: don't reset autorevive progress when a frozen player falls into the void
authorterencehill <piuntn@gmail.com>
Mon, 1 Feb 2021 17:32:38 +0000 (18:32 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 1 Feb 2021 17:32:38 +0000 (18:32 +0100)
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc

index 56f00413005e9d51cb359feec6676e6b36726a61..a8f37678a9105cf8e31b8f8fc010f8073f2edd52 100644 (file)
@@ -384,10 +384,18 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
                        freezetag_Add_Score(frag_target, frag_attacker);
                        freezetag_count_alive_players();
                        freezetag_LastPlayerForTeam_Notify(frag_target);
+                       frag_target.freezetag_frozen_timeout = -2; // freeze on respawn
                }
                else
+               {
+                       float t = frag_target.freezetag_frozen_timeout;
+                       float t2 = frag_target.freezetag_frozen_time;
                        Unfreeze(frag_target, false); // remove ice
-               frag_target.freezetag_frozen_timeout = -2; // freeze on respawn
+                       // keep timeout value so it can be restored when player will be refrozen on respawn
+                       // NOTE this can't be exactly -2 since game starts from time 2
+                       frag_target.freezetag_frozen_timeout = -t;
+                       frag_target.freezetag_frozen_time = t2;
+               }
                return true;
        }
 
@@ -418,9 +426,16 @@ MUTATOR_HOOKFUNCTION(ft, PlayerSpawn)
        if(player.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
                return true; // do nothing, round is starting right now
 
-       if(player.freezetag_frozen_timeout == -2) // player was dead
+       if(player.freezetag_frozen_timeout <= -2) // player was dead
        {
+               float t = player.freezetag_frozen_timeout;
+               float t2 = player.freezetag_frozen_time;
                freezetag_Freeze(player, NULL);
+               if (t < -2)
+               {
+                       player.freezetag_frozen_timeout = -t;
+                       player.freezetag_frozen_time = t2;
+               }
                return true;
        }