});
FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
- STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(
- 1));
- STAT(BLUEALIVE, it) = Team_GetNumberOfAlivePlayers(
- Team_GetTeamFromIndex(2));
- STAT(YELLOWALIVE, it) = Team_GetNumberOfAlivePlayers(
- Team_GetTeamFromIndex(3));
- STAT(PINKALIVE, it) = Team_GetNumberOfAlivePlayers(
- Team_GetTeamFromIndex(4));
+ STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1));
+ STAT(BLUEALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(2));
+ STAT(YELLOWALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(3));
+ STAT(PINKALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(4));
});
}
-int CA_GetWinnerTeam()
-{
- int winner_team = 0;
- if (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1)) >= 1)
- {
- winner_team = NUM_TEAM_1;
- }
- for (int i = 2; i <= NUM_TEAMS; ++i)
- {
- if (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) >= 1)
- {
- if (winner_team != 0)
- {
- return 0;
- }
- winner_team = Team_IndexToTeam(i);
- }
- }
- if (winner_team)
- {
- return winner_team;
- }
- return -1; // no player left
-}
-
void nades_Clear(entity player);
float CA_CheckWinner()
}
CA_count_alive_players();
- if (Team_GetNumberOfAliveTeams() > 1)
- {
+ int winner_team = Team_GetWinnerAliveTeam();
+ if (!winner_team)
return 0;
- }
- int winner_team = CA_GetWinnerTeam();
if(winner_team > 0)
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
});
}
-int Domination_GetWinnerTeam()
-{
- int winner_team = 0;
- if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(1)) ==
- total_control_points)
- {
- winner_team = NUM_TEAM_1;
- }
- for (int i = 2; i <= NUM_TEAMS; ++i)
- {
- if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(i)) ==
- total_control_points)
- {
- if (winner_team != 0)
- {
- return 0;
- }
- winner_team = Team_IndexToTeam(i);
- }
- }
- if (winner_team)
- {
- return winner_team;
- }
- return -1; // no control points left?
-}
-
bool Domination_CheckWinner()
{
if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
}
Domination_count_controlpoints();
-
- float winner_team = Domination_GetWinnerTeam();
-
- if(winner_team == -1)
- return false;
+ int winner_team = Team_GetWinnerTeam_WIthControlPoints(total_control_points);
+ if (winner_team == -1)
+ return 0;
if(winner_team > 0)
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
TeamScore_AddToTeam(winner_team, ST_DOM_CAPS, +1);
}
- 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);
- }
game_stopped = true;
round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
});
FOREACH_CLIENT(IS_REAL_CLIENT(it),
{
- STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(
- 1));
- STAT(BLUEALIVE, it) = Team_GetNumberOfAlivePlayers(
- Team_GetTeamFromIndex(2));
- STAT(YELLOWALIVE, it) = Team_GetNumberOfAlivePlayers(
- Team_GetTeamFromIndex(3));
- STAT(PINKALIVE, it) = Team_GetNumberOfAlivePlayers(
- Team_GetTeamFromIndex(4));
+ STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1));
+ STAT(BLUEALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(2));
+ STAT(YELLOWALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(3));
+ STAT(PINKALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(4));
});
eliminatedPlayers.SendFlags |= 1;
return false;
}
-int freezetag_getWinnerTeam()
-{
- int winner_team = 0;
- if (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1)) >= 1)
- {
- winner_team = NUM_TEAM_1;
- }
- for (int i = 2; i <= NUM_TEAMS; ++i)
- {
- if (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) >= 1)
- {
- if (winner_team != 0)
- {
- return 0;
- }
- winner_team = Team_IndexToTeam(i);
- }
- }
- if (winner_team)
- {
- return winner_team;
- }
- return -1; // no player left
-}
-
void nades_Clear(entity);
void nades_GiveBonus(entity player, float score);
return true;
}
- if (Team_GetNumberOfAliveTeams() > 1)
- {
+ int winner_team = Team_GetWinnerAliveTeam();
+ if (!winner_team)
return false;
- }
- int winner_team = freezetag_getWinnerTeam();
if(winner_team > 0)
{
Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
}
}
-int Onslaught_GetWinnerTeam()
-{
- int winner_team = 0;
- if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(1)) >= 1)
- {
- winner_team = NUM_TEAM_1;
- }
- for (int i = 2; i <= NUM_TEAMS; ++i)
- {
- if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(i)) >= 1)
- {
- if (winner_team != 0)
- {
- return 0;
- }
- winner_team = Team_IndexToTeam(i);
- }
- }
- if (winner_team)
- {
- return winner_team;
- }
- return -1; // no generators left?
-}
-
void nades_Clear(entity e);
bool Onslaught_CheckWinner()
else { wpforenemy_announced = false; ons_stalemate = false; }
Onslaught_count_generators();
-
- if (Team_GetNumberOfTeamsWithControlPoints() > 1)
- {
+ int winner_team = Team_GetWinnerTeam_WIthControlPoints(1); // actually generators
+ if (!winner_team)
return 0;
- }
-
- int winner_team = Onslaught_GetWinnerTeam();
if(winner_team > 0)
{
team_ent.m_num_players_alive = number;
}
+int Team_GetWinnerAliveTeam()
+{
+ int winner = 0;
+ for (int i = 0; i < NUM_TEAMS; ++i)
+ {
+ if (g_team_entities[i].m_num_players_alive > 0)
+ {
+ if (winner)
+ return 0;
+ winner = Team_IndexToTeam(i + 1);
+ }
+ }
+ return (winner ? winner : -1);
+}
+
int Team_GetNumberOfAliveTeams()
{
int result = 0;
return result;
}
+int Team_GetWinnerTeam_WIthControlPoints(int min_control_points)
+{
+ int winner = 0;
+ for (int i = 0; i < NUM_TEAMS; ++i)
+ {
+ if (g_team_entities[i].m_num_control_points >= min_control_points)
+ {
+ if (winner)
+ return 0;
+ winner = Team_IndexToTeam(i + 1);
+ }
+ }
+ return (winner ? winner : -1);
+}
+
int Team_GetNumberOfControlPoints(entity team_ent)
{
return team_ent.m_num_control_points;
/// \param[in] number Number of players to set.
void Team_SetNumberOfAlivePlayers(entity team_ent, int number);
+/// \brief Returns the winner team.
+/// \return Winner team or 0 if 2 or more teams have alive players or -1 if no team has any alive players.
+int Team_GetWinnerAliveTeam();
+
/// \brief Returns the number of alive teams.
/// \return Number of alive teams.
int Team_GetNumberOfAliveTeams();
+/// \brief Returns the winner team.
+/// \param[in] min_control_points Minimum number of control points the winner team must have.
+/// \return Winner team or 0 if 2 or more teams have control points or -1 if no team has any control points.
+int Team_GetWinnerTeam_WIthControlPoints(int min_control_points);
+
/// \brief Returns the number of control points owned by a team.
/// \param[in] team_ent Team entity.
/// \return Number of control points owned by a team.