float autocvar_g_ca_start_ammo_fuel = 0;
.float ca_damage_counter;
+.int prev_team;
void CA_count_alive_players()
{
void CA_RoundStart()
{
allowed_to_spawn = boolean(warmup_stage);
+ if (!warmup_stage)
+ FOREACH_CLIENT(IS_PLAYER(it), it.prev_team = it.team);
}
bool CA_CheckTeams()
INGAME_STATUS_SET(it, INGAME_STATUS_JOINED);
PutClientInServer(it);
}
+ it.prev_team = 0;
});
return true;
}
return true;
}
+MUTATOR_HOOKFUNCTION(ca, MatchEnd_BeforeScores)
+{
+ MatchEnd_RestoreSpectatorAndTeamStatus(prev_team);
+ return true;
+}
+
MUTATOR_HOOKFUNCTION(ca, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
{
M_ARGV(0, float) = ca_teams;
/**/
MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill);
+/** called when the match ends, before recording scores */
+MUTATOR_HOOKABLE(MatchEnd_BeforeScores, EV_NO_ARGS);
+
/** called when the match ends */
MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
//if (!(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance))
// return;
+ if (intermission_running) return;
+
entity balance = TeamBalance_CheckAllowedTeams(NULL);
TeamBalance_GetTeamCounts(balance, NULL);
int smallest_team_index = 0;
}
}
+// it should be called by gametypes where players can join a team but have to wait before playing
+// it puts players who joined too late (without being able to play) back to spectators
+// if prev_team_field is not team it also puts players who previously switched team (without being
+// able to play on the new team) back to previous team
+void MatchEnd_RestoreSpectatorAndTeamStatus(.int prev_team_field)
+{
+ bool fix_team = (teamplay && prev_team_field != team);
+ FOREACH_CLIENT(true,
+ {
+ if (!IS_PLAYER(it) && INGAME_JOINING(it))
+ {
+ INGAME_STATUS_CLEAR(it);
+ PutObserverInServer(it, true, false);
+ bprint(playername(it.netname, it.team, false), " has been moved back to spectator");
+ it.winning = false;
+ }
+ else if (fix_team && INGAME_JOINED(it) && it.(prev_team_field) && it.team != it.(prev_team_field))
+ {
+ Player_SetForcedTeamIndex(it, TEAM_FORCE_DEFAULT);
+ if (MoveToTeam(it, Team_TeamToIndex(it.(prev_team_field)), 6))
+ {
+ string pl_name = playername(it.netname, it.team, false);
+ bprint(pl_name, " has been moved back to the ", Team_ColoredFullName(it.team));
+ }
+ it.winning = (it.team == WinningConditionHelper_winnerteam);
+ }
+ });
+}
+
+void MatchEnd_RestoreSpectatorStatus()
+{
+ MatchEnd_RestoreSpectatorAndTeamStatus(team);
+}
+
/*
go to the next level for deathmatch
only called if a time or frag limit has expired
VoteReset(true);
+ MUTATOR_CALLHOOK(MatchEnd_BeforeScores);
+
DumpStats(true);
// send statistics