]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Keepaway: Throw ball forward
authorz411 <z411@omaera.org>
Thu, 2 Dec 2021 02:06:12 +0000 (23:06 -0300)
committerz411 <z411@omaera.org>
Thu, 2 Dec 2021 02:06:12 +0000 (23:06 -0300)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc
qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh

index 9257cd57d80f7dcb62b0596a3ff35f69902f7de6..d78b73e615430a7d3c3ca9b52c6f3141c8f56faa 100644 (file)
@@ -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"
 
 
 // ==========
index f7f8e104316c5bcf4d0464cf5552988410f0436c..86ad2d8e416409f02ef08f9688767c058dc5c999 100644 (file)
@@ -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;
        }
 }
index 2f1f0764397fe9308810a148e0f36ab5ee4a7559..3690f26ae00ae843cc951ed9809fdab1a58c5f84 100644 (file)
@@ -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);