Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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
int autocvar_g_ca_spectate_enemies
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
bool g_ca_spectate_enemies
const int ST_CA_ROUNDS = 1

Function Documentation

◆ CA_CheckTeams()

bool CA_CheckTeams ( )

Definition at line 220 of file sv_clanarena.qc.

221{
222 static int prev_missing_teams_mask;
223 allowed_to_spawn = true;
227 return true;
228 if(total_players == 0)
229 return false;
230 for (int i = 1; i <= NUM_TEAMS; ++i)
231 {
232 if ((ca_teams & Team_IndexToBit(i)) &&
234 {
236 }
237 }
238 if(prev_missing_teams_mask != missing_teams_mask)
239 prev_missing_teams_mask = missing_teams_mask;
240 return false;
241}
int missing_teams_mask
Definition stats.qh:85
int NumTeams(int teams)
void CA_count_alive_players()
bool allowed_to_spawn
int ca_teams
int total_players
Definition sv_rules.qh:12
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition teamplay.qc:85
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
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

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

Referenced by REGISTER_MUTATOR().

◆ CA_CheckWinner()

bool CA_CheckWinner ( )

Definition at line 141 of file sv_clanarena.qc.

142{
143 int winner_team = 0;
144
146 {
147 // attempt to prevent stalemate by survivor count AND/OR total team health?
148 bool prevent_stalemate_by_survivors = (autocvar_g_ca_prevent_stalemate & BIT(0));
149 bool prevent_stalemate_by_health = (autocvar_g_ca_prevent_stalemate & BIT(1));
150
151 if(prevent_stalemate_by_survivors || prevent_stalemate_by_health)
152 winner_team = CA_PreventStalemate();
153 else
154 winner_team = -2;
155 }
156
158 if (!winner_team)
159 winner_team = Team_GetWinnerAliveTeam();
160 if (!winner_team)
161 {
162 // Dr. Jaska:
163 // reset delay time here only for consistency
164 // CA players currently have no known ways to resurrect
166 return 0;
167 }
168
169 // delay round ending a bit
172 && round_handler_GetEndTime() - time > 0) // don't delay past timelimit
173 {
175 {
177 return 0;
178 }
180 {
181 return 0;
182 }
183 }
184
185 if(winner_team > 0)
186 {
187 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
188 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
189 TeamScore_AddToTeam(winner_team, ST_CA_ROUNDS, +1);
190 }
191 else if(winner_team == -1)
192 {
193 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
194 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
195 }
196 else if(winner_team == -2)
197 {
198 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
199 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
200 }
201
202 allowed_to_spawn = false;
203 game_stopped = true;
205
208 });
209
210 return 1;
211}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
#define IS_PLAYER(s)
Definition player.qh:243
float game_stopped
Definition stats.qh:81
float time
float min(float f,...)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define APP_TEAM_NUM(num, prefix)
Definition all.qh:84
#define NULL
Definition post.qh:14
void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
#define round_handler_GetEndTime()
#define round_handler_SetEndDelayTime(t)
#define round_handler_GetEndDelayTime()
#define round_handler_ResetEndDelayTime()
float TeamScore_AddToTeam(int t, float scorefield, float score)
Adds a score to the given team.
Definition scores.qc:107
int autocvar_g_ca_prevent_stalemate
float autocvar_g_ca_round_enddelay
int CA_PreventStalemate()
float autocvar_g_ca_round_timelimit
const int ST_CA_ROUNDS
float autocvar_g_ca_warmup
void nades_RemovePlayer(entity this)
Definition sv_nades.qc:885
int Team_GetWinnerAliveTeam()
Returns the winner team.
Definition teamplay.qc:95
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References allowed_to_spawn, APP_TEAM_NUM, autocvar_g_ca_prevent_stalemate, autocvar_g_ca_round_enddelay, autocvar_g_ca_round_timelimit, autocvar_g_ca_warmup, BIT, CA_count_alive_players(), CA_PreventStalemate(), FOREACH_CLIENT, game_stopped, IS_PLAYER, min(), nades_RemovePlayer(), NULL, round_handler_GetEndDelayTime, round_handler_GetEndTime, round_handler_Init(), round_handler_ResetEndDelayTime, round_handler_SetEndDelayTime, Send_Notification(), ST_CA_ROUNDS, Team_GetWinnerAliveTeam(), TeamScore_AddToTeam(), and time.

Referenced by REGISTER_MUTATOR().

◆ ca_isEliminated()

bool ca_isEliminated ( entity e)

Definition at line 243 of file sv_clanarena.qc.

244{
245 if(INGAME_JOINED(e) && (IS_DEAD(e) || e.frags == FRAGS_PLAYER_OUT_OF_GAME))
246 return true;
247 if(INGAME_JOINING(e))
248 return true;
249 return false;
250}
#define IS_DEAD(s)
Definition player.qh:245
const int FRAGS_PLAYER_OUT_OF_GAME
Definition constants.qh:5
#define INGAME_JOINED(it)
Definition sv_rules.qh:25
#define INGAME_JOINING(it)
Definition sv_rules.qh:26

References entity(), FRAGS_PLAYER_OUT_OF_GAME, INGAME_JOINED, INGAME_JOINING, and IS_DEAD.

Referenced by REGISTER_MUTATOR().

◆ CA_RoundStart()

void CA_RoundStart ( )

Definition at line 213 of file sv_clanarena.qc.

214{
216 if (!warmup_stage)
217 FOREACH_CLIENT(IS_PLAYER(it), it.prev_team = it.team);
218}
#define boolean(value)
Definition bool.qh:9
bool warmup_stage
Definition main.qh:120

References allowed_to_spawn, boolean, FOREACH_CLIENT, IS_PLAYER, and warmup_stage.

Referenced by REGISTER_MUTATOR().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( ca ,
false  )

Definition at line 30 of file sv_clanarena.qh.

31{
34 {
35 GameRules_teams(true);
39
41 if (ca_teams < 2)
42 ca_teams = cvar("g_ca_teams"); // read the cvar directly as it gets written earlier in the same frame
43
44 ca_teams = BITS(bound(2, ca_teams, 4));
46 {
47 field_team(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
48 });
49
50 allowed_to_spawn = true;
56 }
57 return 0;
58}
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_STATIC()
Definition base.qh:313
#define BITS(n)
Definition bits.qh:9
const int SFL_SORT_PRIO_PRIMARY
Definition scores.qh:134
void EliminatedPlayers_Init(float(entity) isEliminated_func)
float bound(float min, float value, float max)
float cvar(string name)
void round_handler_Spawn(bool() canRoundStart_func, bool() canRoundEnd_func, void() roundStart_func)
void CA_RoundStart()
bool CA_CheckTeams()
float CA_CheckWinner()
bool ca_isEliminated(entity e)
bool g_ca_spectate_enemies
int autocvar_g_ca_teams_override
bool autocvar_g_ca_team_spawns
int autocvar_g_ca_point_limit
int autocvar_g_ca_point_leadlimit
int autocvar_g_ca_spectate_enemies
void GameRules_limit_score(int limit)
Definition sv_rules.qc:23
void GameRules_teams(bool value)
Definition sv_rules.qc:3
void GameRules_limit_lead(int limit)
Definition sv_rules.qc:33
#define GameRules_spawning_teams(value)
Used to disable team spawns in team modes.
Definition sv_rules.qh:35
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition sv_rules.qh:58
bool observe_blocked_if_eliminated
Definition world.qh:160

References allowed_to_spawn, autocvar_g_ca_point_leadlimit, autocvar_g_ca_point_limit, autocvar_g_ca_round_timelimit, autocvar_g_ca_spectate_enemies, 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(), g_ca_spectate_enemies, GameRules_limit_lead(), GameRules_limit_score(), GameRules_scoring, GameRules_spawning_teams, GameRules_teams(), MUTATOR_ONADD, MUTATOR_STATIC, observe_blocked_if_eliminated, round_handler_Init(), round_handler_Spawn(), SFL_SORT_PRIO_PRIMARY, and ST_CA_ROUNDS.

Variable Documentation

◆ allowed_to_spawn

◆ autocvar_g_ca_point_leadlimit

int autocvar_g_ca_point_leadlimit

Definition at line 11 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_point_limit

int autocvar_g_ca_point_limit

Definition at line 10 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_round_timelimit

float autocvar_g_ca_round_timelimit

Definition at line 12 of file sv_clanarena.qh.

Referenced by CA_CheckWinner(), and REGISTER_MUTATOR().

◆ autocvar_g_ca_spectate_enemies

int autocvar_g_ca_spectate_enemies

Definition at line 9 of file sv_clanarena.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and REGISTER_MUTATOR().

◆ autocvar_g_ca_team_spawns

bool autocvar_g_ca_team_spawns

Definition at line 13 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_teams_override

int autocvar_g_ca_teams_override

Definition at line 15 of file sv_clanarena.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_ca_warmup

float autocvar_g_ca_warmup

Definition at line 16 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 17 of file sv_clanarena.qh.

Referenced by MUTATOR_HOOKFUNCTION().

◆ ca_teams

int ca_teams

Definition at line 19 of file sv_clanarena.qh.

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

◆ g_ca_spectate_enemies

◆ ST_CA_ROUNDS

const int ST_CA_ROUNDS = 1

Definition at line 23 of file sv_clanarena.qh.

Referenced by CA_CheckWinner(), and REGISTER_MUTATOR().