]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
If a frozen player falls into space don't increase their armor and ammo; it partially...
authorterencehill <piuntn@gmail.com>
Wed, 24 May 2023 17:44:56 +0000 (19:44 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 24 May 2023 21:26:31 +0000 (23:26 +0200)
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh

index 444268a2dd3da910f9b98c287c6ef7ad89056fd4..08d4935aeca8e1e4c6675e51b828fbd5262e6bbb 100644 (file)
@@ -179,6 +179,8 @@ void freezetag_Freeze(entity targ, entity attacker)
        if(STAT(FROZEN, targ))
                return;
 
+       targ.freezetag_frozen_armor = GetResource(targ, RES_ARMOR);
+
        targ.freezetag_frozen_time = time;
        if (autocvar_g_freezetag_revive_auto && autocvar_g_freezetag_frozen_maxtime > 0)
                targ.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime;
@@ -366,13 +368,22 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
                }
                else
                {
-                       float t = frag_target.freezetag_frozen_timeout;
-                       float t2 = frag_target.freezetag_frozen_time;
-                       Unfreeze(frag_target, false); // remove ice
-                       // 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;
+                       // soft-kill: setting health to something >= 1 after death, ammo won't be reset
+                       SetResourceExplicit(frag_target, RES_HEALTH, 1);
+                       // restore armor as it was removed in PlayerDamage
+                       SetResourceExplicit(frag_target, RES_ARMOR, frag_target.freezetag_frozen_armor);
+
+                       // relocate
+                       entity spot = SelectSpawnPoint(frag_target, true);
+                       setorigin(frag_target, spot.origin);
+                       frag_target.oldorigin = frag_target.origin;
+                       frag_target.fixangle = true; // turn this way immediately
+                       frag_target.angles = vec2(spot.angles);
+                       frag_target.velocity = '0 0 0';
+                       frag_target.oldvelocity = frag_target.velocity; // prevents fall damage, see CreatureFrame_FallDamage
+                       frag_target.avelocity = '0 0 0';
+                       frag_target.punchangle = '0 0 0';
+                       frag_target.punchvector = '0 0 0';
                }
                return true;
        }
@@ -406,14 +417,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerSpawn)
 
        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;
        }
 
index 6fdd693cc044a5c5b7a04d92be38758837f92660..049f037147e19b22fa68d1c0c02d6004f9b30bb7 100644 (file)
@@ -31,6 +31,7 @@ REGISTER_MUTATOR(ft, false)
 .float freezetag_frozen_time;
 .float freezetag_frozen_timeout;
 .float freezetag_frozen_force;
+.float freezetag_frozen_armor;
 const float ICE_MAX_ALPHA = 1;
 const float ICE_MIN_ALPHA = 0.1;
 float freezetag_teams;