]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Introduce some constants to indicate frozen states; improve a few frozen state checks...
authorterencehill <piuntn@gmail.com>
Sun, 23 Sep 2018 10:49:27 +0000 (12:49 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 23 Sep 2018 15:15:21 +0000 (17:15 +0200)
qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/server/client.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc

index 42b3b77f52eede1653ac845ddcd49610ac490376..be6e92523518824a01ff2892bb5ac64c4876e61a 100644 (file)
@@ -19,8 +19,7 @@ void freezetag_count_alive_players()
        FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it),
        {
                ++total_players;
-               if ((GetResourceAmount(it, RESOURCE_HEALTH) < 1) ||
-                       (STAT(FROZEN, it) == 1))
+               if (GetResourceAmount(it, RESOURCE_HEALTH) < 1 || STAT(FROZEN, it) == FROZEN_NORMAL)
                {
                        continue;
                }
@@ -155,7 +154,7 @@ entity freezetag_LastPlayerForTeam(entity this)
 {
        entity last_pl = NULL;
        FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
-               if (!STAT(FROZEN, it) && GetResourceAmount(it, RESOURCE_HEALTH) >= 1)
+               if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResourceAmount(it, RESOURCE_HEALTH) >= 1)
                {
                        if (!last_pl)
                                last_pl = it;
@@ -213,7 +212,7 @@ void freezetag_Freeze(entity targ, entity attacker)
 
 bool freezetag_isEliminated(entity e)
 {
-       if(IS_PLAYER(e) && (STAT(FROZEN, e) == 1 || IS_DEAD(e)))
+       if(IS_PLAYER(e) && (STAT(FROZEN, e) == FROZEN_NORMAL || IS_DEAD(e)))
                return true;
        return false;
 }
@@ -231,7 +230,7 @@ void havocbot_goalrating_ft_freeplayers(entity this, float ratingscale, vector o
        entity best_pl = NULL;
        float best_dist2 = FLOAT_MAX;
        FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), {
-               if (STAT(FROZEN, it) == 1)
+               if (STAT(FROZEN, it) == FROZEN_NORMAL)
                {
                        if(vdist(it.origin - org, >, sradius))
                                continue;
@@ -267,10 +266,12 @@ void havocbot_role_ft_offense(entity this)
 
        // Count how many players on team are unfrozen.
        int unfrozen = 0;
-       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !STAT(FROZEN, it), { unfrozen++; });
+       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && STAT(FROZEN, it) != FROZEN_NORMAL, {
+               unfrozen++;
+       });
 
        // If only one left on team or if role has timed out then start trying to free players.
-       if ((unfrozen == 0 && !STAT(FROZEN, this)) || time > this.havocbot_role_timeout)
+       if ((!unfrozen && STAT(FROZEN, this) != FROZEN_NORMAL) || time > this.havocbot_role_timeout)
        {
                LOG_TRACE("changing role to freeing");
                this.havocbot_role = havocbot_role_ft_freeing;
@@ -327,7 +328,7 @@ void havocbot_role_ft_freeing(entity this)
 
 void ft_RemovePlayer(entity this)
 {
-       if(!STAT(FROZEN, this))
+       if (STAT(FROZEN, this) != FROZEN_NORMAL)
                freezetag_LastPlayerForTeam_Notify(this);
        Unfreeze(this, false);
 
@@ -359,7 +360,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
        if(round_handler_IsActive())
        if(round_handler_CountdownRunning())
        {
-               if(STAT(FROZEN, frag_target))
+               if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
                        Unfreeze(frag_target, true);
                freezetag_count_alive_players();
                return true; // let the player die so that he can respawn whenever he wants
@@ -371,7 +372,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
                || frag_deathtype == DEATH_TEAMCHANGE.m_id || frag_deathtype == DEATH_AUTOTEAMCHANGE.m_id)
        {
                // let the player die, he will be automatically frozen when he respawns
-               if(STAT(FROZEN, frag_target) != 1)
+               if (STAT(FROZEN, frag_target) != FROZEN_NORMAL)
                {
                        freezetag_Add_Score(frag_target, frag_attacker);
                        freezetag_count_alive_players();
@@ -383,7 +384,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies)
                return true;
        }
 
-       if(STAT(FROZEN, frag_target))
+       if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
                return true;
 
        freezetag_Freeze(frag_target, frag_attacker);
@@ -465,7 +466,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
        int n;
        entity o = NULL;
        entity player = M_ARGV(0, entity);
-       //if(STAT(FROZEN, player))
+       //if (STAT(FROZEN, player) == FROZEN_NORMAL)
        //if(player.freezetag_frozen_timeout > 0 && time < player.freezetag_frozen_timeout)
                //player.iceblock.alpha = ICE_MIN_ALPHA + (ICE_MAX_ALPHA - ICE_MIN_ALPHA) * (player.freezetag_frozen_timeout - time) / (player.freezetag_frozen_timeout - player.freezetag_frozen_time);
 
@@ -476,22 +477,19 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
                n = 0;
                FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
-                       if(STAT(FROZEN, it) == 0)
-                       if(!IS_DEAD(it))
-                       if(SAME_TEAM(it, player))
+                       if (!STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player))
                        if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
                        {
                                if(!o)
                                        o = it;
-                               if(STAT(FROZEN, player) == 1)
+                               if (STAT(FROZEN, player) == FROZEN_NORMAL)
                                        it.reviving = true;
                                ++n;
                        }
                });
-
        }
 
-       if(n && STAT(FROZEN, player) == 1) // OK, there is at least one teammate reviving us
+       if (n && STAT(FROZEN, player) == FROZEN_NORMAL) // 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);
                SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
@@ -525,12 +523,12 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                        it.reviving = false;
                });
        }
-       else if(!n && STAT(FROZEN, player) == 1) // only if no teammate is nearby will we reset
+       else if (!n && STAT(FROZEN, player) == FROZEN_NORMAL) // only if no teammate is nearby will we reset
        {
                STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) - frametime * autocvar_g_freezetag_revive_clearspeed, 1);
                SetResourceAmountExplicit(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * ((warmup_stage) ? warmup_start_health : start_health)));
        }
-       else if(!n && !STAT(FROZEN, player))
+       else if (!n && !STAT(FROZEN, player))
        {
                STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody
        }
@@ -591,7 +589,7 @@ MUTATOR_HOOKFUNCTION(ft, FragCenterMessage)
        int kill_count_to_attacker = M_ARGV(3, int);
        int kill_count_to_target = M_ARGV(4, int);
 
-       if(STAT(FROZEN, frag_target))
+       if(STAT(FROZEN, frag_target) == FROZEN_NORMAL)
                return; // target was already frozen, so this is just pushing them off the cliff
 
        Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : CS(frag_target).ping));
index 011e14ca385627e91a276132f420e2e3fb276cca..004fbf92b659a8c5641f20f8eea173770c676771 100644 (file)
@@ -1157,7 +1157,7 @@ void Monster_Anim(entity this)
 
 void Monster_Frozen_Think(entity this)
 {
-       if (STAT(FROZEN, this) == 2) // reviving in progress
+       if (STAT(FROZEN, this) == FROZEN_TEMP_REVIVING)
        {
                STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + this.ticrate * this.revive_speed, 1);
                SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * this.max_health));
@@ -1169,7 +1169,7 @@ void Monster_Frozen_Think(entity this)
                if(STAT(REVIVE_PROGRESS, this) >= 1)
                        Unfreeze(this, false);
        }
-       else if (STAT(FROZEN, this) == 3) // ice nade progress until explosion
+       else if (STAT(FROZEN, this) == FROZEN_TEMP_DYING)
        {
                STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - this.ticrate * this.revive_speed, 1);
                SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
index ef9be3459a53a995fa6af2db5c49f9d2a75f7f9a..b6dafe7604dc709798bf2be59de7e01d9b45f5d8 100644 (file)
@@ -1021,7 +1021,7 @@ void nades_GiveBonus(entity player, float score)
        if (autocvar_g_nades_bonus)
        if (IS_REAL_CLIENT(player))
        if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
-       if (STAT(FROZEN, player) == 0)
+       if (!STAT(FROZEN, player))
        if (!IS_DEAD(player))
        {
                if ( STAT(NADE_BONUS_SCORE, player) < 1 )
@@ -1332,12 +1332,12 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
        entity o = NULL;
        if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
                n = -1;
-       else if(STAT(FROZEN, player) == 3)
+       else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
        {
                vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
                n = 0;
                FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
-                       if(!IS_DEAD(it) && STAT(FROZEN, it) == 0 && SAME_TEAM(it, player))
+                       if (!IS_DEAD(it) && !STAT(FROZEN, it) && SAME_TEAM(it, player))
                        if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
                        {
                                if(!o)
@@ -1348,7 +1348,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                });
        }
 
-       if(n > 0 && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
+       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);
                SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
index 4962ddbe6ed6b414623ee595f632cffc742c4b6a..37fb5f0d524d78bc7b8180d049213ab407fd72da 100644 (file)
@@ -733,7 +733,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
        // Cant touch this
        if (GetResourceAmount(e_target, RESOURCE_HEALTH) <= 0)
                return -6;
-       else if(STAT(FROZEN, e_target) > 0)
+       else if (STAT(FROZEN, e_target))
                return -6;
 
        // vehicle
index 2f5e8e46bf234d50efeb7e9a3670bf7466955823..be8d468fa78dca4048312bc69df8fc4c52fe6c6f 100644 (file)
@@ -966,7 +966,7 @@ bool vehicle_impulse(entity this, int imp)
 
 void vehicles_enter(entity pl, entity veh)
 {
-   // Remove this when bots know how to use vehicles
+       // Remove this when bots know how to use vehicles
        if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
                return;
 
index d927e9c6f8d693081086d140b9a735d5dd7e0ab3..489f2cc764a1f5bbeb82b176e96a8acc0ea0746a 100644 (file)
@@ -2404,7 +2404,7 @@ void PlayerPreThink (entity this)
 
        if(IS_PLAYER(this))
        {
-               if (STAT(FROZEN, this) == 2) // reviving in progress
+               if (STAT(FROZEN, this) == FROZEN_TEMP_REVIVING)
                {
                        STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) + frametime * this.revive_speed, 1);
                        SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, this) * start_health));
@@ -2413,7 +2413,7 @@ void PlayerPreThink (entity this)
                        if (STAT(REVIVE_PROGRESS, this) >= 1)
                                Unfreeze(this, false);
                }
-               else if (STAT(FROZEN, this) == 3) // ice nade progress until explosion
+               else if (STAT(FROZEN, this) == FROZEN_TEMP_DYING)
                {
                        STAT(REVIVE_PROGRESS, this) = bound(0, STAT(REVIVE_PROGRESS, this) - frametime * this.revive_speed, 1);
                        SetResourceAmountExplicit(this, RESOURCE_HEALTH, max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * STAT(REVIVE_PROGRESS, this)));
index 58111fb12bcfea9482a8d89b6d0dbceaf31ab42e..e81cf7228b937c6b2c1a108c388d4bb898d995d9 100644 (file)
@@ -340,6 +340,11 @@ string deathmessage;
 
 .float ballistics_density; // wall piercing factor, larger = bullet can pass through more
 
+//const int FROZEN_NOT                         = 0;
+const int FROZEN_NORMAL                                = 1;
+const int FROZEN_TEMP_REVIVING         = 2;
+const int FROZEN_TEMP_DYING                    = 3;
+
 const int ACTIVE_NOT           = 0;
 const int ACTIVE_ACTIVE        = 1;
 const int ACTIVE_IDLE          = 2;
index c2c2b85bc54bcf0678121697bc2334ae40ba69a5..c238b93f6ece829649afef7b136824d1585b1692 100644 (file)
@@ -489,8 +489,8 @@ void Freeze(entity targ, float revivespeed, int frozen_type, bool show_waypoint)
        float targ_maxhealth = ((IS_MONSTER(targ)) ? targ.max_health : start_health);
 
        STAT(FROZEN, targ) = frozen_type;
-       STAT(REVIVE_PROGRESS, targ) = ((frozen_type == 3) ? 1 : 0);
-       SetResourceAmount(targ, RESOURCE_HEALTH, ((frozen_type == 3) ? targ_maxhealth : 1));
+       STAT(REVIVE_PROGRESS, targ) = ((frozen_type == FROZEN_TEMP_DYING) ? 1 : 0);
+       SetResourceAmount(targ, RESOURCE_HEALTH, ((frozen_type == FROZEN_TEMP_DYING) ? targ_maxhealth : 1));
        targ.revive_speed = revivespeed;
        if(targ.bot_attack)
                IL_REMOVE(g_bot_targets, targ);
@@ -534,7 +534,7 @@ void Unfreeze(entity targ, bool reset_health)
        if(!STAT(FROZEN, targ))
                return;
 
-       if (reset_health && STAT(FROZEN, targ) != 3) // only reset health if target was frozen
+       if (reset_health && STAT(FROZEN, targ) != FROZEN_TEMP_DYING)
                SetResourceAmount(targ, RESOURCE_HEALTH, ((IS_PLAYER(targ)) ? start_health : targ.max_health));
 
        targ.pauseregen_finished = time + autocvar_g_balance_pause_health_regen;
@@ -1248,7 +1248,6 @@ void Fire_ApplyDamage(entity e)
                        }
                });
        }
-                       
 }
 
 void Fire_ApplyEffect(entity e)