3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5 #include <server/client.qh>
6 #include <server/world.qh>
8 #include <server/items/items.qh>
10 #include <server/mutators/_mod.qh>
12 #include <common/constants.qh>
13 #include <common/mapinfo.qh>
14 #include <common/turrets/all.qh>
16 .vector dropped_origin;
18 entity eliminatedPlayers;
19 void EliminatedPlayers_Init(float(entity) isEliminated_func);
21 void write_recordmarker(entity pl, float tstart, float dt);
23 void play2all(string samp);
25 void play2team(float t, string filename);
27 void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .float field, string name);
29 float spamsound(entity e, float chan, Sound samp, float vol, float _atten);
31 void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name);
33 void precache_all_playermodels(string pattern);
35 void soundat(entity e, vector o, float chan, string samp, float vol, float _atten);
37 void InitializeEntitiesRun();
39 void stopsoundto(float _dest, entity e, float chan);
40 void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten, float _pitch);
42 void droptofloor(entity this);
44 float trace_hits_box_1d(float end, float thmi, float thma);
46 float trace_hits_box(vector start, vector end, vector thmi, vector thma);
48 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
50 void attach_sameorigin(entity e, entity to, string tag);
52 void crosshair_trace(entity pl);
54 void crosshair_trace_plusvisibletriggers(entity pl);
55 void WarpZone_crosshair_trace_plusvisibletriggers(entity pl);
56 void crosshair_trace_plusvisibletriggers__is_wz(entity pl, bool is_wz);
58 void detach_sameorigin(entity e);
60 void follow_sameorigin(entity e, entity to);
62 string formatmessage(entity this, string msg);
64 /** print(), but only print if the server is not local */
65 void dedicated_print(string input);
67 void GetCvars(entity this, entity store, int f);
71 float isPushable(entity e);
73 float LostMovetypeFollow(entity ent);
75 string uid2name(string myuid);
77 bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance);
79 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
81 string NearestLocation(vector p);
83 void play2(entity e, string filename);
85 string playername(entity p, bool team_colorize);
87 void remove_safely(entity e);
89 void remove_unsafely(entity e);
91 void SetMovetypeFollow(entity ent, entity e);
93 void soundto(float dest, entity e, float chan, string samp, float vol, float atten, float _pitch);
95 void stopsound(entity e, float chan);
97 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
99 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
101 void WarpZone_crosshair_trace(entity pl);
103 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
105 #define IS_DEAD(s) ((s).deadflag != DEAD_NO)
108 #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
109 #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))
111 #define PROJECTILE_TOUCH(e,t) MACRO_BEGIN if (WarpZone_Projectile_Touch(e,t)) return; MACRO_END
113 #define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))
115 // copies a string to a tempstring (so one can strunzone it)
116 string strcat1(string s) = #115; // FRIK_FILE
119 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
120 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
121 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
122 // BE CONSTANT OR strzoneD!
123 float strstrofs(string haystack, string needle, float offset)
127 len = strlen(needle);
128 endpos = strlen(haystack) - len;
129 while(offset <= endpos)
131 found = substring(haystack, offset, len);
140 const float NUM_NEAREST_ENTITIES = 4;
141 entity nearest_entity[NUM_NEAREST_ENTITIES];
142 float nearest_length[NUM_NEAREST_ENTITIES];
145 //#NO AUTOCVARS START
147 float g_pickup_shells_max;
148 float g_pickup_nails_max;
149 float g_pickup_rockets_max;
150 float g_pickup_cells_max;
151 float g_pickup_plasma_max;
152 float g_pickup_fuel_max;
153 float g_pickup_weapons_anyway;
155 WepSet g_weaponarena_weapons;
156 float g_weaponarena_random; // TODO
157 string g_weaponarena_list;
158 float g_weaponspeedfactor;
159 float g_weaponratefactor;
160 float g_weapondamagefactor;
161 float g_weaponforcefactor;
162 float g_weaponspreadfactor;
164 WepSet start_weapons;
165 WepSet start_weapons_default;
166 WepSet start_weapons_defaultmask;
168 float start_ammo_shells;
169 float start_ammo_nails;
170 float start_ammo_rockets;
171 float start_ammo_cells;
172 float start_ammo_plasma;
173 float start_ammo_fuel;
174 /// \brief Number of random start weapons to give to players.
175 int random_start_weapons_count;
176 /// \brief Holds a list of possible random start weapons.
177 string autocvar_g_random_start_weapons;
178 /// \brief Entity that contains amount of ammo to give with random start
180 entity random_start_ammo;
182 float start_armorvalue;
183 WepSet warmup_start_weapons;
184 WepSet warmup_start_weapons_default;
185 WepSet warmup_start_weapons_defaultmask;
186 #define WARMUP_START_WEAPONS ((g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)
187 float warmup_start_ammo_shells;
188 float warmup_start_ammo_nails;
189 float warmup_start_ammo_rockets;
190 float warmup_start_ammo_cells;
191 float warmup_start_ammo_plasma;
192 float warmup_start_ammo_fuel;
193 float warmup_start_health;
194 float warmup_start_armorvalue;
197 float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done?
198 void readplayerstartcvars();
203 float g_footsteps, g_grappling_hook;
204 float g_warmup_allguns;
205 float g_warmup_allow_timeout;
209 bool sv_ready_restart;
210 bool sv_ready_restart_after_countdown;
211 bool sv_ready_restart_repeatable;
214 float sv_foginterval;
216 void readlevelcvars()
218 if(cvar("sv_allow_fullbright"))
219 serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
221 sv_clones = cvar("sv_clones");
222 sv_foginterval = cvar("sv_foginterval");
223 g_footsteps = cvar("g_footsteps");
224 g_jetpack = cvar("g_jetpack");
225 sv_maxidle = cvar("sv_maxidle");
226 sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
227 sv_maxidle_slots = cvar("sv_maxidle_slots");
228 sv_maxidle_slots_countbots = cvar("sv_maxidle_slots_countbots");
229 sv_autotaunt = cvar("sv_autotaunt");
230 sv_taunt = cvar("sv_taunt");
231 sv_ready_restart = cvar("sv_ready_restart");
232 sv_ready_restart_after_countdown = cvar("sv_ready_restart_after_countdown");
233 sv_ready_restart_repeatable = cvar("sv_ready_restart_repeatable");
235 warmup_stage = cvar("g_warmup");
236 warmup_limit = cvar("g_warmup_limit");
237 g_warmup_allguns = cvar("g_warmup_allguns");
238 g_warmup_allow_timeout = cvar("g_warmup_allow_timeout");
240 if(cvar("g_campaign"))
241 warmup_stage = 0; // no warmup during campaign
243 g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon");
244 g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon");
245 g_pickup_respawntime_ammo = cvar("g_pickup_respawntime_ammo");
246 g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
247 g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
248 g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
249 g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
250 g_pickup_respawntimejitter_weapon = cvar("g_pickup_respawntimejitter_weapon");
251 g_pickup_respawntimejitter_superweapon = cvar("g_pickup_respawntimejitter_superweapon");
252 g_pickup_respawntimejitter_ammo = cvar("g_pickup_respawntimejitter_ammo");
253 g_pickup_respawntimejitter_short = cvar("g_pickup_respawntimejitter_short");
254 g_pickup_respawntimejitter_medium = cvar("g_pickup_respawntimejitter_medium");
255 g_pickup_respawntimejitter_long = cvar("g_pickup_respawntimejitter_long");
256 g_pickup_respawntimejitter_powerup = cvar("g_pickup_respawntimejitter_powerup");
258 g_weaponspeedfactor = cvar("g_weaponspeedfactor");
259 g_weaponratefactor = cvar("g_weaponratefactor");
260 g_weapondamagefactor = cvar("g_weapondamagefactor");
261 g_weaponforcefactor = cvar("g_weaponforcefactor");
262 g_weaponspreadfactor = cvar("g_weaponspreadfactor");
264 g_pickup_shells = cvar("g_pickup_shells");
265 g_pickup_shells_max = cvar("g_pickup_shells_max");
266 g_pickup_nails = cvar("g_pickup_nails");
267 g_pickup_nails_max = cvar("g_pickup_nails_max");
268 g_pickup_rockets = cvar("g_pickup_rockets");
269 g_pickup_rockets_max = cvar("g_pickup_rockets_max");
270 g_pickup_cells = cvar("g_pickup_cells");
271 g_pickup_cells_max = cvar("g_pickup_cells_max");
272 g_pickup_plasma = cvar("g_pickup_plasma");
273 g_pickup_plasma_max = cvar("g_pickup_plasma_max");
274 g_pickup_fuel = cvar("g_pickup_fuel");
275 g_pickup_fuel_jetpack = cvar("g_pickup_fuel_jetpack");
276 g_pickup_fuel_max = cvar("g_pickup_fuel_max");
277 g_pickup_armorsmall = cvar("g_pickup_armorsmall");
278 g_pickup_armorsmall_max = cvar("g_pickup_armorsmall_max");
279 g_pickup_armorsmall_anyway = cvar("g_pickup_armorsmall_anyway");
280 g_pickup_armormedium = cvar("g_pickup_armormedium");
281 g_pickup_armormedium_max = cvar("g_pickup_armormedium_max");
282 g_pickup_armormedium_anyway = cvar("g_pickup_armormedium_anyway");
283 g_pickup_armorbig = cvar("g_pickup_armorbig");
284 g_pickup_armorbig_max = cvar("g_pickup_armorbig_max");
285 g_pickup_armorbig_anyway = cvar("g_pickup_armorbig_anyway");
286 g_pickup_armormega = cvar("g_pickup_armormega");
287 g_pickup_armormega_max = cvar("g_pickup_armormega_max");
288 g_pickup_armormega_anyway = cvar("g_pickup_armormega_anyway");
289 g_pickup_healthsmall = cvar("g_pickup_healthsmall");
290 g_pickup_healthsmall_max = cvar("g_pickup_healthsmall_max");
291 g_pickup_healthsmall_anyway = cvar("g_pickup_healthsmall_anyway");
292 g_pickup_healthmedium = cvar("g_pickup_healthmedium");
293 g_pickup_healthmedium_max = cvar("g_pickup_healthmedium_max");
294 g_pickup_healthmedium_anyway = cvar("g_pickup_healthmedium_anyway");
295 g_pickup_healthbig = cvar("g_pickup_healthbig");
296 g_pickup_healthbig_max = cvar("g_pickup_healthbig_max");
297 g_pickup_healthbig_anyway = cvar("g_pickup_healthbig_anyway");
298 g_pickup_healthmega = cvar("g_pickup_healthmega");
299 g_pickup_healthmega_max = cvar("g_pickup_healthmega_max");
300 g_pickup_healthmega_anyway = cvar("g_pickup_healthmega_anyway");
302 g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway");
303 g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway");
305 g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
307 g_weapon_stay = cvar("g_weapon_stay");
309 MUTATOR_CALLHOOK(ReadLevelCvars);
312 game_starttime = time + cvar("g_start_delay");
314 FOREACH(Weapons, it != WEP_Null, { it.wr_init(it); });
316 readplayerstartcvars();
321 const int INITPRIO_FIRST = 0;
322 const int INITPRIO_GAMETYPE = 0;
323 const int INITPRIO_GAMETYPE_FALLBACK = 1;
324 const int INITPRIO_FINDTARGET = 10;
325 const int INITPRIO_DROPTOFLOOR = 20;
326 const int INITPRIO_SETLOCATION = 90;
327 const int INITPRIO_LINKDOORS = 91;
328 const int INITPRIO_LAST = 99;
330 .void(entity this) initialize_entity;
331 .int initialize_entity_order;
332 .entity initialize_entity_next;
333 entity initialize_entity_first;
339 bool sound_allowed(int dest, entity e);
340 void InitializeEntity(entity e, void(entity this) func, int order);
342 IntrusiveList g_ctrace_changed;
343 STATIC_INIT(g_ctrace_changed) { g_ctrace_changed = IL_NEW(); }