From 631838ce6dfbdb204df43c346c80b8bc557adb30 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 7 Jul 2023 20:02:41 +1000 Subject: [PATCH] Disable keepaway ball pickup delay The delay was frustrating when getting a bckill in midair but being unable to pick up the ball despite having travelled through it. We still need to prevent instant pickup by the previous owner so the ball can be dropped manually. Sharing a field from KH for this with the same 0.5s delay as used when throwing a weapon. --- .../gamemode/keepaway/sv_keepaway.qc | 7 +++++-- .../gamemodes/gamemode/keyhunt/sv_keyhunt.qc | 20 +++++++++---------- qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc | 7 +++++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index 9f694a0e0..cdb56060d 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -8,6 +8,7 @@ #include .entity ballcarried; +.entity previous_owner; // also used on kh keys int autocvar_g_keepaway_ballcarrier_effects; float autocvar_g_keepaway_ballcarrier_damage; @@ -124,7 +125,8 @@ void ka_TouchEvent(entity this, entity toucher) // runs any time that the ball c sound(this, CH_TRIGGER, SND_KA_TOUCH, VOL_BASE, ATTEN_NORM); return; } - else if(this.wait > time) { return; } + else if(this.wait > time && this.previous_owner == toucher) + return; // attach the ball to the player this.owner = toucher; @@ -189,7 +191,8 @@ void ka_DropEvent(entity player) // runs any time that a player is supposed to l // reset the ball setattachment(ball, NULL, ""); set_movetype(ball, MOVETYPE_BOUNCE); - ball.wait = time + 1; + ball.previous_owner = player; + ball.wait = time + 0.5; // same as for thrown weapons settouch(ball, ka_TouchEvent); setthink(ball, ka_RespawnBall); ball.nextthink = time + autocvar_g_keepawayball_respawntime; diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index 15024ed88..d9dda802c 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -76,7 +76,7 @@ float kh_interferemsg_time; .entity kh_next, kh_prev; // linked list .float kh_droptime; .int kh_dropperteam; -.entity kh_previous_owner; +.entity previous_owner; // also used on ka balls .int kh_previous_owner_playerid; int kh_key_dropped, kh_key_carried; @@ -298,7 +298,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs // let key.team stay key.modelindex = kh_key_dropped; navigation_dynamicgoal_set(key, key.owner); - key.kh_previous_owner = key.owner; + key.previous_owner = key.owner; key.kh_previous_owner_playerid = key.owner.playerid; } @@ -584,8 +584,8 @@ void kh_LoserTeam(int loser_team, entity lostkey) // runs when a player pushes if(attacker) { - if(lostkey.kh_previous_owner) - kh_Scores_Event(lostkey.kh_previous_owner, NULL, "pushed", 0, -autocvar_g_balance_keyhunt_score_push); + if(lostkey.previous_owner) + kh_Scores_Event(lostkey.previous_owner, NULL, "pushed", 0, -autocvar_g_balance_keyhunt_score_push); // don't actually GIVE them the -nn points, just log kh_Scores_Event(attacker, NULL, "push", autocvar_g_balance_keyhunt_score_push, 0); GameRules_scoring_add(attacker, KH_PUSHES, 1); @@ -604,12 +604,12 @@ void kh_LoserTeam(int loser_team, entity lostkey) // runs when a player pushes if(key.owner && key.team != loser_team) ++keys; - if(lostkey.kh_previous_owner) - kh_Scores_Event(lostkey.kh_previous_owner, NULL, "destroyed", 0, -autocvar_g_balance_keyhunt_score_destroyed); + if(lostkey.previous_owner) + kh_Scores_Event(lostkey.previous_owner, NULL, "destroyed", 0, -autocvar_g_balance_keyhunt_score_destroyed); // don't actually GIVE them the -nn points, just log - if(lostkey.kh_previous_owner.playerid == lostkey.kh_previous_owner_playerid) - GameRules_scoring_add(lostkey.kh_previous_owner, KH_DESTRUCTIONS, 1); + if(lostkey.previous_owner.playerid == lostkey.kh_previous_owner_playerid) + GameRules_scoring_add(lostkey.previous_owner, KH_DESTRUCTIONS, 1); DistributeEvenly_Init(autocvar_g_balance_keyhunt_score_destroyed, keys * of + players); @@ -649,9 +649,9 @@ void kh_LoserTeam(int loser_team, entity lostkey) // runs when a player pushes int realteam = kh_Team_ByID(lostkey.count); Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(loser_team, CENTER_ROUND_TEAM_LOSS)); if(attacker) - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(realteam, INFO_KEYHUNT_PUSHED), attacker.netname, lostkey.kh_previous_owner.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(realteam, INFO_KEYHUNT_PUSHED), attacker.netname, lostkey.previous_owner.netname); else - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(realteam, INFO_KEYHUNT_DESTROYED), lostkey.kh_previous_owner.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(realteam, INFO_KEYHUNT_DESTROYED), lostkey.previous_owner.netname); play2all(SND(KH_DESTROY)); te_tarexplosion(lostkey.origin); diff --git a/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc b/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc index 0935b9709..e0c4647c5 100644 --- a/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc +++ b/qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc @@ -3,6 +3,7 @@ #include .entity ballcarried; +.entity previous_owner; // also used on kh keys int autocvar_g_tka_ballcarrier_effects; float autocvar_g_tka_ballcarrier_damage; @@ -101,7 +102,8 @@ void tka_TouchEvent(entity this, entity toucher) // runs any time that the ball sound(this, CH_TRIGGER, SND_KA_TOUCH, VOL_BASE, ATTEN_NORM); return; } - else if(this.wait > time) { return; } + else if(this.wait > time && this.previous_owner == toucher) + return; // attach the ball to the player this.owner = toucher; @@ -173,7 +175,8 @@ void tka_DropEvent(entity player) // runs any time that a player is supposed to // reset the ball setattachment(ball, NULL, ""); set_movetype(ball, MOVETYPE_BOUNCE); - ball.wait = time + 1; + ball.previous_owner = player; + ball.wait = time + 0.5; // same as for thrown weapons settouch(ball, tka_TouchEvent); setthink(ball, tka_RespawnBall); ball.nextthink = time + autocvar_g_tkaball_respawntime; -- 2.39.5