]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move the buff checks below the BuffTouch hook incase the new target isn't valid,...
authorMario <mario@smbclan.net>
Tue, 18 Jul 2017 17:06:57 +0000 (03:06 +1000)
committerMario <mario@smbclan.net>
Tue, 18 Jul 2017 17:06:57 +0000 (03:06 +1000)
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/server/client.qh

index 032ecff0a0d78b844d0f195f379916ddd441e520..fdc555dd2a90ede54ae5bfe332cce78a9108b833 100644 (file)
@@ -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
                }
        }
 
index 01b6ad9fd754424c61da7c0e7e5b08a36b6c478d..8e8c8d71b3a5af1d0e8c17d164bae28f2f858e23 100644 (file)
@@ -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;