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