5 #include "../gamemode.qh"
9 REGISTER_MUTATOR(ctf, false)
14 GameRules_teams(true);
15 GameRules_limit_score(autocvar_capturelimit_override);
16 GameRules_limit_lead(autocvar_captureleadlimit_override);
24 void ctf_RespawnFlag(entity flag);
26 // score rule declarations
27 const int ST_CTF_CAPS = 1;
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);
38 void ctf_FlagTouch(entity this, entity toucher) { ITEM_HANDLE(Pickup, CTF_FLAG, this, toucher); }
40 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
42 const float FLAG_SCALE = 0.6;
44 const float FLAG_THINKRATE = 0.2;
45 const float FLAG_TOUCHRATE = 0.5;
46 const float WPFE_THINKRATE = 0.5;
48 const vector FLAG_DROP_OFFSET = ('0 0 32');
49 const vector FLAG_CARRY_OFFSET = ('-16 0 8');
50 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_CONST.z - 13))
51 const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
52 const vector FLAG_FLOAT_OFFSET = ('0 0 32');
53 const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10');
55 const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
56 const float VEHICLE_FLAG_SCALE = 1.0;
59 #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
60 #define WPCOLOR_FLAGCARRIER(t) (WP_FlagCarrier.m_color)
61 #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
64 #define snd_flag_taken noise
65 #define snd_flag_returned noise1
66 #define snd_flag_capture noise2
67 #define snd_flag_respawn noise3
68 .string snd_flag_dropped;
69 .string snd_flag_touch;
70 .string snd_flag_pass;
75 .float score_drop; // note: negated
78 .float score_team_capture; // shouldn't be too high
85 // list of flags on the map
86 entity ctf_worldflaglist;
87 .entity ctf_worldflagnext;
88 .entity ctf_staleflagnext;
93 .entity wps_flagcarrier;
94 .entity wps_flagdropped;
95 .entity wps_flagreturn;
96 .entity wps_enemyflagcarrier;
97 .float wps_helpme_time;
98 bool wpforenemy_announced;
99 float wpforenemy_nextthink;
102 const int FLAG_BASE = 1;
103 const int FLAG_DROPPED = 2;
104 const int FLAG_CARRY = 3;
105 const int FLAG_PASSING = 4;
107 const int DROP_NORMAL = 1;
108 const int DROP_THROW = 2;
109 const int DROP_PASS = 3;
110 const int DROP_RESET = 4;
112 const int PICKUP_BASE = 1;
113 const int PICKUP_DROPPED = 2;
115 const int CAPTURE_NORMAL = 1;
116 const int CAPTURE_DROPPED = 2;
118 const int RETURN_TIMEOUT = 1;
119 const int RETURN_DROPPED = 2;
120 const int RETURN_DAMAGE = 3;
121 const int RETURN_SPEEDRUN = 4;
122 const int RETURN_NEEDKILL = 5;
124 bool ctf_Stalemate_Customize(entity this, entity client);
126 void ctf_Handle_Throw(entity player, entity receiver, float droptype);
129 #define ctf_spawnorigin dropped_origin
130 bool ctf_stalemate; // indicates that a stalemate is active
131 float ctf_captimerecord; // record time for capturing the flag
132 .float ctf_pickuptime;
134 .int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
135 .entity ctf_dropper; // don't allow spam of dropping the flag
136 .int max_flag_health;
137 .float next_take_time;
138 .bool ctf_flagdamaged_byworld;
141 // passing/throwing properties
142 .float pass_distance;
145 .float throw_antispam;
146 .float throw_prevtime;
149 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
150 .bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
151 float ctf_captureshield_min_negscore; // punish at -20 points
152 float ctf_captureshield_max_ratio; // punish at most 30% of each team
153 float ctf_captureshield_force; // push force of the shield
156 bool ctf_oneflag; // indicates whether or not a neutral flag has been found
159 const int HAVOCBOT_CTF_ROLE_NONE = 0;
160 const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
161 const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
162 const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
163 const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
164 const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
165 const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
167 .bool havocbot_cantfindflag;
169 void havocbot_role_ctf_setrole(entity bot, int role);
172 #define CTF_SAMETEAM(a, b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a, b) : SAME_TEAM(a, b))
173 #define CTF_DIFFTEAM(a, b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a, b) : DIFF_TEAM(a, b))
175 // networked flag statuses
176 .int ctf_flagstatus = _STAT(CTF_FLAGSTATUS);
179 const int CTF_RED_FLAG_TAKEN = 1;
180 const int CTF_RED_FLAG_LOST = 2;
181 const int CTF_RED_FLAG_CARRYING = 3;
182 const int CTF_BLUE_FLAG_TAKEN = 4;
183 const int CTF_BLUE_FLAG_LOST = 8;
184 const int CTF_BLUE_FLAG_CARRYING = 12;
185 const int CTF_YELLOW_FLAG_TAKEN = 16;
186 const int CTF_YELLOW_FLAG_LOST = 32;
187 const int CTF_YELLOW_FLAG_CARRYING = 48;
188 const int CTF_PINK_FLAG_TAKEN = 64;
189 const int CTF_PINK_FLAG_LOST = 128;
190 const int CTF_PINK_FLAG_CARRYING = 192;
191 const int CTF_NEUTRAL_FLAG_TAKEN = 256;
192 const int CTF_NEUTRAL_FLAG_LOST = 512;
193 const int CTF_NEUTRAL_FLAG_CARRYING = 768;
194 const int CTF_FLAG_NEUTRAL = 2048;
195 const int CTF_SHIELDED = 4096;
196 const int CTF_STALEMATE = 8192;