]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement full stalemate detection code (shows enemy flag carrier locations after...
authorSamual <samual@xonotic.org>
Wed, 11 Apr 2012 20:42:40 +0000 (16:42 -0400)
committerSamual <samual@xonotic.org>
Wed, 11 Apr 2012 20:42:40 +0000 (16:42 -0400)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_ctf.qh

index f430022f0601784d3eabe813184e15dc3a658f1e..b0b221ebb19fe1cc4078aba7f0981180f2039d89 100644 (file)
@@ -600,7 +600,7 @@ set g_ctf_flagcarrier_selfdamagefactor 1
 set g_ctf_flagcarrier_selfforcefactor 1
 set g_ctf_flagcarrier_damagefactor 1
 set g_ctf_flagcarrier_forcefactor 1
-set g_ctf_flagcarrier_waypointforenemy_time 30 "show the enemy flagcarrier location after this time period is up"
+set g_ctf_flagcarrier_waypointforenemy_stalemate 30 "show the enemy flagcarrier location after both teams have held the flags for this amount of time"
 set g_ctf_flagcarrier_waypointforenemy_spotting 1 "show the enemy flagcarrier location if a team mate presses +use to spot them"
 set g_ctf_dropped_capture_radius 100 "allow dropped flags to be automatically captured by base flags if the dropped flag is within this radius of it"
 set g_ctf_fullbrightflags 0
index db783ae638d05d4f6c7199b9ef3ae0325f8b5e13..e2a4708a737371b722b625ba5bdf7df279245e63 100644 (file)
@@ -795,7 +795,7 @@ float autocvar_g_ctf_flagcarrier_selfdamagefactor;
 float autocvar_g_ctf_flagcarrier_selfforcefactor;
 float autocvar_g_ctf_flagcarrier_damagefactor;
 float autocvar_g_ctf_flagcarrier_forcefactor;
-float autocvar_g_ctf_flagcarrier_waypointforenemy_time;
+float autocvar_g_ctf_flagcarrier_waypointforenemy_stalemate;
 float autocvar_g_ctf_flagcarrier_waypointforenemy_spotting;
 float autocvar_g_ctf_fullbrightflags;
 float autocvar_g_ctf_ignore_frags;
index dd16e17681249f9c92f7c493174b4200741992e8..5e5f17241ae18d34e5f1915d41d3a925af733bcb 100644 (file)
@@ -531,6 +531,53 @@ void ctf_CheckFlagReturn(entity flag, float returntype)
        }
 }
 
+void ctf_CheckStalemate(void)
+{
+       // declarations
+       float stale_red_flags, stale_blue_flags;
+       entity tmp_entity;
+
+       // 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(time >= tmp_entity.ctf_pickuptime + autocvar_g_ctf_flagcarrier_waypointforenemy_stalemate)
+               {
+                       tmp_entity.ctf_staleflagnext = ctf_staleflaglist; // link flag into staleflaglist
+                       ctf_staleflaglist = tmp_entity;
+                       
+                       switch(tmp_entity.team)
+                       {
+                               case COLOR_TEAM1: ++stale_red_flags; break;
+                               case COLOR_TEAM2: ++stale_blue_flags; break;
+                       }
+               }
+       }
+       
+       // if sufficient stalemate, then set up the waypointsprite and announce the stalemate if necessary
+       if(stale_red_flags && stale_blue_flags)
+       {
+               for(tmp_entity = ctf_staleflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_staleflagnext)
+               {
+                       if not(tmp_entity.owner.wps_enemyflagcarrier)   
+                               WaypointSprite_Spawn("enemyflagcarrier", 0, 0, tmp_entity.owner, FLAG_WAYPOINT_OFFSET, world, tmp_entity.team, tmp_entity.owner, wps_enemyflagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_ENEMYFC(tmp_entity.owner.team));
+               }
+               
+               if not(wpforenemy_announced)
+               {
+                       FOR_EACH_REALPLAYER(tmp_entity)
+                       {
+                               if(tmp_entity.flagcarried)
+                                       centerprint(tmp_entity, "Stalemate! Enemies can now see you on radar!");
+                               else
+                                       centerprint(tmp_entity, "Stalemate! Flag carriers can now be seen by enemies on radar!");
+                       }
+                       
+                       wpforenemy_announced = TRUE;
+               }
+       }
+}
+
 void ctf_FlagDamage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
@@ -632,25 +679,12 @@ void ctf_FlagThink()
                                ImpulseCommands();
                                self = tmp_entity;
                        }
-                       
-                       if(autocvar_g_ctf_flagcarrier_waypointforenemy_time)
-                       if((time >= self.ctf_pickuptime + autocvar_g_ctf_flagcarrier_waypointforenemy_time) && !self.owner.wps_enemyflagcarrier)
+                       if(autocvar_g_ctf_flagcarrier_waypointforenemy_stalemate)
                        {
-                               WaypointSprite_Spawn("enemyflagcarrier", 0, 0, self.owner, FLAG_WAYPOINT_OFFSET, world, self.team, self.owner, wps_enemyflagcarrier, TRUE, RADARICON_FLAG, WPCOLOR_ENEMYFC(self.owner.team));
-                               
-                               if(!self.wpforenemy_announced)
+                               if(time >= wpforenemy_nextthink)
                                {
-                                       FOR_EACH_REALPLAYER(tmp_entity)
-                                       {
-                                               if(tmp_entity == self.owner)
-                                                       centerprint(tmp_entity, strcat("Enemies can now see you on radar! (held ", self.netname, " for ", ftos(autocvar_g_ctf_flagcarrier_waypointforenemy_time), " seconds)"));
-                                               else if(IsDifferentTeam(tmp_entity, self.owner))
-                                                       centerprint(tmp_entity, strcat("You can now see the enemy flag carrier on radar! (held ", self.netname, " for ", ftos(autocvar_g_ctf_flagcarrier_waypointforenemy_time), " seconds)"));
-                                               else
-                                                       centerprint(tmp_entity, strcat("Enemies can now see your flag carrier on radar! (held ", self.netname, " for ", ftos(autocvar_g_ctf_flagcarrier_waypointforenemy_time), " seconds)"));
-                                       }
-                                       
-                                       self.wpforenemy_announced = TRUE;
+                                       ctf_CheckStalemate();
+                                       wpforenemy_nextthink = time + WPFE_THINKRATE; // waypoint for enemy think rate (to reduce unnecessary spam of this check)
                                }
                        }
                        return;
@@ -805,7 +839,8 @@ void ctf_RespawnFlag(entity flag)
        flag.ctf_dropper = world;
        flag.ctf_pickuptime = 0;
        flag.ctf_droptime = 0;
-       flag.wpforenemy_announced = FALSE;
+
+       wpforenemy_announced = FALSE;
 }
 
 void ctf_Reset()
index 522ccfcb76943850b97bfbb226515b0e33a0ca8e..aa6d6a02046ee18657aba15fb50c07a3fa9fad0b 100644 (file)
@@ -20,6 +20,7 @@ void spawnfunc_ctf_team();
 
 #define FLAG_THINKRATE 0.2
 #define FLAG_TOUCHRATE 0.5
+#define WPFE_THINKRATE 0.5
 
 #define FLAG_DROP_OFFSET ('0 0 32')
 #define FLAG_CARRY_OFFSET ('-16 0 8')
@@ -45,6 +46,8 @@ void spawnfunc_ctf_team();
 // list of flags on the map
 entity ctf_worldflaglist;
 .entity ctf_worldflagnext;
+entity ctf_staleflaglist;
+.entity ctf_staleflagnext;
 
 // waypoint sprites
 .entity bot_basewaypoint; // flag waypointsprite
@@ -87,7 +90,9 @@ float ctf_captimerecord; // record time for capturing the flag
 .entity ctf_dropper; // don't allow spam of dropping the flag
 .float max_flag_health;
 .float next_take_time;
-.float wpforenemy_announced;
+
+float wpforenemy_announced;
+float wpforenemy_nextthink;
 
 // passing properties
 .entity pass_sender;