]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/miscfunctions.qh
Merge branch 'master' into Mario/bulldozer
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qh
1 #ifndef MISCFUNCTIONS_H
2 #define MISCFUNCTIONS_H
3
4 #include "t_items.qh"
5
6 #include "mutators/events.qh"
7
8 #include "../common/constants.qh"
9 #include "../common/mapinfo.qh"
10 #include "../common/turrets/all.qh"
11
12 #ifdef RELEASE
13 #define cvar_string_normal builtin_cvar_string
14 #define cvar_normal builtin_cvar
15 #else
16 string cvar_string_normal(string n)
17 {
18         if (!(cvar_type(n) & CVAR_TYPEFLAG_EXISTS))
19                 backtrace(strcat("Attempt to access undefined cvar: ", n));
20         return builtin_cvar_string(n);
21 }
22
23 float cvar_normal(string n)
24 {
25         return stof(cvar_string_normal(n));
26 }
27 #endif
28 #define cvar_set_normal builtin_cvar_set
29
30 .vector dropped_origin;
31 .float nottargeted;
32
33 entity eliminatedPlayers;
34 void EliminatedPlayers_Init(float(entity) isEliminated_func);
35
36 string admin_name();
37
38 void write_recordmarker(entity pl, float tstart, float dt);
39
40 void play2all(string samp);
41
42 void play2team(float t, string filename);
43
44 void GetCvars_handleFloat(string thisname, float f, .float field, string name);
45
46 float spamsound(entity e, float chan, string samp, float vol, float _atten);
47
48 void GetCvars_handleString(string thisname, float f, .string field, string name);
49
50 void precache_all_playermodels(string pattern);
51
52 void soundat(entity e, vector o, float chan, string samp, float vol, float _atten);
53
54 void InitializeEntitiesRun();
55
56 void stopsoundto(float _dest, entity e, float chan);
57 void soundtoat(float _dest, entity e, vector o, float chan, string samp, float vol, float _atten);
58
59 void objerror(string s);
60 void droptofloor();
61 void() SUB_Remove;
62
63 void attach_sameorigin(entity e, entity to, string tag);
64
65 void crosshair_trace(entity pl);
66
67 void crosshair_trace_plusvisibletriggers(entity pl);
68
69 void detach_sameorigin(entity e);
70
71 void follow_sameorigin(entity e, entity to);
72
73 string formatmessage(string msg);
74
75 void GameLogEcho(string s);
76
77 void GameLogInit();
78
79 void GameLogClose();
80
81 void GetCvars(float f);
82
83 string GetMapname();
84
85 float isPushable(entity e);
86
87 float LostMovetypeFollow(entity ent);
88
89 string uid2name(string myuid);
90
91 float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
92
93 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
94
95 string NearestLocation(vector p);
96
97 void play2(entity e, string filename);
98
99 string playername(entity p);
100
101 void precache();
102
103 void remove_safely(entity e);
104
105 void remove_unsafely(entity e);
106
107 void SetMovetypeFollow(entity ent, entity e);
108
109 void soundto(float dest, entity e, float chan, string samp, float vol, float atten);
110
111 void stopsound(entity e, float chan);
112
113 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
114
115 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
116
117 void WarpZone_crosshair_trace(entity pl);
118
119 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
120
121
122 #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
123 #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
125 #define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return
126
127 #define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))
128
129 // copies a string to a tempstring (so one can strunzone it)
130 string strcat1(string s) = #115; // FRIK_FILE
131
132 float logfile_open;
133 float logfile;
134
135 #define strstr strstrofs
136 /*
137 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
138 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
139 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
140 // BE CONSTANT OR strzoneD!
141 float strstr(string haystack, string needle, float offset)
142 {
143         float len, endpos;
144         string found;
145         len = strlen(needle);
146         endpos = strlen(haystack) - len;
147         while(offset <= endpos)
148         {
149                 found = substring(haystack, offset, len);
150                 if(found == needle)
151                         return offset;
152                 offset = offset + 1;
153         }
154         return -1;
155 }
156 */
157
158 const float NUM_NEAREST_ENTITIES = 4;
159 entity nearest_entity[NUM_NEAREST_ENTITIES];
160 float nearest_length[NUM_NEAREST_ENTITIES];
161
162
163 //#NO AUTOCVARS START
164
165 float g_pickup_shells;
166 float g_pickup_shells_max;
167 float g_pickup_nails;
168 float g_pickup_nails_max;
169 float g_pickup_rockets;
170 float g_pickup_rockets_max;
171 float g_pickup_cells;
172 float g_pickup_cells_max;
173 float g_pickup_plasma;
174 float g_pickup_plasma_max;
175 float g_pickup_fuel;
176 float g_pickup_fuel_jetpack;
177 float g_pickup_fuel_max;
178 float g_pickup_armorsmall;
179 float g_pickup_armorsmall_max;
180 float g_pickup_armorsmall_anyway;
181 float g_pickup_armormedium;
182 float g_pickup_armormedium_max;
183 float g_pickup_armormedium_anyway;
184 float g_pickup_armorbig;
185 float g_pickup_armorbig_max;
186 float g_pickup_armorbig_anyway;
187 float g_pickup_armorlarge;
188 float g_pickup_armorlarge_max;
189 float g_pickup_armorlarge_anyway;
190 float g_pickup_healthsmall;
191 float g_pickup_healthsmall_max;
192 float g_pickup_healthsmall_anyway;
193 float g_pickup_healthmedium;
194 float g_pickup_healthmedium_max;
195 float g_pickup_healthmedium_anyway;
196 float g_pickup_healthlarge;
197 float g_pickup_healthlarge_max;
198 float g_pickup_healthlarge_anyway;
199 float g_pickup_healthmega;
200 float g_pickup_healthmega_max;
201 float g_pickup_healthmega_anyway;
202 float g_pickup_ammo_anyway;
203 float g_pickup_weapons_anyway;
204 float g_weaponarena;
205 WepSet g_weaponarena_weapons;
206 float g_weaponarena_random;
207 float g_weaponarena_random_with_blaster;
208 string g_weaponarena_list;
209 float g_weaponspeedfactor;
210 float g_weaponratefactor;
211 float g_weapondamagefactor;
212 float g_weaponforcefactor;
213 float g_weaponspreadfactor;
214
215 WepSet start_weapons;
216 WepSet start_weapons_default;
217 WepSet start_weapons_defaultmask;
218 int start_items;
219 float start_ammo_shells;
220 float start_ammo_nails;
221 float start_ammo_rockets;
222 float start_ammo_cells;
223 float start_ammo_plasma;
224 float start_ammo_fuel;
225 float start_health;
226 float start_armorvalue;
227 WepSet warmup_start_weapons;
228 WepSet warmup_start_weapons_default;
229 WepSet warmup_start_weapons_defaultmask;
230 #define WARMUP_START_WEAPONS ((g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)
231 float warmup_start_ammo_shells;
232 float warmup_start_ammo_nails;
233 float warmup_start_ammo_rockets;
234 float warmup_start_ammo_cells;
235 float warmup_start_ammo_plasma;
236 float warmup_start_ammo_fuel;
237 float warmup_start_health;
238 float warmup_start_armorvalue;
239 float g_weapon_stay;
240
241 float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done?
242 void readplayerstartcvars();
243
244 float g_bugrigs;
245 float g_bugrigs_planar_movement;
246 float g_bugrigs_planar_movement_car_jumping;
247 float g_bugrigs_reverse_spinning;
248 float g_bugrigs_reverse_speeding;
249 float g_bugrigs_reverse_stopping;
250 float g_bugrigs_air_steering;
251 float g_bugrigs_angle_smoothing;
252 float g_bugrigs_friction_floor;
253 float g_bugrigs_friction_brake;
254 float g_bugrigs_friction_air;
255 float g_bugrigs_accel;
256 float g_bugrigs_speed_ref;
257 float g_bugrigs_speed_pow;
258 float g_bugrigs_steer;
259
260 float sv_autotaunt;
261 float sv_taunt;
262
263 string GetGametype(); // g_world.qc
264 void readlevelcvars()
265 {
266         if(cvar("sv_allow_fullbright"))
267                 serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
268
269     g_bugrigs = cvar("g_bugrigs");
270     g_bugrigs_planar_movement = cvar("g_bugrigs_planar_movement");
271     g_bugrigs_planar_movement_car_jumping = cvar("g_bugrigs_planar_movement_car_jumping");
272     g_bugrigs_reverse_spinning = cvar("g_bugrigs_reverse_spinning");
273     g_bugrigs_reverse_speeding = cvar("g_bugrigs_reverse_speeding");
274     g_bugrigs_reverse_stopping = cvar("g_bugrigs_reverse_stopping");
275     g_bugrigs_air_steering = cvar("g_bugrigs_air_steering");
276     g_bugrigs_angle_smoothing = cvar("g_bugrigs_angle_smoothing");
277     g_bugrigs_friction_floor = cvar("g_bugrigs_friction_floor");
278     g_bugrigs_friction_brake = cvar("g_bugrigs_friction_brake");
279     g_bugrigs_friction_air = cvar("g_bugrigs_friction_air");
280     g_bugrigs_accel = cvar("g_bugrigs_accel");
281     g_bugrigs_speed_ref = cvar("g_bugrigs_speed_ref");
282     g_bugrigs_speed_pow = cvar("g_bugrigs_speed_pow");
283     g_bugrigs_steer = cvar("g_bugrigs_steer");
284
285         g_instagib = cvar("g_instagib");
286
287         sv_clones = cvar("sv_clones");
288         sv_foginterval = cvar("sv_foginterval");
289         g_footsteps = cvar("g_footsteps");
290         g_jetpack = cvar("g_jetpack");
291         sv_maxidle = cvar("sv_maxidle");
292         sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
293         sv_autotaunt = cvar("sv_autotaunt");
294         sv_taunt = cvar("sv_taunt");
295
296         warmup_stage = cvar("g_warmup");
297         g_warmup_limit = cvar("g_warmup_limit");
298         g_warmup_allguns = cvar("g_warmup_allguns");
299         g_warmup_allow_timeout = cvar("g_warmup_allow_timeout");
300
301         if(cvar("g_campaign"))
302                 warmup_stage = 0; // no warmup during campaign
303
304         g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon");
305         g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon");
306         g_pickup_respawntime_ammo = cvar("g_pickup_respawntime_ammo");
307         g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
308         g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
309         g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
310         g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
311         g_pickup_respawntimejitter_weapon = cvar("g_pickup_respawntimejitter_weapon");
312         g_pickup_respawntimejitter_superweapon = cvar("g_pickup_respawntimejitter_superweapon");
313         g_pickup_respawntimejitter_ammo = cvar("g_pickup_respawntimejitter_ammo");
314         g_pickup_respawntimejitter_short = cvar("g_pickup_respawntimejitter_short");
315         g_pickup_respawntimejitter_medium = cvar("g_pickup_respawntimejitter_medium");
316         g_pickup_respawntimejitter_long = cvar("g_pickup_respawntimejitter_long");
317         g_pickup_respawntimejitter_powerup = cvar("g_pickup_respawntimejitter_powerup");
318
319         g_weaponspeedfactor = cvar("g_weaponspeedfactor");
320         g_weaponratefactor = cvar("g_weaponratefactor");
321         g_weapondamagefactor = cvar("g_weapondamagefactor");
322         g_weaponforcefactor = cvar("g_weaponforcefactor");
323         g_weaponspreadfactor = cvar("g_weaponspreadfactor");
324
325         g_pickup_shells = cvar("g_pickup_shells");
326         g_pickup_shells_max = cvar("g_pickup_shells_max");
327         g_pickup_nails = cvar("g_pickup_nails");
328         g_pickup_nails_max = cvar("g_pickup_nails_max");
329         g_pickup_rockets = cvar("g_pickup_rockets");
330         g_pickup_rockets_max = cvar("g_pickup_rockets_max");
331         g_pickup_cells = cvar("g_pickup_cells");
332         g_pickup_cells_max = cvar("g_pickup_cells_max");
333         g_pickup_plasma = cvar("g_pickup_plasma");
334         g_pickup_plasma_max = cvar("g_pickup_plasma_max");
335         g_pickup_fuel = cvar("g_pickup_fuel");
336         g_pickup_fuel_jetpack = cvar("g_pickup_fuel_jetpack");
337         g_pickup_fuel_max = cvar("g_pickup_fuel_max");
338         g_pickup_armorsmall = cvar("g_pickup_armorsmall");
339         g_pickup_armorsmall_max = cvar("g_pickup_armorsmall_max");
340         g_pickup_armorsmall_anyway = cvar("g_pickup_armorsmall_anyway");
341         g_pickup_armormedium = cvar("g_pickup_armormedium");
342         g_pickup_armormedium_max = cvar("g_pickup_armormedium_max");
343         g_pickup_armormedium_anyway = cvar("g_pickup_armormedium_anyway");
344         g_pickup_armorbig = cvar("g_pickup_armorbig");
345         g_pickup_armorbig_max = cvar("g_pickup_armorbig_max");
346         g_pickup_armorbig_anyway = cvar("g_pickup_armorbig_anyway");
347         g_pickup_armorlarge = cvar("g_pickup_armorlarge");
348         g_pickup_armorlarge_max = cvar("g_pickup_armorlarge_max");
349         g_pickup_armorlarge_anyway = cvar("g_pickup_armorlarge_anyway");
350         g_pickup_healthsmall = cvar("g_pickup_healthsmall");
351         g_pickup_healthsmall_max = cvar("g_pickup_healthsmall_max");
352         g_pickup_healthsmall_anyway = cvar("g_pickup_healthsmall_anyway");
353         g_pickup_healthmedium = cvar("g_pickup_healthmedium");
354         g_pickup_healthmedium_max = cvar("g_pickup_healthmedium_max");
355         g_pickup_healthmedium_anyway = cvar("g_pickup_healthmedium_anyway");
356         g_pickup_healthlarge = cvar("g_pickup_healthlarge");
357         g_pickup_healthlarge_max = cvar("g_pickup_healthlarge_max");
358         g_pickup_healthlarge_anyway = cvar("g_pickup_healthlarge_anyway");
359         g_pickup_healthmega = cvar("g_pickup_healthmega");
360         g_pickup_healthmega_max = cvar("g_pickup_healthmega_max");
361         g_pickup_healthmega_anyway = cvar("g_pickup_healthmega_anyway");
362
363         g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway");
364         g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway");
365
366     g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
367     if(!g_weapon_stay)
368         g_weapon_stay = cvar("g_weapon_stay");
369
370     MUTATOR_CALLHOOK(ReadLevelCvars);
371
372         if (!warmup_stage)
373                 game_starttime = time + cvar("g_start_delay");
374
375         for(int i = WEP_FIRST; i <= WEP_LAST; ++i) {
376                 Weapon w = get_weaponinfo(i);
377                 w.wr_init(w);
378         }
379
380         readplayerstartcvars();
381 }
382
383 //#NO AUTOCVARS END
384
385 const float INITPRIO_FIRST                              = 0;
386 const float INITPRIO_GAMETYPE                   = 0;
387 const float INITPRIO_GAMETYPE_FALLBACK  = 1;
388 const float INITPRIO_FINDTARGET                 = 10;
389 const float INITPRIO_DROPTOFLOOR                = 20;
390 const float INITPRIO_SETLOCATION                = 90;
391 const float INITPRIO_LINKDOORS                  = 91;
392 const float INITPRIO_LAST                               = 99;
393
394 .void() initialize_entity;
395 .float initialize_entity_order;
396 .entity initialize_entity_next;
397 entity initialize_entity_first;
398
399
400
401
402
403 float sound_allowed(float dest, entity e);
404 void InitializeEntity(entity e, void() func, float order);
405 void SetCustomizer(entity e, float() customizer, void() uncustomizer);
406
407 #endif