From e019e93fac1785e09156f2c3c04a71c6246d8179 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Apr 2020 22:54:50 +1000 Subject: [PATCH] Attempt to separate .strength_finished and STAT(STRENGTH_FINISHED) (the former acts as a map editor key) --- qcsrc/common/items/item.qh | 2 +- .../common/mutators/mutator/buffs/sv_buffs.qc | 4 ++-- .../mutators/mutator/instagib/sv_instagib.qc | 6 +++--- qcsrc/common/t_items.qc | 18 +++++++++--------- qcsrc/common/vehicles/vehicle/racer.qc | 1 + qcsrc/server/bot/default/havocbot/havocbot.qc | 2 +- qcsrc/server/bot/default/havocbot/roles.qc | 4 ++-- qcsrc/server/cheats.qc | 4 ++-- qcsrc/server/client.qc | 12 ++++++------ qcsrc/server/compat/quake3.qc | 2 +- qcsrc/server/g_damage.qc | 2 +- 11 files changed, 29 insertions(+), 28 deletions(-) diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index 8ba009671..1a71a217d 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -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) \ diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 83b471cd8..5ec00e125 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 93812044c..272680fb2 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -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; diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index a05f90f9e..4ab00a027 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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 diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index b3cac72e5..eb11c2709 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -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"); diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 619d08dc5..db56478f8 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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 diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 84c597329..ba61b8394 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -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; } diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 1acab9c00..edec56a80 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 271c80396..76bb8f8c2 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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; diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 630b1ceb8..dbf2a8017 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -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 { diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index e14ecd6ce..fc7962599 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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"); -- 2.39.2