]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Disable keepaway ball pickup delay 1432/head
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 7 Jul 2023 10:02:41 +0000 (20:02 +1000)
committerterencehill <piuntn@gmail.com>
Tue, 14 Jan 2025 14:22:42 +0000 (14:22 +0000)
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.

qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc
qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc
qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc

index 9f694a0e09d55895fe0765330e9c2cc1430347de..cdb56060d10ddce0f3a95f224eb092481c44e760 100644 (file)
@@ -8,6 +8,7 @@
 #include <server/world.qh>
 
 .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;
index 15024ed88d9153780bcb103a26fb6899ad094e2b..d9dda802c085224fd8b3cb259954876feeacd3ff 100644 (file)
@@ -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);
index 0935b9709aed2d0c25df12b6a1a10ccd38d3b9ba..e0c4647c52ec6734f8917f2cea88a3507bb44561 100644 (file)
@@ -3,6 +3,7 @@
 #include <common/effects/all.qh>
 
 .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;