]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
Separated `g_ca_prevent_stalemate`'s survivor count and health checking.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / clanarena / sv_clanarena.qc
1 #include "sv_clanarena.qh"
2
3 float autocvar_g_ca_damage2score = 100;
4 int autocvar_g_ca_prevent_stalemate;
5
6 float autocvar_g_ca_start_health = 200;
7 float autocvar_g_ca_start_armor = 200;
8 float autocvar_g_ca_start_ammo_shells = 60;
9 float autocvar_g_ca_start_ammo_nails = 320;
10 float autocvar_g_ca_start_ammo_rockets = 160;
11 float autocvar_g_ca_start_ammo_cells = 180;
12 float autocvar_g_ca_start_ammo_plasma = 180;
13 float autocvar_g_ca_start_ammo_fuel = 0;
14
15 .float ca_damage_counter;
16
17 void CA_count_alive_players()
18 {
19         total_players = 0;
20         for (int i = 1; i <= NUM_TEAMS; ++i)
21         {
22                 Team_SetNumberOfAlivePlayers(Team_GetTeamFromIndex(i), 0);
23         }
24         FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it),
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         });
36         FOREACH_CLIENT(IS_REAL_CLIENT(it),
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 }
44
45 void nades_Clear(entity player);
46
47 int CA_PreventStalemate()
48 {
49         //bprint("PreventStalemate running\n");
50
51         // g_ca_prevent_stalemate:
52         // Run survivor count check with 1 aka bit 0b0001
53         // Run total health check with 2 aka bit 0b0010
54         // With a value like 3 which has both bits both are ran
55
56         bool prevent_stalemate_by_survivors = (autocvar_g_ca_prevent_stalemate & BIT(0));
57         bool prevent_stalemate_by_health    = (autocvar_g_ca_prevent_stalemate & BIT(1));
58
59         // Check which team has more alive players
60         if (prevent_stalemate_by_survivors)
61         {
62                 int winnerTeam = 0;
63                 int secondTeam = 0;
64
65                 for(int i = 1; i <= AVAILABLE_TEAMS; ++i)
66                 {
67                         if(!winnerTeam || Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) > Team_GetNumberOfAlivePlayers(Team_GetTeam(winnerTeam)))
68                         {
69                                 secondTeam = winnerTeam;
70                                 winnerTeam = Team_IndexToTeam(i);
71                         }
72                         else
73                         {
74                                 if(!secondTeam || Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) > Team_GetNumberOfAlivePlayers(Team_GetTeam(secondTeam)))
75                                         secondTeam = Team_IndexToTeam(i);
76                         }
77                 }
78
79                 if(Team_GetNumberOfAlivePlayers(Team_GetTeam(winnerTeam)) != Team_GetNumberOfAlivePlayers(Team_GetTeam(secondTeam)))
80                 {
81                         bprint(sprintf("Stalemate broken by alive players. Best team: %s%s (%d)^7 - Trailing team: %s%s (%d)\n",
82                                 Team_ColorCode(winnerTeam), Team_ColorName(winnerTeam), Team_GetNumberOfAlivePlayers(Team_GetTeam(winnerTeam)),
83                                 Team_ColorCode(secondTeam), Team_ColorName(secondTeam), Team_GetNumberOfAlivePlayers(Team_GetTeam(secondTeam))));
84                         return winnerTeam;
85                 }
86         }
87
88         // Check which team has more health
89         if (prevent_stalemate_by_health)
90         {
91                 int winnerTeam = 0;
92                 int secondTeam = 0;
93                 int winnerTeamHealth = 0;
94                 int secondTeamHealth = 0;
95                 int teamIndex, teamHealth;
96
97                 for(int i = 1; i <= AVAILABLE_TEAMS; ++i)
98                 {
99                         teamIndex = i;
100                         teamHealth = 0;
101
102                         // Add up health for the players in this team
103                         FOREACH_CLIENT(IS_PLAYER(it) && Entity_HasValidTeam(it) && it.team == Team_IndexToTeam(teamIndex),
104                         {
105                                 if (IS_DEAD(it))
106                                         continue;
107                                 teamHealth += GetResource(it, RES_HEALTH) + GetResource(it, RES_ARMOR);
108                         });
109
110                         // Set the winner teams
111                         if(!winnerTeam || teamHealth > winnerTeamHealth)
112                         {
113                                 secondTeam = winnerTeam;
114                                 secondTeamHealth = winnerTeamHealth;
115                                 winnerTeam = Team_IndexToTeam(i);
116                                 winnerTeamHealth = teamHealth;
117                         }
118                         else
119                         {
120                                 if(!secondTeam || teamHealth > secondTeamHealth)
121                                 {
122                                         secondTeam = Team_IndexToTeam(i);
123                                         secondTeamHealth = teamHealth;
124                                 }
125                         }
126                 }
127
128                 if(winnerTeamHealth != secondTeamHealth)
129                 {
130                         bprint(sprintf("Stalemate broken by team health. Best team: %s%s (%d)^7 - Trailing team: %s%s (%d)\n",
131                                 Team_ColorCode(winnerTeam), Team_ColorName(winnerTeam), winnerTeamHealth,
132                                 Team_ColorCode(secondTeam), Team_ColorName(secondTeam), secondTeamHealth));
133                         return winnerTeam;
134                 }
135         }
136
137         return -2; // Equality. Can't avoid the stalemate.
138 }
139
140 float CA_CheckWinner()
141 {
142         int winner_team = 0;
143
144         if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
145         {
146                 // attempt to prevent stalemate by survivor count AND/OR total team health?
147                 bool prevent_stalemate_by_survivors = (autocvar_g_ca_prevent_stalemate & BIT(0));
148                 bool prevent_stalemate_by_health    = (autocvar_g_ca_prevent_stalemate & BIT(1));
149
150                 if(prevent_stalemate_by_survivors || prevent_stalemate_by_health)
151                         winner_team = CA_PreventStalemate();
152                 else
153                         winner_team = -2;
154         }
155
156         CA_count_alive_players();
157         if (!winner_team)
158                 winner_team = Team_GetWinnerAliveTeam();
159         if (!winner_team)
160                 return 0;
161
162         if(winner_team > 0)
163         {
164                 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
165                 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
166                 TeamScore_AddToTeam(winner_team, ST_CA_ROUNDS, +1);
167         }
168         else if(winner_team == -1)
169         {
170                 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
171                 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
172         }
173         else if(winner_team == -2)
174         {
175                 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
176                 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
177         }
178
179         allowed_to_spawn = false;
180         game_stopped = true;
181         round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
182
183         FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
184
185         return 1;
186 }
187
188 void CA_RoundStart()
189 {
190         allowed_to_spawn = boolean(warmup_stage);
191 }
192
193 bool CA_CheckTeams()
194 {
195         static int prev_missing_teams_mask;
196         allowed_to_spawn = true;
197         CA_count_alive_players();
198         if (Team_GetNumberOfAliveTeams() == NumTeams(ca_teams))
199         {
200                 if(prev_missing_teams_mask > 0)
201                         Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
202                 prev_missing_teams_mask = -1;
203                 return true;
204         }
205         if(total_players == 0)
206         {
207                 if(prev_missing_teams_mask > 0)
208                         Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_MISSING_TEAMS);
209                 prev_missing_teams_mask = -1;
210                 return false;
211         }
212         int missing_teams_mask = 0;
213         for (int i = 1; i <= NUM_TEAMS; ++i)
214         {
215                 if ((ca_teams & Team_IndexToBit(i)) &&
216                         (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(i)) == 0))
217                 {
218                         missing_teams_mask |= Team_IndexToBit(i);
219                 }
220         }
221         if(prev_missing_teams_mask != missing_teams_mask)
222         {
223                 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
224                 prev_missing_teams_mask = missing_teams_mask;
225         }
226         return false;
227 }
228
229 bool ca_isEliminated(entity e)
230 {
231         if(INGAME_JOINED(e) && (IS_DEAD(e) || e.frags == FRAGS_PLAYER_OUT_OF_GAME))
232                 return true;
233         if(INGAME_JOINING(e))
234                 return true;
235         return false;
236 }
237
238 /** Returns next available player to spectate if g_ca_spectate_enemies == 0 */
239 entity CA_SpectateNext(entity player, entity start)
240 {
241         if (SAME_TEAM(start, player)) return start;
242         // continue from current player
243         for (entity e = start; (e = find(e, classname, STR_PLAYER)); )
244         {
245                 if (SAME_TEAM(player, e)) return e;
246         }
247         // restart from the beginning
248         for (entity e = NULL; (e = find(e, classname, STR_PLAYER)); )
249         {
250                 if (SAME_TEAM(player, e)) return e;
251         }
252         return start;
253 }
254
255
256 MUTATOR_HOOKFUNCTION(ca, PlayerSpawn)
257 {
258         entity player = M_ARGV(0, entity);
259
260         INGAME_STATUS_SET(player, INGAME_STATUS_JOINED);
261         if (time <= game_starttime) // reset on game restart, not on round start
262                 player.ca_damage_counter = 0;
263         if (!warmup_stage)
264                 eliminatedPlayers.SendFlags |= 1;
265 }
266
267 MUTATOR_HOOKFUNCTION(ca, ForbidSpawn)
268 {
269         entity player = M_ARGV(0, entity);
270
271         // spectators / observers that weren't playing can join; they are
272         // immediately forced to observe in the PutClientInServer hook
273         // this way they are put in a team and can play in the next round
274         if (!allowed_to_spawn && INGAME(player))
275                 return true;
276         return false;
277 }
278
279 MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
280 {
281         entity player = M_ARGV(0, entity);
282
283         if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join
284         {
285                 TRANSMUTE(Observer, player);
286                 if (CS(player).jointime != time && !INGAME(player)) // not when connecting
287                 {
288                         INGAME_STATUS_SET(player, INGAME_STATUS_JOINING);
289                         Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
290                 }
291         }
292
293         if (!warmup_stage)
294                 eliminatedPlayers.SendFlags |= 1;
295 }
296
297 MUTATOR_HOOKFUNCTION(ca, reset_map_players)
298 {
299         g_ca_spectate_enemies = autocvar_g_ca_spectate_enemies;
300         observe_blocked_if_eliminated = (g_ca_spectate_enemies == -1);
301         // we can avoid sending observe_blocked_if_eliminated to all clients here (with ClientData_Touch)
302         // since it will get sent whenever the client spectates someone anyway
303
304         FOREACH_CLIENT(true, {
305                 CS(it).killcount = 0;
306                 if (INGAME(it) || IS_BOT_CLIENT(it))
307                 {
308                         TRANSMUTE(Player, it);
309                         INGAME_STATUS_SET(it, INGAME_STATUS_JOINED);
310                         PutClientInServer(it);
311                 }
312         });
313         return true;
314 }
315
316 MUTATOR_HOOKFUNCTION(ca, reset_map_global)
317 {
318         allowed_to_spawn = true;
319         return true;
320 }
321
322 MUTATOR_HOOKFUNCTION(ca, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
323 {
324         M_ARGV(0, float) = ca_teams;
325         return true;
326 }
327
328 entity ca_LastPlayerForTeam(entity this)
329 {
330         entity last_pl = NULL;
331         FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
332                 if (!IS_DEAD(it) && SAME_TEAM(this, it))
333                 {
334                         if (!last_pl)
335                                 last_pl = it;
336                         else
337                                 return NULL;
338                 }
339         });
340         return last_pl;
341 }
342
343 void ca_LastPlayerForTeam_Notify(entity this)
344 {
345         if (!warmup_stage && round_handler_IsActive() && round_handler_IsRoundStarted())
346         {
347                 entity pl = ca_LastPlayerForTeam(this);
348                 if (pl)
349                         Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
350         }
351 }
352
353 MUTATOR_HOOKFUNCTION(ca, PlayerDies)
354 {
355         entity frag_target = M_ARGV(2, entity);
356
357         ca_LastPlayerForTeam_Notify(frag_target);
358         if (!allowed_to_spawn)
359         {
360                 frag_target.respawn_flags = RESPAWN_SILENT;
361                 // prevent unwanted sudden rejoin as spectator and movement of spectator camera
362                 frag_target.respawn_time = time + 2;
363         }
364         frag_target.respawn_flags |= RESPAWN_FORCE;
365         if (!warmup_stage)
366                 eliminatedPlayers.SendFlags |= 1;
367         return true;
368 }
369
370
371 MUTATOR_HOOKFUNCTION(ca, ClientDisconnect)
372 {
373         entity player = M_ARGV(0, entity);
374
375         if (IS_PLAYER(player) && !IS_DEAD(player))
376                 ca_LastPlayerForTeam_Notify(player);
377         return true;
378 }
379
380 MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
381 {
382         entity player = M_ARGV(0, entity);
383
384         bool is_forced = M_ARGV(1, bool);
385         if (is_forced && INGAME(player))
386                 INGAME_STATUS_CLEAR(player);
387
388         if (IS_PLAYER(player) && !IS_DEAD(player))
389                 ca_LastPlayerForTeam_Notify(player);
390         if (player.killindicator_teamchange == -2) // player wants to spectate
391         {
392                 entcs_update_players(player);
393                 INGAME_STATUS_CLEAR(player);
394         }
395         if (INGAME(player))
396         {
397                 player.frags = FRAGS_PLAYER_OUT_OF_GAME;
398                 player.would_spectate = observe_blocked_if_eliminated; // if blocked from observing force to spectate now
399         }
400         if (!warmup_stage)
401                 eliminatedPlayers.SendFlags |= 1;
402         if (!INGAME(player))
403                 return false;  // allow team reset
404         return true;  // prevent team reset
405 }
406
407 MUTATOR_HOOKFUNCTION(ca, ForbidThrowCurrentWeapon)
408 {
409         return true;
410 }
411
412 MUTATOR_HOOKFUNCTION(ca, GiveFragsForKill, CBC_ORDER_FIRST)
413 {
414         M_ARGV(2, float) = 0; // score will be given to the winner team when the round ends
415         return true;
416 }
417
418 MUTATOR_HOOKFUNCTION(ca, SetStartItems)
419 {
420         start_items       &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
421         if(!cvar("g_use_ammunition"))
422                 start_items |= IT_UNLIMITED_AMMO;
423
424         start_health       = warmup_start_health       = autocvar_g_ca_start_health;
425         start_armorvalue   = warmup_start_armorvalue   = autocvar_g_ca_start_armor;
426         start_ammo_shells  = warmup_start_ammo_shells  = autocvar_g_ca_start_ammo_shells;
427         start_ammo_nails   = warmup_start_ammo_nails   = autocvar_g_ca_start_ammo_nails;
428         start_ammo_rockets = warmup_start_ammo_rockets = autocvar_g_ca_start_ammo_rockets;
429         start_ammo_cells   = warmup_start_ammo_cells   = autocvar_g_ca_start_ammo_cells;
430         start_ammo_plasma  = warmup_start_ammo_plasma  = autocvar_g_ca_start_ammo_plasma;
431         start_ammo_fuel    = warmup_start_ammo_fuel    = autocvar_g_ca_start_ammo_fuel;
432 }
433
434 MUTATOR_HOOKFUNCTION(ca, Damage_Calculate)
435 {
436         entity frag_attacker = M_ARGV(1, entity);
437         entity frag_target = M_ARGV(2, entity);
438         float frag_deathtype = M_ARGV(3, float);
439         float frag_damage = M_ARGV(4, float);
440         float frag_mirrordamage = M_ARGV(5, float);
441
442         if (IS_PLAYER(frag_target))
443         if (!IS_DEAD(frag_target))
444         if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
445                 frag_damage = 0;
446
447         frag_mirrordamage = 0;
448
449         M_ARGV(4, float) = frag_damage;
450         M_ARGV(5, float) = frag_mirrordamage;
451 }
452
453 MUTATOR_HOOKFUNCTION(ca, FilterItem)
454 {
455         entity item = M_ARGV(0, entity);
456
457         if (autocvar_g_powerups <= 0)
458         if (item.itemdef.instanceOfPowerup)
459                 return true;
460
461         if (autocvar_g_pickup_items <= 0)
462                 return true;
463 }
464
465 MUTATOR_HOOKFUNCTION(ca, PlayerDamage_SplitHealthArmor)
466 {
467         if (time < game_starttime || (round_handler_IsActive() && !round_handler_IsRoundStarted()))
468                 return;
469
470         entity frag_attacker = M_ARGV(1, entity);
471         entity frag_target = M_ARGV(2, entity);
472         float frag_deathtype = M_ARGV(6, float);
473         float frag_damage = M_ARGV(7, float);
474         float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
475         float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
476
477         float excess = max(0, frag_damage - damage_take - damage_save);
478
479         if (autocvar_g_ca_damage2score <= 0 || frag_damage - excess == 0) return;
480
481         entity scorer = NULL;
482         float scorer_damage = 0;
483
484         if (IS_PLAYER(frag_attacker))
485         {
486                 if (DIFF_TEAM(frag_target, frag_attacker))
487                         scorer_damage = frag_damage - excess;
488                 else // friendly fire
489                         scorer_damage = -(frag_damage - excess);
490
491                 scorer = frag_attacker;
492         }
493         else
494         {
495                 //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
496                 //deathtypes:
497                 //kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks
498                 //camp = campcheck, lava = lava, slime = slime
499                 //team change / rebalance suicides are currently not included
500                 if (frag_deathtype == DEATH_KILL.m_id ||
501                         frag_deathtype == DEATH_DROWN.m_id ||
502                         frag_deathtype == DEATH_HURTTRIGGER.m_id ||
503                         frag_deathtype == DEATH_CAMP.m_id ||
504                         frag_deathtype == DEATH_LAVA.m_id ||
505                         frag_deathtype == DEATH_SLIME.m_id ||
506                         frag_deathtype == DEATH_SWAMP.m_id)
507                 {
508                         scorer_damage = -(frag_damage - excess);
509                         scorer = frag_target;
510                 }
511         }
512
513         if (scorer)
514                 GameRules_scoring_add_float2int(scorer, SCORE, scorer_damage, ca_damage_counter, autocvar_g_ca_damage2score);
515 }
516
517 MUTATOR_HOOKFUNCTION(ca, CalculateRespawnTime)
518 {
519         // no respawn calculations needed, player is forced to spectate anyway
520         return true;
521 }
522
523 MUTATOR_HOOKFUNCTION(ca, PlayerRegen)
524 {
525         // no regeneration in CA
526         return true;
527 }
528
529 MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining)
530 {
531         // announce remaining frags
532         return true;
533 }
534
535 MUTATOR_HOOKFUNCTION(ca, SpectateSet)
536 {
537         entity client = M_ARGV(0, entity);
538         entity targ = M_ARGV(1, entity);
539
540         if (g_ca_spectate_enemies != 1 && INGAME(client))
541         if (DIFF_TEAM(targ, client))
542                 return true;
543 }
544
545 MUTATOR_HOOKFUNCTION(ca, SpectateNext)
546 {
547         entity client = M_ARGV(0, entity);
548
549         if (g_ca_spectate_enemies != 1 && INGAME(client)
550                 && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
551         {
552                 entity targ = M_ARGV(1, entity);
553                 M_ARGV(1, entity) = CA_SpectateNext(client, targ);
554                 return true;
555         }
556 }
557
558 MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
559 {
560         entity client = M_ARGV(0, entity);
561         entity targ = M_ARGV(1, entity);
562         entity first = M_ARGV(2, entity);
563
564         if (g_ca_spectate_enemies != 1 && INGAME(client)
565                 && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
566         {
567                 do { targ = targ.chain; }
568                 while(targ && DIFF_TEAM(targ, client));
569
570                 if (!targ)
571                 {
572                         for (targ = first; targ && DIFF_TEAM(targ, client); targ = targ.chain);
573
574                         if (targ == client.enemy)
575                                 return MUT_SPECPREV_RETURN;
576                 }
577         }
578         else
579                 return MUT_SPECPREV_CONTINUE;
580
581         M_ARGV(1, entity) = targ;
582
583         return MUT_SPECPREV_FOUND;
584 }
585
586 MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
587 {
588         FOREACH_CLIENT(IS_REAL_CLIENT(it), {
589                 if (IS_PLAYER(it) || INGAME_JOINED(it))
590                         ++M_ARGV(0, int);
591                 ++M_ARGV(1, int);
592         });
593         return true;
594 }
595
596 MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
597 {
598         entity player = M_ARGV(0, entity);
599
600         if (INGAME(player))
601         {
602                 // they're going to spec, we can do other checks
603                 if (autocvar_sv_spectate && (IS_SPEC(player) || IS_OBSERVER(player)))
604                         Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_LEAVE);
605                 return MUT_SPECCMD_FORCE;
606         }
607
608         return MUT_SPECCMD_CONTINUE;
609 }
610
611 MUTATOR_HOOKFUNCTION(ca, HideTeamNagger)
612 {
613         return true; // doesn't work well with the whole spectator as player thing
614 }
615
616 MUTATOR_HOOKFUNCTION(ca, SetWeaponArena)
617 {
618         if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
619                 M_ARGV(0, string) = autocvar_g_ca_weaponarena;
620 }
621
622 MUTATOR_HOOKFUNCTION(ca, SV_ParseServerCommand)
623 {
624         string cmd_name = M_ARGV(0, string);
625         if (cmd_name == "shuffleteams")
626                 shuffleteams_on_reset_map = !allowed_to_spawn;
627         return false;
628 }