1 void CA_count_alive_players()
4 total_players = redalive = bluealive = yellowalive = pinkalive = 0;
6 if(e.team == COLOR_TEAM1)
9 if (e.health >= 1) ++redalive;
11 else if(e.team == COLOR_TEAM2)
14 if (e.health >= 1) ++bluealive;
16 else if(e.team == COLOR_TEAM3)
19 if (e.health >= 1) ++yellowalive;
21 else if(e.team == COLOR_TEAM4)
24 if (e.health >= 1) ++pinkalive;
27 FOR_EACH_REALCLIENT(e) {
28 e.redalive_stat = redalive;
29 e.bluealive_stat = bluealive;
30 e.yellowalive_stat = yellowalive;
31 e.pinkalive_stat = pinkalive;
35 float CA_GetWinnerTeam()
39 winner_team = COLOR_TEAM1;
42 if(winner_team) return 0;
43 winner_team = COLOR_TEAM2;
47 if(winner_team) return 0;
48 winner_team = COLOR_TEAM3;
52 if(winner_team) return 0;
53 winner_team = COLOR_TEAM4;
57 return -1; // no player left
60 float CA_CheckWinner()
63 if(round_handler_GetTimeLeft() <= 0)
65 FOR_EACH_REALCLIENT(e)
66 centerprint(e, "Round over, there's no winner");
67 bprint("Round over, there's no winner.\n");
68 allowed_to_spawn = TRUE;
72 CA_count_alive_players();
73 if(CA_ALIVE_TEAMS() > 1)
78 winner_team = CA_GetWinnerTeam();
81 teamname = ColoredTeamName(winner_team);
82 FOR_EACH_REALCLIENT(e)
83 centerprint(e, strcat(teamname, " wins the round"));
84 bprint(teamname, " wins the round.\n");
85 TeamScore_AddToTeam(winner_team, ST_SCORE, +1);
87 else if(winner_team == -1)
89 FOR_EACH_REALCLIENT(e)
90 centerprint(e, "Round tied");
91 bprint("Round tied.\n");
94 allowed_to_spawn = TRUE;
101 allowed_to_spawn = TRUE;
103 allowed_to_spawn = FALSE;
106 float prev_total_players;
107 float CA_CheckTeams()
110 allowed_to_spawn = TRUE;
111 CA_count_alive_players();
112 if(CA_ALIVE_TEAMS_OK())
114 if(prev_total_players != -1)
116 FOR_EACH_REALCLIENT(e)
117 Send_CSQC_Centerprint_Generic_Expire(e, CPID_WAITING_PLAYERS);
119 prev_total_players = -1;
122 if(prev_total_players != total_players)
124 string teams_missing;
125 if(!redalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM1), ", ");
126 if(!bluealive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM2), ", ");
128 if(!yellowalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM3), ", ");
130 if(!pinkalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM4), ", ");
131 teams_missing = substring(teams_missing, 0, strlen(teams_missing)-2);
133 FOR_EACH_REALCLIENT(e)
134 Send_CSQC_Centerprint_Generic(e, CPID_WAITING_PLAYERS, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, 0);
135 prev_total_players = total_players;
140 MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
142 self.caplayer = TRUE;
146 MUTATOR_HOOKFUNCTION(ca_PutClientInServer)
148 if(clienttype(self) == CLIENTTYPE_BOT)
149 self.caplayer = TRUE;
150 if(!allowed_to_spawn)
151 self.classname = "observer";
155 MUTATOR_HOOKFUNCTION(ca_reset_map_players)
157 FOR_EACH_CLIENT(self)
161 self.classname = "player";
168 MUTATOR_HOOKFUNCTION(ca_reset_map_global)
170 allowed_to_spawn = TRUE;
174 MUTATOR_HOOKFUNCTION(ca_GetTeamCount)
176 ca_teams = autocvar_g_ca_teams_override;
178 ca_teams = autocvar_g_ca_teams;
179 ca_teams = bound(2, ca_teams, 4);
180 ret_float = ca_teams;
184 MUTATOR_HOOKFUNCTION(ca_PlayerPreThink)
186 if(!allowed_to_spawn)
187 self.stat_respawn_time = 0;
191 MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear)
196 MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver)
199 self.frags = FRAGS_LMS_LOSER;
203 MUTATOR_HOOKFUNCTION(ca_ForbidThrowCurrentWeapon)
210 allowed_to_spawn = TRUE;
212 round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart, 5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
214 addstat(STAT_REDALIVE, AS_INT, redalive_stat);
215 addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
216 addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
217 addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
220 MUTATOR_DEFINITION(gamemode_ca)
222 MUTATOR_HOOK(PlayerSpawn, ca_PlayerSpawn, CBC_ORDER_ANY);
223 MUTATOR_HOOK(PutClientInServer, ca_PutClientInServer, CBC_ORDER_ANY);
224 MUTATOR_HOOK(MakePlayerObserver, ca_MakePlayerObserver, CBC_ORDER_ANY);
225 MUTATOR_HOOK(reset_map_global, ca_reset_map_global, CBC_ORDER_ANY);
226 MUTATOR_HOOK(reset_map_players, ca_reset_map_players, CBC_ORDER_ANY);
227 MUTATOR_HOOK(GetTeamCount, ca_GetTeamCount, CBC_ORDER_EXCLUSIVE);
228 MUTATOR_HOOK(PlayerPreThink, ca_PlayerPreThink, CBC_ORDER_ANY);
229 MUTATOR_HOOK(ForbidPlayerScore_Clear, ca_ForbidPlayerScore_Clear, CBC_ORDER_ANY);
230 MUTATOR_HOOK(ForbidThrowCurrentWeapon, ca_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
234 if(time > 1) // game loads at time 1
235 error("This is a game type and it cannot be added at runtime.");
241 error("This is a game type and it cannot be removed at runtime.");