]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator/gamemode_ctf.qh
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ctf.qh
1 #pragma once
2
3 #ifdef SVQC
4
5 #include "../gamemode.qh"
6
7 void ctf_Initialize();
8
9 REGISTER_MUTATOR(ctf, false)
10 {
11     MUTATOR_STATIC();
12     MUTATOR_ONADD
13     {
14         GameRules_teams(true);
15         GameRules_limit_score(autocvar_capturelimit_override);
16         GameRules_limit_lead(autocvar_captureleadlimit_override);
17
18         ctf_Initialize();
19     }
20     return 0;
21 }
22
23 // used in cheats.qc
24 void ctf_RespawnFlag(entity flag);
25
26 // score rule declarations
27 const int ST_CTF_CAPS = 1;
28
29 CLASS(Flag, Pickup)
30     ATTRIB(Flag, m_mins, vector, (PL_MIN_CONST + '0 0 -13') * 1.4); // scaling be damned
31     ATTRIB(Flag, m_maxs, vector, (PL_MAX_CONST + '0 0 -13') * 1.4);
32 ENDCLASS(Flag)
33 Flag CTF_FLAG; STATIC_INIT(Flag) { CTF_FLAG = NEW(Flag); }
34 void ctf_FlagTouch(entity this, entity toucher) { ITEM_HANDLE(Pickup, CTF_FLAG, this, toucher); }
35
36 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
37
38 const float FLAG_SCALE = 0.6;
39
40 const float FLAG_THINKRATE = 0.2;
41 const float FLAG_TOUCHRATE = 0.5;
42 const float WPFE_THINKRATE = 0.5;
43
44 const vector FLAG_DROP_OFFSET = ('0 0 32');
45 const vector FLAG_CARRY_OFFSET = ('-16 0 8');
46 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_CONST.z - 13))
47 const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
48 const vector FLAG_FLOAT_OFFSET = ('0 0 32');
49 const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10');
50
51 const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
52 const float VEHICLE_FLAG_SCALE = 1.0;
53
54 // waypoint colors
55 #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
56 #define WPCOLOR_FLAGCARRIER(t) (WP_FlagCarrier.m_color)
57 #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
58
59 // sounds
60 #define snd_flag_taken noise
61 #define snd_flag_returned noise1
62 #define snd_flag_capture noise2
63 #define snd_flag_respawn noise3
64 .string snd_flag_dropped;
65 .string snd_flag_touch;
66 .string snd_flag_pass;
67
68 // score fields
69 .float score_assist;
70 .float score_capture;
71 .float score_drop; // note: negated
72 .float score_pickup;
73 .float score_return;
74 .float score_team_capture; // shouldn't be too high
75
76 // effects
77 .string toucheffect;
78 .string passeffect;
79 .string capeffect;
80
81 // list of flags on the map
82 entity ctf_worldflaglist;
83 .entity ctf_worldflagnext;
84 .entity ctf_staleflagnext;
85
86 // waypoint sprites
87 .entity wps_helpme;
88 .entity wps_flagbase;
89 .entity wps_flagcarrier;
90 .entity wps_flagdropped;
91 .entity wps_flagreturn;
92 .entity wps_enemyflagcarrier;
93 .float wps_helpme_time;
94 bool wpforenemy_announced;
95 float wpforenemy_nextthink;
96
97 // statuses
98 const int FLAG_BASE = 1;
99 const int FLAG_DROPPED = 2;
100 const int FLAG_CARRY = 3;
101 const int FLAG_PASSING = 4;
102
103 const int DROP_NORMAL = 1;
104 const int DROP_THROW = 2;
105 const int DROP_PASS = 3;
106 const int DROP_RESET = 4;
107
108 const int PICKUP_BASE = 1;
109 const int PICKUP_DROPPED = 2;
110
111 const int CAPTURE_NORMAL = 1;
112 const int CAPTURE_DROPPED = 2;
113
114 const int RETURN_TIMEOUT = 1;
115 const int RETURN_DROPPED = 2;
116 const int RETURN_DAMAGE = 3;
117 const int RETURN_SPEEDRUN = 4;
118 const int RETURN_NEEDKILL = 5;
119
120 bool ctf_Stalemate_Customize(entity this, entity client);
121
122 void ctf_Handle_Throw(entity player, entity receiver, float droptype);
123
124 // flag properties
125 #define ctf_spawnorigin dropped_origin
126 bool ctf_stalemate; // indicates that a stalemate is active
127 float ctf_captimerecord; // record time for capturing the flag
128 .float ctf_pickuptime;
129 .float ctf_droptime;
130 .int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
131 .entity ctf_dropper; // don't allow spam of dropping the flag
132 .int max_flag_health;
133 .float next_take_time;
134 .bool ctf_flagdamaged_byworld;
135 int ctf_teams;
136
137 // passing/throwing properties
138 .float pass_distance;
139 .entity pass_sender;
140 .entity pass_target;
141 .float throw_antispam;
142 .float throw_prevtime;
143 .int throw_count;
144
145 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
146 .bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
147 float ctf_captureshield_min_negscore; // punish at -20 points
148 float ctf_captureshield_max_ratio; // punish at most 30% of each team
149 float ctf_captureshield_force; // push force of the shield
150
151 // 1 flag ctf
152 bool ctf_oneflag; // indicates whether or not a neutral flag has been found
153
154 // bot player logic
155 const int HAVOCBOT_CTF_ROLE_NONE = 0;
156 const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
157 const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
158 const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
159 const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
160 const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
161 const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
162
163 .bool havocbot_cantfindflag;
164
165 void havocbot_role_ctf_setrole(entity bot, int role);
166
167 // team checking
168 #define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
169 #define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
170
171 // networked flag statuses
172 .int ctf_flagstatus = _STAT(CTF_FLAGSTATUS);
173 #endif
174
175 const int CTF_RED_FLAG_TAKEN                    = 1;
176 const int CTF_RED_FLAG_LOST                             = 2;
177 const int CTF_RED_FLAG_CARRYING                 = 3;
178 const int CTF_BLUE_FLAG_TAKEN                   = 4;
179 const int CTF_BLUE_FLAG_LOST                    = 8;
180 const int CTF_BLUE_FLAG_CARRYING                = 12;
181 const int CTF_YELLOW_FLAG_TAKEN                 = 16;
182 const int CTF_YELLOW_FLAG_LOST                  = 32;
183 const int CTF_YELLOW_FLAG_CARRYING              = 48;
184 const int CTF_PINK_FLAG_TAKEN                   = 64;
185 const int CTF_PINK_FLAG_LOST                    = 128;
186 const int CTF_PINK_FLAG_CARRYING                = 192;
187 const int CTF_NEUTRAL_FLAG_TAKEN                = 256;
188 const int CTF_NEUTRAL_FLAG_LOST                 = 512;
189 const int CTF_NEUTRAL_FLAG_CARRYING             = 768;
190 const int CTF_FLAG_NEUTRAL                              = 2048;
191 const int CTF_SHIELDED                                  = 4096;
192 const int CTF_STALEMATE                                 = 8192;