From: terencehill Date: Tue, 12 May 2020 12:16:34 +0000 (+0200) Subject: Fixes the invincible portion of #2422 "target_items issues" X-Git-Tag: xonotic-v0.8.5~1079 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c4bfc02ca6a736d20abf4d57fe19b599b9150356;p=xonotic%2Fxonotic-data.pk3dir.git Fixes the invincible portion of #2422 "target_items issues" --- diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index 1a71a217d..d095c8134 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -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)) \ diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 272680fb2..0e0716dd1 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc b/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc index 5fe52b2d5..c721f4571 100644 --- a/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc +++ b/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc @@ -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; diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 0fcc35a31..d3f113d03 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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 diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index eb11c2709..ff124d0b4 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index fce84c3b8..997f6eb36 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 7f60c5b57..90090077c 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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; diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index f5587d69d..aee350635 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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) diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index ba61b8394..d078cae86 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -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; diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index edec56a80..186677df9 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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(); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 0326d1987..734dbc9f5 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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); diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index dbf2a8017..2517923f2 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -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; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index fc7962599..ac38e645b 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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");