2 void CreatureFrame (void)
7 self = findfloat(world, iscreature, TRUE);
10 if (self.movetype != MOVETYPE_NOCLIP)
14 if (!(self.flags & FL_INWATER))
16 self.flags |= FL_INWATER;
19 if (self.waterlevel != WATERLEVEL_SUBMERGED)
21 if(self.air_finished < time + 9)
22 PlayerSound(playersound_gasp, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
23 self.air_finished = time + 12;
26 else if (self.air_finished < time)
29 if (self.pain_finished < time)
31 Damage (self, world, world, 5, DEATH_DROWN, self.origin, '0 0 0');
32 self.pain_finished = time + 0.5;
35 if (self.dmgtime < time)
37 self.dmgtime = time + 0.2;
38 if (self.watertype == CONTENT_LAVA)
40 if (self.watersound_finished < time)
42 self.watersound_finished = time + 0.5;
43 sound (self, CHAN_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
45 Damage (self, world, world, 6 * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
47 else if (self.watertype == CONTENT_SLIME)
49 if (self.watersound_finished < time)
51 self.watersound_finished = time + 0.5;
52 sound (self, CHAN_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
54 Damage (self, world, world, 2 * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
60 if (self.flags & FL_INWATER)
62 // play leave water sound
63 self.flags &~= FL_INWATER;
66 self.air_finished = time + 12;
69 // check for falling damage
70 float velocity_len = vlen(self.velocity);
71 if(!self.hook.state && !g_ca && !(g_cts && !autocvar_g_cts_selfdamage))
73 dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
75 dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
77 dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
79 Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
82 if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
83 Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
88 if (self.flags & FL_ONGROUND)
89 if (velocity_len > autocvar_sv_maxspeed * 0.6)
91 if (time < self.lastground + 0.2)
93 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
95 self.nextstep = time + 0.3 + random() * 0.1;
96 trace_dphitq3surfaceflags = 0;
97 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
99 if(trace_fraction == 1)
102 dprint(ftos(trace_dphitq3surfaceflags), "\n");
104 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
106 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
107 GlobalSound(globalsound_metalstep, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
109 GlobalSound(globalsound_step, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
113 self.oldvelocity = self.velocity;
115 self = findfloat(self, iscreature, TRUE);
125 Called before each frame by the server
130 float game_delay_last;
132 void RuneMatchGivePoints();
133 float RedirectionThink();
134 entity SelectSpawnPoint (float anypoint);
135 void StartFrame (void)
137 remove = remove_unsafely; // not during spawning!
138 serverprevtime = servertime;
140 serverframetime = frametime;
143 if(time > client_cefc_accumulatortime + 1)
145 float t, pp, c_seeing, c_seen;
147 t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
148 print("CEFC time: ", ftos(t * 1000), "ms; ");
153 if(clienttype(cl) == CLIENTTYPE_REAL)
155 if(cl.classname == "player")
158 print("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
159 print("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
161 client_cefc_accumulatortime = time;
162 client_cefc_accumulator = 0;
167 for(e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
168 CSQCProjectile_Check(e);
170 if(RedirectionThink())
173 UncustomizeEntitiesRun();
174 InitializeEntitiesRun();
176 WarpZone_StartFrame();
178 sys_frametime = autocvar_sys_ticrate * autocvar_slowmo;
179 if(sys_frametime <= 0)
180 sys_frametime = 1.0 / 60.0; // somewhat safe fallback
182 if (timeoutStatus == 1) // just before the timeout (when timeoutStatus will be 2)
183 orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
185 skill = autocvar_skill;
190 // detect when the pre-game countdown (if any) has ended and the game has started
191 game_delay = (time < game_starttime) ? TRUE : FALSE;
193 if(game_delay_last == TRUE)
194 if(game_delay == FALSE)
195 if(autocvar_sv_eventlog)
196 GameLogEcho(":startdelay_ended");
198 game_delay_last = game_delay;
200 // if in warmup stage and limit for warmup is hit start match
202 if ((g_warmup_limit > 0 && time >= g_warmup_limit)
203 || (g_warmup_limit == 0 && autocvar_timelimit != 0 && time >= autocvar_timelimit * 60))
214 RuneMatchGivePoints();
217 if(autocvar_spawn_debugview)
219 RandomSelection_Init();
220 for(self = world; (self = find(self, classname, "player")); )
221 RandomSelection_Add(self, 0, string_null, 1, 0);
222 self = RandomSelection_chosen_ent;
226 FOR_EACH_PLAYER(self)
227 self.porto_forbidden = max(0, self.porto_forbidden - 1);
230 .vector originjitter;
231 .vector anglesjitter;
233 .string gametypefilter;
235 float DoesQ3ARemoveThisEntity();
236 void SV_OnEntityPreSpawnFunction()
238 if(self.gametypefilter != "")
239 if not(isGametypeInFilter(game, teamplay, have_team_spawns, self.gametypefilter))
244 if(self.cvarfilter != "")
251 if(substring(s, 0, 1) == "+")
253 s = substring(s, 1, -1);
255 else if(substring(s, 0, 1) == "-")
258 s = substring(s, 1, -1);
262 for(i = 0; i < n; ++i)
274 if((o = strstrofs(s, ">=", 0)) >= 0)
276 k = substring(s, 0, o);
277 v = substring(s, o+2, -1);
278 if(cvar(k) < stof(v))
281 else if((o = strstrofs(s, "<=", 0)) >= 0)
283 k = substring(s, 0, o);
284 v = substring(s, o+2, -1);
285 if(cvar(k) > stof(v))
288 else if((o = strstrofs(s, ">", 0)) >= 0)
290 k = substring(s, 0, o);
291 v = substring(s, o+1, -1);
292 if(cvar(k) <= stof(v))
295 else if((o = strstrofs(s, "<", 0)) >= 0)
297 k = substring(s, 0, o);
298 v = substring(s, o+1, -1);
299 if(cvar(k) >= stof(v))
302 else if((o = strstrofs(s, "==", 0)) >= 0)
304 k = substring(s, 0, o);
305 v = substring(s, o+2, -1);
306 if(cvar(k) != stof(v))
309 else if((o = strstrofs(s, "!=", 0)) >= 0)
311 k = substring(s, 0, o);
312 v = substring(s, o+2, -1);
313 if(cvar(k) == stof(v))
316 else if((o = strstrofs(s, "===", 0)) >= 0)
318 k = substring(s, 0, o);
319 v = substring(s, o+2, -1);
320 if(cvar_string(k) != v)
323 else if((o = strstrofs(s, "!==", 0)) >= 0)
325 k = substring(s, 0, o);
326 v = substring(s, o+2, -1);
327 if(cvar_string(k) == v)
330 else if(substring(s, 0, 1) == "!")
332 k = substring(s, 1, -1);
345 // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it
348 //print("cvarfilter fail\n");
354 if(DoesQ3ARemoveThisEntity())
360 // support special -1 and -2 angle from radiant
361 if (self.angles == '0 -1 0')
362 self.angles = '-90 0 0';
363 else if (self.angles == '0 -2 0')
364 self.angles = '+90 0 0';
366 if(self.originjitter_x != 0)
367 self.origin_x = self.origin_x + (random() * 2 - 1) * self.originjitter_x;
368 if(self.originjitter_y != 0)
369 self.origin_y = self.origin_y + (random() * 2 - 1) * self.originjitter_y;
370 if(self.originjitter_z != 0)
371 self.origin_z = self.origin_z + (random() * 2 - 1) * self.originjitter_z;
372 if(self.anglesjitter_x != 0)
373 self.angles_x = self.angles_x + (random() * 2 - 1) * self.anglesjitter_x;
374 if(self.anglesjitter_y != 0)
375 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglesjitter_y;
376 if(self.anglesjitter_z != 0)
377 self.angles_z = self.angles_z + (random() * 2 - 1) * self.anglesjitter_z;
378 if(self.anglejitter != 0)
379 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglejitter;
381 if(MUTATOR_CALLHOOK(OnEntityPreSpawn))