]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/gamemode_invasion.qh
GameRules: make `GameRules_teams(true)` imply `have_team_spawns = -1`
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_invasion.qh
1 #pragma once
2
3 #include "../gamemode.qh"
4
5 #define autocvar_g_invasion_point_limit cvar("g_invasion_point_limit")
6 int autocvar_g_invasion_teams;
7 int autocvar_g_invasion_type;
8 bool autocvar_g_invasion_team_spawns;
9 bool g_invasion;
10 void invasion_Initialize();
11
12 REGISTER_MUTATOR(inv, false)
13 {
14         MUTATOR_ONADD
15         {
16                 if (time > 1) // game loads at time 1
17                         error("This is a game type and it cannot be added at runtime.");
18                 g_invasion = true;
19                 invasion_Initialize();
20
21                 cvar_settemp("g_monsters", "1");
22
23         GameRules_limit_score(autocvar_g_invasion_point_limit);
24
25                 if (autocvar_g_invasion_teams >= 2)
26                 {
27                         GameRules_teams(true);
28                         GameRules_spawning_teams(autocvar_g_invasion_team_spawns);
29                 }
30         }
31
32         MUTATOR_ONROLLBACK_OR_REMOVE
33         {
34                 // we actually cannot roll back invasion_Initialize here
35                 // BUT: we don't need to! If this gets called, adding always
36                 // succeeds.
37         }
38
39         MUTATOR_ONREMOVE
40         {
41                 LOG_INFO("This is a game type and it cannot be removed at runtime.");
42                 return -1;
43         }
44
45         return 0;
46 }
47
48 float inv_numspawned;
49 float inv_maxspawned;
50 float inv_roundcnt;
51 float inv_maxrounds;
52 float inv_numkilled;
53 float inv_lastcheck;
54 float inv_maxcurrent;
55
56 float invasion_teams;
57 float inv_monsters_perteam[17];
58
59 float inv_monsterskill;
60
61 const float ST_INV_KILLS = 1;
62
63 const int INV_TYPE_ROUND = 0; // round-based waves of enemies
64 const int INV_TYPE_HUNT = 1; // clear the map of placed enemies
65 const int INV_TYPE_STAGE = 2; // reach the end of the level