for (int i = 1; i <= NUM_TEAMS; ++i)
{
Team_SetNumberOfAlivePlayers(Team_GetTeamFromIndex(i), 0);
+ Team_SetNumberOfPlayers(Team_GetTeamFromIndex(i), 0);
}
- FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it),
+ FOREACH_CLIENT(Entity_HasValidTeam(it),
{
++total_players;
- if (IS_DEAD(it))
+ entity team_ = Entity_GetTeam(it);
+
+ int num_total = Team_GetNumberOfPlayers(team_);
+ ++num_total;
+ Team_SetNumberOfPlayers(team_, num_total);
+
+ if (IS_DEAD(it) || !IS_PLAYER(it))
{
continue;
}
- entity team_ = Entity_GetTeam(it);
+
int num_alive = Team_GetNumberOfAlivePlayers(team_);
++num_alive;
Team_SetNumberOfAlivePlayers(team_, num_alive);
void nades_Clear(entity player);
+entity ca_LastPlayer(float tm)
+{
+ entity last_pl = NULL;
+ FOREACH_CLIENT(IS_PLAYER(it) && it.team == tm, {
+ if (!IS_DEAD(it))
+ {
+ if (!last_pl)
+ last_pl = it;
+ else
+ return NULL;
+ }
+ });
+ return last_pl;
+}
+
+
float CA_CheckWinner()
{
if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
+ Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_ROUND_OVER);
FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
allowed_to_spawn = false;
- game_stopped = true;
+ if(autocvar_g_ca_round_stop)
+ game_stopped = true;
round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
return 1;
}
int winner_team = Team_GetWinnerAliveTeam();
if (!winner_team)
return 0;
-
+
+ bool perfect = false;
if(winner_team > 0)
{
+ entity tm = Team_GetTeam(winner_team);
+ entity last_pl = ca_LastPlayer(winner_team);
+
+ if(last_pl && Team_GetNumberOfPlayers(tm) >= 3) {
+ Give_Medal(last_pl, DEFENSE);
+ }
+
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
+ if(fragsleft > 1) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(winner_team, ANNCE_ROUND_TEAM_WIN));
TeamScore_AddToTeam(winner_team, ST_CA_ROUNDS, +1);
+
+ if (Team_GetNumberOfPlayers(tm) >= 3 &&
+ Team_GetNumberOfAlivePlayers(tm) == Team_GetNumberOfPlayers(tm))
+ perfect = true;
}
else if(winner_team == -1)
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
+ Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_ROUND_TIED);
}
allowed_to_spawn = false;
- game_stopped = true;
+ if(autocvar_g_ca_round_stop)
+ game_stopped = true;
round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
- FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
+ FOREACH_CLIENT(IS_PLAYER(it), {
+ nades_Clear(it);
+
+ // Give perfect medal if everyone in the winner team is alive
+ if(perfect && it.team == winner_team) {
+ Give_Medal(it, PERFECT);
+ }
+
+ // Give accuracy medal for each weapon above 50%
+ entity ra = it.roundaccuracy;
+ for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
+ if(ra.accuracy_fired[w] > 1 && (ra.accuracy_hit[w] / ra.accuracy_fired[w]) > 0.5) {
+ Give_Medal(it, ACCURACY);
+ }
+ }
+ });
return 1;
}
if (!warmup_stage && round_handler_IsActive() && round_handler_IsRoundStarted())
{
entity pl = ca_LastPlayerForTeam(this);
- if (pl)
+ if (pl) {
Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+ Send_Notification(NOTIF_ONE, pl, MSG_ANNCE, ANNCE_ALONE);
+ }
}
}
return true;
}
-MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining)
-{
- // announce remaining frags
- return true;
-}
-
MUTATOR_HOOKFUNCTION(ca, SpectateSet)
{
entity client = M_ARGV(0, entity);