5 #include <common/items/item/pickup.qh>
6 #include <common/mutators/base.qh>
7 #include <common/gamemodes/sv_rules.qh>
11 int autocvar_captureleadlimit_override;
12 int autocvar_capturelimit_override;
14 REGISTER_MUTATOR(ctf, false)
19 GameRules_teams(true);
20 GameRules_limit_score(autocvar_capturelimit_override);
21 GameRules_limit_lead(autocvar_captureleadlimit_override);
29 void ctf_RespawnFlag(entity flag);
31 // score rule declarations
32 const int ST_CTF_CAPS = 1;
35 ATTRIB(Flag, m_mins, vector, (PL_MIN_CONST + '0 0 -13') * 1.4); // scaling be damned
36 ATTRIB(Flag, m_maxs, vector, (PL_MAX_CONST + '0 0 -13') * 1.4);
39 STATIC_INIT(Flag) { CTF_FLAG = NEW(Flag); }
40 void ctf_FlagTouch(entity this, entity toucher) { ITEM_HANDLE(Pickup, CTF_FLAG, this, toucher); }
42 // flag constants // for most of these, there is just one question to be asked: WHYYYYY?
44 const float FLAG_SCALE = 0.6;
46 const float FLAG_THINKRATE = 0.2;
47 const float FLAG_TOUCHRATE = 0.5;
48 const float WPFE_THINKRATE = 0.5;
50 const vector FLAG_DROP_OFFSET = ('0 0 32');
51 const vector FLAG_CARRY_OFFSET = ('-16 0 8');
52 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_CONST.z - 13))
53 const vector FLAG_WAYPOINT_OFFSET = ('0 0 64');
54 const int FLAG_FLOAT_OFFSET_Z = 32;
55 const int FLAG_PASS_ARC_OFFSET_Z = -10;
57 const vector VEHICLE_FLAG_OFFSET = ('0 0 96');
58 const float VEHICLE_FLAG_SCALE = 1.0;
61 #define WPCOLOR_ENEMYFC(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
62 #define WPCOLOR_FLAGCARRIER(t) ((t) ? colormapPaletteColor(t - 1, false) * 0.75 : '1 1 1')
63 //#define WPCOLOR_FLAGCARRIER(t) (WP_FlagCarrier.m_color)
64 #define WPCOLOR_DROPPEDFLAG(t) ((t) ? ('0.25 0.25 0.25' + colormapPaletteColor(t - 1, false)) * 0.5 : '1 1 1')
67 #define snd_flag_taken noise
68 #define snd_flag_returned noise1
69 #define snd_flag_capture noise2
70 #define snd_flag_respawn noise3
71 .string snd_flag_dropped;
72 .string snd_flag_touch;
73 .string snd_flag_pass;
78 .float score_drop; // note: negated
81 .float score_team_capture; // shouldn't be too high
83 // property set on objects to point to the flag they're carrying (if any)
91 // list of flags on the map
92 entity ctf_worldflaglist;
93 .entity ctf_worldflagnext;
94 .entity ctf_staleflagnext;
99 .entity wps_flagcarrier;
100 .entity wps_flagdropped;
101 .entity wps_flagreturn;
102 .entity wps_enemyflagcarrier;
103 .float wps_helpme_time;
104 bool wpforenemy_announced;
105 float wpforenemy_nextthink;
108 const int FLAG_BASE = 1;
109 const int FLAG_DROPPED = 2;
110 const int FLAG_CARRY = 3;
111 const int FLAG_PASSING = 4;
113 const int DROP_NORMAL = 1;
114 const int DROP_THROW = 2;
115 const int DROP_PASS = 3;
116 const int DROP_RESET = 4;
118 const int PICKUP_BASE = 1;
119 const int PICKUP_DROPPED = 2;
121 const int CAPTURE_NORMAL = 1;
122 const int CAPTURE_DROPPED = 2;
124 const int RETURN_TIMEOUT = 1;
125 const int RETURN_DROPPED = 2;
126 const int RETURN_DAMAGE = 3;
127 const int RETURN_SPEEDRUN = 4;
128 const int RETURN_NEEDKILL = 5;
130 bool ctf_Stalemate_Customize(entity this, entity client);
132 void ctf_Handle_Throw(entity player, entity receiver, float droptype);
135 #define ctf_spawnorigin dropped_origin
136 bool ctf_stalemate; // indicates that a stalemate is active
137 float ctf_captimerecord; // record time for capturing the flag
138 .float ctf_pickuptime;
140 .int ctf_status; // status of the flag (FLAG_BASE, FLAG_DROPPED, FLAG_CARRY declared globally)
141 .entity ctf_dropper; // don't allow spam of dropping the flag
142 .float next_take_time;
143 .bool ctf_flagdamaged_byworld;
145 .entity enemy; // when flag is back in the base, it remembers last player who carried/touched the flag, useful to bots
147 // passing/throwing properties
148 .float pass_distance;
151 .float throw_antispam;
152 .float throw_prevtime;
155 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
156 .bool ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
157 float ctf_captureshield_min_negscore; // punish at -20 points
158 float ctf_captureshield_max_ratio; // punish at most 30% of each team
159 float ctf_captureshield_force; // push force of the shield
162 bool ctf_oneflag; // indicates whether or not a neutral flag has been found
165 const int HAVOCBOT_CTF_ROLE_NONE = 0;
166 const int HAVOCBOT_CTF_ROLE_DEFENSE = 2;
167 const int HAVOCBOT_CTF_ROLE_MIDDLE = 4;
168 const int HAVOCBOT_CTF_ROLE_OFFENSE = 8;
169 const int HAVOCBOT_CTF_ROLE_CARRIER = 16;
170 const int HAVOCBOT_CTF_ROLE_RETRIEVER = 32;
171 const int HAVOCBOT_CTF_ROLE_ESCORT = 64;
173 .bool havocbot_cantfindflag;
175 void havocbot_role_ctf_setrole(entity bot, int role);
178 #define CTF_SAMETEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? DIFF_TEAM(a,b) : SAME_TEAM(a,b))
179 #define CTF_DIFFTEAM(a,b) ((autocvar_g_ctf_reverse || (ctf_oneflag && autocvar_g_ctf_oneflag_reverse)) ? SAME_TEAM(a,b) : DIFF_TEAM(a,b))