]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_ctf.qc
Fixes to stalemate
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_ctf.qc
index 5edf74d16cc7fc53c9823475359c2f5e8b846851..5233aa635c8679f7cba7d6e895dad0e52284e523 100644 (file)
@@ -502,9 +502,12 @@ void ctf_Handle_Pickup(entity flag, entity player, float pickuptype)
        FOR_EACH_REALPLAYER(tmp_player)
        {
                if(tmp_player == player)
+               {
                        centerprint(tmp_player, strcat("You got the ", flag.netname, "!"));
-               else if(!IsDifferentTeam(tmp_player, player))
-                       centerprint(tmp_player, strcat("Your ", Team_ColorCode(player.team), "team mate ", verbosename, "^7got the flag! Protect them!"));
+                       //if(ctf_stalemate) { centerprint(tmp_player, "Stalemate! Enemies can see you on radar!"); }
+               }
+               //else if(!IsDifferentTeam(tmp_player, player))
+               //      centerprint(tmp_player, strcat("Your ", Team_ColorCode(player.team), "team mate ", verbosename, "^7got the flag! Protect them!"));
                else if(!IsDifferentTeam(tmp_player, flag))
                        centerprint(tmp_player, strcat("The ", Team_ColorCode(player.team), "enemy ", verbosename, "^7got your flag! Retrieve it!"));
        }
@@ -592,9 +595,9 @@ void ctf_CheckStalemate(void)
        // build list of stale flags
        for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
        {
-               if(autocvar_g_ctf_flagcarrier_waypointforenemy_stalemate)
+               if(autocvar_g_ctf_stalemate)
                if(tmp_entity.ctf_status != FLAG_BASE)
-               if(time >= tmp_entity.ctf_pickuptime + autocvar_g_ctf_flagcarrier_waypointforenemy_stalemate)
+               if(time >= tmp_entity.ctf_pickuptime + autocvar_g_ctf_stalemate_time)
                {
                        tmp_entity.ctf_staleflagnext = ctf_staleflaglist; // link flag into staleflaglist
                        ctf_staleflaglist = tmp_entity;
@@ -609,9 +612,11 @@ void ctf_CheckStalemate(void)
 
        if(stale_red_flags && stale_blue_flags)
                ctf_stalemate = TRUE;
-       else if(!stale_red_flags && !stale_blue_flags)
-               ctf_stalemate = FALSE;
-       
+       else if((!stale_red_flags && !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 2)
+               { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
+       else if((!stale_red_flags || !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 1)
+               { ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
+               
        // if sufficient stalemate, then set up the waypointsprite and announce the stalemate if necessary
        if(ctf_stalemate)
        {
@@ -691,8 +696,9 @@ void ctf_FlagThink()
                        {
                                for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
                                        if(tmp_entity.ctf_status == FLAG_DROPPED)
-                                               if(vlen(self.origin - tmp_entity.origin) < autocvar_g_ctf_dropped_capture_radius)
-                                                       ctf_Handle_Capture(self, tmp_entity, CAPTURE_DROPPED);
+                                       if(vlen(self.origin - tmp_entity.origin) < autocvar_g_ctf_dropped_capture_radius)
+                                       if(time > tmp_entity.ctf_droptime + autocvar_g_ctf_dropped_capture_delay)
+                                               ctf_Handle_Capture(self, tmp_entity, CAPTURE_DROPPED);
                        }
                        return;
                }
@@ -744,7 +750,7 @@ void ctf_FlagThink()
                                ImpulseCommands();
                                self = tmp_entity;
                        }
-                       if(autocvar_g_ctf_flagcarrier_waypointforenemy_stalemate)
+                       if(autocvar_g_ctf_stalemate)
                        {
                                if(time >= wpforenemy_nextthink)
                                {
@@ -906,8 +912,6 @@ void ctf_RespawnFlag(entity flag)
        flag.ctf_dropper = world;
        flag.ctf_pickuptime = 0;
        flag.ctf_droptime = 0;
-
-       wpforenemy_announced = FALSE;
 }
 
 void ctf_Reset()
@@ -1825,8 +1829,8 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
                                if(!head.speedrunning && !head.vehicle)
                                {
                                        // if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc) 
-                                       vector head_center = WarpZone_UnTransformOrigin(head, PLAYER_CENTER(head));
-                                       vector passer_center = PLAYER_CENTER(player);
+                                       vector head_center = WarpZone_UnTransformOrigin(head, CENTER_OR_VIEWOFS(head));
+                                       vector passer_center = CENTER_OR_VIEWOFS(player);
                                        
                                        if(ctf_CheckPassDirection(head_center, passer_center, player.v_angle, head.WarpZone_findradius_nearest))
                                        {
@@ -1849,7 +1853,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
                                                {
                                                        if(closest_target)
                                                        {
-                                                               vector closest_target_center = WarpZone_UnTransformOrigin(closest_target, PLAYER_CENTER(closest_target));
+                                                               vector closest_target_center = WarpZone_UnTransformOrigin(closest_target, CENTER_OR_VIEWOFS(closest_target));
                                                                if(vlen(passer_center - head_center) < vlen(passer_center - closest_target_center))
                                                                        { closest_target = head; }
                                                        }
@@ -1865,7 +1869,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(rint((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;
@@ -1890,7 +1920,7 @@ MUTATOR_HOOKFUNCTION(ctf_VehicleEnter)
 {
        if(vh_player.flagcarried)
        {
-               if(!autocvar_g_ctf_allow_vehicle_carry)
+               if(!autocvar_g_ctf_allow_vehicle_carry && !autocvar_g_ctf_allow_vehicle_touch)
                {
                        ctf_Handle_Throw(vh_player, world, DROP_NORMAL);
                }