]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement flag throwing punishment if you spam it too much
authorSamual Lenks <samual@xonotic.org>
Fri, 21 Sep 2012 22:11:39 +0000 (18:11 -0400)
committerSamual Lenks <samual@xonotic.org>
Fri, 21 Sep 2012 22:11:39 +0000 (18:11 -0400)
gamemodes.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_ctf.qh

index 9d804878873d5ceabc7842b2e742984ed9de693e..252bd55a428265b1d09ff1782520a06fca054907 100644 (file)
@@ -196,11 +196,14 @@ set g_ctf_flag_dropped_waypoint 2 "show dropped flag waypointsprite when a flag
 set g_ctf_flag_dropped_floatinwater 200 "move upwards while in water at this velocity"
 set g_ctf_flag_pickup_verbosename 0 "show the name of the person who picked up the flag too"
 set g_ctf_throw 1 "throwing allows circumventing carrierkill score, so enable this with care!"
+set g_ctf_throw_angle_max 90 "maximum upwards angle you can throw the flag"
+set g_ctf_throw_angle_min -90 "minimum downwards angle you can throw the flag"
+set g_ctf_throw_punish_count 3
+set g_ctf_throw_punish_delay 30
+set g_ctf_throw_punish_time 8
 set g_ctf_throw_strengthmultiplier 2 "multiplier for velocity when you have the strength... essentially, throw the flag REALLY hard when you have the strength :D"
 set g_ctf_throw_velocity_forward 500 "how fast or far a player can throw the flag"
 set g_ctf_throw_velocity_up 200 "upwards velocity added upon initial throw"
-set g_ctf_throw_angle_max 90 "maximum upwards angle you can throw the flag"
-set g_ctf_throw_angle_min -90 "minimum downwards angle you can throw the flag"
 set g_ctf_drop_velocity_up 200 "upwards velocity when a flag is dropped (i.e. when a flag carrier dies)"
 set g_ctf_drop_velocity_side 100 "randomized sideways velocity when a flag is dropped"
 set g_ctf_pass 1 "allow passing of flags to nearby team mates"
index 0517dcf10e89037b21e651235c0ac02e9c70fd0d..c383d69e7ad99e31b99747c3343f9568e82017c0 100644 (file)
@@ -766,6 +766,9 @@ float autocvar_g_ctf_allow_vehicle_touch;
 float autocvar_g_ctf_throw;
 float autocvar_g_ctf_throw_angle_max;
 float autocvar_g_ctf_throw_angle_min;
+float autocvar_g_ctf_throw_punish_count;
+float autocvar_g_ctf_throw_punish_delay;
+float autocvar_g_ctf_throw_punish_time;
 float autocvar_g_ctf_throw_strengthmultiplier;
 float autocvar_g_ctf_throw_velocity_forward;
 float autocvar_g_ctf_throw_velocity_up;
index b12e2857820f1280e818f14b76c6e48ffc9f4594..7467346a1bd070adcf850c414e72d9d85aabbef0 100644 (file)
@@ -1866,7 +1866,33 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
                
                // throw the flag in front of you
                if(autocvar_g_ctf_throw && player.flagcarried)
-                       { ctf_Handle_Throw(player, world, DROP_THROW); return TRUE; }
+               {
+                       if(player.throw_count == -1)
+                       {
+                               if(time > player.throw_prevtime + autocvar_g_ctf_throw_punish_delay)
+                               {
+                                       player.throw_prevtime = time;
+                                       player.throw_count = 1;
+                                       ctf_Handle_Throw(player, world, DROP_THROW);
+                                       return TRUE;
+                               }
+                               else
+                               {
+                                       centerprint(player, strcat("Too many flag throws, throwing disabled for ", ftos((player.throw_prevtime + autocvar_g_ctf_throw_punish_delay) - time), " seconds."));
+                                       return FALSE;
+                               }
+                       }
+                       else
+                       {
+                               if(time > player.throw_prevtime + autocvar_g_ctf_throw_punish_time) { player.throw_count = 1; }
+                               else { player.throw_count += 1; }
+                               if(player.throw_count >= autocvar_g_ctf_throw_punish_count) { player.throw_count = -1; }
+                                       
+                               player.throw_prevtime = time;
+                               ctf_Handle_Throw(player, world, DROP_THROW);
+                               return TRUE;
+                       }
+               }
        }
                
        return FALSE;
index 97222124bd5a25d9cad265c2f049df5f64973a8e..a6d79c2a2155bfb86574b3444405b2ff99b5f90f 100644 (file)
@@ -105,6 +105,8 @@ float ctf_captimerecord; // record time for capturing the flag
 .entity pass_sender;
 .entity pass_target;
 .float throw_antispam;
+.float throw_prevtime;
+.float throw_count;
 
 // passing macros
 #define PLAYER_CENTER(ent) (ent.origin + ((ent.classname == "player") ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))