else { return TRUE; }
}
- if(!IsDifferentTeam(self.owner, e))
- return FALSE;
- if not(IS_PLAYER(e))
+float ctf_IsDifferentTeam(entity a, entity b)
+{
+ float f = IsDifferentTeam(a, b);
+ return (autocvar_g_ctf_reverse) ? !f : f;
+}
+
+float ctf_Stalemate_waypointsprite_visible_for_player(entity e)
+{
++ // personal waypoints
++ if(self.enemy)
++ if(self.enemy != e)
++ return FALSE;
++
+ // team waypoints
++ if(self.rule == SPRITERULE_DEFAULT)
+ if(ctf_IsDifferentTeam(self.owner.flagcarried, self.owner))
+ if(ctf_IsDifferentTeam(self.owner.flagcarried, e))
++ if(!IsDifferentTeam(self.owner, e) || !IS_PLAYER(e))
+ return FALSE;
+
+ return TRUE;
+}
+
// =======================
// CaptureShield Functions
tmp_entity.ctf_staleflagnext = ctf_staleflaglist; // link flag into staleflaglist
ctf_staleflaglist = tmp_entity;
- if(tmp_entity.team == NUM_TEAM_1) { ++stale_red_flags; }
- if(tmp_entity.team == NUM_TEAM_2) { ++stale_blue_flags; }
- if(tmp_entity.team == NUM_TEAM_3) { ++stale_yellow_flags; }
- if(tmp_entity.team == NUM_TEAM_4) { ++stale_pink_flags; }
+ switch(tmp_entity.team)
+ {
+ case NUM_TEAM_1: ++stale_red_flags; break;
+ case NUM_TEAM_2: ++stale_blue_flags; break;
++ case NUM_TEAM_3: ++stale_yellow_flags; break;
++ case NUM_TEAM_4: ++stale_pink_flags; break;
+ }
}
}
-
- if(stale_red_flags && stale_blue_flags)
+
+ stale_flags = (stale_red_flags > 0) + (stale_blue_flags > 0) + (stale_yellow_flags > 0) + (stale_pink_flags > 0);
+
- if(stale_flags >= ctf_teams)
++ if(stale_flags == ctf_teams)
ctf_stalemate = TRUE;
- else if(stale_flags < ctf_teams && autocvar_g_ctf_stalemate_endcondition == 2)
- else if((!stale_red_flags && !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 2)
++ else if(stale_flags == 0 && autocvar_g_ctf_stalemate_endcondition == 2)
{ ctf_stalemate = FALSE; wpforenemy_announced = FALSE; }
- else if(stale_flags > 0 && autocvar_g_ctf_stalemate_endcondition == 1)
- else if((!stale_red_flags || !stale_blue_flags) && autocvar_g_ctf_stalemate_endcondition == 1)
++ else if(stale_flags < ctf_teams && stale_flags > 0 && 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
wpforenemy_nextthink = time + WPFE_THINKRATE; // waypoint for enemy think rate (to reduce unnecessary spam of this check)
}
}
+ if(!ctf_IsDifferentTeam(self, self.owner))
+ {
++ // drop the flag if reverse status has changed
+ ctf_Handle_Throw(self.owner, world, DROP_THROW);
+ }
return;
}
// scan through all the flags and notify the client about them
for(flag = ctf_worldflaglist; flag; flag = flag.ctf_worldflagnext)
{
- if(flag.team == NUM_TEAM_1) { t = IT_RED_FLAG_CARRYING; t2 = IT_RED_FLAG_TAKEN; t3 = IT_RED_FLAG_LOST; }
- if(flag.team == NUM_TEAM_2) { t = IT_BLUE_FLAG_CARRYING; t2 = IT_BLUE_FLAG_TAKEN; t3 = IT_BLUE_FLAG_LOST; }
- if(flag.team == NUM_TEAM_3) { t = IT_YELLOW_FLAG_CARRYING; t2 = IT_YELLOW_FLAG_TAKEN; t3 = IT_YELLOW_FLAG_LOST; }
- if(flag.team == NUM_TEAM_4) { t = IT_PINK_FLAG_CARRYING; t2 = IT_PINK_FLAG_TAKEN; t3 = IT_PINK_FLAG_LOST; }
++ if(flag.team == NUM_TEAM_1) { t = IT_RED_FLAG_CARRYING; t2 = IT_RED_FLAG_TAKEN; t3 = IT_RED_FLAG_LOST; }
++ if(flag.team == NUM_TEAM_2) { t = IT_BLUE_FLAG_CARRYING; t2 = IT_BLUE_FLAG_TAKEN; t3 = IT_BLUE_FLAG_LOST; }
++ if(flag.team == NUM_TEAM_3) { t = IT_YELLOW_FLAG_CARRYING; t2 = IT_YELLOW_FLAG_TAKEN; t3 = IT_YELLOW_FLAG_LOST; }
++ if(flag.team == NUM_TEAM_4) { t = IT_PINK_FLAG_CARRYING; t2 = IT_PINK_FLAG_TAKEN; t3 = IT_PINK_FLAG_LOST; }
+
switch(flag.ctf_status)
{
case FLAG_PASSING:
print("No ""ctf_team"" entities found on this map, creating them anyway.\n");
ctf_SpawnTeam("Red", NUM_TEAM_1 - 1);
ctf_SpawnTeam("Blue", NUM_TEAM_2 - 1);
+ if(ctf_teams >= 3)
+ ctf_SpawnTeam("Yellow", NUM_TEAM_3 - 1);
+ if(ctf_teams >= 4)
+ ctf_SpawnTeam("Pink", NUM_TEAM_4 - 1);
}
- ret_float = ctf_teams;
- ctf_ScoreRules();
+ ctf_ScoreRules(ctf_teams);
}
void ctf_Initialize()