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