]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/miscfunctions.qh
Merge branch 'terencehill/menu_fixes' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qh
1 #ifndef MISCFUNCTIONS_H
2 #define MISCFUNCTIONS_H
3
4 #include "../common/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
62 void attach_sameorigin(entity e, entity to, string tag);
63
64 void crosshair_trace(entity pl);
65
66 void crosshair_trace_plusvisibletriggers(entity pl);
67
68 void detach_sameorigin(entity e);
69
70 void follow_sameorigin(entity e, entity to);
71
72 string formatmessage(string msg);
73
74 void GameLogEcho(string s);
75
76 void GameLogInit();
77
78 void GameLogClose();
79
80 void GetCvars(float f);
81
82 string GetMapname();
83
84 float isPushable(entity e);
85
86 float LostMovetypeFollow(entity ent);
87
88 string uid2name(string myuid);
89
90 float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
91
92 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
93
94 string NearestLocation(vector p);
95
96 void play2(entity e, string filename);
97
98 string playername(entity p);
99
100 void precache();
101
102 void remove_safely(entity e);
103
104 void remove_unsafely(entity e);
105
106 void SetMovetypeFollow(entity ent, entity e);
107
108 void soundto(float dest, entity e, float chan, string samp, float vol, float atten);
109
110 void stopsound(entity e, float chan);
111
112 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
113
114 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
115
116 void WarpZone_crosshair_trace(entity pl);
117
118 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
119
120 #define IS_DEAD(s) ((s).deadflag != DEAD_NO)
121
122
123 #define ITEM_TOUCH_NEEDKILL() (((trace_dpstartcontents | trace_dphitcontents) & DPCONTENTS_NODROP) || (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
124 #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))
125
126 #define PROJECTILE_TOUCH if(WarpZone_Projectile_Touch()) return
127
128 #define CENTER_OR_VIEWOFS(ent) (ent.origin + (IS_PLAYER(ent) ? ent.view_ofs : ((ent.mins + ent.maxs) * 0.5)))
129
130 // copies a string to a tempstring (so one can strunzone it)
131 string strcat1(string s) = #115; // FRIK_FILE
132
133 float logfile_open;
134 float logfile;
135
136 #define strstr strstrofs
137 /*
138 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
139 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
140 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
141 // BE CONSTANT OR strzoneD!
142 float strstr(string haystack, string needle, float offset)
143 {
144         float len, endpos;
145         string found;
146         len = strlen(needle);
147         endpos = strlen(haystack) - len;
148         while(offset <= endpos)
149         {
150                 found = substring(haystack, offset, len);
151                 if(found == needle)
152                         return offset;
153                 offset = offset + 1;
154         }
155         return -1;
156 }
157 */
158
159 const float NUM_NEAREST_ENTITIES = 4;
160 entity nearest_entity[NUM_NEAREST_ENTITIES];
161 float nearest_length[NUM_NEAREST_ENTITIES];
162
163
164 //#NO AUTOCVARS START
165
166 float g_pickup_shells;
167 float g_pickup_shells_max;
168 float g_pickup_nails;
169 float g_pickup_nails_max;
170 float g_pickup_rockets;
171 float g_pickup_rockets_max;
172 float g_pickup_cells;
173 float g_pickup_cells_max;
174 float g_pickup_plasma;
175 float g_pickup_plasma_max;
176 float g_pickup_fuel;
177 float g_pickup_fuel_jetpack;
178 float g_pickup_fuel_max;
179 float g_pickup_armorsmall;
180 float g_pickup_armorsmall_max;
181 float g_pickup_armorsmall_anyway;
182 float g_pickup_armormedium;
183 float g_pickup_armormedium_max;
184 float g_pickup_armormedium_anyway;
185 float g_pickup_armorbig;
186 float g_pickup_armorbig_max;
187 float g_pickup_armorbig_anyway;
188 float g_pickup_armorlarge;
189 float g_pickup_armorlarge_max;
190 float g_pickup_armorlarge_anyway;
191 float g_pickup_healthsmall;
192 float g_pickup_healthsmall_max;
193 float g_pickup_healthsmall_anyway;
194 float g_pickup_healthmedium;
195 float g_pickup_healthmedium_max;
196 float g_pickup_healthmedium_anyway;
197 float g_pickup_healthlarge;
198 float g_pickup_healthlarge_max;
199 float g_pickup_healthlarge_anyway;
200 float g_pickup_healthmega;
201 float g_pickup_healthmega_max;
202 float g_pickup_healthmega_anyway;
203 float g_pickup_ammo_anyway;
204 float g_pickup_weapons_anyway;
205 float g_weaponarena;
206 WepSet g_weaponarena_weapons;
207 float g_weaponarena_random;
208 float g_weaponarena_random_with_blaster;
209 string g_weaponarena_list;
210 float g_weaponspeedfactor;
211 float g_weaponratefactor;
212 float g_weapondamagefactor;
213 float g_weaponforcefactor;
214 float g_weaponspreadfactor;
215
216 WepSet start_weapons;
217 WepSet start_weapons_default;
218 WepSet start_weapons_defaultmask;
219 int start_items;
220 float start_ammo_shells;
221 float start_ammo_nails;
222 float start_ammo_rockets;
223 float start_ammo_cells;
224 float start_ammo_plasma;
225 float start_ammo_fuel;
226 float start_health;
227 float start_armorvalue;
228 WepSet warmup_start_weapons;
229 WepSet warmup_start_weapons_default;
230 WepSet warmup_start_weapons_defaultmask;
231 #define WARMUP_START_WEAPONS ((g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)
232 float warmup_start_ammo_shells;
233 float warmup_start_ammo_nails;
234 float warmup_start_ammo_rockets;
235 float warmup_start_ammo_cells;
236 float warmup_start_ammo_plasma;
237 float warmup_start_ammo_fuel;
238 float warmup_start_health;
239 float warmup_start_armorvalue;
240 float g_weapon_stay;
241
242 float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done?
243 void readplayerstartcvars();
244
245 float sv_autotaunt;
246 float sv_taunt;
247
248 string GetGametype(); // g_world.qc
249 void readlevelcvars()
250 {
251         if(cvar("sv_allow_fullbright"))
252                 serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
253
254         g_instagib = cvar("g_instagib");
255
256         sv_clones = cvar("sv_clones");
257         sv_foginterval = cvar("sv_foginterval");
258         g_footsteps = cvar("g_footsteps");
259         g_jetpack = cvar("g_jetpack");
260         sv_maxidle = cvar("sv_maxidle");
261         sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
262         sv_autotaunt = cvar("sv_autotaunt");
263         sv_taunt = cvar("sv_taunt");
264
265         warmup_stage = cvar("g_warmup");
266         g_warmup_limit = cvar("g_warmup_limit");
267         g_warmup_allguns = cvar("g_warmup_allguns");
268         g_warmup_allow_timeout = cvar("g_warmup_allow_timeout");
269
270         if(cvar("g_campaign"))
271                 warmup_stage = 0; // no warmup during campaign
272
273         g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon");
274         g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon");
275         g_pickup_respawntime_ammo = cvar("g_pickup_respawntime_ammo");
276         g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
277         g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
278         g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
279         g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
280         g_pickup_respawntimejitter_weapon = cvar("g_pickup_respawntimejitter_weapon");
281         g_pickup_respawntimejitter_superweapon = cvar("g_pickup_respawntimejitter_superweapon");
282         g_pickup_respawntimejitter_ammo = cvar("g_pickup_respawntimejitter_ammo");
283         g_pickup_respawntimejitter_short = cvar("g_pickup_respawntimejitter_short");
284         g_pickup_respawntimejitter_medium = cvar("g_pickup_respawntimejitter_medium");
285         g_pickup_respawntimejitter_long = cvar("g_pickup_respawntimejitter_long");
286         g_pickup_respawntimejitter_powerup = cvar("g_pickup_respawntimejitter_powerup");
287
288         g_weaponspeedfactor = cvar("g_weaponspeedfactor");
289         g_weaponratefactor = cvar("g_weaponratefactor");
290         g_weapondamagefactor = cvar("g_weapondamagefactor");
291         g_weaponforcefactor = cvar("g_weaponforcefactor");
292         g_weaponspreadfactor = cvar("g_weaponspreadfactor");
293
294         g_pickup_shells = cvar("g_pickup_shells");
295         g_pickup_shells_max = cvar("g_pickup_shells_max");
296         g_pickup_nails = cvar("g_pickup_nails");
297         g_pickup_nails_max = cvar("g_pickup_nails_max");
298         g_pickup_rockets = cvar("g_pickup_rockets");
299         g_pickup_rockets_max = cvar("g_pickup_rockets_max");
300         g_pickup_cells = cvar("g_pickup_cells");
301         g_pickup_cells_max = cvar("g_pickup_cells_max");
302         g_pickup_plasma = cvar("g_pickup_plasma");
303         g_pickup_plasma_max = cvar("g_pickup_plasma_max");
304         g_pickup_fuel = cvar("g_pickup_fuel");
305         g_pickup_fuel_jetpack = cvar("g_pickup_fuel_jetpack");
306         g_pickup_fuel_max = cvar("g_pickup_fuel_max");
307         g_pickup_armorsmall = cvar("g_pickup_armorsmall");
308         g_pickup_armorsmall_max = cvar("g_pickup_armorsmall_max");
309         g_pickup_armorsmall_anyway = cvar("g_pickup_armorsmall_anyway");
310         g_pickup_armormedium = cvar("g_pickup_armormedium");
311         g_pickup_armormedium_max = cvar("g_pickup_armormedium_max");
312         g_pickup_armormedium_anyway = cvar("g_pickup_armormedium_anyway");
313         g_pickup_armorbig = cvar("g_pickup_armorbig");
314         g_pickup_armorbig_max = cvar("g_pickup_armorbig_max");
315         g_pickup_armorbig_anyway = cvar("g_pickup_armorbig_anyway");
316         g_pickup_armorlarge = cvar("g_pickup_armorlarge");
317         g_pickup_armorlarge_max = cvar("g_pickup_armorlarge_max");
318         g_pickup_armorlarge_anyway = cvar("g_pickup_armorlarge_anyway");
319         g_pickup_healthsmall = cvar("g_pickup_healthsmall");
320         g_pickup_healthsmall_max = cvar("g_pickup_healthsmall_max");
321         g_pickup_healthsmall_anyway = cvar("g_pickup_healthsmall_anyway");
322         g_pickup_healthmedium = cvar("g_pickup_healthmedium");
323         g_pickup_healthmedium_max = cvar("g_pickup_healthmedium_max");
324         g_pickup_healthmedium_anyway = cvar("g_pickup_healthmedium_anyway");
325         g_pickup_healthlarge = cvar("g_pickup_healthlarge");
326         g_pickup_healthlarge_max = cvar("g_pickup_healthlarge_max");
327         g_pickup_healthlarge_anyway = cvar("g_pickup_healthlarge_anyway");
328         g_pickup_healthmega = cvar("g_pickup_healthmega");
329         g_pickup_healthmega_max = cvar("g_pickup_healthmega_max");
330         g_pickup_healthmega_anyway = cvar("g_pickup_healthmega_anyway");
331
332         g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway");
333         g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway");
334
335     g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
336     if(!g_weapon_stay)
337         g_weapon_stay = cvar("g_weapon_stay");
338
339     MUTATOR_CALLHOOK(ReadLevelCvars);
340
341         if (!warmup_stage)
342                 game_starttime = time + cvar("g_start_delay");
343
344         FOREACH(Weapons, it != WEP_Null, LAMBDA(it.wr_init(it)));
345
346         readplayerstartcvars();
347 }
348
349 //#NO AUTOCVARS END
350
351 const float INITPRIO_FIRST                              = 0;
352 const float INITPRIO_GAMETYPE                   = 0;
353 const float INITPRIO_GAMETYPE_FALLBACK  = 1;
354 const float INITPRIO_FINDTARGET                 = 10;
355 const float INITPRIO_DROPTOFLOOR                = 20;
356 const float INITPRIO_SETLOCATION                = 90;
357 const float INITPRIO_LINKDOORS                  = 91;
358 const float INITPRIO_LAST                               = 99;
359
360 .void() initialize_entity;
361 .float initialize_entity_order;
362 .entity initialize_entity_next;
363 entity initialize_entity_first;
364
365
366
367
368
369 float sound_allowed(float dest, entity e);
370 void InitializeEntity(entity e, void() func, float order);
371 void SetCustomizer(entity e, float() customizer, void() uncustomizer);
372
373 #endif