waeponarena {all,most}_available
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / clanarena / sv_clanarena.qh
1 #pragma once
2
3 #include <common/mutators/base.qh>
4 #include <server/round_handler.qh>
5 #include <server/miscfunctions.qh>
6
7 int autocvar_g_ca_point_limit;
8 int autocvar_g_ca_point_leadlimit;
9 float autocvar_g_ca_round_timelimit;
10 bool autocvar_g_ca_team_spawns;
11 //int autocvar_g_ca_teams;
12 int autocvar_g_ca_teams_override;
13 float autocvar_g_ca_warmup;
14 string autocvar_g_ca_weaponarena;
15
16
17 int ca_teams;
18 bool allowed_to_spawn;
19
20 const int ST_CA_ROUNDS = 1;
21
22 bool CA_CheckTeams();
23 bool CA_CheckWinner();
24 void CA_RoundStart();
25 bool ca_isEliminated(entity e);
26
27 REGISTER_MUTATOR(ca, false)
28 {
29     MUTATOR_STATIC();
30         MUTATOR_ONADD
31         {
32                 GameRules_teams(true);
33         GameRules_spawning_teams(autocvar_g_ca_team_spawns);
34         GameRules_limit_score(autocvar_g_ca_point_limit);
35         GameRules_limit_lead(autocvar_g_ca_point_leadlimit);
36
37                 ca_teams = autocvar_g_ca_teams_override;
38                 if (ca_teams < 2)
39                         ca_teams = cvar("g_ca_teams"); // read the cvar directly as it gets written earlier in the same frame
40
41                 ca_teams = BITS(bound(2, ca_teams, 4));
42         GameRules_scoring(ca_teams, SFL_SORT_PRIO_PRIMARY, 0, {
43             field_team(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
44         });
45
46                 allowed_to_spawn = true;
47                 round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
48                 round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
49                 EliminatedPlayers_Init(ca_isEliminated);
50         }
51         return 0;
52 }
53
54 // should be removed in the future, as other code should not have to care
55 .float caplayer; // 0.5 if scheduled to join the next round