2 void CreatureFrame (void)
7 for(self = world; (self = findfloat(self, iscreature, TRUE)); )
9 if (self.movetype == MOVETYPE_NOCLIP)
11 float vehic = (self.vehicle_flags & VHF_ISVEHICLE);
14 if (!(self.flags & FL_INWATER))
16 self.flags |= FL_INWATER;
19 if(!vehic) // vehicles don't drown
21 if (self.waterlevel != WATERLEVEL_SUBMERGED)
23 if(self.air_finished < time + 9)
24 PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
25 self.air_finished = time + 12;
28 else if (self.air_finished < time)
31 if (self.pain_finished < time)
33 Damage (self, world, world, 5, DEATH_DROWN, self.origin, '0 0 0');
34 self.pain_finished = time + 0.5;
38 if (self.dmgtime < time)
40 self.dmgtime = time + 0.2;
41 if (self.watertype == CONTENT_LAVA)
43 if (self.watersound_finished < time)
45 self.watersound_finished = time + 0.5;
46 sound (self, CH_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
48 Damage (self, world, world, 6 * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
50 else if (self.watertype == CONTENT_SLIME)
52 if (self.watersound_finished < time)
54 self.watersound_finished = time + 0.5;
55 sound (self, CH_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
57 Damage (self, world, world, 2 * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
63 if (self.flags & FL_INWATER)
65 // play leave water sound
66 self.flags &~= FL_INWATER;
69 self.air_finished = time + 12;
73 if(!vehic) // vehicles don't get falling damage
75 // check for falling damage
76 float velocity_len = vlen(self.velocity);
77 if(!self.hook.state && !g_ca && !(g_cts && !autocvar_g_cts_selfdamage))
79 dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
81 dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
83 dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
85 Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
88 if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
89 Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
93 if (self.flags & FL_ONGROUND)
94 if (velocity_len > autocvar_sv_maxspeed * 0.6)
96 if (time < self.lastground + 0.2)
98 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
100 self.nextstep = time + 0.3 + random() * 0.1;
101 trace_dphitq3surfaceflags = 0;
102 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
104 if(trace_fraction == 1)
107 dprint(ftos(trace_dphitq3surfaceflags), "\n");
109 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
111 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
112 GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
114 GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
120 self.oldvelocity = self.velocity;
130 Called before each frame by the server
135 float game_delay_last;
137 void RuneMatchGivePoints();
138 float RedirectionThink();
139 entity SelectSpawnPoint (float anypoint);
140 void StartFrame (void)
142 remove = remove_unsafely; // not during spawning!
143 serverprevtime = servertime;
145 serverframetime = frametime;
148 if(time > client_cefc_accumulatortime + 1)
150 float t, pp, c_seeing, c_seen;
152 t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
153 print("CEFC time: ", ftos(t * 1000), "ms; ");
158 if(clienttype(cl) == CLIENTTYPE_REAL)
160 if(cl.classname == "player")
163 print("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
164 print("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
166 client_cefc_accumulatortime = time;
167 client_cefc_accumulator = 0;
172 for(e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
173 CSQCProjectile_Check(e);
175 if(RedirectionThink())
178 UncustomizeEntitiesRun();
179 InitializeEntitiesRun();
181 WarpZone_StartFrame();
183 sys_frametime = autocvar_sys_ticrate * autocvar_slowmo;
184 if(sys_frametime <= 0)
185 sys_frametime = 1.0 / 60.0; // somewhat safe fallback
187 if (timeoutStatus == 1) // just before the timeout (when timeoutStatus will be 2)
188 orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
190 skill = autocvar_skill;
195 // detect when the pre-game countdown (if any) has ended and the game has started
196 game_delay = (time < game_starttime) ? TRUE : FALSE;
198 if(game_delay_last == TRUE)
199 if(game_delay == FALSE)
200 if(autocvar_sv_eventlog)
201 GameLogEcho(":startdelay_ended");
203 game_delay_last = game_delay;
205 // if in warmup stage and limit for warmup is hit start match
207 if ((g_warmup_limit > 0 && time >= g_warmup_limit)
208 || (g_warmup_limit == 0 && autocvar_timelimit != 0 && time >= autocvar_timelimit * 60))
219 RuneMatchGivePoints();
222 if(autocvar_spawn_debugview)
224 RandomSelection_Init();
225 for(self = world; (self = find(self, classname, "player")); )
226 RandomSelection_Add(self, 0, string_null, 1, 0);
227 self = RandomSelection_chosen_ent;
231 FOR_EACH_PLAYER(self)
232 self.porto_forbidden = max(0, self.porto_forbidden - 1);
235 .vector originjitter;
236 .vector anglesjitter;
238 .string gametypefilter;
240 float DoesQ3ARemoveThisEntity();
241 void SV_OnEntityPreSpawnFunction()
243 if(self.gametypefilter != "")
244 if not(isGametypeInFilter(game, teamplay, have_team_spawns, self.gametypefilter))
249 if(self.cvarfilter != "")
256 if(substring(s, 0, 1) == "+")
258 s = substring(s, 1, -1);
260 else if(substring(s, 0, 1) == "-")
263 s = substring(s, 1, -1);
267 for(i = 0; i < n; ++i)
279 if((o = strstrofs(s, ">=", 0)) >= 0)
281 k = substring(s, 0, o);
282 v = substring(s, o+2, -1);
283 if(cvar(k) < stof(v))
286 else if((o = strstrofs(s, "<=", 0)) >= 0)
288 k = substring(s, 0, o);
289 v = substring(s, o+2, -1);
290 if(cvar(k) > stof(v))
293 else if((o = strstrofs(s, ">", 0)) >= 0)
295 k = substring(s, 0, o);
296 v = substring(s, o+1, -1);
297 if(cvar(k) <= stof(v))
300 else if((o = strstrofs(s, "<", 0)) >= 0)
302 k = substring(s, 0, o);
303 v = substring(s, o+1, -1);
304 if(cvar(k) >= stof(v))
307 else if((o = strstrofs(s, "==", 0)) >= 0)
309 k = substring(s, 0, o);
310 v = substring(s, o+2, -1);
311 if(cvar(k) != stof(v))
314 else if((o = strstrofs(s, "!=", 0)) >= 0)
316 k = substring(s, 0, o);
317 v = substring(s, o+2, -1);
318 if(cvar(k) == stof(v))
321 else if((o = strstrofs(s, "===", 0)) >= 0)
323 k = substring(s, 0, o);
324 v = substring(s, o+2, -1);
325 if(cvar_string(k) != v)
328 else if((o = strstrofs(s, "!==", 0)) >= 0)
330 k = substring(s, 0, o);
331 v = substring(s, o+2, -1);
332 if(cvar_string(k) == v)
335 else if(substring(s, 0, 1) == "!")
337 k = substring(s, 1, -1);
350 // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it
353 //print("cvarfilter fail\n");
359 if(DoesQ3ARemoveThisEntity())
365 // support special -1 and -2 angle from radiant
366 if (self.angles == '0 -1 0')
367 self.angles = '-90 0 0';
368 else if (self.angles == '0 -2 0')
369 self.angles = '+90 0 0';
371 if(self.originjitter_x != 0)
372 self.origin_x = self.origin_x + (random() * 2 - 1) * self.originjitter_x;
373 if(self.originjitter_y != 0)
374 self.origin_y = self.origin_y + (random() * 2 - 1) * self.originjitter_y;
375 if(self.originjitter_z != 0)
376 self.origin_z = self.origin_z + (random() * 2 - 1) * self.originjitter_z;
377 if(self.anglesjitter_x != 0)
378 self.angles_x = self.angles_x + (random() * 2 - 1) * self.anglesjitter_x;
379 if(self.anglesjitter_y != 0)
380 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglesjitter_y;
381 if(self.anglesjitter_z != 0)
382 self.angles_z = self.angles_z + (random() * 2 - 1) * self.anglesjitter_z;
383 if(self.anglejitter != 0)
384 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglejitter;
386 if(MUTATOR_CALLHOOK(OnEntityPreSpawn))