From 6dcf8fd6472b3874f9a8240e460b6a98793bf0b1 Mon Sep 17 00:00:00 2001 From: z411 Date: Wed, 1 Dec 2021 23:06:12 -0300 Subject: [PATCH] Keepaway: Throw ball forward --- gamemodes-server.cfg | 2 +- .../gamemode/keepaway/sv_keepaway.qc | 19 ++++++++++++------- .../gamemode/keepaway/sv_keepaway.qh | 3 ++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 9257cd57d..d78b73e61 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -409,8 +409,8 @@ set g_keepaway_noncarrier_selfforce 1 "self force if you don't have the ball" set g_keepawayball_effects 0 "Add together the numbers you want: EF_ADDITIVE (32) / EF_NODEPTHTEST (8192) / EF_DIMLIGHT (8)" set g_keepawayball_trail_color 254 "particle trail color from player/ball" set g_keepawayball_damageforcescale 3 "Scale of force which is applied to the ball by weapons/explosions/etc" +set g_keepawayball_pickup_delay 1 "time until the ball can be picked up again after getting dropped" set g_keepawayball_respawntime 10 "if no one picks up the ball, how long to wait until the ball respawns" -set g_keepawayball_wait 1 "time until the ball can be picked up again after getting dropped" // ========== diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index f7f8e1043..86ad2d8e4 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -26,8 +26,8 @@ int autocvar_g_keepaway_score_timepoints; float autocvar_g_keepaway_score_timeinterval; float autocvar_g_keepawayball_damageforcescale; int autocvar_g_keepawayball_effects; +float autocvar_g_keepawayball_pickup_delay; float autocvar_g_keepawayball_respawntime; -float autocvar_g_keepawayball_wait; int autocvar_g_keepawayball_trail_color; bool ka_ballcarrier_waypointsprite_visible_for_player(entity this, entity player, entity view) // runs on waypoints which are attached to ballcarriers, updates once per frame @@ -171,7 +171,7 @@ void ka_PlayerReset(entity player) player.effects &= ~autocvar_g_keepaway_ballcarrier_effects; } -void ka_DropEvent(entity player) // runs any time that a player is supposed to lose the ball +void ka_DropBall(entity player, vector org, vector velo) // runs any time that a player is supposed to lose the ball { entity ball = player.ballcarried; @@ -180,7 +180,7 @@ 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 + autocvar_g_keepawayball_wait; + ball.wait = time + autocvar_g_keepawayball_pickup_delay; settouch(ball, ka_TouchEvent); setthink(ball, ka_RespawnBall); ball.nextthink = time + autocvar_g_keepawayball_respawntime; @@ -189,8 +189,8 @@ void ka_DropEvent(entity player) // runs any time that a player is supposed to l ball.damagedbycontents = true; IL_PUSH(g_damagedbycontents, ball); ball.effects &= ~EF_NODRAW; - setorigin(ball, player.origin + '0 0 10'); - ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom(); + setorigin(ball, org); + ball.velocity = velo; ball.owner = NULL; navigation_dynamicgoal_set(ball, player); @@ -208,6 +208,10 @@ void ka_DropEvent(entity player) // runs any time that a player is supposed to l ka_PlayerReset(player); } +void ka_DropEvent(entity player) { + ka_DropBall(player, player.origin + '0 0 10', '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom()); +} + .bool pushable; MODEL(KA_BALL, "models/orbs/orbblue.md3"); @@ -383,7 +387,8 @@ MUTATOR_HOOKFUNCTION(ka, PlayerDies) GameRules_scoring_add(frag_attacker, SCORE, autocvar_g_keepaway_score_killac); } - if(frag_target.ballcarried) { ka_DropEvent(frag_target); } // a player with the ball has died, drop it + if(frag_target.ballcarried) // a player with the ball has died, drop it + ka_DropEvent(frag_target); } MUTATOR_HOOKFUNCTION(ka, GiveFragsForKill) @@ -413,7 +418,7 @@ MUTATOR_HOOKFUNCTION(ka, PlayerUseKey) if(MUTATOR_RETURNVALUE == 0) if(player.ballcarried) { - ka_DropEvent(player); + ka_DropBall(player, player.origin + (v_forward * 100), '0 0 200' + (v_forward * 500)); return true; } } diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh index 2f1f07643..3690f26ae 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh @@ -32,4 +32,5 @@ void ka_DamageEvent(entity this, entity inflictor, entity attacker, float damage void ka_TouchEvent(entity this, entity toucher); -void ka_DropEvent(entity plyr); +void ka_DropEvent(entity player); +void ka_DropBall(entity player, vector velo, vector delta); -- 2.39.2