7 REGISTER_MUTATOR(ctf, false)
12 GameRules_teams(true);
13 GameRules_limit_score(autocvar_capturelimit_override);
14 GameRules_limit_lead(autocvar_captureleadlimit_override);
22 void ctf_RespawnFlag(entity flag);
24 // score rule declarations
25 const int ST_CTF_CAPS = 1;
28 ATTRIB(Flag, m_mins, vector, (PL_MIN_CONST + '0 0 -13') * 1.4); // scaling be damned
29 ATTRIB(Flag, m_maxs, vector, (PL_MAX_CONST + '0 0 -13') * 1.4);
31 Flag CTF_FLAG; STATIC_INIT(Flag) { CTF_FLAG = NEW(Flag); }
32 void ctf_FlagTouch(entity this, entity toucher) { ITEM_HANDLE(Pickup, CTF_FLAG, this, toucher); }
34 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
36 const float FLAG_SCALE = 0.6;
38 const float FLAG_THINKRATE = 0.2;
39 const float FLAG_TOUCHRATE = 0.5;
40 const float WPFE_THINKRATE = 0.5;
42 const vector FLAG_DROP_OFFSET = ('0 0 32');
43 const vector FLAG_CARRY_OFFSET = ('-16 0 8');
44 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_CONST.z - 13))
45 const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
46 const vector FLAG_FLOAT_OFFSET = ('0 0 32');
47 const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10');
49 const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
50 const float VEHICLE_FLAG_SCALE = 1.0;
53 #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
54 #define WPCOLOR_FLAGCARRIER(t) (WP_FlagCarrier.m_color)
55 #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
58 #define snd_flag_taken noise
59 #define snd_flag_returned noise1
60 #define snd_flag_capture noise2
61 #define snd_flag_respawn noise3
62 .string snd_flag_dropped;
63 .string snd_flag_touch;
64 .string snd_flag_pass;
69 .float score_drop; // note: negated
72 .float score_team_capture; // shouldn't be too high
79 // list of flags on the map
80 entity ctf_worldflaglist;
81 .entity ctf_worldflagnext;
82 .entity ctf_staleflagnext;
87 .entity wps_flagcarrier;
88 .entity wps_flagdropped;
89 .entity wps_flagreturn;
90 .entity wps_enemyflagcarrier;
91 .float wps_helpme_time;
92 bool wpforenemy_announced;
93 float wpforenemy_nextthink;
96 const int FLAG_BASE = 1;
97 const int FLAG_DROPPED = 2;
98 const int FLAG_CARRY = 3;
99 const int FLAG_PASSING = 4;
101 const int DROP_NORMAL = 1;
102 const int DROP_THROW = 2;
103 const int DROP_PASS = 3;
104 const int DROP_RESET = 4;
106 const int PICKUP_BASE = 1;
107 const int PICKUP_DROPPED = 2;
109 const int CAPTURE_NORMAL = 1;
110 const int CAPTURE_DROPPED = 2;
112 const int RETURN_TIMEOUT = 1;
113 const int RETURN_DROPPED = 2;
114 const int RETURN_DAMAGE = 3;
115 const int RETURN_SPEEDRUN = 4;
116 const int RETURN_NEEDKILL = 5;
118 bool ctf_Stalemate_Customize(entity this, entity client);
120 void ctf_Handle_Throw(entity player, entity receiver, float droptype);
123 #define ctf_spawnorigin dropped_origin
124 bool ctf_stalemate; // indicates that a stalemate is active
125 float ctf_captimerecord; // record time for capturing the flag
126 .float ctf_pickuptime;
128 .int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
129 .entity ctf_dropper; // don't allow spam of dropping the flag
130 .int max_flag_health;
131 .float next_take_time;
132 .bool ctf_flagdamaged_byworld;
134 .entity enemy; // when flag is back in the base, it remembers last player who carried/touched the flag, useful to bots
136 // passing/throwing properties
137 .float pass_distance;
140 .float throw_antispam;
141 .float throw_prevtime;
144 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
145 .bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
146 float ctf_captureshield_min_negscore; // punish at -20 points
147 float ctf_captureshield_max_ratio; // punish at most 30% of each team
148 float ctf_captureshield_force; // push force of the shield
151 bool ctf_oneflag; // indicates whether or not a neutral flag has been found
154 const int HAVOCBOT_CTF_ROLE_NONE = 0;
155 const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
156 const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
157 const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
158 const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
159 const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
160 const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
162 .bool havocbot_cantfindflag;
164 void havocbot_role_ctf_setrole(entity bot, int role);
167 #define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
168 #define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))
171 const int CTF_RED_FLAG_TAKEN = 1;
172 const int CTF_RED_FLAG_LOST = 2;
173 const int CTF_RED_FLAG_CARRYING = 3;
174 const int CTF_BLUE_FLAG_TAKEN = 4;
175 const int CTF_BLUE_FLAG_LOST = 8;
176 const int CTF_BLUE_FLAG_CARRYING = 12;
177 const int CTF_YELLOW_FLAG_TAKEN = 16;
178 const int CTF_YELLOW_FLAG_LOST = 32;
179 const int CTF_YELLOW_FLAG_CARRYING = 48;
180 const int CTF_PINK_FLAG_TAKEN = 64;
181 const int CTF_PINK_FLAG_LOST = 128;
182 const int CTF_PINK_FLAG_CARRYING = 192;
183 const int CTF_NEUTRAL_FLAG_TAKEN = 256;
184 const int CTF_NEUTRAL_FLAG_LOST = 512;
185 const int CTF_NEUTRAL_FLAG_CARRYING = 768;
186 const int CTF_FLAG_NEUTRAL = 2048;
187 const int CTF_SHIELDED = 4096;
188 const int CTF_STALEMATE = 8192;