if (STAT(FROZEN, frag_target) == FROZEN_NORMAL)
Unfreeze(frag_target, true);
freezetag_count_alive_players();
- return true; // let the player die so that he can respawn whenever he wants
+ frag_target.respawn_time = time;
+ frag_target.respawn_flags |= RESPAWN_FORCE;
+ return true;
}
// Cases DEATH_TEAMCHANGE and DEATH_AUTOTEAMCHANGE are needed to fix a bug whe
return true;
}
+MUTATOR_HOOKFUNCTION(ft, SV_ParseServerCommand)
+{
+ shuffleteams_on_reset_map = !(round_handler_IsActive() && !round_handler_IsRoundStarted());
+ return false;
+}
+
void freezetag_Initialize()
{
freezetag_teams = autocvar_g_freezetag_teams_override;
}
}
+void shuffleteams()
+{
+ if (!teamplay)
+ {
+ LOG_INFO("Can't shuffle teams when currently not playing a team game.");
+ return;
+ }
+
+ FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
+ if (Player_HasRealForcedTeam(it)) {
+ // we could theoretically assign forced players to their teams
+ // and shuffle the rest to fill the empty spots but in practise
+ // either all players or none are gonna have forced teams
+ LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
+ return;
+ }
+ });
+
+ int number_of_teams = 0;
+ entity balance = TeamBalance_CheckAllowedTeams(NULL);
+ for (int i = 1; i <= NUM_TEAMS; ++i)
+ {
+ if (TeamBalance_IsTeamAllowed(balance, i))
+ {
+ number_of_teams = max(i, number_of_teams);
+ }
+ }
+ TeamBalance_Destroy(balance);
+
+ int team_index = 0;
+ FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
+ int target_team_index = team_index + 1;
+ if (Entity_GetTeamIndex(it) != target_team_index)
+ {
+ MoveToTeam(it, target_team_index, 6);
+ }
+ team_index = (team_index + 1) % number_of_teams;
+ });
+
+ bprint("Successfully shuffled the players around randomly.\n");
+}
+
void GameCommand_shuffleteams(int request)
{
switch (request)
{
case CMD_REQUEST_COMMAND:
{
- if (!teamplay)
+ if (shuffleteams_on_reset_map)
{
- LOG_INFO("Can't shuffle teams when currently not playing a team game.");
- return;
+ bprint("Players will be shuffled when this round is over.\n");
+ shuffleteams_on_reset_map = true;
}
-
- FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
- if (Player_HasRealForcedTeam(it)) {
- // we could theoretically assign forced players to their teams
- // and shuffle the rest to fill the empty spots but in practise
- // either all players or none are gonna have forced teams
- LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
- return;
- }
- });
-
- int number_of_teams = 0;
- entity balance = TeamBalance_CheckAllowedTeams(NULL);
- for (int i = 1; i <= NUM_TEAMS; ++i)
- {
- if (TeamBalance_IsTeamAllowed(balance, i))
- {
- number_of_teams = max(i, number_of_teams);
- }
- }
- TeamBalance_Destroy(balance);
-
- int team_index = 0;
- FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
- int target_team_index = team_index + 1;
- if (Entity_GetTeamIndex(it) != target_team_index)
- {
- MoveToTeam(it, target_team_index, 6);
- }
- team_index = (team_index + 1) % number_of_teams;
- });
-
- bprint("Successfully shuffled the players around randomly.\n");
+ else
+ shuffleteams();
return;
}