From: Samual Date: Wed, 11 Apr 2012 20:42:40 +0000 (-0400) Subject: Implement full stalemate detection code (shows enemy flag carrier locations after... X-Git-Tag: xonotic-v0.7.0~240^2~82 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a0970b2d5522da44fc50d5be94d7103473768d97;p=xonotic%2Fxonotic-data.pk3dir.git Implement full stalemate detection code (shows enemy flag carrier locations after 30 seconds of both teams having the enemy flag) --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index f430022f0..b0b221ebb 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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 diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index db783ae63..e2a4708a7 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index dd16e1768..5e5f17241 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -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() diff --git a/qcsrc/server/mutators/gamemode_ctf.qh b/qcsrc/server/mutators/gamemode_ctf.qh index 522ccfcb7..aa6d6a020 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qh +++ b/qcsrc/server/mutators/gamemode_ctf.qh @@ -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;