Fixes the invincible portion of #2422 "target_items issues"
authorterencehill <piuntn@gmail.com>
Tue, 12 May 2020 12:16:34 +0000 (14:16 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 12 May 2020 12:16:34 +0000 (14:16 +0200)
13 files changed:
qcsrc/common/items/item.qh
qcsrc/common/mutators/mutator/instagib/sv_instagib.qc
qcsrc/common/mutators/mutator/superspec/sv_superspec.qc
qcsrc/common/t_items.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/minelayer.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 1a71a21..d095c81 100644 (file)
@@ -48,7 +48,7 @@ const int IT_PICKUPMASK                       = IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPER
 
 #ifdef SVQC
 .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);
+.float invincible_finished; // ditto
 
 #define spawnfunc_body(item) \
        if (!Item_IsDefinitionAllowed(item)) \
index 272680f..0e0716d 100644 (file)
@@ -255,8 +255,8 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
 
        if (player.items & ITEM_Speed.m_itemid)
        {
-               play_countdown(player, player.invincible_finished, SND_POWEROFF);
-               if (time > player.invincible_finished)
+               play_countdown(player, STAT(INVINCIBLE_FINISHED, player), SND_POWEROFF);
+               if (time > STAT(INVINCIBLE_FINISHED, player))
                {
                        player.items &= ~ITEM_Speed.m_itemid;
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_POWERDOWN_SPEED);
@@ -264,7 +264,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups)
        }
        else
        {
-               if (time < player.invincible_finished)
+               if (time < STAT(INVINCIBLE_FINISHED, player))
                {
                        player.items |= ITEM_Speed.m_itemid;
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_SPEED, player.netname);
index 5fe52b2..c721f45 100644 (file)
@@ -346,7 +346,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
 
        if(cmd_name == "followpowerup")
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && (STAT(STRENGTH_FINISHED, it) > time || it.invincible_finished > time), { return superspec_Spectate(player, it); });
+               FOREACH_CLIENT(IS_PLAYER(it) && (STAT(STRENGTH_FINISHED, it) > time || STAT(INVINCIBLE_FINISHED, it) > time), { return superspec_Spectate(player, it); });
 
                superspec_msg("", "", player, "No active powerup\n", 1);
                return true;
@@ -362,7 +362,7 @@ MUTATOR_HOOKFUNCTION(superspec, SV_ParseClientCommand)
 
        if(cmd_name == "followshield")
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && it.invincible_finished > time, { return superspec_Spectate(player, it); });
+               FOREACH_CLIENT(IS_PLAYER(it) && STAT(INVINCIBLE_FINISHED, it) > time, { return superspec_Spectate(player, it); });
 
                superspec_msg("", "", player, "No active Shield\n", 1);
                return true;
index 0fcc35a..d3f113d 100644 (file)
@@ -831,7 +831,7 @@ bool Item_GiveTo(entity item, entity player)
        if (item.invincible_finished)
        {
                pickedup = true;
-               player.invincible_finished = max(player.invincible_finished, time) + item.invincible_finished;
+               STAT(INVINCIBLE_FINISHED, player) = max(STAT(INVINCIBLE_FINISHED, player), time) + item.invincible_finished;
        }
        if (item.superweapons_finished)
        {
@@ -1718,14 +1718,14 @@ float GiveItems(entity e, float beginarg, float endarg)
        }
 
        STAT(STRENGTH_FINISHED, e) = max(0, STAT(STRENGTH_FINISHED, e) - time);
-       e.invincible_finished = max(0, e.invincible_finished - time);
+       STAT(INVINCIBLE_FINISHED, e) = max(0, STAT(INVINCIBLE_FINISHED, e) - 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, stat_STRENGTH_FINISHED);
-       PREGIVE(e, invincible_finished);
+       PREGIVE(e, stat_INVINCIBLE_FINISHED);
        PREGIVE(e, superweapons_finished);
        PREGIVE_RESOURCE(e, RES_BULLETS);
        PREGIVE_RESOURCE(e, RES_CELLS);
@@ -1766,7 +1766,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                        case "ALL":
                                got += GiveBit(e, items, ITEM_JetpackRegen.m_itemid, op, val);
                                got += GiveValue(e, stat_STRENGTH_FINISHED, op, val);
-                               got += GiveValue(e, invincible_finished, op, val);
+                               got += GiveValue(e, stat_INVINCIBLE_FINISHED, op, val);
                                got += GiveValue(e, superweapons_finished, op, val);
                                got += GiveBit(e, items, IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS, op, val);
                        case "all":
@@ -1805,7 +1805,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveValue(e, stat_STRENGTH_FINISHED, op, val);
                                break;
                        case "invincible":
-                               got += GiveValue(e, invincible_finished, op, val);
+                               got += GiveValue(e, stat_INVINCIBLE_FINISHED, op, val);
                                break;
                        case "superweapons":
                                got += GiveValue(e, superweapons_finished, op, val);
@@ -1862,7 +1862,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                it.wr_init(it);
        });
        POSTGIVE_VALUE(e, stat_STRENGTH_FINISHED, 1, SND_POWERUP, SND_POWEROFF);
-       POSTGIVE_VALUE(e, invincible_finished, 1, SND_Shield, SND_POWEROFF);
+       POSTGIVE_VALUE(e, stat_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);
        POSTGIVE_RESOURCE(e, RES_CELLS, 0, SND_ITEMPICKUP, SND_Null);
@@ -1881,10 +1881,10 @@ float GiveItems(entity e, float beginarg, float endarg)
                STAT(STRENGTH_FINISHED, e) = 0;
        else
                STAT(STRENGTH_FINISHED, e) += time;
-       if(e.invincible_finished <= 0)
-               e.invincible_finished = 0;
+       if(STAT(INVINCIBLE_FINISHED, e) <= 0)
+               STAT(INVINCIBLE_FINISHED, e) = 0;
        else
-               e.invincible_finished += time;
+               STAT(INVINCIBLE_FINISHED, e) += time;
        if(e.superweapons_finished <= 0)
                e.superweapons_finished = 0;
        else
index eb11c27..ff124d0 100644 (file)
@@ -255,6 +255,7 @@ bool racer_frame(entity this, float dt)
                }
 
 #ifdef SVQC
+               // NOTE: reusing .invincible_finished here as delay counter for the smoke effect
                if(vehic.invincible_finished < time)
                {
                        traceline(vehic.origin, vehic.origin - '0 0 256', MOVE_NORMAL, vehic);
index fce84c3..997f6eb 100644 (file)
@@ -401,7 +401,7 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponenti
         });
         float desirabledamage;
         desirabledamage = enemydamage;
-        if(time > actor.invincible_finished && time > actor.spawnshieldtime)
+        if(time > STAT(INVINCIBLE_FINISHED, actor) && time > actor.spawnshieldtime)
             desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent;
         if(teamplay && actor.team)
             desirabledamage = desirabledamage - teamdamage;
index 7f60c5b..9009007 100644 (file)
@@ -389,7 +389,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit
 
         float desirabledamage;
         desirabledamage = enemydamage;
-        if(time > actor.invincible_finished && time > actor.spawnshieldtime)
+        if(time > STAT(INVINCIBLE_FINISHED, actor) && time > actor.spawnshieldtime)
             desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent;
         if(teamplay && actor.team)
             desirabledamage = desirabledamage - teamdamage;
index f5587d6..aee3506 100644 (file)
@@ -562,7 +562,7 @@ void havocbot_movetogoal(entity this)
        {
                #define ROCKETJUMP_DAMAGE() WEP_CVAR(devastator, damage) * 0.8 \
                        * ((STAT(STRENGTH_FINISHED, this) > time) ? autocvar_g_balance_powerup_strength_selfdamage : 1) \
-                       * ((this.invincible_finished > time) ? autocvar_g_balance_powerup_invincible_takedamage : 1)
+                       * ((STAT(INVINCIBLE_FINISHED, this) > time) ? autocvar_g_balance_powerup_invincible_takedamage : 1)
 
                // save some CPU cycles by checking trigger_hurt after checking
                // that something can be done to evade it (cheaper checks)
index ba61b83..d078cae 100644 (file)
@@ -202,8 +202,8 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
                {
                        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;
+                       if (time < STAT(INVINCIBLE_FINISHED, this) - 1) t += 0.2;
+                       if (time < STAT(INVINCIBLE_FINISHED, it) - 1) t -= 0.4;
                }
                t += max(0, 8 - skill) * 0.05; // less skilled bots attack more mindlessly
                ratingscale *= t;
index edec56a..186677d 100644 (file)
@@ -169,7 +169,7 @@ float CheatImpulse(entity this, int imp)
                        this.personal.pauserotfuel_finished = this.pauserotfuel_finished;
                        this.personal.pauseregen_finished = this.pauseregen_finished;
                        STAT(STRENGTH_FINISHED, this.personal) = STAT(STRENGTH_FINISHED, this);
-                       this.personal.invincible_finished = this.invincible_finished;
+                       STAT(INVINCIBLE_FINISHED, this.personal) = STAT(INVINCIBLE_FINISHED, this);
                        this.personal.teleport_time = time;
                        break; // this part itself doesn't cheat, so let's not count this
                case CHIMPULSE_CLONE_MOVING.impulse:
@@ -230,7 +230,7 @@ float CheatImpulse(entity this, int imp)
                                this.pauserotfuel_finished = time + this.personal.pauserotfuel_finished - this.personal.teleport_time;
                                this.pauseregen_finished = time + this.personal.pauseregen_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;
+                               STAT(INVINCIBLE_FINISHED, this) = time + STAT(INVINCIBLE_FINISHED, this.personal) - this.personal.teleport_time;
 
                                if(!autocvar_g_allow_checkpoints)
                                        DID_CHEAT();
index 0326d19..734dbc9 100644 (file)
@@ -335,7 +335,7 @@ void PutObserverInServer(entity this)
        this.pain_frame = 0;
        this.pain_finished = 0;
        STAT(STRENGTH_FINISHED, this) = 0;
-       this.invincible_finished = 0;
+       STAT(INVINCIBLE_FINISHED, this) = 0;
        this.superweapons_finished = 0;
        this.air_finished = 0;
        //this.dphitcontentsmask = 0;
@@ -639,7 +639,7 @@ void PutPlayerInServer(entity this)
        this.punchvector = '0 0 0';
 
        STAT(STRENGTH_FINISHED, this) = 0;
-       this.invincible_finished = 0;
+       STAT(INVINCIBLE_FINISHED, this) = 0;
        this.fire_endtime = -1;
        STAT(REVIVE_PROGRESS, this) = 0;
        this.revival_time = 0;
@@ -1436,9 +1436,9 @@ void player_powerups(entity this)
                }
                if (this.items & ITEM_Shield.m_itemid)
                {
-                       play_countdown(this, this.invincible_finished, SND_POWEROFF);
+                       play_countdown(this, STAT(INVINCIBLE_FINISHED, this), SND_POWEROFF);
                        this.effects = this.effects | (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
-                       if (time > this.invincible_finished)
+                       if (time > STAT(INVINCIBLE_FINISHED, this))
                        {
                                this.items = this.items - (this.items & ITEM_Shield.m_itemid);
                                //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERDOWN_SHIELD, this.netname);
@@ -1447,7 +1447,7 @@ void player_powerups(entity this)
                }
                else
                {
-                       if (time < this.invincible_finished)
+                       if (time < STAT(INVINCIBLE_FINISHED, this))
                        {
                                this.items = this.items | ITEM_Shield.m_itemid;
                                if(!g_cts)
@@ -1683,7 +1683,7 @@ void SpectateCopy(entity this, entity spectatee)
        STAT(LAST_PICKUP, this) = STAT(LAST_PICKUP, spectatee);
        STAT(HIT_TIME, this) = STAT(HIT_TIME, spectatee);
        STAT(STRENGTH_FINISHED, this) = STAT(STRENGTH_FINISHED, spectatee);
-       this.invincible_finished = spectatee.invincible_finished;
+       STAT(INVINCIBLE_FINISHED, this) = STAT(INVINCIBLE_FINISHED, spectatee);
        this.superweapons_finished = spectatee.superweapons_finished;
        this.air_finished = spectatee.air_finished;
        STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee);
index dbf2a80..2517923 100644 (file)
@@ -117,7 +117,7 @@ void target_init_use(entity this, entity actor, entity trigger)
        if (!(this.spawnflags & 8))
        {
                STAT(STRENGTH_FINISHED, actor) = 0;
-               actor.invincible_finished = 0;
+               STAT(INVINCIBLE_FINISHED, actor) = 0;
                if(STAT(BUFFS, actor)) // TODO: make a dropbuffs function to handle this
                {
                        int buffid = buff_FirstFromFlags(STAT(BUFFS, actor)).m_id;
index fc79625..ac38e64 100644 (file)
@@ -87,7 +87,7 @@ string AppendItemcodes(string s, entity player)
        }
        if(time < STAT(STRENGTH_FINISHED, player))
                s = strcat(s, "S");
-       if(time < player.invincible_finished)
+       if(time < STAT(INVINCIBLE_FINISHED, player))
                s = strcat(s, "I");
        if(PHYS_INPUT_BUTTON_CHAT(player))
                s = strcat(s, "T");