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;
73 allowed_to_spawn = TRUE;
75 allowed_to_spawn = FALSE;
77 CA_count_alive_players();
78 if(CA_ALIVE_TEAMS() > 1)
83 winner_team = CA_GetWinnerTeam();
86 teamname = ColoredTeamName(winner_team);
87 FOR_EACH_REALCLIENT(e)
88 centerprint(e, strcat(teamname, " wins the round"));
89 bprint(teamname, " wins the round.\n");
90 TeamScore_AddToTeam(winner_team, ST_SCORE, +1);
92 else if(winner_team == -1)
94 FOR_EACH_REALCLIENT(e)
95 centerprint(e, "Round tied");
96 bprint("Round tied.\n");
99 allowed_to_spawn = TRUE;
103 float prev_total_players;
104 float CA_CheckTeams()
107 allowed_to_spawn = TRUE;
108 CA_count_alive_players();
109 if(CA_ALIVE_TEAMS_OK())
111 if(prev_total_players != -1)
113 FOR_EACH_REALCLIENT(e)
114 Send_CSQC_Centerprint_Generic_Expire(e, CPID_WAITING_PLAYERS);
116 prev_total_players = -1;
119 if(prev_total_players != total_players)
121 string teams_missing;
122 if(!redalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM1), ", ");
123 if(!bluealive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM2), ", ");
125 if(!yellowalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM3), ", ");
127 if(!pinkalive) teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM4), ", ");
128 teams_missing = substring(teams_missing, 0, strlen(teams_missing)-2);
130 FOR_EACH_REALCLIENT(e)
131 Send_CSQC_Centerprint_Generic(e, CPID_WAITING_PLAYERS, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, 0);
132 prev_total_players = total_players;
137 MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
139 self.caplayer = TRUE;
143 MUTATOR_HOOKFUNCTION(ca_reset_map_players)
145 FOR_EACH_CLIENT(self)
149 self.classname = "player";
156 MUTATOR_HOOKFUNCTION(ca_reset_map_global)
158 allowed_to_spawn = TRUE;
162 MUTATOR_HOOKFUNCTION(ca_GetTeamCount)
164 ca_teams = autocvar_g_ca_teams_override;
166 ca_teams = autocvar_g_ca_teams;
167 ca_teams = bound(2, ca_teams, 4);
168 ret_float = ca_teams;
172 MUTATOR_HOOKFUNCTION(ca_PlayerPreThink)
174 if(!allowed_to_spawn)
175 self.stat_respawn_time = 0;
179 MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear)
183 MUTATOR_HOOKFUNCTION(ca_ForbidThrowCurrentWeapon)
190 allowed_to_spawn = TRUE;
192 round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, 5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
194 addstat(STAT_REDALIVE, AS_INT, redalive_stat);
195 addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
196 addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
197 addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
200 MUTATOR_DEFINITION(gamemode_ca)
202 MUTATOR_HOOK(PlayerSpawn, ca_PlayerSpawn, CBC_ORDER_ANY);
203 MUTATOR_HOOK(reset_map_global, ca_reset_map_global, CBC_ORDER_ANY);
204 MUTATOR_HOOK(reset_map_players, ca_reset_map_players, CBC_ORDER_ANY);
205 MUTATOR_HOOK(GetTeamCount, ca_GetTeamCount, CBC_ORDER_EXCLUSIVE);
206 MUTATOR_HOOK(PlayerPreThink, ca_PlayerPreThink, CBC_ORDER_ANY);
207 MUTATOR_HOOK(ForbidPlayerScore_Clear, ca_ForbidPlayerScore_Clear, CBC_ORDER_ANY);
208 MUTATOR_HOOK(ForbidThrowCurrentWeapon, ca_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
212 if(time > 1) // game loads at time 1
213 error("This is a game type and it cannot be added at runtime.");
219 error("This is a game type and it cannot be removed at runtime.");