Xonotic
sv_clanarena.qh File Reference
+ Include dependency graph for sv_clanarena.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool CA_CheckTeams ()
 
bool CA_CheckWinner ()
 
bool ca_isEliminated (entity e)
 
void CA_RoundStart ()
 
 REGISTER_MUTATOR (ca, false)
 

Variables

bool allowed_to_spawn
 
int autocvar_g_ca_point_leadlimit
 
int autocvar_g_ca_point_limit
 
float autocvar_g_ca_round_timelimit
 
bool autocvar_g_ca_team_spawns
 
int autocvar_g_ca_teams_override
 
float autocvar_g_ca_warmup
 
string autocvar_g_ca_weaponarena = "most"
 
int ca_teams
 
const int ST_CA_ROUNDS = 1
 

Function Documentation

◆ CA_CheckTeams()

bool CA_CheckTeams ( )

Definition at line 92 of file sv_clanarena.qc.

References allowed_to_spawn, CA_count_alive_players(), ca_teams, NULL, NUM_TEAMS, NumTeams(), Team_GetNumberOfAlivePlayers(), Team_GetNumberOfAliveTeams(), Team_GetTeamFromIndex(), Team_IndexToBit(), and total_players.

Referenced by REGISTER_MUTATOR().

93 {
94  static int prev_missing_teams_mask;
95  allowed_to_spawn = true;
98  {
99  if(prev_missing_teams_mask > 0)
100  Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
101  prev_missing_teams_mask = -1;
102  return true;
103  }
104  if(total_players == 0)
105  {
106  if(prev_missing_teams_mask > 0)
107  Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
108  prev_missing_teams_mask = -1;
109  return false;
110  }
111  int missing_teams_mask = 0;
112  for (int i = 1; i <= NUM_TEAMS; ++i)
113  {
114  if ((ca_teams & Team_IndexToBit(i)) &&
116  {
117  missing_teams_mask |= Team_IndexToBit(i);
118  }
119  }
120  if(prev_missing_teams_mask != missing_teams_mask)
121  {
122  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
123  prev_missing_teams_mask = missing_teams_mask;
124  }
125  return false;
126 }
const int NUM_TEAMS
Number of teams in the game.
Definition: teams.qh:3
int Team_IndexToBit(int index)
Converts team index into bit value that is used in team bitmasks.
Definition: teams.qh:211
int NumTeams(int teams)
Definition: scores_rules.qc:17
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition: teamplay.qc:85
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
void CA_count_alive_players()
Definition: sv_clanarena.qc:17
#define NULL
Definition: post.qh:17
int Team_GetNumberOfAliveTeams()
Returns the number of alive teams.
Definition: teamplay.qc:110
entity Team_GetTeamFromIndex(int index)
Returns the global team entity at the given index.
Definition: teamplay.qc:57
int total_players
Definition: sv_rules.qh:8
int ca_teams
Definition: sv_clanarena.qh:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CA_CheckWinner()

bool CA_CheckWinner ( )

Definition at line 47 of file sv_clanarena.qc.

References allowed_to_spawn, APP_TEAM_NUM, autocvar_g_ca_round_timelimit, autocvar_g_ca_warmup, CA_count_alive_players(), FOREACH_CLIENT, IS_PLAYER, nades_Clear(), NULL, round_handler_GetEndTime, round_handler_Init(), ST_CA_ROUNDS, Team_GetWinnerAliveTeam(), TeamScore_AddToTeam(), and time.

Referenced by REGISTER_MUTATOR().

48 {
50  {
51  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
52  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
53  FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
54 
55  allowed_to_spawn = false;
56  game_stopped = true;
58  return 1;
59  }
60 
62  int winner_team = Team_GetWinnerAliveTeam();
63  if (!winner_team)
64  return 0;
65 
66  if(winner_team > 0)
67  {
68  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
69  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
70  TeamScore_AddToTeam(winner_team, ST_CA_ROUNDS, +1);
71  }
72  else if(winner_team == -1)
73  {
74  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
75  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
76  }
77 
78  allowed_to_spawn = false;
79  game_stopped = true;
81 
82  FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
83 
84  return 1;
85 }
#define APP_TEAM_NUM(num, prefix)
Definition: all.qh:85
float TeamScore_AddToTeam(int t, float scorefield, float score)
Adds a score to the given team.
Definition: scores.qc:108
void nades_Clear(entity player)
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
void CA_count_alive_players()
Definition: sv_clanarena.qc:17
#define NULL
Definition: post.qh:17
#define round_handler_GetEndTime()
float autocvar_g_ca_round_timelimit
Definition: sv_clanarena.qh:10
const int ST_CA_ROUNDS
Definition: sv_clanarena.qh:21
float autocvar_g_ca_warmup
Definition: sv_clanarena.qh:14
int Team_GetWinnerAliveTeam()
Returns the winner team.
Definition: teamplay.qc:95
float time
Definition: csprogsdefs.qc:16
void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ca_isEliminated()

bool ca_isEliminated ( entity  e)

Definition at line 128 of file sv_clanarena.qc.

References FRAGS_PLAYER_OUT_OF_GAME, INGAME_JOINED, INGAME_JOINING, and IS_DEAD.

Referenced by REGISTER_MUTATOR().

129 {
130  if(INGAME_JOINED(e) && (IS_DEAD(e) || e.frags == FRAGS_PLAYER_OUT_OF_GAME))
131  return true;
132  if(INGAME_JOINING(e))
133  return true;
134  return false;
135 }
#define IS_DEAD(s)
Definition: utils.qh:26
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
#define INGAME_JOINED(it)
Definition: sv_rules.qh:21
#define INGAME_JOINING(it)
Definition: sv_rules.qh:22
+ Here is the caller graph for this function:

◆ CA_RoundStart()

void CA_RoundStart ( )

Definition at line 87 of file sv_clanarena.qc.

References allowed_to_spawn, boolean, and warmup_stage.

Referenced by REGISTER_MUTATOR().

88 {
90 }
bool warmup_stage
Definition: main.qh:103
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
#define boolean(value)
Definition: bool.qh:9
+ Here is the caller graph for this function:

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( ca  ,
false   
)

Definition at line 28 of file sv_clanarena.qh.

References allowed_to_spawn, autocvar_g_ca_point_leadlimit, autocvar_g_ca_point_limit, autocvar_g_ca_round_timelimit, autocvar_g_ca_team_spawns, autocvar_g_ca_teams_override, autocvar_g_ca_warmup, BITS, bound(), CA_CheckTeams(), CA_CheckWinner(), ca_isEliminated(), CA_RoundStart(), ca_teams, cvar(), EliminatedPlayers_Init(), GameRules_limit_lead(), GameRules_limit_score(), GameRules_scoring, GameRules_spawning_teams(), GameRules_teams(), MUTATOR_ONADD, MUTATOR_STATIC, round_handler_Init(), round_handler_Spawn(), SFL_SORT_PRIO_PRIMARY, and ST_CA_ROUNDS.

29 {
32  {
33  GameRules_teams(true);
37 
39  if (ca_teams < 2)
40  ca_teams = cvar("g_ca_teams"); // read the cvar directly as it gets written earlier in the same frame
41 
42  ca_teams = BITS(bound(2, ca_teams, 4));
44  field_team(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
45  });
46 
47  allowed_to_spawn = true;
51  }
52  return 0;
53 }
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition: sv_rules.qh:53
#define MUTATOR_STATIC()
Definition: base.qh:288
void GameRules_spawning_teams(bool value)
Used to disable team spawns in team modes.
Definition: sv_rules.qc:22
int autocvar_g_ca_point_limit
Definition: sv_clanarena.qh:8
void round_handler_Spawn(bool() canRoundStart_func, bool() canRoundEnd_func, void() roundStart_func)
bool ca_isEliminated(entity e)
bool CA_CheckWinner()
Definition: sv_clanarena.qc:47
void EliminatedPlayers_Init(float(entity) isEliminated_func)
Definition: elimination.qc:27
void GameRules_limit_score(int limit)
Definition: sv_rules.qc:34
const int SFL_SORT_PRIO_PRIMARY
Definition: scores.qh:127
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
bool autocvar_g_ca_team_spawns
Definition: sv_clanarena.qh:11
int autocvar_g_ca_teams_override
Definition: sv_clanarena.qh:13
bool CA_CheckTeams()
Definition: sv_clanarena.qc:92
void GameRules_teams(bool value)
Definition: sv_rules.qc:6
int autocvar_g_ca_point_leadlimit
Definition: sv_clanarena.qh:9
float autocvar_g_ca_round_timelimit
Definition: sv_clanarena.qh:10
const int ST_CA_ROUNDS
Definition: sv_clanarena.qh:21
float autocvar_g_ca_warmup
Definition: sv_clanarena.qh:14
int ca_teams
Definition: sv_clanarena.qh:18
void GameRules_limit_lead(int limit)
Definition: sv_rules.qc:44
#define MUTATOR_ONADD
Definition: base.qh:284
void CA_RoundStart()
Definition: sv_clanarena.qc:87
void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
#define BITS(n)
Definition: bits.qh:9
+ Here is the call graph for this function:

Variable Documentation

◆ allowed_to_spawn

bool allowed_to_spawn

◆ autocvar_g_ca_point_leadlimit

int autocvar_g_ca_point_leadlimit

Definition at line 9 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_point_limit

int autocvar_g_ca_point_limit

Definition at line 8 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_round_timelimit

float autocvar_g_ca_round_timelimit

Definition at line 10 of file sv_clanarena.qh.

Referenced by CA_CheckWinner(), and REGISTER_MUTATOR().

◆ autocvar_g_ca_team_spawns

bool autocvar_g_ca_team_spawns

Definition at line 11 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_teams_override

int autocvar_g_ca_teams_override

Definition at line 13 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_warmup

float autocvar_g_ca_warmup

Definition at line 14 of file sv_clanarena.qh.

Referenced by CA_CheckWinner(), and REGISTER_MUTATOR().

◆ autocvar_g_ca_weaponarena

string autocvar_g_ca_weaponarena = "most"

Definition at line 15 of file sv_clanarena.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ ca_teams

int ca_teams

Definition at line 18 of file sv_clanarena.qh.

Referenced by CA_CheckTeams(), MUTATOR_HOOKFUNCTION(), and REGISTER_MUTATOR().

◆ ST_CA_ROUNDS

const int ST_CA_ROUNDS = 1

Definition at line 21 of file sv_clanarena.qh.

Referenced by CA_CheckWinner(), and REGISTER_MUTATOR().