Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_clanarena.qc File Reference
#include "sv_clanarena.qh"
Include dependency graph for sv_clanarena.qc:
This graph shows which files directly or indirectly include this file:

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)
int CA_PreventStalemate ()
void CA_RoundStart ()
entity CA_SpectateNext (entity player, entity start)
 Returns next available player to spectate if g_ca_spectate_enemies == 0.
 MUTATOR_HOOKFUNCTION (ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 MUTATOR_HOOKFUNCTION (ca, CalculateRespawnTime)
 MUTATOR_HOOKFUNCTION (ca, ClientCommand_Spectate)
 MUTATOR_HOOKFUNCTION (ca, ClientDisconnect)
 MUTATOR_HOOKFUNCTION (ca, Damage_Calculate)
 MUTATOR_HOOKFUNCTION (ca, FilterItem)
 MUTATOR_HOOKFUNCTION (ca, ForbidSpawn)
 MUTATOR_HOOKFUNCTION (ca, ForbidThrowCurrentWeapon)
 MUTATOR_HOOKFUNCTION (ca, GiveFragsForKill, CBC_ORDER_FIRST)
 MUTATOR_HOOKFUNCTION (ca, MakePlayerObserver)
 MUTATOR_HOOKFUNCTION (ca, MatchEnd_BeforeScores)
 MUTATOR_HOOKFUNCTION (ca, PlayerDamage_SplitHealthArmor)
 MUTATOR_HOOKFUNCTION (ca, PlayerDies)
 MUTATOR_HOOKFUNCTION (ca, PlayerRegen)
 MUTATOR_HOOKFUNCTION (ca, PlayerSpawn)
 MUTATOR_HOOKFUNCTION (ca, PutClientInServer)
 MUTATOR_HOOKFUNCTION (ca, reset_map_global)
 MUTATOR_HOOKFUNCTION (ca, reset_map_players)
 MUTATOR_HOOKFUNCTION (ca, Scores_CountFragsRemaining)
 MUTATOR_HOOKFUNCTION (ca, SetStartItems)
 MUTATOR_HOOKFUNCTION (ca, SetWeaponArena)
 MUTATOR_HOOKFUNCTION (ca, SpectateNext)
 MUTATOR_HOOKFUNCTION (ca, SpectatePrev)
 MUTATOR_HOOKFUNCTION (ca, SpectateSet)
 MUTATOR_HOOKFUNCTION (ca, SV_ParseServerCommand)
 MUTATOR_HOOKFUNCTION (ca, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)

Variables

float autocvar_g_ca_damage2score = 100
int autocvar_g_ca_prevent_stalemate
float autocvar_g_ca_round_enddelay
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_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 float2int_decimal_fld
int prev_team

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

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

void CA_count_alive_players ( )

Definition at line 17 of file sv_clanarena.qc.

18{
19 total_players = 0;
20 for (int i = 1; i <= NUM_TEAMS; ++i)
21 {
23 }
25 {
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 {
42 });
43}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IS_DEAD(s)
Definition player.qh:245
#define STAT(...)
Definition stats.qh:82
entity Entity_GetTeam(entity this)
Returns the team entity of the given entity.
Definition teamplay.qc:186
bool Entity_HasValidTeam(entity this)
Returns whether the given entity belongs to a valid team.
Definition teamplay.qc:176
void Team_SetNumberOfAlivePlayers(entity team_ent, int number)
Sets the number of alive players in a team.
Definition teamplay.qc:90
#define IS_REAL_CLIENT(v)
Definition utils.qh:17

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

Referenced by CA_CheckTeams(), and CA_CheckWinner().

◆ 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}
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_LastPlayerForTeam()

entity ca_LastPlayerForTeam ( entity this)

Definition at line 351 of file sv_clanarena.qc.

352{
353 entity last_pl = NULL;
354 FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
355 if (!IS_DEAD(it) && SAME_TEAM(this, it))
356 {
357 if (!last_pl)
358 last_pl = it;
359 else
360 return NULL;
361 }
362 });
363 return last_pl;
364}
#define SAME_TEAM(a, b)
Definition teams.qh:241

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

Referenced by ca_LastPlayerForTeam_Notify().

◆ ca_LastPlayerForTeam_Notify()

void ca_LastPlayerForTeam_Notify ( entity this)

Definition at line 366 of file sv_clanarena.qc.

367{
369 {
370 entity pl = ca_LastPlayerForTeam(this);
371 if (pl)
372 Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
373 }
374}
bool warmup_stage
Definition main.qh:120
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
entity ca_LastPlayerForTeam(entity this)

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

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

◆ CA_PreventStalemate()

int CA_PreventStalemate ( )

Definition at line 45 of file sv_clanarena.qc.

46{
47 //bprint("PreventStalemate running\n");
48
49 // g_ca_prevent_stalemate:
50 // Run survivor count check with 1 aka bit 0b0001
51 // Run total health check with 2 aka bit 0b0010
52 // With a value like 3 which has both bits both are ran
53
54 bool prevent_stalemate_by_survivors = (autocvar_g_ca_prevent_stalemate & BIT(0));
55 bool prevent_stalemate_by_health = (autocvar_g_ca_prevent_stalemate & BIT(1));
56
57 // Check which team has more alive players
58 if (prevent_stalemate_by_survivors)
59 {
60 int winnerTeam = 0;
61 int secondTeam = 0;
62
63 for(int i = 1; i <= AVAILABLE_TEAMS; ++i)
64 {
66 {
67 secondTeam = winnerTeam;
68 winnerTeam = Team_IndexToTeam(i);
69 }
70 else
71 {
73 secondTeam = Team_IndexToTeam(i);
74 }
75 }
76
78 {
79 bprint(sprintf("Stalemate broken by alive players. Best team: %s%s (%d)^7 - Trailing team: %s%s (%d)\n",
80 Team_ColorCode(winnerTeam), Team_ColorName(winnerTeam), Team_GetNumberOfAlivePlayers(Team_GetTeam(winnerTeam)),
81 Team_ColorCode(secondTeam), Team_ColorName(secondTeam), Team_GetNumberOfAlivePlayers(Team_GetTeam(secondTeam))));
82 return winnerTeam;
83 }
84 }
85
86 // Check which team has more health
87 if (prevent_stalemate_by_health)
88 {
89 int winnerTeam = 0;
90 int secondTeam = 0;
91 int winnerTeamHealth = 0;
92 int secondTeamHealth = 0;
93 int teamIndex, teamHealth;
94
95 for(int i = 1; i <= AVAILABLE_TEAMS; ++i)
96 {
97 teamIndex = i;
98 teamHealth = 0;
99
100 // Add up health for the players in this team
101 FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it) && it.team == Team_IndexToTeam(teamIndex),
102 {
103 if (IS_DEAD(it))
104 continue;
105 teamHealth += floor(GetResource(it, RES_HEALTH)) + floor(GetResource(it, RES_ARMOR));
106 });
107
108 // Round the resulting team health just in case
109 teamHealth = rint(teamHealth);
110
111 // Set the winner teams
112 if(!winnerTeam || teamHealth > winnerTeamHealth)
113 {
114 secondTeam = winnerTeam;
115 secondTeamHealth = winnerTeamHealth;
116 winnerTeam = Team_IndexToTeam(i);
117 winnerTeamHealth = teamHealth;
118 }
119 else
120 {
121 if(!secondTeam || teamHealth > secondTeamHealth)
122 {
123 secondTeam = Team_IndexToTeam(i);
124 secondTeamHealth = teamHealth;
125 }
126 }
127 }
128
129 if(winnerTeamHealth != secondTeamHealth)
130 {
131 bprint(sprintf("Stalemate broken by team health. Best team: %s%s (%d)^7 - Trailing team: %s%s (%d)\n",
132 Team_ColorCode(winnerTeam), Team_ColorName(winnerTeam), winnerTeamHealth,
133 Team_ColorCode(secondTeam), Team_ColorName(secondTeam), secondTeamHealth));
134 return winnerTeam;
135 }
136 }
137
138 return -2; // Equality. Can't avoid the stalemate.
139}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
RES_ARMOR
Definition ent_cs.qc:130
void bprint(string text,...)
float rint(float f)
float floor(float f)
#define AVAILABLE_TEAMS
entity Team_GetTeam(int team_num)
Returns the global team entity that corresponds to the given TEAM_NUM value.
Definition teamplay.qc:66
string Team_ColorName(int teamid)
Definition teams.qh:89
int Team_IndexToTeam(int index)
Converts team index into team value.
Definition teams.qh:169
string Team_ColorCode(int teamid)
Definition teams.qh:63

References autocvar_g_ca_prevent_stalemate, AVAILABLE_TEAMS, BIT, bprint(), Entity_HasValidTeam(), floor(), FOREACH_CLIENT, GetResource(), IS_DEAD, IS_PLAYER, RES_ARMOR, rint(), Team_ColorCode(), Team_ColorName(), Team_GetNumberOfAlivePlayers(), Team_GetTeam(), Team_GetTeamFromIndex(), and Team_IndexToTeam().

Referenced by CA_CheckWinner().

◆ 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

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

Referenced by REGISTER_MUTATOR().

◆ CA_SpectateNext()

entity CA_SpectateNext ( entity player,
entity start )

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

Definition at line 253 of file sv_clanarena.qc.

254{
255 if (SAME_TEAM(start, player)) return start;
256 // continue from current player
257 for (entity e = start; (e = find(e, classname, STR_PLAYER)); )
258 {
259 if (SAME_TEAM(player, e)) return e;
260 }
261 // restart from the beginning
262 for (entity e = NULL; (e = find(e, classname, STR_PLAYER)); )
263 {
264 if (SAME_TEAM(player, e)) return e;
265 }
266 return start;
267}
string classname
entity find(entity start,.string field, string match)
const string STR_PLAYER
Definition utils.qh:5

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

Referenced by MUTATOR_HOOKFUNCTION().

◆ MUTATOR_HOOKFUNCTION() [1/26]

MUTATOR_HOOKFUNCTION ( ca ,
Bot_FixCount ,
CBC_ORDER_EXCLUSIVE  )

Definition at line 608 of file sv_clanarena.qc.

609{
611 if (IS_PLAYER(it) || INGAME_JOINED(it))
612 ++M_ARGV(0, int);
613 ++M_ARGV(1, int);
614 });
615 return true;
616}
#define M_ARGV(x, type)
Definition events.qh:17

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

◆ MUTATOR_HOOKFUNCTION() [2/26]

MUTATOR_HOOKFUNCTION ( ca ,
CalculateRespawnTime  )

Definition at line 539 of file sv_clanarena.qc.

540{
541 // no respawn calculations needed, player is forced to spectate anyway
542 return true;
543}

◆ MUTATOR_HOOKFUNCTION() [3/26]

MUTATOR_HOOKFUNCTION ( ca ,
ClientCommand_Spectate  )

Definition at line 618 of file sv_clanarena.qc.

619{
620 entity player = M_ARGV(0, entity);
621
622 if (INGAME(player))
623 {
624 // they're going to spec, we can do other checks
625 if (autocvar_sv_spectate && (IS_SPEC(player) || IS_OBSERVER(player)))
626 Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_LEAVE);
627 return MUT_SPECCMD_FORCE;
628 }
629
631}
bool autocvar_sv_spectate
Definition client.qh:57
@ MUT_SPECCMD_FORCE
Definition events.qh:1006
@ MUT_SPECCMD_CONTINUE
Definition events.qh:1004
#define INGAME(it)
Definition sv_rules.qh:24
#define IS_OBSERVER(v)
Definition utils.qh:11
#define IS_SPEC(v)
Definition utils.qh:10

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

◆ MUTATOR_HOOKFUNCTION() [4/26]

MUTATOR_HOOKFUNCTION ( ca ,
ClientDisconnect  )

Definition at line 394 of file sv_clanarena.qc.

395{
396 entity player = M_ARGV(0, entity);
397
398 if (IS_PLAYER(player) && !IS_DEAD(player))
400 return true;
401}
void ca_LastPlayerForTeam_Notify(entity this)

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

◆ MUTATOR_HOOKFUNCTION() [5/26]

MUTATOR_HOOKFUNCTION ( ca ,
Damage_Calculate  )

Definition at line 456 of file sv_clanarena.qc.

457{
458 entity frag_attacker = M_ARGV(1, entity);
460 float frag_deathtype = M_ARGV(3, float);
461 float frag_damage = M_ARGV(4, float);
462 float frag_mirrordamage = M_ARGV(5, float);
463
465 if (!IS_DEAD(frag_target))
466 if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
467 frag_damage = 0;
468
469 frag_mirrordamage = 0;
470
471 M_ARGV(4, float) = frag_damage;
472 M_ARGV(5, float) = frag_mirrordamage;
473}
float frag_damage
Definition sv_ctf.qc:2322
entity frag_target
Definition sv_ctf.qc:2321

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

◆ MUTATOR_HOOKFUNCTION() [6/26]

MUTATOR_HOOKFUNCTION ( ca ,
FilterItem  )

Definition at line 475 of file sv_clanarena.qc.

476{
477 entity item = M_ARGV(0, entity);
478
479 if (autocvar_g_powerups <= 0)
480 if (item.itemdef.instanceOfPowerup)
481 return true;
482
484 return true;
485}
int autocvar_g_pickup_items
Definition items.qh:10
int autocvar_g_powerups
Definition sv_powerups.qh:7

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

◆ MUTATOR_HOOKFUNCTION() [7/26]

MUTATOR_HOOKFUNCTION ( ca ,
ForbidSpawn  )

Definition at line 283 of file sv_clanarena.qc.

284{
285 entity player = M_ARGV(0, entity);
286
287 // spectators / observers that weren't playing can join; they are
288 // immediately forced to observe in the PutClientInServer hook
289 // this way they are put in a team and can play in the next round
290 if (!allowed_to_spawn && INGAME(player))
291 return true;
292 return false;
293}

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

◆ MUTATOR_HOOKFUNCTION() [8/26]

MUTATOR_HOOKFUNCTION ( ca ,
ForbidThrowCurrentWeapon  )

Definition at line 430 of file sv_clanarena.qc.

431{
432 return true;
433}

◆ MUTATOR_HOOKFUNCTION() [9/26]

MUTATOR_HOOKFUNCTION ( ca ,
GiveFragsForKill ,
CBC_ORDER_FIRST  )

Definition at line 435 of file sv_clanarena.qc.

436{
437 M_ARGV(2, float) = 0; // score will be given to the winner team when the round ends
438 return true;
439}

References CBC_ORDER_FIRST, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [10/26]

MUTATOR_HOOKFUNCTION ( ca ,
MakePlayerObserver  )

Definition at line 403 of file sv_clanarena.qc.

404{
405 entity player = M_ARGV(0, entity);
406
407 bool is_forced = M_ARGV(1, bool);
408 if (is_forced && INGAME(player))
409 INGAME_STATUS_CLEAR(player);
410
411 if (IS_PLAYER(player) && !IS_DEAD(player))
413 if (player.killindicator_teamchange == -2) // player wants to spectate
414 {
415 entcs_update_players(player);
416 INGAME_STATUS_CLEAR(player);
417 }
418 if (INGAME(player))
419 {
420 player.frags = FRAGS_PLAYER_OUT_OF_GAME;
421 player.would_spectate = observe_blocked_if_eliminated; // if blocked from observing force to spectate now
422 }
423 if (!warmup_stage)
424 eliminatedPlayers.SendFlags |= 1;
425 if (!INGAME(player))
426 return false; // allow team reset
427 return true; // prevent team reset
428}
entity eliminatedPlayers
Definition elimination.qh:3
void entcs_update_players(entity player)
Definition ent_cs.qc:183
#define INGAME_STATUS_CLEAR(it)
Definition sv_rules.qh:22
bool observe_blocked_if_eliminated
Definition world.qh:160

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

◆ MUTATOR_HOOKFUNCTION() [11/26]

MUTATOR_HOOKFUNCTION ( ca ,
MatchEnd_BeforeScores  )

Definition at line 339 of file sv_clanarena.qc.

340{
342 return true;
343}
int prev_team
void MatchEnd_RestoreSpectatorAndTeamStatus(.int prev_team_field)
Definition world.qc:1350

References MatchEnd_RestoreSpectatorAndTeamStatus(), and prev_team.

◆ MUTATOR_HOOKFUNCTION() [12/26]

MUTATOR_HOOKFUNCTION ( ca ,
PlayerDamage_SplitHealthArmor  )

Definition at line 487 of file sv_clanarena.qc.

488{
490 return;
491
492 entity frag_attacker = M_ARGV(1, entity);
494 float frag_deathtype = M_ARGV(6, float);
495 float frag_damage = M_ARGV(7, float);
496 float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
497 float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
498
499 float excess = max(0, frag_damage - damage_take - damage_save);
500
501 if (autocvar_g_ca_damage2score <= 0 || frag_damage - excess == 0) return;
502
503 entity scorer = NULL;
504 float scorer_damage = 0;
505
506 if (IS_PLAYER(frag_attacker))
507 {
508 if (DIFF_TEAM(frag_target, frag_attacker))
509 scorer_damage = frag_damage - excess;
510 else // friendly fire
511 scorer_damage = -(frag_damage - excess);
512
513 scorer = frag_attacker;
514 }
515 else
516 {
517 //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
518 //deathtypes:
519 //kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks
520 //camp = campcheck, lava = lava, slime = slime
521 //team change / rebalance suicides are currently not included
522 if (frag_deathtype == DEATH_KILL.m_id ||
523 frag_deathtype == DEATH_DROWN.m_id ||
524 frag_deathtype == DEATH_HURTTRIGGER.m_id ||
525 frag_deathtype == DEATH_CAMP.m_id ||
526 frag_deathtype == DEATH_LAVA.m_id ||
527 frag_deathtype == DEATH_SLIME.m_id ||
528 frag_deathtype == DEATH_SWAMP.m_id)
529 {
530 scorer_damage = -(frag_damage - excess);
531 scorer = frag_target;
532 }
533 }
534
535 if (scorer)
537}
float game_starttime
Definition stats.qh:82
float bound(float min, float value, float max)
float max(float f,...)
float autocvar_g_ca_damage2score
float float2int_decimal_fld
#define GameRules_scoring_add_float2int(client, fld, value, float_field, score_factor)
Definition sv_rules.qh:83
#define DIFF_TEAM(a, b)
Definition teams.qh:242

References autocvar_g_ca_damage2score, bound(), DIFF_TEAM, entity(), float2int_decimal_fld, frag_damage, frag_target, game_starttime, GameRules_scoring_add_float2int, GetResource(), IS_PLAYER, M_ARGV, max(), NULL, RES_ARMOR, round_handler_IsActive, round_handler_IsRoundStarted, and time.

◆ MUTATOR_HOOKFUNCTION() [13/26]

MUTATOR_HOOKFUNCTION ( ca ,
PlayerDies  )

Definition at line 376 of file sv_clanarena.qc.

377{
379
381 if (!allowed_to_spawn)
382 {
383 frag_target.respawn_flags = RESPAWN_SILENT;
384 // prevent unwanted sudden rejoin as spectator and movement of spectator camera
385 frag_target.respawn_time = time + 2;
386 }
387 frag_target.respawn_flags |= RESPAWN_FORCE;
388 if (!warmup_stage)
389 eliminatedPlayers.SendFlags |= 1;
390 return true;
391}
const int RESPAWN_SILENT
Definition client.qh:327
const int RESPAWN_FORCE
Definition client.qh:326

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

◆ MUTATOR_HOOKFUNCTION() [14/26]

MUTATOR_HOOKFUNCTION ( ca ,
PlayerRegen  )

Definition at line 545 of file sv_clanarena.qc.

546{
547 // no regeneration in CA
548 return true;
549}

◆ MUTATOR_HOOKFUNCTION() [15/26]

MUTATOR_HOOKFUNCTION ( ca ,
PlayerSpawn  )

Definition at line 272 of file sv_clanarena.qc.

273{
274 entity player = M_ARGV(0, entity);
275
277 if (time <= game_starttime) // reset on game restart, not on round start
278 player.float2int_decimal_fld = 0;
279 if (!warmup_stage)
280 eliminatedPlayers.SendFlags |= 1;
281}
#define INGAME_STATUS_JOINED
Definition sv_rules.qh:17
#define INGAME_STATUS_SET(it, s)
Definition sv_rules.qh:21

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

◆ MUTATOR_HOOKFUNCTION() [16/26]

MUTATOR_HOOKFUNCTION ( ca ,
PutClientInServer  )

Definition at line 295 of file sv_clanarena.qc.

296{
297 entity player = M_ARGV(0, entity);
298
299 if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join
300 {
301 TRANSMUTE(Observer, player);
302 if (CS(player).jointime != time && !INGAME(player)) // not when connecting
303 {
305 Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
306 }
307 }
308
309 if (!warmup_stage)
310 eliminatedPlayers.SendFlags |= 1;
311}
#define TRANSMUTE(cname, this,...)
Definition oo.qh:136
float jointime
Definition client.qh:66
ClientState CS(Client this)
Definition state.qh:47
#define INGAME_STATUS_JOINING
Definition sv_rules.qh:16

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

◆ MUTATOR_HOOKFUNCTION() [17/26]

MUTATOR_HOOKFUNCTION ( ca ,
reset_map_global  )

Definition at line 333 of file sv_clanarena.qc.

334{
335 allowed_to_spawn = true;
336 return true;
337}

References allowed_to_spawn.

◆ MUTATOR_HOOKFUNCTION() [18/26]

MUTATOR_HOOKFUNCTION ( ca ,
reset_map_players  )

Definition at line 313 of file sv_clanarena.qc.

314{
317 // we can avoid sending observe_blocked_if_eliminated to all clients here (with ClientData_Touch)
318 // since it will get sent whenever the client spectates someone anyway
319
320 FOREACH_CLIENT(true, {
321 CS(it).killcount = 0;
322 if (INGAME(it) || IS_BOT_CLIENT(it))
323 {
324 TRANSMUTE(Player, it);
327 }
328 it.prev_team = 0;
329 });
330 return true;
331}
#define PutClientInServer
Definition _all.inc:246
bool g_ca_spectate_enemies
int autocvar_g_ca_spectate_enemies
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15

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

◆ MUTATOR_HOOKFUNCTION() [19/26]

MUTATOR_HOOKFUNCTION ( ca ,
Scores_CountFragsRemaining  )

Definition at line 551 of file sv_clanarena.qc.

552{
553 // announce remaining frags
554 return true;
555}

◆ MUTATOR_HOOKFUNCTION() [20/26]

MUTATOR_HOOKFUNCTION ( ca ,
SetStartItems  )

Definition at line 441 of file sv_clanarena.qc.

442{
444 if(!cvar("g_use_ammunition"))
446
454}
const int IT_UNLIMITED_AMMO
Definition item.qh:23
const int IT_UNLIMITED_SUPERWEAPONS
Definition item.qh:24
float cvar(string name)
float autocvar_g_ca_start_ammo_rockets
float autocvar_g_ca_start_ammo_cells
float autocvar_g_ca_start_armor
float autocvar_g_ca_start_ammo_nails
float autocvar_g_ca_start_health
float autocvar_g_ca_start_ammo_fuel
float autocvar_g_ca_start_ammo_shells
float warmup_start_ammo_cells
Definition world.qh:105
float start_ammo_shells
Definition world.qh:84
float warmup_start_ammo_rockets
Definition world.qh:104
float warmup_start_ammo_shells
Definition world.qh:102
float start_ammo_fuel
Definition world.qh:88
int start_items
Definition world.qh:83
float warmup_start_ammo_nails
Definition world.qh:103
float start_ammo_cells
Definition world.qh:87
float warmup_start_health
Definition world.qh:107
float start_ammo_rockets
Definition world.qh:86
float start_armorvalue
Definition world.qh:97
float warmup_start_ammo_fuel
Definition world.qh:106
float start_health
Definition world.qh:96
float warmup_start_armorvalue
Definition world.qh:108
float start_ammo_nails
Definition world.qh:85

References autocvar_g_ca_start_ammo_cells, autocvar_g_ca_start_ammo_fuel, autocvar_g_ca_start_ammo_nails, autocvar_g_ca_start_ammo_rockets, autocvar_g_ca_start_ammo_shells, autocvar_g_ca_start_armor, autocvar_g_ca_start_health, cvar(), IT_UNLIMITED_AMMO, IT_UNLIMITED_SUPERWEAPONS, start_ammo_cells, start_ammo_fuel, start_ammo_nails, 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_rockets, warmup_start_ammo_shells, warmup_start_armorvalue, and warmup_start_health.

◆ MUTATOR_HOOKFUNCTION() [21/26]

MUTATOR_HOOKFUNCTION ( ca ,
SetWeaponArena  )

Definition at line 633 of file sv_clanarena.qc.

634{
635 if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
637}
string autocvar_g_ca_weaponarena

References autocvar_g_ca_weaponarena, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [22/26]

MUTATOR_HOOKFUNCTION ( ca ,
SpectateNext  )

Definition at line 567 of file sv_clanarena.qc.

568{
569 entity client = M_ARGV(0, entity);
570
571 if (g_ca_spectate_enemies != 1 && INGAME(client)
573 {
574 entity targ = M_ARGV(1, entity);
575 M_ARGV(1, entity) = CA_SpectateNext(client, targ);
576 return true;
577 }
578}
entity CA_SpectateNext(entity player, entity start)
Returns next available player to spectate if g_ca_spectate_enemies == 0.

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

◆ MUTATOR_HOOKFUNCTION() [23/26]

MUTATOR_HOOKFUNCTION ( ca ,
SpectatePrev  )

Definition at line 580 of file sv_clanarena.qc.

581{
582 entity client = M_ARGV(0, entity);
583 entity targ = M_ARGV(1, entity);
584 entity first = M_ARGV(2, entity);
585
586 if (g_ca_spectate_enemies != 1 && INGAME(client)
588 {
589 do { targ = targ.chain; }
590 while(targ && DIFF_TEAM(targ, client));
591
592 if (!targ)
593 {
594 for (targ = first; targ && DIFF_TEAM(targ, client); targ = targ.chain);
595
596 if (targ == client.enemy)
597 return MUT_SPECPREV_RETURN;
598 }
599 }
600 else
602
603 M_ARGV(1, entity) = targ;
604
605 return MUT_SPECPREV_FOUND;
606}
@ MUT_SPECPREV_RETURN
Definition events.qh:985
@ MUT_SPECPREV_CONTINUE
Definition events.qh:984
@ MUT_SPECPREV_FOUND
Definition events.qh:986

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

◆ MUTATOR_HOOKFUNCTION() [24/26]

MUTATOR_HOOKFUNCTION ( ca ,
SpectateSet  )

Definition at line 557 of file sv_clanarena.qc.

558{
559 entity client = M_ARGV(0, entity);
560 entity targ = M_ARGV(1, entity);
561
562 if (g_ca_spectate_enemies != 1 && INGAME(client))
563 if (DIFF_TEAM(targ, client))
564 return true;
565}

References DIFF_TEAM, entity(), g_ca_spectate_enemies, INGAME, M_ARGV, and SpectateSet().

◆ MUTATOR_HOOKFUNCTION() [25/26]

MUTATOR_HOOKFUNCTION ( ca ,
SV_ParseServerCommand  )

Definition at line 639 of file sv_clanarena.qc.

640{
641 string cmd_name = M_ARGV(0, string);
642 if (cmd_name == "shuffleteams")
644 return false;
645}
string cmd_name
Definition events.qh:12
bool shuffleteams_on_reset_map
Definition sv_cmd.qh:7

References allowed_to_spawn, cmd_name, M_ARGV, and shuffleteams_on_reset_map.

◆ MUTATOR_HOOKFUNCTION() [26/26]

MUTATOR_HOOKFUNCTION ( ca ,
TeamBalance_CheckAllowedTeams ,
CBC_ORDER_EXCLUSIVE  )

Definition at line 345 of file sv_clanarena.qc.

346{
347 M_ARGV(0, float) = ca_teams;
348 return true;
349}

References ca_teams, CBC_ORDER_EXCLUSIVE, M_ARGV, and TeamBalance_CheckAllowedTeams().

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_prevent_stalemate

int autocvar_g_ca_prevent_stalemate

Definition at line 4 of file sv_clanarena.qc.

Referenced by CA_CheckWinner(), and CA_PreventStalemate().

◆ autocvar_g_ca_round_enddelay

float autocvar_g_ca_round_enddelay

Definition at line 5 of file sv_clanarena.qc.

Referenced by CA_CheckWinner().

◆ autocvar_g_ca_start_ammo_cells

float autocvar_g_ca_start_ammo_cells = 180

Definition at line 12 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 10 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 11 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 9 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_armor

float autocvar_g_ca_start_armor = 200

Definition at line 8 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_ca_start_health

float autocvar_g_ca_start_health = 200

Definition at line 7 of file sv_clanarena.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ float2int_decimal_fld

float float2int_decimal_fld

◆ prev_team

int prev_team

Definition at line 15 of file sv_clanarena.qc.

Referenced by HUD_Scoreboard_InputEvent(), and MUTATOR_HOOKFUNCTION().