]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Attempt to separate .strength_finished and STAT(STRENGTH_FINISHED) (the former acts...
authorMario <mario.mario@y7mail.com>
Mon, 13 Apr 2020 12:54:50 +0000 (22:54 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 13 Apr 2020 12:54:50 +0000 (22:54 +1000)
qcsrc/common/items/item.qh
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/instagib/sv_instagib.qc
qcsrc/common/t_items.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/cheats.qc
qcsrc/server/client.qc
qcsrc/server/compat/quake3.qc
qcsrc/server/g_damage.qc

index 8ba0096713342a7c7a5364b95ffe8fb58674c2e2..1a71a217db170904944254ed02ddb615209c5603 100644 (file)
@@ -47,7 +47,7 @@ const int IT_STRENGTH                                 = BIT(22);
 const int IT_PICKUPMASK                        = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
 
 #ifdef SVQC
-const .float strength_finished = _STAT(STRENGTH_FINISHED);
+.float strength_finished; // NOTE: this field is used only by map entities, it does not directly apply the strength stat
 const .float invincible_finished = _STAT(INVINCIBLE_FINISHED);
 
 #define spawnfunc_body(item) \
index 83b471cd810e0c6ae992c9f115d70abc0cabff2a..5ec00e1253008e57e4c330e7ccb0ee82d171260e 100644 (file)
@@ -955,7 +955,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONADD(BUFF_INVISIBLE)
                {
-                       if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
+                       if(time < STAT(STRENGTH_FINISHED, player) && MUTATOR_IS_ENABLED(mutator_instagib))
                                player.buff_invisible_prev_alpha = default_player_alpha; // we don't want to save the powerup's alpha, as player may lose the powerup while holding the buff
                        else
                                player.buff_invisible_prev_alpha = player.alpha;
@@ -964,7 +964,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
 
                BUFF_ONREM(BUFF_INVISIBLE)
                {
-                       if(time < player.strength_finished && MUTATOR_IS_ENABLED(mutator_instagib))
+                       if(time < STAT(STRENGTH_FINISHED, player) && MUTATOR_IS_ENABLED(mutator_instagib))
                                player.alpha = autocvar_g_instagib_invis_alpha;
                        else
                                player.alpha = player.buff_invisible_prev_alpha;
index 93812044c6b4b19ec79437ec8acd73dc9719451a..272680fb20351adf6de41097db683967036ce2e2 100644 (file)
@@ -232,8 +232,8 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
 
        if (player.items & ITEM_Invisibility.m_itemid)
        {
-               play_countdown(player, player.strength_finished, SND_POWEROFF);
-               if (time > player.strength_finished)
+               play_countdown(player, STAT(STRENGTH_FINISHED, player), SND_POWEROFF);
+               if (time > STAT(STRENGTH_FINISHED, player))
                {
                        player.alpha = default_player_alpha;
                        player.exteriorweaponentity.alpha = default_weapon_alpha;
@@ -243,7 +243,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
        }
        else
        {
-               if (time < player.strength_finished)
+               if (time < STAT(STRENGTH_FINISHED, player))
                {
                        player.alpha = autocvar_g_instagib_invis_alpha;
                        player.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
index a05f90f9e60b1aa757dac29975714102344a4b9b..4ab00a0272edb33b0081efb199ef54cb0d88eecc 100644 (file)
@@ -825,7 +825,7 @@ bool Item_GiveTo(entity item, entity player)
        if (item.strength_finished)
        {
                pickedup = true;
-               player.strength_finished = max(player.strength_finished, time) + item.strength_finished;
+               STAT(STRENGTH_FINISHED, player) = max(STAT(STRENGTH_FINISHED, player), time) + item.strength_finished;
        }
        if (item.invincible_finished)
        {
@@ -1705,14 +1705,14 @@ float GiveItems(entity e, float beginarg, float endarg)
                }
        }
 
-       e.strength_finished = max(0, e.strength_finished - time);
+       STAT(STRENGTH_FINISHED, e) = max(0, STAT(STRENGTH_FINISHED, e) - time);
        e.invincible_finished = max(0, e.invincible_finished - time);
        e.superweapons_finished = max(0, e.superweapons_finished - time);
        STAT(BUFF_TIME, e) = max(0, STAT(BUFF_TIME, e) - time);
 
        PREGIVE(e, items);
        PREGIVE_WEAPONS(e);
-       PREGIVE(e, strength_finished);
+       PREGIVE(e, stat_STRENGTH_FINISHED);
        PREGIVE(e, invincible_finished);
        PREGIVE(e, superweapons_finished);
        PREGIVE_RESOURCE(e, RES_BULLETS);
@@ -1753,7 +1753,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                continue;
                        case "ALL":
                                got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
-                               got += GiveValue(e, strength_finished, op, val);
+                               got += GiveValue(e, stat_STRENGTH_FINISHED, op, val);
                                got += GiveValue(e, invincible_finished, op, val);
                                got += GiveValue(e, superweapons_finished, op, val);
                                got += GiveBit(e, items, IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS, op, val);
@@ -1790,7 +1790,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
                                break;
                        case "strength":
-                               got += GiveValue(e, strength_finished, op, val);
+                               got += GiveValue(e, stat_STRENGTH_FINISHED, op, val);
                                break;
                        case "invincible":
                                got += GiveValue(e, invincible_finished, op, val);
@@ -1849,7 +1849,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                        if(STAT(WEAPONS, e) & (it.m_wepset))
                                it.wr_init(it);
        });
-       POSTGIVE_VALUE(e, strength_finished, 1, SND_POWERUP, SND_POWEROFF);
+       POSTGIVE_VALUE(e, stat_STRENGTH_FINISHED, 1, SND_POWERUP, SND_POWEROFF);
        POSTGIVE_VALUE(e, invincible_finished, 1, SND_Shield, SND_POWEROFF);
        //POSTGIVE_VALUE(e, superweapons_finished, 1, SND_Null, SND_Null);
        POSTGIVE_RESOURCE(e, RES_BULLETS, 0, SND_ITEMPICKUP, SND_Null);
@@ -1865,10 +1865,10 @@ float GiveItems(entity e, float beginarg, float endarg)
                if(!g_weaponarena && (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
                        e.superweapons_finished = autocvar_g_balance_superweapons_time;
 
-       if(e.strength_finished <= 0)
-               e.strength_finished = 0;
+       if(STAT(STRENGTH_FINISHED, e) <= 0)
+               STAT(STRENGTH_FINISHED, e) = 0;
        else
-               e.strength_finished += time;
+               STAT(STRENGTH_FINISHED, e) += time;
        if(e.invincible_finished <= 0)
                e.invincible_finished = 0;
        else
index b3cac72e5c8d8dddad0a0e72ae103ccf23d3fdf8..eb11c27093a022e9edd348a27e98cb83e504bb8f 100644 (file)
@@ -264,6 +264,7 @@ bool racer_frame(entity this, float dt)
                        vehic.invincible_finished = time + 0.1 + (random() * 0.1);
                }
 
+               // NOTE: reusing .strength_finished here as a sound delay counter
                if(vehic.strength_finished < time)
                {
                        vehic.strength_finished = time + 10.922667; //soundlength("vehicles/racer_boost.wav");
index 619d08dc5c878e23f4d131d2ecb2dd10a93ee826..db56478f87eadd33a7c63ba318d575b8e5d80215 100644 (file)
@@ -561,7 +561,7 @@ void havocbot_movetogoal(entity this)
        if (skill > 6 && !(IS_ONGROUND(this)))
        {
                #define ROCKETJUMP_DAMAGE() WEP_CVAR(devastator, damage) * 0.8 \
-                       * ((this.strength_finished > time) ? autocvar_g_balance_powerup_strength_selfdamage : 1) \
+                       * ((STAT(STRENGTH_FINISHED, this) > time) ? autocvar_g_balance_powerup_strength_selfdamage : 1) \
                        * ((this.invincible_finished > time) ? autocvar_g_balance_powerup_invincible_takedamage : 1)
 
                // save some CPU cycles by checking trigger_hurt after checking
index 84c597329ea5fda0eb0930dfec079be15e7edb22..ba61b83940fb547b44649a8bfee6369141711920 100644 (file)
@@ -200,8 +200,8 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
                t = bound(0, 1 + t, 3);
                if (skill > 3)
                {
-                       if (time < this.strength_finished - 1) t += 0.5;
-                       if (time < it.strength_finished - 1) t -= 0.5;
+                       if (time < STAT(STRENGTH_FINISHED, this) - 1) t += 0.5;
+                       if (time < STAT(STRENGTH_FINISHED, it) - 1) t -= 0.5;
                        if (time < this.invincible_finished - 1) t += 0.2;
                        if (time < it.invincible_finished - 1) t -= 0.4;
                }
index 1acab9c00535d647e18a26f1ba35ff55d0ba7cf2..edec56a809a8dcc63fb822383b8c8a666bc54ba9 100644 (file)
@@ -168,7 +168,7 @@ float CheatImpulse(entity this, int imp)
                        this.personal.pauserothealth_finished = this.pauserothealth_finished;
                        this.personal.pauserotfuel_finished = this.pauserotfuel_finished;
                        this.personal.pauseregen_finished = this.pauseregen_finished;
-                       this.personal.strength_finished = this.strength_finished;
+                       STAT(STRENGTH_FINISHED, this.personal) = STAT(STRENGTH_FINISHED, this);
                        this.personal.invincible_finished = this.invincible_finished;
                        this.personal.teleport_time = time;
                        break; // this part itself doesn't cheat, so let's not count this
@@ -229,7 +229,7 @@ float CheatImpulse(entity this, int imp)
                                this.pauserothealth_finished = time + this.personal.pauserothealth_finished - this.personal.teleport_time;
                                this.pauserotfuel_finished = time + this.personal.pauserotfuel_finished - this.personal.teleport_time;
                                this.pauseregen_finished = time + this.personal.pauseregen_finished - this.personal.teleport_time;
-                               this.strength_finished = time + this.personal.strength_finished - this.personal.teleport_time;
+                               STAT(STRENGTH_FINISHED, this) = time + STAT(STRENGTH_FINISHED, this.personal) - this.personal.teleport_time;
                                this.invincible_finished = time + this.personal.invincible_finished - this.personal.teleport_time;
 
                                if(!autocvar_g_allow_checkpoints)
index 271c803961bbd8cd6b4d28bcc065150018fea1d4..76bb8f8c2f33128a1a4f538b8f3d7309f8b27586 100644 (file)
@@ -334,7 +334,7 @@ void PutObserverInServer(entity this)
        this.fade_time = 0;
        this.pain_frame = 0;
        this.pain_finished = 0;
-       this.strength_finished = 0;
+       STAT(STRENGTH_FINISHED, this) = 0;
        this.invincible_finished = 0;
        this.superweapons_finished = 0;
        this.air_finished = 0;
@@ -638,7 +638,7 @@ void PutPlayerInServer(entity this)
        this.punchangle = '0 0 0';
        this.punchvector = '0 0 0';
 
-       this.strength_finished = 0;
+       STAT(STRENGTH_FINISHED, this) = 0;
        this.invincible_finished = 0;
        this.fire_endtime = -1;
        STAT(REVIVE_PROGRESS, this) = 0;
@@ -1415,9 +1415,9 @@ void player_powerups(entity this)
        {
                if (this.items & ITEM_Strength.m_itemid)
                {
-                       play_countdown(this, this.strength_finished, SND_POWEROFF);
+                       play_countdown(this, STAT(STRENGTH_FINISHED, this), SND_POWEROFF);
                        this.effects = this.effects | (EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT);
-                       if (time > this.strength_finished)
+                       if (time > STAT(STRENGTH_FINISHED, this))
                        {
                                this.items = this.items - (this.items & ITEM_Strength.m_itemid);
                                //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERDOWN_STRENGTH, this.netname);
@@ -1426,7 +1426,7 @@ void player_powerups(entity this)
                }
                else
                {
-                       if (time < this.strength_finished)
+                       if (time < STAT(STRENGTH_FINISHED, this))
                        {
                                this.items = this.items | ITEM_Strength.m_itemid;
                                if(!g_cts)
@@ -1682,7 +1682,7 @@ void SpectateCopy(entity this, entity spectatee)
        this.items = spectatee.items;
        STAT(LAST_PICKUP, this) = STAT(LAST_PICKUP, spectatee);
        STAT(HIT_TIME, this) = STAT(HIT_TIME, spectatee);
-       this.strength_finished = spectatee.strength_finished;
+       STAT(STRENGTH_FINISHED, this) = STAT(STRENGTH_FINISHED, spectatee);
        this.invincible_finished = spectatee.invincible_finished;
        this.superweapons_finished = spectatee.superweapons_finished;
        this.air_finished = spectatee.air_finished;
index 630b1ceb850702ff30eb1323ba559317cd97600e..dbf2a80177ec55718aed480b1748f7fc23385d2d 100644 (file)
@@ -116,7 +116,7 @@ void target_init_use(entity this, entity actor, entity trigger)
 
        if (!(this.spawnflags & 8))
        {
-               actor.strength_finished = 0;
+               STAT(STRENGTH_FINISHED, actor) = 0;
                actor.invincible_finished = 0;
                if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
                {
index e14ecd6ce7808ebeeca7dd436dc1aa4d41db2127..fc7962599d10375918d0b946e33e0c600152cff9 100644 (file)
@@ -85,7 +85,7 @@ string AppendItemcodes(string s, entity player)
                if(w != 0 || slot == 0)
                        s = strcat(s, ftos(w));
        }
-       if(time < player.strength_finished)
+       if(time < STAT(STRENGTH_FINISHED, player))
                s = strcat(s, "S");
        if(time < player.invincible_finished)
                s = strcat(s, "I");