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, CHAN_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, CHAN_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, CHAN_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');
89 if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
90 Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
93 if (!vehic) // vehicles don't get footsteps
96 if (self.flags & FL_ONGROUND)
97 if (velocity_len > autocvar_sv_maxspeed * 0.6)
99 if (time < self.lastground + 0.2)
101 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
103 self.nextstep = time + 0.3 + random() * 0.1;
104 trace_dphitq3surfaceflags = 0;
105 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
107 if(trace_fraction == 1)
110 dprint(ftos(trace_dphitq3surfaceflags), "\n");
112 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
114 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
115 GlobalSound(globalsound_metalstep, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
117 GlobalSound(globalsound_step, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
121 self.oldvelocity = self.velocity;
131 Called before each frame by the server
136 float game_delay_last;
138 void RuneMatchGivePoints();
139 float RedirectionThink();
140 entity SelectSpawnPoint (float anypoint);
141 void StartFrame (void)
143 remove = remove_unsafely; // not during spawning!
144 serverprevtime = servertime;
146 serverframetime = frametime;
149 if(time > client_cefc_accumulatortime + 1)
151 float t, pp, c_seeing, c_seen;
153 t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
154 print("CEFC time: ", ftos(t * 1000), "ms; ");
159 if(clienttype(cl) == CLIENTTYPE_REAL)
161 if(cl.classname == "player")
164 print("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
165 print("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
167 client_cefc_accumulatortime = time;
168 client_cefc_accumulator = 0;
173 for(e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
174 CSQCProjectile_Check(e);
176 if(RedirectionThink())
179 UncustomizeEntitiesRun();
180 InitializeEntitiesRun();
182 WarpZone_StartFrame();
184 sys_frametime = autocvar_sys_ticrate * autocvar_slowmo;
185 if(sys_frametime <= 0)
186 sys_frametime = 1.0 / 60.0; // somewhat safe fallback
188 if (timeoutStatus == 1) // just before the timeout (when timeoutStatus will be 2)
189 orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
191 skill = autocvar_skill;
196 // detect when the pre-game countdown (if any) has ended and the game has started
197 game_delay = (time < game_starttime) ? TRUE : FALSE;
199 if(game_delay_last == TRUE)
200 if(game_delay == FALSE)
201 if(autocvar_sv_eventlog)
202 GameLogEcho(":startdelay_ended");
204 game_delay_last = game_delay;
206 // if in warmup stage and limit for warmup is hit start match
208 if ((g_warmup_limit > 0 && time >= g_warmup_limit)
209 || (g_warmup_limit == 0 && autocvar_timelimit != 0 && time >= autocvar_timelimit * 60))
220 RuneMatchGivePoints();
223 if(autocvar_spawn_debugview)
225 RandomSelection_Init();
226 for(self = world; (self = find(self, classname, "player")); )
227 RandomSelection_Add(self, 0, string_null, 1, 0);
228 self = RandomSelection_chosen_ent;
232 FOR_EACH_PLAYER(self)
233 self.porto_forbidden = max(0, self.porto_forbidden - 1);
236 .vector originjitter;
237 .vector anglesjitter;
239 .string gametypefilter;
241 float DoesQ3ARemoveThisEntity();
242 void SV_OnEntityPreSpawnFunction()
244 if(self.gametypefilter != "")
245 if not(isGametypeInFilter(game, teamplay, have_team_spawns, self.gametypefilter))
250 if(self.cvarfilter != "")
257 if(substring(s, 0, 1) == "+")
259 s = substring(s, 1, -1);
261 else if(substring(s, 0, 1) == "-")
264 s = substring(s, 1, -1);
268 for(i = 0; i < n; ++i)
280 if((o = strstrofs(s, ">=", 0)) >= 0)
282 k = substring(s, 0, o);
283 v = substring(s, o+2, -1);
284 if(cvar(k) < stof(v))
287 else if((o = strstrofs(s, "<=", 0)) >= 0)
289 k = substring(s, 0, o);
290 v = substring(s, o+2, -1);
291 if(cvar(k) > stof(v))
294 else if((o = strstrofs(s, ">", 0)) >= 0)
296 k = substring(s, 0, o);
297 v = substring(s, o+1, -1);
298 if(cvar(k) <= stof(v))
301 else if((o = strstrofs(s, "<", 0)) >= 0)
303 k = substring(s, 0, o);
304 v = substring(s, o+1, -1);
305 if(cvar(k) >= stof(v))
308 else if((o = strstrofs(s, "==", 0)) >= 0)
310 k = substring(s, 0, o);
311 v = substring(s, o+2, -1);
312 if(cvar(k) != stof(v))
315 else if((o = strstrofs(s, "!=", 0)) >= 0)
317 k = substring(s, 0, o);
318 v = substring(s, o+2, -1);
319 if(cvar(k) == stof(v))
322 else if((o = strstrofs(s, "===", 0)) >= 0)
324 k = substring(s, 0, o);
325 v = substring(s, o+2, -1);
326 if(cvar_string(k) != v)
329 else if((o = strstrofs(s, "!==", 0)) >= 0)
331 k = substring(s, 0, o);
332 v = substring(s, o+2, -1);
333 if(cvar_string(k) == v)
336 else if(substring(s, 0, 1) == "!")
338 k = substring(s, 1, -1);
351 // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it
354 //print("cvarfilter fail\n");
360 if(DoesQ3ARemoveThisEntity())
366 // support special -1 and -2 angle from radiant
367 if (self.angles == '0 -1 0')
368 self.angles = '-90 0 0';
369 else if (self.angles == '0 -2 0')
370 self.angles = '+90 0 0';
372 if(self.originjitter_x != 0)
373 self.origin_x = self.origin_x + (random() * 2 - 1) * self.originjitter_x;
374 if(self.originjitter_y != 0)
375 self.origin_y = self.origin_y + (random() * 2 - 1) * self.originjitter_y;
376 if(self.originjitter_z != 0)
377 self.origin_z = self.origin_z + (random() * 2 - 1) * self.originjitter_z;
378 if(self.anglesjitter_x != 0)
379 self.angles_x = self.angles_x + (random() * 2 - 1) * self.anglesjitter_x;
380 if(self.anglesjitter_y != 0)
381 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglesjitter_y;
382 if(self.anglesjitter_z != 0)
383 self.angles_z = self.angles_z + (random() * 2 - 1) * self.anglesjitter_z;
384 if(self.anglejitter != 0)
385 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglejitter;
387 if(MUTATOR_CALLHOOK(OnEntityPreSpawn))