From c9c3f1ef20432b621841a572b84ee47a171bcf44 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Feb 2017 00:01:51 +1000 Subject: [PATCH] To prevent spamming pickups, add a delay between dropping a buff and picking up a new one (workaround for a bug when instantly picking up a buff of the same type) --- mutators.cfg | 1 + qcsrc/common/mutators/mutator/buffs/sv_buffs.qc | 5 ++++- qcsrc/common/mutators/mutator/buffs/sv_buffs.qh | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mutators.cfg b/mutators.cfg index d487327bc..d6ffe0c63 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -291,6 +291,7 @@ set cl_buffs_autoreplace 1 "automatically drop current buff when picking up anot set g_buffs -1 "enable buffs (requires buff items or powerups)" set g_buffs_effects 1 "show particle effects from carried buffs" set g_buffs_waypoint_distance 1024 "maximum distance at which buff waypoint can be seen from item" +set g_buffs_pickup_delay 0.7 "cooldown before player can pick up another buff after dropping one" set g_buffs_randomize 1 "randomize buff type when player drops buff" set g_buffs_random_lifetime 30 "re-spawn the buff again if it hasn't been touched after this time in seconds" set g_buffs_random_location 0 "randomize buff location on start and when reset" diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index edd970126..119829cba 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -160,6 +160,7 @@ void buff_Touch(entity this, entity toucher) if((this.team && DIFF_TEAM(toucher, this)) || (STAT(FROZEN, toucher)) || (toucher.vehicle) + || (time < toucher.buff_shield) || (!this.buff_active) ) { @@ -639,7 +640,8 @@ 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_time = 0; // already notified + 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; } @@ -840,6 +842,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 } } diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh index 8383a72ef..f738e9d9d 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh @@ -6,6 +6,7 @@ bool autocvar_g_buffs_effects; float autocvar_g_buffs_waypoint_distance; +float autocvar_g_buffs_pickup_delay = 0.7; bool autocvar_g_buffs_randomize; float autocvar_g_buffs_random_lifetime; bool autocvar_g_buffs_random_location; @@ -70,6 +71,7 @@ float autocvar_g_buffs_luck_damagemultiplier = 3; .float buff_activetime_updated; .entity buff_waypoint; .int oldbuffs; // for updating effects +.float buff_shield; // delay for players to keep them from spamming buff pickups .entity buff_model; // controls effects (TODO: make csqc) const vector BUFF_MIN = ('-16 -16 0'); -- 2.39.2