]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/gamemode_domination.qh
Refactor game rules
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_domination.qh
1 #pragma once
2
3 #include "../gamemode.qh"
4
5 #define autocvar_g_domination_point_limit cvar("g_domination_point_limit")
6 bool autocvar_g_domination_roundbased;
7 int autocvar_g_domination_roundbased_point_limit;
8 int autocvar_g_domination_point_leadlimit;
9
10 void dom_Initialize();
11
12 REGISTER_MUTATOR(dom, 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                 dom_Initialize();
19
20                 int fraglimit_override = autocvar_g_domination_point_limit;
21                 if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit)
22                         fraglimit_override = autocvar_g_domination_roundbased_point_limit;
23
24                 GameRules_teams(true);
25         GameRules_limit_score(fraglimit_override);
26         GameRules_limit_lead(autocvar_g_domination_point_leadlimit);
27                 have_team_spawns = -1; // request team spawns
28         }
29
30         MUTATOR_ONREMOVE
31         {
32                 LOG_INFO("This is a game type and it cannot be removed at runtime.");
33                 return -1;
34         }
35
36         return 0;
37 }
38
39 // score rule declarations
40 const float ST_DOM_TICKS = 1;
41 const float ST_DOM_CAPS = 1;
42
43 // pps: points per second
44 .float dom_total_pps = _STAT(DOM_TOTAL_PPS);
45 .float dom_pps_red = _STAT(DOM_PPS_RED);
46 .float dom_pps_blue = _STAT(DOM_PPS_BLUE);
47 .float dom_pps_yellow = _STAT(DOM_PPS_YELLOW);
48 .float dom_pps_pink = _STAT(DOM_PPS_PINK);
49 float total_pps;
50 float pps_red;
51 float pps_blue;
52 float pps_yellow;
53 float pps_pink;
54
55 // capture declarations
56 .float enemy_playerid;
57 .entity sprite;
58 .float captime;
59
60 // misc globals
61 float domination_roundbased;
62 float domination_teams;
63
64 void AnimateDomPoint(entity this);
65
66 IntrusiveList g_dompoints;
67 STATIC_INIT(g_dompoints) { g_dompoints = IL_NEW(); }