From: Samual Lenks Date: Fri, 21 Sep 2012 22:11:39 +0000 (-0400) Subject: Implement flag throwing punishment if you spam it too much X-Git-Tag: xonotic-v0.7.0~218^2~7 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=d65311344a88e8b3fb151fba6891ba1f37d1a7eb;p=xonotic%2Fxonotic-data.pk3dir.git Implement flag throwing punishment if you spam it too much --- diff --git a/gamemodes.cfg b/gamemodes.cfg index 9d8048788..252bd55a4 100644 --- a/gamemodes.cfg +++ b/gamemodes.cfg @@ -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" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 0517dcf10..c383d69e7 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index b12e28578..7467346a1 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -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; diff --git a/qcsrc/server/mutators/gamemode_ctf.qh b/qcsrc/server/mutators/gamemode_ctf.qh index 97222124b..a6d79c2a2 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qh +++ b/qcsrc/server/mutators/gamemode_ctf.qh @@ -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)))