]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/miscfunctions.qh
87b02725ba07a998512b0022f3846d1b5df48647
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qh
1 #pragma once
2
3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5 #include <server/client.qh>
6 #include <server/world.qh>
7
8 #include <server/intermission.qh>
9 #include <server/items/items.qh>
10
11 #include <server/mutators/_mod.qh>
12
13 #include <common/constants.qh>
14 #include <common/mapinfo.qh>
15 #include <common/turrets/all.qh>
16
17 .vector dropped_origin;
18
19 void write_recordmarker(entity pl, float tstart, float dt);
20
21 void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .float field, string name);
22
23 void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name);
24
25 void precache_all_playermodels(string pattern);
26
27 void InitializeEntitiesRun();
28
29 void droptofloor(entity this);
30
31 float trace_hits_box_1d(float end, float thmi, float thma);
32
33 float trace_hits_box(vector start, vector end, vector thmi, vector thma);
34
35 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
36
37 void attach_sameorigin(entity e, entity to, string tag);
38
39 void crosshair_trace(entity pl);
40
41 void crosshair_trace_plusvisibletriggers(entity pl);
42 void WarpZone_crosshair_trace_plusvisibletriggers(entity pl);
43 void crosshair_trace_plusvisibletriggers__is_wz(entity pl, bool is_wz);
44
45 void detach_sameorigin(entity e);
46
47 void follow_sameorigin(entity e, entity to);
48
49 void GetCvars(entity this, entity store, int f);
50
51 float LostMovetypeFollow(entity ent);
52
53 string uid2name(string myuid);
54
55 bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance);
56
57 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance);
58
59 string playername(entity p, bool team_colorize);
60
61 void SetMovetypeFollow(entity ent, entity e);
62
63 float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
64
65 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
66
67 void WarpZone_crosshair_trace(entity pl);
68
69 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
70
71 #define PROJECTILE_TOUCH(e,t) MACRO_BEGIN if (WarpZone_Projectile_Touch(e,t)) return; MACRO_END
72
73 // copies a string to a tempstring (so one can strunzone it)
74 string strcat1(string s) = #115; // FRIK_FILE
75
76
77 //#NO AUTOCVARS START
78
79 float g_pickup_shells_max;
80 float g_pickup_nails_max;
81 float g_pickup_rockets_max;
82 float g_pickup_cells_max;
83 float g_pickup_plasma_max;
84 float g_pickup_fuel_max;
85 float g_pickup_weapons_anyway;
86 float g_weaponarena;
87 WepSet g_weaponarena_weapons;
88 float g_weaponarena_random; // TODO
89 string g_weaponarena_list;
90
91 WepSet start_weapons;
92 WepSet start_weapons_default;
93 WepSet start_weapons_defaultmask;
94 int start_items;
95 float start_ammo_shells;
96 float start_ammo_nails;
97 float start_ammo_rockets;
98 float start_ammo_cells;
99 float start_ammo_plasma;
100 float start_ammo_fuel;
101 /// \brief Number of random start weapons to give to players.
102 int random_start_weapons_count;
103 /// \brief Holds a list of possible random start weapons.
104 string autocvar_g_random_start_weapons;
105 /// \brief Entity that contains amount of ammo to give with random start
106 /// weapons.
107 entity random_start_ammo;
108 float start_health;
109 float start_armorvalue;
110 WepSet warmup_start_weapons;
111 WepSet warmup_start_weapons_default;
112 WepSet warmup_start_weapons_defaultmask;
113 #define WARMUP_START_WEAPONS ((autocvar_g_warmup_allguns == 1) ? (warmup_start_weapons & (weaponsInMap | start_weapons)) : warmup_start_weapons)
114 float warmup_start_ammo_shells;
115 float warmup_start_ammo_nails;
116 float warmup_start_ammo_rockets;
117 float warmup_start_ammo_cells;
118 float warmup_start_ammo_plasma;
119 float warmup_start_ammo_fuel;
120 float warmup_start_health;
121 float warmup_start_armorvalue;
122 float g_weapon_stay;
123
124 float want_weapon(entity weaponinfo, float allguns); // WEAPONTODO: what still needs done?
125 void readplayerstartcvars();
126
127 float g_grappling_hook;
128 float warmup_stage;
129
130 bool sv_ready_restart_after_countdown;
131
132 void readlevelcvars()
133 {
134         if(cvar("sv_allow_fullbright"))
135                 serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
136
137         sv_ready_restart_after_countdown = cvar("sv_ready_restart_after_countdown");
138
139         warmup_stage = cvar("g_warmup");
140         warmup_limit = cvar("g_warmup_limit");
141
142         if(cvar("g_campaign"))
143                 warmup_stage = 0; // no warmup during campaign
144
145         g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon");
146         g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon");
147         g_pickup_respawntime_ammo = cvar("g_pickup_respawntime_ammo");
148         g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
149         g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
150         g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
151         g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
152         g_pickup_respawntimejitter_weapon = cvar("g_pickup_respawntimejitter_weapon");
153         g_pickup_respawntimejitter_superweapon = cvar("g_pickup_respawntimejitter_superweapon");
154         g_pickup_respawntimejitter_ammo = cvar("g_pickup_respawntimejitter_ammo");
155         g_pickup_respawntimejitter_short = cvar("g_pickup_respawntimejitter_short");
156         g_pickup_respawntimejitter_medium = cvar("g_pickup_respawntimejitter_medium");
157         g_pickup_respawntimejitter_long = cvar("g_pickup_respawntimejitter_long");
158         g_pickup_respawntimejitter_powerup = cvar("g_pickup_respawntimejitter_powerup");
159
160         g_pickup_shells = cvar("g_pickup_shells");
161         g_pickup_shells_max = cvar("g_pickup_shells_max");
162         g_pickup_nails = cvar("g_pickup_nails");
163         g_pickup_nails_max = cvar("g_pickup_nails_max");
164         g_pickup_rockets = cvar("g_pickup_rockets");
165         g_pickup_rockets_max = cvar("g_pickup_rockets_max");
166         g_pickup_cells = cvar("g_pickup_cells");
167         g_pickup_cells_max = cvar("g_pickup_cells_max");
168         g_pickup_plasma = cvar("g_pickup_plasma");
169         g_pickup_plasma_max = cvar("g_pickup_plasma_max");
170         g_pickup_fuel = cvar("g_pickup_fuel");
171         g_pickup_fuel_jetpack = cvar("g_pickup_fuel_jetpack");
172         g_pickup_fuel_max = cvar("g_pickup_fuel_max");
173         g_pickup_armorsmall = cvar("g_pickup_armorsmall");
174         g_pickup_armorsmall_max = cvar("g_pickup_armorsmall_max");
175         g_pickup_armorsmall_anyway = cvar("g_pickup_armorsmall_anyway");
176         g_pickup_armormedium = cvar("g_pickup_armormedium");
177         g_pickup_armormedium_max = cvar("g_pickup_armormedium_max");
178         g_pickup_armormedium_anyway = cvar("g_pickup_armormedium_anyway");
179         g_pickup_armorbig = cvar("g_pickup_armorbig");
180         g_pickup_armorbig_max = cvar("g_pickup_armorbig_max");
181         g_pickup_armorbig_anyway = cvar("g_pickup_armorbig_anyway");
182         g_pickup_armormega = cvar("g_pickup_armormega");
183         g_pickup_armormega_max = cvar("g_pickup_armormega_max");
184         g_pickup_armormega_anyway = cvar("g_pickup_armormega_anyway");
185         g_pickup_healthsmall = cvar("g_pickup_healthsmall");
186         g_pickup_healthsmall_max = cvar("g_pickup_healthsmall_max");
187         g_pickup_healthsmall_anyway = cvar("g_pickup_healthsmall_anyway");
188         g_pickup_healthmedium = cvar("g_pickup_healthmedium");
189         g_pickup_healthmedium_max = cvar("g_pickup_healthmedium_max");
190         g_pickup_healthmedium_anyway = cvar("g_pickup_healthmedium_anyway");
191         g_pickup_healthbig = cvar("g_pickup_healthbig");
192         g_pickup_healthbig_max = cvar("g_pickup_healthbig_max");
193         g_pickup_healthbig_anyway = cvar("g_pickup_healthbig_anyway");
194         g_pickup_healthmega = cvar("g_pickup_healthmega");
195         g_pickup_healthmega_max = cvar("g_pickup_healthmega_max");
196         g_pickup_healthmega_anyway = cvar("g_pickup_healthmega_anyway");
197
198         g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway");
199         g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway");
200
201     g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
202     if(!g_weapon_stay)
203         g_weapon_stay = cvar("g_weapon_stay");
204
205     MUTATOR_CALLHOOK(ReadLevelCvars);
206
207         if (!warmup_stage)
208                 game_starttime = time + cvar("g_start_delay");
209
210         FOREACH(Weapons, it != WEP_Null, { it.wr_init(it); });
211
212         readplayerstartcvars();
213 }
214
215 //#NO AUTOCVARS END
216
217 const int INITPRIO_FIRST                = 0;
218 const int INITPRIO_GAMETYPE             = 0;
219 const int INITPRIO_GAMETYPE_FALLBACK    = 1;
220 const int INITPRIO_FINDTARGET           = 10;
221 const int INITPRIO_DROPTOFLOOR          = 20;
222 const int INITPRIO_SETLOCATION          = 90;
223 const int INITPRIO_LINKDOORS            = 91;
224 const int INITPRIO_LAST                 = 99;
225
226 .void(entity this) initialize_entity;
227 .int initialize_entity_order;
228 .entity initialize_entity_next;
229 entity initialize_entity_first;
230
231 void InitializeEntity(entity e, void(entity this) func, int order);
232
233 IntrusiveList g_ctrace_changed;
234 STATIC_INIT(g_ctrace_changed) { g_ctrace_changed = IL_NEW(); }