3 #include <common/t_items.qh>
5 #include "mutators/events.qh"
7 #include <common/constants.qh>
8 #include <common/mapinfo.qh>
9 #include <common/turrets/all.qh>
12 #define cvar_string_normal builtin_cvar_string
13 #define cvar_normal builtin_cvar
15 string cvar_string_normal(string n)
17 if (!(cvar_type(n) & CVAR_TYPEFLAG_EXISTS))
18 backtrace(strcat("Attempt to access undefined cvar: ", n));
19 return builtin_cvar_string(n);
22 float cvar_normal(string n)
24 return stof(cvar_string_normal(n));
27 #define cvar_set_normal builtin_cvar_set
29 .vector dropped_origin;
32 entity eliminatedPlayers;
33 void EliminatedPlayers_Init(float(entity) isEliminated_func);
37 void write_recordmarker(entity pl, float tstart, float dt);
39 void play2all(string samp);
41 void play2team(float t, string filename);
43 void GetCvars_handleFloat(entity this, string thisname, float f, .float field, string name);
45 float spamsound(entity e, float chan, string samp, float vol, float _atten);
47 void GetCvars_handleString(entity this, string thisname, float f, .string field, string name);
49 void precache_all_playermodels(string pattern);
51 void soundat(entity e, vector o, float chan, string samp, float vol, float _atten);
53 void InitializeEntitiesRun();
55 void stopsoundto(float _dest, entity e, float chan);
56 void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten);
58 void droptofloor(entity this);
60 void attach_sameorigin(entity e, entity to, string tag);
62 void crosshair_trace(entity pl);
64 void crosshair_trace_plusvisibletriggers(entity pl);
66 void detach_sameorigin(entity e);
68 void follow_sameorigin(entity e, entity to);
70 string formatmessage(entity this, string msg);
72 void GameLogEcho(string s);
78 void GetCvars(entity this, float f);
82 float isPushable(entity e);
84 float LostMovetypeFollow(entity ent);
86 string uid2name(string myuid);
88 float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
90 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
92 string NearestLocation(vector p);
94 void play2(entity e, string filename);
96 string playername(entity p);
100 void remove_safely(entity e);
102 void remove_unsafely(entity e);
104 void SetMovetypeFollow(entity ent, entity e);
106 void soundto(float dest, entity e, float chan, string samp, float vol, float atten);
108 void stopsound(entity e, float chan);
110 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
112 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
114 void WarpZone_crosshair_trace(entity pl);
116 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
118 #define IS_DEAD(s) ((s).deadflag != DEAD_NO)
121 #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
122 #define ITEM_DAMAGE_NEEDKILL(dt) (((dt) == DEATH_HURTTRIGGER.m_id) || ((dt) == DEATH_SLIME.m_id) || ((dt) == DEATH_LAVA.m_id) || ((dt) == DEATH_SWAMP.m_id))
124 #define PROJECTILE_TOUCH(e,t) MACRO_BEGIN if (WarpZone_Projectile_Touch(e,t)) return; MACRO_END
126 #define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))
128 // copies a string to a tempstring (so one can strunzone it)
129 string strcat1(string s) = #115; // FRIK_FILE
135 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
136 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
137 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
138 // BE CONSTANT OR strzoneD!
139 float strstrofs(string haystack, string needle, float offset)
143 len = strlen(needle);
144 endpos = strlen(haystack) - len;
145 while(offset <= endpos)
147 found = substring(haystack, offset, len);
156 const float NUM_NEAREST_ENTITIES = 4;
157 entity nearest_entity[NUM_NEAREST_ENTITIES];
158 float nearest_length[NUM_NEAREST_ENTITIES];
161 //#NO AUTOCVARS START
163 float g_pickup_shells;
164 float g_pickup_shells_max;
165 float g_pickup_nails;
166 float g_pickup_nails_max;
167 float g_pickup_rockets;
168 float g_pickup_rockets_max;
169 float g_pickup_cells;
170 float g_pickup_cells_max;
171 float g_pickup_plasma;
172 float g_pickup_plasma_max;
174 float g_pickup_fuel_jetpack;
175 float g_pickup_fuel_max;
176 float g_pickup_armorsmall;
177 float g_pickup_armorsmall_max;
178 float g_pickup_armormedium;
179 float g_pickup_armormedium_max;
180 float g_pickup_armorbig;
181 float g_pickup_armorbig_max;
182 float g_pickup_armormega;
183 float g_pickup_armormega_max;
184 float g_pickup_healthsmall;
185 float g_pickup_healthsmall_max;
186 float g_pickup_healthmedium;
187 float g_pickup_healthmedium_max;
188 float g_pickup_healthbig;
189 float g_pickup_healthbig_max;
190 float g_pickup_healthmega;
191 float g_pickup_healthmega_max;
192 float g_pickup_weapons_anyway;
194 WepSet g_weaponarena_weapons;
195 float g_weaponarena_random;
196 float g_weaponarena_random_with_blaster;
197 string g_weaponarena_list;
198 float g_weaponspeedfactor;
199 float g_weaponratefactor;
200 float g_weapondamagefactor;
201 float g_weaponforcefactor;
202 float g_weaponspreadfactor;
204 WepSet start_weapons;
205 WepSet start_weapons_default;
206 WepSet start_weapons_defaultmask;
208 float start_ammo_shells;
209 float start_ammo_nails;
210 float start_ammo_rockets;
211 float start_ammo_cells;
212 float start_ammo_plasma;
213 float start_ammo_fuel;
215 float start_armorvalue;
216 WepSet warmup_start_weapons;
217 WepSet warmup_start_weapons_default;
218 WepSet warmup_start_weapons_defaultmask;
219 #define WARMUP_START_WEAPONS ((g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)
220 float warmup_start_ammo_shells;
221 float warmup_start_ammo_nails;
222 float warmup_start_ammo_rockets;
223 float warmup_start_ammo_cells;
224 float warmup_start_ammo_plasma;
225 float warmup_start_ammo_fuel;
226 float warmup_start_health;
227 float warmup_start_armorvalue;
230 float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done?
231 void readplayerstartcvars();
236 string GetGametype(); // g_world.qc
237 void readlevelcvars()
239 if(cvar("sv_allow_fullbright"))
240 serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
242 g_instagib = cvar("g_instagib");
244 sv_clones = cvar("sv_clones");
245 sv_foginterval = cvar("sv_foginterval");
246 g_footsteps = cvar("g_footsteps");
247 g_jetpack = cvar("g_jetpack");
248 sv_maxidle = cvar("sv_maxidle");
249 sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
250 sv_maxidle_slots = cvar("sv_maxidle_slots");
251 sv_maxidle_slots_countbots = cvar("sv_maxidle_slots_countbots");
252 sv_autotaunt = cvar("sv_autotaunt");
253 sv_taunt = cvar("sv_taunt");
255 warmup_stage = cvar("g_warmup");
256 warmup_limit = cvar("g_warmup_limit");
257 g_warmup_allguns = cvar("g_warmup_allguns");
258 g_warmup_allow_timeout = cvar("g_warmup_allow_timeout");
260 if(cvar("g_campaign"))
261 warmup_stage = 0; // no warmup during campaign
263 g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon");
264 g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon");
265 g_pickup_respawntime_ammo = cvar("g_pickup_respawntime_ammo");
266 g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
267 g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
268 g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
269 g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
270 g_pickup_respawntimejitter_weapon = cvar("g_pickup_respawntimejitter_weapon");
271 g_pickup_respawntimejitter_superweapon = cvar("g_pickup_respawntimejitter_superweapon");
272 g_pickup_respawntimejitter_ammo = cvar("g_pickup_respawntimejitter_ammo");
273 g_pickup_respawntimejitter_short = cvar("g_pickup_respawntimejitter_short");
274 g_pickup_respawntimejitter_medium = cvar("g_pickup_respawntimejitter_medium");
275 g_pickup_respawntimejitter_long = cvar("g_pickup_respawntimejitter_long");
276 g_pickup_respawntimejitter_powerup = cvar("g_pickup_respawntimejitter_powerup");
278 g_weaponspeedfactor = cvar("g_weaponspeedfactor");
279 g_weaponratefactor = cvar("g_weaponratefactor");
280 g_weapondamagefactor = cvar("g_weapondamagefactor");
281 g_weaponforcefactor = cvar("g_weaponforcefactor");
282 g_weaponspreadfactor = cvar("g_weaponspreadfactor");
284 g_pickup_shells = cvar("g_pickup_shells");
285 g_pickup_shells_max = cvar("g_pickup_shells_max");
286 g_pickup_nails = cvar("g_pickup_nails");
287 g_pickup_nails_max = cvar("g_pickup_nails_max");
288 g_pickup_rockets = cvar("g_pickup_rockets");
289 g_pickup_rockets_max = cvar("g_pickup_rockets_max");
290 g_pickup_cells = cvar("g_pickup_cells");
291 g_pickup_cells_max = cvar("g_pickup_cells_max");
292 g_pickup_plasma = cvar("g_pickup_plasma");
293 g_pickup_plasma_max = cvar("g_pickup_plasma_max");
294 g_pickup_fuel = cvar("g_pickup_fuel");
295 g_pickup_fuel_jetpack = cvar("g_pickup_fuel_jetpack");
296 g_pickup_fuel_max = cvar("g_pickup_fuel_max");
297 g_pickup_armorsmall = cvar("g_pickup_armorsmall");
298 g_pickup_armorsmall_max = cvar("g_pickup_armorsmall_max");
299 g_pickup_armorsmall_anyway = cvar("g_pickup_armorsmall_anyway");
300 g_pickup_armormedium = cvar("g_pickup_armormedium");
301 g_pickup_armormedium_max = cvar("g_pickup_armormedium_max");
302 g_pickup_armormedium_anyway = cvar("g_pickup_armormedium_anyway");
303 g_pickup_armorbig = cvar("g_pickup_armorbig");
304 g_pickup_armorbig_max = cvar("g_pickup_armorbig_max");
305 g_pickup_armorbig_anyway = cvar("g_pickup_armorbig_anyway");
306 g_pickup_armormega = cvar("g_pickup_armormega");
307 g_pickup_armormega_max = cvar("g_pickup_armormega_max");
308 g_pickup_armormega_anyway = cvar("g_pickup_armormega_anyway");
309 g_pickup_healthsmall = cvar("g_pickup_healthsmall");
310 g_pickup_healthsmall_max = cvar("g_pickup_healthsmall_max");
311 g_pickup_healthsmall_anyway = cvar("g_pickup_healthsmall_anyway");
312 g_pickup_healthmedium = cvar("g_pickup_healthmedium");
313 g_pickup_healthmedium_max = cvar("g_pickup_healthmedium_max");
314 g_pickup_healthmedium_anyway = cvar("g_pickup_healthmedium_anyway");
315 g_pickup_healthbig = cvar("g_pickup_healthbig");
316 g_pickup_healthbig_max = cvar("g_pickup_healthbig_max");
317 g_pickup_healthbig_anyway = cvar("g_pickup_healthbig_anyway");
318 g_pickup_healthmega = cvar("g_pickup_healthmega");
319 g_pickup_healthmega_max = cvar("g_pickup_healthmega_max");
320 g_pickup_healthmega_anyway = cvar("g_pickup_healthmega_anyway");
322 g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway");
323 g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway");
325 g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
327 g_weapon_stay = cvar("g_weapon_stay");
329 MUTATOR_CALLHOOK(ReadLevelCvars);
332 game_starttime = time + cvar("g_start_delay");
334 FOREACH(Weapons, it != WEP_Null, LAMBDA(it.wr_init(it)));
336 readplayerstartcvars();
341 const float INITPRIO_FIRST = 0;
342 const float INITPRIO_GAMETYPE = 0;
343 const float INITPRIO_GAMETYPE_FALLBACK = 1;
344 const float INITPRIO_FINDTARGET = 10;
345 const float INITPRIO_DROPTOFLOOR = 20;
346 const float INITPRIO_SETLOCATION = 90;
347 const float INITPRIO_LINKDOORS = 91;
348 const float INITPRIO_LAST = 99;
350 .void(entity this) initialize_entity;
351 .float initialize_entity_order;
352 .entity initialize_entity_next;
353 entity initialize_entity_first;
359 float sound_allowed(float dest, entity e);
360 void InitializeEntity(entity e, void(entity this) func, float order);