From: Mario Date: Tue, 18 Jul 2017 17:06:57 +0000 (+1000) Subject: Move the buff checks below the BuffTouch hook incase the new target isn't valid,... X-Git-Tag: xonotic-v0.8.5~2563 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5e0c59a38d6c8c7153ad1b41409630c6df0673ba;p=xonotic%2Fxonotic-data.pk3dir.git Move the buff checks below the BuffTouch hook incase the new target isn't valid, also port buff_shield to PlayerState --- diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 032ecff0a..fdc555dd2 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -157,16 +157,8 @@ void buff_Touch(entity this, entity toucher) return; } - if((this.team && DIFF_TEAM(toucher, this)) - || (STAT(FROZEN, toucher)) - || (toucher.vehicle) - || (time < toucher.buff_shield) - || (!this.buff_active) - ) - { - // can't touch this + if(!this.buff_active) return; - } if(MUTATOR_CALLHOOK(BuffTouch, this, toucher)) return; @@ -175,6 +167,16 @@ void buff_Touch(entity this, entity toucher) if(!IS_PLAYER(toucher)) return; // incase mutator changed toucher + if((this.team && DIFF_TEAM(toucher, this)) + || (STAT(FROZEN, toucher)) + || (toucher.vehicle) + || (time < PS(toucher).buff_shield) + ) + { + // can't touch this + return; + } + if (toucher.buffs) { if (toucher.cvar_cl_buffs_autoreplace && toucher.buffs != this.buffs) @@ -550,7 +552,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerSpawn) player.buffs = 0; player.buff_time = 0; - player.buff_shield = time + 0.5; // prevent picking up buffs immediately + PS(player).buff_shield = time + 0.5; // prevent picking up buffs immediately // reset timers here to prevent them continuing after re-spawn player.buff_disability_time = 0; player.buff_disability_effect_time = 0; @@ -619,7 +621,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerUseKey, CBC_ORDER_FIRST) Send_Notification(NOTIF_ALL_EXCEPT, player, MSG_INFO, INFO_ITEM_BUFF_LOST, player.netname, buffid); player.buffs = 0; - player.buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); + PS(player).buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); //player.buff_time = 0; // already notified sound(player, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM); return true; @@ -821,7 +823,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) else Send_Notification(NOTIF_ALL_EXCEPT, player, MSG_INFO, INFO_ITEM_BUFF_LOST, player.netname, buffid); player.buffs = 0; - player.buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); // always put in a delay, even if small + PS(player).buff_shield = time + max(0, autocvar_g_buffs_pickup_delay); // always put in a delay, even if small } } diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 01b6ad9fd..8e8c8d71b 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -156,6 +156,7 @@ CLASS(Player, Client) ATTRIB(Player, ballistics_density, float, this.ballistics_density); ATTRIB(Player, prevstrengthsound, float, this.prevstrengthsound); ATTRIB(Player, prevstrengthsoundattempt, float, this.prevstrengthsoundattempt); + ATTRIB(Player, buff_shield, float, this.buff_shield); INIT(Player) { this.classname = STR_PLAYER;