Xonotic
sv_clanarena.qc File Reference
#include "sv_clanarena.qh"
+ Include dependency graph for sv_clanarena.qc:

Go to the source code of this file.

Functions

bool CA_CheckTeams ()
 
float CA_CheckWinner ()
 
void CA_count_alive_players ()
 
bool ca_isEliminated (entity e)
 
entity ca_LastPlayerForTeam (entity this)
 
void ca_LastPlayerForTeam_Notify (entity this)
 
void CA_RoundStart ()
 
entity CA_SpectateNext (entity player, entity start)
 Returns next available player to spectate if g_ca_spectate_enemies == 0. More...
 
 MUTATOR_HOOKFUNCTION (ca, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION (ca, ForbidSpawn)
 
 MUTATOR_HOOKFUNCTION (ca, PutClientInServer)
 
 MUTATOR_HOOKFUNCTION (ca, reset_map_players)
 
 MUTATOR_HOOKFUNCTION (ca, reset_map_global)
 
 MUTATOR_HOOKFUNCTION (ca, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
 
 MUTATOR_HOOKFUNCTION (ca, PlayerDies)
 
 MUTATOR_HOOKFUNCTION (ca, ClientDisconnect)
 
 MUTATOR_HOOKFUNCTION (ca, MakePlayerObserver)
 
 MUTATOR_HOOKFUNCTION (ca, ForbidThrowCurrentWeapon)
 
 MUTATOR_HOOKFUNCTION (ca, GiveFragsForKill, CBC_ORDER_FIRST)
 
 MUTATOR_HOOKFUNCTION (ca, SetStartItems)
 
 MUTATOR_HOOKFUNCTION (ca, Damage_Calculate)
 
 MUTATOR_HOOKFUNCTION (ca, FilterItem)
 
 MUTATOR_HOOKFUNCTION (ca, PlayerDamage_SplitHealthArmor)
 
 MUTATOR_HOOKFUNCTION (ca, CalculateRespawnTime)
 
 MUTATOR_HOOKFUNCTION (ca, PlayerRegen)
 
 MUTATOR_HOOKFUNCTION (ca, Scores_CountFragsRemaining)
 
 MUTATOR_HOOKFUNCTION (ca, SpectateSet)
 
 MUTATOR_HOOKFUNCTION (ca, SpectateNext)
 
 MUTATOR_HOOKFUNCTION (ca, SpectatePrev)
 
 MUTATOR_HOOKFUNCTION (ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 
 MUTATOR_HOOKFUNCTION (ca, ClientCommand_Spectate)
 
 MUTATOR_HOOKFUNCTION (ca, HideTeamNagger)
 
 MUTATOR_HOOKFUNCTION (ca, SetWeaponArena)
 
 MUTATOR_HOOKFUNCTION (ca, SV_ParseServerCommand)
 
void nades_Clear (entity player)
 

Variables

float autocvar_g_ca_damage2score = 100
 
bool autocvar_g_ca_spectate_enemies
 
float autocvar_g_ca_start_ammo_cells = 180
 
float autocvar_g_ca_start_ammo_fuel = 0
 
float autocvar_g_ca_start_ammo_nails = 320
 
float autocvar_g_ca_start_ammo_plasma = 180
 
float autocvar_g_ca_start_ammo_rockets = 160
 
float autocvar_g_ca_start_ammo_shells = 60
 
float autocvar_g_ca_start_armor = 200
 
float autocvar_g_ca_start_health = 200
 
float ca_damage_counter
 

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()

float 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_count_alive_players()

void CA_count_alive_players ( )

Definition at line 17 of file sv_clanarena.qc.

References entity(), Entity_GetTeam(), Entity_HasValidTeam(), FOREACH_CLIENT, IS_DEAD, IS_PLAYER, IS_REAL_CLIENT, nades_Clear(), NUM_TEAMS, Team_GetNumberOfAlivePlayers(), Team_GetTeamFromIndex(), Team_SetNumberOfAlivePlayers(), and total_players.

Referenced by CA_CheckTeams(), and CA_CheckWinner().

18 {
19  total_players = 0;
20  for (int i = 1; i <= NUM_TEAMS; ++i)
21  {
23  }
25  {
26  ++total_players;
27  if (IS_DEAD(it))
28  {
29  continue;
30  }
31  entity team_ = Entity_GetTeam(it);
32  int num_alive = Team_GetNumberOfAlivePlayers(team_);
33  ++num_alive;
34  Team_SetNumberOfAlivePlayers(team_, num_alive);
35  });
37  {
38  STAT(REDALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1));
39  STAT(BLUEALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(2));
40  STAT(YELLOWALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(3));
41  STAT(PINKALIVE, it) = Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(4));
42  });
43 }
const int NUM_TEAMS
Number of teams in the game.
Definition: teams.qh:3
entity() spawn
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition: teamplay.qc:85
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition: teamplay.qc:181
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
bool Entity_HasValidTeam(entity this)
Returns whether the given entity belongs to a valid team.
Definition: teamplay.qc:171
void Team_SetNumberOfAlivePlayers(entity team_ent, int number)
Sets the number of alive players in a team.
Definition: teamplay.qc:90
#define IS_DEAD(s)
Definition: utils.qh:26
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
#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_LastPlayerForTeam()

entity ca_LastPlayerForTeam ( entity  this)

Definition at line 224 of file sv_clanarena.qc.

References entity(), FOREACH_CLIENT, IS_DEAD, IS_PLAYER, NULL, and SAME_TEAM.

Referenced by ca_LastPlayerForTeam_Notify().

225 {
226  entity last_pl = NULL;
227  FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
228  if (!IS_DEAD(it) && SAME_TEAM(this, it))
229  {
230  if (!last_pl)
231  last_pl = it;
232  else
233  return NULL;
234  }
235  });
236  return last_pl;
237 }
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define NULL
Definition: post.qh:17
#define SAME_TEAM(a, b)
Definition: teams.qh:239
#define IS_DEAD(s)
Definition: utils.qh:26
#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_LastPlayerForTeam_Notify()

void ca_LastPlayerForTeam_Notify ( entity  this)

Definition at line 239 of file sv_clanarena.qc.

References ca_LastPlayerForTeam(), entity(), round_handler_IsActive, round_handler_IsRoundStarted, and warmup_stage.

Referenced by MUTATOR_HOOKFUNCTION().

240 {
242  {
243  entity pl = ca_LastPlayerForTeam(this);
244  if (pl)
245  Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
246  }
247 }
#define round_handler_IsActive()
entity() spawn
bool warmup_stage
Definition: main.qh:103
#define round_handler_IsRoundStarted()
entity ca_LastPlayerForTeam(entity this)
+ Here is the call graph for this function:
+ 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:

◆ CA_SpectateNext()

entity CA_SpectateNext ( entity  player,
entity  start 
)

Returns next available player to spectate if g_ca_spectate_enemies == 0.

Definition at line 138 of file sv_clanarena.qc.

References classname, entity(), find(), NULL, SAME_TEAM, and STR_PLAYER.

Referenced by MUTATOR_HOOKFUNCTION().

139 {
140  if (SAME_TEAM(start, player)) return start;
141  // continue from current player
142  for (entity e = start; (e = find(e, classname, STR_PLAYER)); )
143  {
144  if (SAME_TEAM(player, e)) return e;
145  }
146  // restart from the beginning
147  for (entity e = NULL; (e = find(e, classname, STR_PLAYER)); )
148  {
149  if (SAME_TEAM(player, e)) return e;
150  }
151  return start;
152 }
entity() spawn
string classname
Definition: csprogsdefs.qc:107
#define NULL
Definition: post.qh:17
#define SAME_TEAM(a, b)
Definition: teams.qh:239
const string STR_PLAYER
Definition: utils.qh:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MUTATOR_HOOKFUNCTION() [1/26]

MUTATOR_HOOKFUNCTION ( ca  ,
PlayerSpawn   
)

Definition at line 155 of file sv_clanarena.qc.

References eliminatedPlayers, entity(), INGAME_STATUS_JOINED, INGAME_STATUS_SET, M_ARGV, time, and warmup_stage.

156 {
157  entity player = M_ARGV(0, entity);
158 
160  if (time <= game_starttime) // reset on game restart, not on round start
161  player.ca_damage_counter = 0;
162  if (!warmup_stage)
163  eliminatedPlayers.SendFlags |= 1;
164 }
#define INGAME_STATUS_SET(it, s)
Definition: sv_rules.qh:17
#define INGAME_STATUS_JOINED
Definition: sv_rules.qh:13
entity() spawn
bool warmup_stage
Definition: main.qh:103
#define M_ARGV(x, type)
Definition: events.qh:17
entity eliminatedPlayers
Definition: elimination.qh:3
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [2/26]

MUTATOR_HOOKFUNCTION ( ca  ,
ForbidSpawn   
)

Definition at line 166 of file sv_clanarena.qc.

References allowed_to_spawn, entity(), INGAME, and M_ARGV.

167 {
168  entity player = M_ARGV(0, entity);
169 
170  // spectators / observers that weren't playing can join; they are
171  // immediately forced to observe in the PutClientInServer hook
172  // this way they are put in a team and can play in the next round
173  if (!allowed_to_spawn && INGAME(player))
174  return true;
175  return false;
176 }
#define INGAME(it)
Definition: sv_rules.qh:20
entity() spawn
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [3/26]

MUTATOR_HOOKFUNCTION ( ca  ,
PutClientInServer   
)

Definition at line 178 of file sv_clanarena.qc.

References allowed_to_spawn, CS(), entity(), INGAME, INGAME_STATUS_JOINING, INGAME_STATUS_SET, IS_PLAYER, jointime, M_ARGV, time, and TRANSMUTE().

179 {
180  entity player = M_ARGV(0, entity);
181 
182  if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join
183  {
184  TRANSMUTE(Observer, player);
185  if (CS(player).jointime != time && !INGAME(player)) // not when connecting
186  {
188  Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
189  }
190  }
191 }
#define INGAME(it)
Definition: sv_rules.qh:20
#define INGAME_STATUS_SET(it, s)
Definition: sv_rules.qh:17
TRANSMUTE(Player, this)
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
float jointime
Definition: client.qh:64
#define M_ARGV(x, type)
Definition: events.qh:17
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
#define INGAME_STATUS_JOINING
Definition: sv_rules.qh:12
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [4/26]

MUTATOR_HOOKFUNCTION ( ca  ,
reset_map_players   
)

Definition at line 193 of file sv_clanarena.qc.

References CS(), FOREACH_CLIENT, INGAME, INGAME_STATUS_JOINED, INGAME_STATUS_SET, IS_BOT_CLIENT, PutClientInServer(), and TRANSMUTE().

194 {
195  FOREACH_CLIENT(true, {
196  CS(it).killcount = 0;
197  if (!INGAME(it) && IS_BOT_CLIENT(it))
198  {
199  it.team = -1;
201  }
202  if (INGAME(it))
203  {
204  TRANSMUTE(Player, it);
206  PutClientInServer(it);
207  }
208  });
209  return true;
210 }
#define INGAME(it)
Definition: sv_rules.qh:20
#define INGAME_STATUS_SET(it, s)
Definition: sv_rules.qh:17
TRANSMUTE(Player, this)
#define INGAME_STATUS_JOINED
Definition: sv_rules.qh:13
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
PutClientInServer(this)
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [5/26]

MUTATOR_HOOKFUNCTION ( ca  ,
reset_map_global   
)

Definition at line 212 of file sv_clanarena.qc.

References allowed_to_spawn.

213 {
214  allowed_to_spawn = true;
215  return true;
216 }
bool allowed_to_spawn
Definition: sv_clanarena.qh:19

◆ MUTATOR_HOOKFUNCTION() [6/26]

MUTATOR_HOOKFUNCTION ( ca  ,
TeamBalance_CheckAllowedTeams  ,
CBC_ORDER_EXCLUSIVE   
)

Definition at line 218 of file sv_clanarena.qc.

References ca_teams, and M_ARGV.

219 {
220  M_ARGV(0, float) = ca_teams;
221  return true;
222 }
#define M_ARGV(x, type)
Definition: events.qh:17
int ca_teams
Definition: sv_clanarena.qh:18

◆ MUTATOR_HOOKFUNCTION() [7/26]

MUTATOR_HOOKFUNCTION ( ca  ,
PlayerDies   
)

Definition at line 249 of file sv_clanarena.qc.

References allowed_to_spawn, ca_LastPlayerForTeam_Notify(), eliminatedPlayers, entity(), M_ARGV, RESPAWN_FORCE, RESPAWN_SILENT, time, and warmup_stage.

250 {
251  entity frag_target = M_ARGV(2, entity);
252 
253  ca_LastPlayerForTeam_Notify(frag_target);
254  if (!allowed_to_spawn)
255  {
256  frag_target.respawn_flags = RESPAWN_SILENT;
257  // prevent unwanted sudden rejoin as spectator and movement of spectator camera
258  frag_target.respawn_time = time + 2;
259  }
260  frag_target.respawn_flags |= RESPAWN_FORCE;
261  if (!warmup_stage)
262  eliminatedPlayers.SendFlags |= 1;
263  return true;
264 }
const int RESPAWN_FORCE
Definition: client.qh:330
void ca_LastPlayerForTeam_Notify(entity this)
entity() spawn
bool warmup_stage
Definition: main.qh:103
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
#define M_ARGV(x, type)
Definition: events.qh:17
entity eliminatedPlayers
Definition: elimination.qh:3
float time
Definition: csprogsdefs.qc:16
const int RESPAWN_SILENT
Definition: client.qh:331
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [8/26]

MUTATOR_HOOKFUNCTION ( ca  ,
ClientDisconnect   
)

Definition at line 267 of file sv_clanarena.qc.

References ca_LastPlayerForTeam_Notify(), entity(), IS_DEAD, IS_PLAYER, and M_ARGV.

268 {
269  entity player = M_ARGV(0, entity);
270 
271  if (IS_PLAYER(player) && !IS_DEAD(player))
273  return true;
274 }
void ca_LastPlayerForTeam_Notify(entity this)
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [9/26]

MUTATOR_HOOKFUNCTION ( ca  ,
MakePlayerObserver   
)

Definition at line 276 of file sv_clanarena.qc.

References ca_LastPlayerForTeam_Notify(), eliminatedPlayers, entity(), FRAGS_PLAYER_OUT_OF_GAME, INGAME, INGAME_STATUS_CLEAR, IS_DEAD, IS_PLAYER, M_ARGV, and warmup_stage.

277 {
278  entity player = M_ARGV(0, entity);
279 
280  bool is_forced = M_ARGV(1, bool);
281  if (is_forced && INGAME(player))
282  INGAME_STATUS_CLEAR(player);
283 
284  if (IS_PLAYER(player) && !IS_DEAD(player))
286  if (player.killindicator_teamchange == -2) // player wants to spectate
287  {
288  entcs_update_players(player);
289  INGAME_STATUS_CLEAR(player);
290  }
291  if (INGAME(player))
292  player.frags = FRAGS_PLAYER_OUT_OF_GAME;
293  if (!warmup_stage)
294  eliminatedPlayers.SendFlags |= 1;
295  if (!INGAME(player))
296  return false; // allow team reset
297  return true; // prevent team reset
298 }
#define INGAME(it)
Definition: sv_rules.qh:20
void ca_LastPlayerForTeam_Notify(entity this)
entity() spawn
bool warmup_stage
Definition: main.qh:103
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
#define INGAME_STATUS_CLEAR(it)
Definition: sv_rules.qh:18
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
entity eliminatedPlayers
Definition: elimination.qh:3
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [10/26]

MUTATOR_HOOKFUNCTION ( ca  ,
ForbidThrowCurrentWeapon   
)

Definition at line 300 of file sv_clanarena.qc.

301 {
302  return true;
303 }

◆ MUTATOR_HOOKFUNCTION() [11/26]

MUTATOR_HOOKFUNCTION ( ca  ,
GiveFragsForKill  ,
CBC_ORDER_FIRST   
)

Definition at line 305 of file sv_clanarena.qc.

References M_ARGV.

306 {
307  M_ARGV(2, float) = 0; // score will be given to the winner team when the round ends
308  return true;
309 }
#define M_ARGV(x, type)
Definition: events.qh:17

◆ MUTATOR_HOOKFUNCTION() [12/26]

MUTATOR_HOOKFUNCTION ( ca  ,
SetStartItems   
)

Definition at line 311 of file sv_clanarena.qc.

References autocvar_g_ca_start_ammo_cells, autocvar_g_ca_start_ammo_fuel, autocvar_g_ca_start_ammo_nails, autocvar_g_ca_start_ammo_plasma, autocvar_g_ca_start_ammo_rockets, autocvar_g_ca_start_ammo_shells, autocvar_g_ca_start_armor, autocvar_g_ca_start_health, cvar(), start_ammo_cells, start_ammo_fuel, start_ammo_nails, start_ammo_plasma, start_ammo_rockets, start_ammo_shells, start_armorvalue, start_health, start_items, warmup_start_ammo_cells, warmup_start_ammo_fuel, warmup_start_ammo_nails, warmup_start_ammo_plasma, warmup_start_ammo_rockets, warmup_start_ammo_shells, warmup_start_armorvalue, and warmup_start_health.

312 {
313  start_items &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
314  if(!cvar("g_use_ammunition"))
315  start_items |= IT_UNLIMITED_AMMO;
316 
325 }
float start_ammo_rockets
Definition: world.qh:87
float autocvar_g_ca_start_ammo_fuel
Definition: sv_clanarena.qc:13
float start_ammo_fuel
Definition: world.qh:90
float warmup_start_ammo_shells
Definition: world.qh:104
float autocvar_g_ca_start_health
Definition: sv_clanarena.qc:6
int start_items
Definition: world.qh:84
float autocvar_g_ca_start_ammo_rockets
Definition: sv_clanarena.qc:10
float start_ammo_shells
Definition: world.qh:85
float autocvar_g_ca_start_armor
Definition: sv_clanarena.qc:7
float warmup_start_ammo_plasma
Definition: world.qh:108
float autocvar_g_ca_start_ammo_nails
Definition: sv_clanarena.qc:9
float autocvar_g_ca_start_ammo_plasma
Definition: sv_clanarena.qc:12
float warmup_start_ammo_cells
Definition: world.qh:107
float warmup_start_ammo_fuel
Definition: world.qh:109
float autocvar_g_ca_start_ammo_shells
Definition: sv_clanarena.qc:8
float start_ammo_cells
Definition: world.qh:88
float autocvar_g_ca_start_ammo_cells
Definition: sv_clanarena.qc:11
float warmup_start_armorvalue
Definition: world.qh:111
float start_health
Definition: world.qh:98
float warmup_start_ammo_rockets
Definition: world.qh:106
float start_ammo_nails
Definition: world.qh:86
float warmup_start_health
Definition: world.qh:110
float start_armorvalue
Definition: world.qh:99
float start_ammo_plasma
Definition: world.qh:89
float warmup_start_ammo_nails
Definition: world.qh:105
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [13/26]

MUTATOR_HOOKFUNCTION ( ca  ,
Damage_Calculate   
)

Definition at line 327 of file sv_clanarena.qc.

References entity(), IS_DEAD, IS_PLAYER, M_ARGV, and SAME_TEAM.

328 {
329  entity frag_attacker = M_ARGV(1, entity);
330  entity frag_target = M_ARGV(2, entity);
331  float frag_deathtype = M_ARGV(3, float);
332  float frag_damage = M_ARGV(4, float);
333  float frag_mirrordamage = M_ARGV(5, float);
334 
335  if (IS_PLAYER(frag_target))
336  if (!IS_DEAD(frag_target))
337  if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
338  frag_damage = 0;
339 
340  frag_mirrordamage = 0;
341 
342  M_ARGV(4, float) = frag_damage;
343  M_ARGV(5, float) = frag_mirrordamage;
344 }
entity() spawn
#define SAME_TEAM(a, b)
Definition: teams.qh:239
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [14/26]

MUTATOR_HOOKFUNCTION ( ca  ,
FilterItem   
)

Definition at line 346 of file sv_clanarena.qc.

References autocvar_g_pickup_items, autocvar_g_powerups, entity(), and M_ARGV.

347 {
348  entity item = M_ARGV(0, entity);
349 
350  if (autocvar_g_powerups <= 0)
351  if (item.itemdef.instanceOfPowerup)
352  return true;
353 
354  if (autocvar_g_pickup_items <= 0)
355  return true;
356 }
entity() spawn
int autocvar_g_powerups
Definition: sv_powerups.qh:7
#define M_ARGV(x, type)
Definition: events.qh:17
int autocvar_g_pickup_items
Definition: items.qh:11
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [15/26]

MUTATOR_HOOKFUNCTION ( ca  ,
PlayerDamage_SplitHealthArmor   
)

Definition at line 358 of file sv_clanarena.qc.

References autocvar_g_ca_damage2score, bound(), ca_damage_counter, DIFF_TEAM, entity(), GameRules_scoring_add_float2int, GetResource(), IS_PLAYER, M_ARGV, max(), NULL, RES_HEALTH, round_handler_IsActive, round_handler_IsRoundStarted, and time.

359 {
360  if (time < game_starttime || (round_handler_IsActive() && !round_handler_IsRoundStarted()))
361  return;
362 
363  entity frag_attacker = M_ARGV(1, entity);
364  entity frag_target = M_ARGV(2, entity);
365  float frag_deathtype = M_ARGV(6, float);
366  float frag_damage = M_ARGV(7, float);
367  float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
368  float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
369 
370  float excess = max(0, frag_damage - damage_take - damage_save);
371 
372  if (autocvar_g_ca_damage2score <= 0 || frag_damage - excess == 0) return;
373 
374  entity scorer = NULL;
375  float scorer_damage = 0;
376 
377  if (IS_PLAYER(frag_attacker))
378  {
379  if (DIFF_TEAM(frag_target, frag_attacker))
380  scorer_damage = frag_damage - excess;
381  else // friendly fire
382  scorer_damage = -(frag_damage - excess);
383 
384  scorer = frag_attacker;
385  }
386  else
387  {
388  //handle (environmental hazard) suiciding, check first if player has a registered attacker who most likely pushed them there to avoid punishing pushed players as pushers are already rewarded
389  //deathtypes:
390  //kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks
391  //camp = campcheck, lava = lava, slime = slime
392  //team change / rebalance suicides are currently not included
393  if (frag_deathtype == DEATH_KILL.m_id ||
394  frag_deathtype == DEATH_DROWN.m_id ||
395  frag_deathtype == DEATH_HURTTRIGGER.m_id ||
396  frag_deathtype == DEATH_CAMP.m_id ||
397  frag_deathtype == DEATH_LAVA.m_id ||
398  frag_deathtype == DEATH_SLIME.m_id ||
399  frag_deathtype == DEATH_SWAMP.m_id)
400  {
401  scorer_damage = -(frag_damage - excess);
402  scorer = frag_target;
403  }
404  }
405 
406  if (scorer)
408 }
#define round_handler_IsActive()
entity() spawn
#define round_handler_IsRoundStarted()
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
RES_HEALTH
Definition: ent_cs.qc:126
#define NULL
Definition: post.qh:17
#define GameRules_scoring_add_float2int(client, fld, value, float_field, score_factor)
Definition: sv_rules.qh:75
#define M_ARGV(x, type)
Definition: events.qh:17
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float ca_damage_counter
Definition: sv_clanarena.qc:15
float time
Definition: csprogsdefs.qc:16
float autocvar_g_ca_damage2score
Definition: sv_clanarena.qc:3
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [16/26]

MUTATOR_HOOKFUNCTION ( ca  ,
CalculateRespawnTime   
)

Definition at line 410 of file sv_clanarena.qc.

411 {
412  // no respawn calculations needed, player is forced to spectate anyway
413  return true;
414 }

◆ MUTATOR_HOOKFUNCTION() [17/26]

MUTATOR_HOOKFUNCTION ( ca  ,
PlayerRegen   
)

Definition at line 416 of file sv_clanarena.qc.

417 {
418  // no regeneration in CA
419  return true;
420 }

◆ MUTATOR_HOOKFUNCTION() [18/26]

MUTATOR_HOOKFUNCTION ( ca  ,
Scores_CountFragsRemaining   
)

Definition at line 422 of file sv_clanarena.qc.

423 {
424  // announce remaining frags
425  return true;
426 }

◆ MUTATOR_HOOKFUNCTION() [19/26]

MUTATOR_HOOKFUNCTION ( ca  ,
SpectateSet   
)

Definition at line 428 of file sv_clanarena.qc.

References autocvar_g_ca_spectate_enemies, DIFF_TEAM, entity(), INGAME, and M_ARGV.

429 {
430  entity client = M_ARGV(0, entity);
431  entity targ = M_ARGV(1, entity);
432 
433  if (!autocvar_g_ca_spectate_enemies && INGAME(client))
434  if (DIFF_TEAM(targ, client))
435  return true;
436 }
#define INGAME(it)
Definition: sv_rules.qh:20
entity() spawn
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
bool autocvar_g_ca_spectate_enemies
Definition: sv_clanarena.qc:4
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [20/26]

MUTATOR_HOOKFUNCTION ( ca  ,
SpectateNext   
)

Definition at line 438 of file sv_clanarena.qc.

References autocvar_g_ca_spectate_enemies, CA_SpectateNext(), entity(), Entity_GetTeam(), INGAME, M_ARGV, and Team_GetNumberOfAlivePlayers().

439 {
440  entity client = M_ARGV(0, entity);
441 
442  if (!autocvar_g_ca_spectate_enemies && INGAME(client)
444  {
445  entity targ = M_ARGV(1, entity);
446  M_ARGV(1, entity) = CA_SpectateNext(client, targ);
447  return true;
448  }
449 }
#define INGAME(it)
Definition: sv_rules.qh:20
entity() spawn
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition: teamplay.qc:85
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition: teamplay.qc:181
bool autocvar_g_ca_spectate_enemies
Definition: sv_clanarena.qc:4
#define M_ARGV(x, type)
Definition: events.qh:17
entity CA_SpectateNext(entity player, entity start)
Returns next available player to spectate if g_ca_spectate_enemies == 0.
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [21/26]

MUTATOR_HOOKFUNCTION ( ca  ,
SpectatePrev   
)

Definition at line 451 of file sv_clanarena.qc.

References autocvar_g_ca_spectate_enemies, DIFF_TEAM, entity(), Entity_GetTeam(), INGAME, M_ARGV, MUT_SPECPREV_CONTINUE, MUT_SPECPREV_FOUND, MUT_SPECPREV_RETURN, and Team_GetNumberOfAlivePlayers().

452 {
453  entity client = M_ARGV(0, entity);
454  entity targ = M_ARGV(1, entity);
455  entity first = M_ARGV(2, entity);
456 
457  if (!autocvar_g_ca_spectate_enemies && INGAME(client)
459  {
460  do { targ = targ.chain; }
461  while(targ && DIFF_TEAM(targ, client));
462 
463  if (!targ)
464  {
465  for (targ = first; targ && DIFF_TEAM(targ, client); targ = targ.chain);
466 
467  if (targ == client.enemy)
468  return MUT_SPECPREV_RETURN;
469  }
470  }
471  else
472  return MUT_SPECPREV_CONTINUE;
473 
474  M_ARGV(1, entity) = targ;
475 
476  return MUT_SPECPREV_FOUND;
477 }
#define INGAME(it)
Definition: sv_rules.qh:20
entity() spawn
int Team_GetNumberOfAlivePlayers(entity team_ent)
Returns the number of alive players in a team.
Definition: teamplay.qc:85
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition: teamplay.qc:181
bool autocvar_g_ca_spectate_enemies
Definition: sv_clanarena.qc:4
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [22/26]

MUTATOR_HOOKFUNCTION ( ca  ,
Bot_FixCount  ,
CBC_ORDER_EXCLUSIVE   
)

Definition at line 479 of file sv_clanarena.qc.

References FOREACH_CLIENT, INGAME_JOINED, IS_PLAYER, IS_REAL_CLIENT, and M_ARGV.

480 {
482  if (IS_PLAYER(it) || INGAME_JOINED(it))
483  ++M_ARGV(0, int);
484  ++M_ARGV(1, int);
485  });
486  return true;
487 }
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define M_ARGV(x, type)
Definition: events.qh:17
#define INGAME_JOINED(it)
Definition: sv_rules.qh:21
#define IS_PLAYER(v)
Definition: utils.qh:9

◆ MUTATOR_HOOKFUNCTION() [23/26]

MUTATOR_HOOKFUNCTION ( ca  ,
ClientCommand_Spectate   
)

Definition at line 489 of file sv_clanarena.qc.

References autocvar_sv_spectate, entity(), INGAME, IS_OBSERVER, IS_SPEC, M_ARGV, MUT_SPECCMD_CONTINUE, and MUT_SPECCMD_FORCE.

490 {
491  entity player = M_ARGV(0, entity);
492 
493  if (INGAME(player))
494  {
495  // they're going to spec, we can do other checks
496  if (autocvar_sv_spectate && (IS_SPEC(player) || IS_OBSERVER(player)))
497  Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_LEAVE);
498  return MUT_SPECCMD_FORCE;
499  }
500 
501  return MUT_SPECCMD_CONTINUE;
502 }
#define INGAME(it)
Definition: sv_rules.qh:20
entity() spawn
#define IS_OBSERVER(v)
Definition: utils.qh:11
#define IS_SPEC(v)
Definition: utils.qh:10
int autocvar_sv_spectate
Definition: client.qh:54
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [24/26]

MUTATOR_HOOKFUNCTION ( ca  ,
HideTeamNagger   
)

Definition at line 504 of file sv_clanarena.qc.

505 {
506  return true; // doesn't work well with the whole spectator as player thing
507 }

◆ MUTATOR_HOOKFUNCTION() [25/26]

MUTATOR_HOOKFUNCTION ( ca  ,
SetWeaponArena   
)

Definition at line 509 of file sv_clanarena.qc.

References autocvar_g_ca_weaponarena, and M_ARGV.

510 {
511  if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
512  M_ARGV(0, string) = autocvar_g_ca_weaponarena;
513 }
#define M_ARGV(x, type)
Definition: events.qh:17
string autocvar_g_ca_weaponarena
Definition: sv_clanarena.qh:15

◆ MUTATOR_HOOKFUNCTION() [26/26]

MUTATOR_HOOKFUNCTION ( ca  ,
SV_ParseServerCommand   
)

Definition at line 515 of file sv_clanarena.qc.

References allowed_to_spawn, cmd_name, M_ARGV, and shuffleteams_on_reset_map.

516 {
517  string cmd_name = M_ARGV(0, string);
518  if (cmd_name == "shuffleteams")
520  return false;
521 }
bool allowed_to_spawn
Definition: sv_clanarena.qh:19
#define M_ARGV(x, type)
Definition: events.qh:17
bool shuffleteams_on_reset_map
Definition: sv_cmd.qh:7

◆ nades_Clear()

void nades_Clear ( entity  player)

Referenced by CA_CheckWinner(), and CA_count_alive_players().

+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_g_ca_damage2score

float autocvar_g_ca_damage2score = 100

Definition at line 3 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_spectate_enemies

bool autocvar_g_ca_spectate_enemies

Definition at line 4 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_ammo_cells

float autocvar_g_ca_start_ammo_cells = 180

Definition at line 11 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_ammo_fuel

float autocvar_g_ca_start_ammo_fuel = 0

Definition at line 13 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_ammo_nails

float autocvar_g_ca_start_ammo_nails = 320

Definition at line 9 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_ammo_plasma

float autocvar_g_ca_start_ammo_plasma = 180

Definition at line 12 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_ammo_rockets

float autocvar_g_ca_start_ammo_rockets = 160

Definition at line 10 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_ammo_shells

float autocvar_g_ca_start_ammo_shells = 60

Definition at line 8 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_armor

float autocvar_g_ca_start_armor = 200

Definition at line 7 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_health

float autocvar_g_ca_start_health = 200

Definition at line 6 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ ca_damage_counter

float ca_damage_counter

Definition at line 15 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().