2 void CreatureFrame (void)
5 local float dm, maxspeed;
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.1;
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 if(!self.hook.state && !g_ca && !(g_cts && !cvar("g_cts_selfdamage")))
72 dm = vlen(self.oldvelocity) - vlen(self.velocity); // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
74 dm = (dm - cvar("g_balance_falldamage_deadminspeed")) * cvar("g_balance_falldamage_factor");
76 dm = min((dm - cvar("g_balance_falldamage_minspeed")) * cvar("g_balance_falldamage_factor"), cvar("g_balance_falldamage_maxdamage"));
79 Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
80 // this must be allowed to cut the normal pain sounds (played after them and on the same channel)
81 // there's no way to detect falling damage and prevent the pain sounds for this to be played instead
83 PlayerSound(playersound_fall, CHAN_PAIN, VOICETYPE_PLAYERSOUND);
87 maxspeed = cvar("g_maxspeed");
88 if(maxspeed > 0 && vlen(self.velocity) > maxspeed)
89 Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
94 if (self.flags & FL_ONGROUND)
95 if (vlen(self.velocity) > sv_maxspeed * 0.6)
97 if (time < self.lastground + 0.2)
99 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
101 self.nextstep = time + 0.3 + random() * 0.1;
102 trace_dphitq3surfaceflags = 0;
103 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
105 if(trace_fraction == 1)
108 dprint(ftos(trace_dphitq3surfaceflags), "\n");
110 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
112 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
113 GlobalSound(globalsound_metalstep, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
115 GlobalSound(globalsound_step, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
119 self.oldvelocity = self.velocity;
121 self = findfloat(self, iscreature, TRUE);
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 sv_gravity = cvar("sv_gravity");
185 sv_maxairspeed = cvar("sv_maxairspeed");
186 sv_maxspeed = cvar ("sv_maxspeed");
187 sv_friction = cvar ("sv_friction");
188 sv_accelerate = cvar ("sv_accelerate");
189 sv_airaccelerate = cvar("sv_airaccelerate");
190 sv_airaccel_sideways_friction = cvar("sv_airaccel_sideways_friction");
191 sv_airaccel_qw = cvar("sv_airaccel_qw");
192 sv_stopspeed = cvar ("sv_stopspeed");
193 sv_airstopaccelerate = cvar("sv_airstopaccelerate");
194 sv_airstrafeaccelerate = cvar("sv_airstrafeaccelerate");
195 sv_maxairstrafespeed = cvar("sv_maxairstrafespeed");
196 sv_airstrafeaccel_qw = cvar("sv_airstrafeaccel_qw");
197 sv_aircontrol = cvar("sv_aircontrol");
198 sv_aircontrol_penalty = cvar("sv_aircontrol_penalty");
199 sv_aircontrol_power = cvar("sv_aircontrol_power");
200 sv_warsowbunny_airforwardaccel = cvar("sv_warsowbunny_airforwardaccel");
201 sv_warsowbunny_accel = cvar("sv_warsowbunny_accel");
202 sv_warsowbunny_topspeed = cvar("sv_warsowbunny_topspeed");
203 sv_warsowbunny_turnaccel = cvar("sv_warsowbunny_turnaccel");
204 sv_warsowbunny_backtosideratio = cvar("sv_warsowbunny_backtosideratio");
205 sv_airspeedlimit_nonqw = cvar("sv_airspeedlimit_nonqw");
206 teamplay = cvar ("teamplay");
207 sys_frametime = cvar("sys_ticrate") * cvar("slowmo");
208 sv_doublejump = cvar("sv_doublejump");
210 if (timeoutStatus == 1) // just before the timeout (when timeoutStatus will be 2)
211 orig_slowmo = cvar("slowmo"); // slowmo will be restored after the timeout
213 if(teams_matter && !teamplay)
215 if(!teams_matter && teamplay)
218 skill = cvar("skill");
223 // detect when the pre-game countdown (if any) has ended and the game has started
224 game_delay = (time < game_starttime) ? TRUE : FALSE;
226 if(game_delay_last == TRUE)
227 if(game_delay == FALSE)
228 if(cvar("sv_eventlog"))
229 GameLogEcho(":startdelay_ended");
231 game_delay_last = game_delay;
233 // if in warmup stage and limit for warmup is hit start match
235 if ((g_warmup_limit > 0 && time >= g_warmup_limit)
236 || (g_warmup_limit == 0 && cvar("timelimit") != 0 && time >= cvar("timelimit") * 60))
247 RuneMatchGivePoints();
250 if(cvar("spawn_debugview"))
252 RandomSelection_Init();
253 for(self = world; (self = find(self, classname, "player")); )
254 RandomSelection_Add(self, 0, string_null, 1, 0);
255 self = RandomSelection_chosen_ent;
259 FOR_EACH_PLAYER(self)
260 self.porto_forbidden = max(0, self.porto_forbidden - 1);
263 .vector originjitter;
264 .vector anglesjitter;
266 .string gametypefilter;
268 void SV_OnEntityPreSpawnFunction()
270 if(self.gametypefilter != "")
271 if not(isGametypeInFilter(game, teams_matter, self.gametypefilter))
276 if(self.cvarfilter != "")
283 if(substring(s, 0, 1) == "+")
285 s = substring(s, 1, -1);
287 else if(substring(s, 0, 1) == "-")
290 s = substring(s, 1, -1);
294 for(i = 0; i < n; ++i)
306 if((o = strstrofs(s, ">=", 0)) >= 0)
308 k = substring(s, 0, o);
309 v = substring(s, o+2, -1);
310 if(cvar(k) < stof(v))
313 else if((o = strstrofs(s, "<=", 0)) >= 0)
315 k = substring(s, 0, o);
316 v = substring(s, o+2, -1);
317 if(cvar(k) > stof(v))
320 else if((o = strstrofs(s, ">", 0)) >= 0)
322 k = substring(s, 0, o);
323 v = substring(s, o+1, -1);
324 if(cvar(k) <= stof(v))
327 else if((o = strstrofs(s, "<", 0)) >= 0)
329 k = substring(s, 0, o);
330 v = substring(s, o+1, -1);
331 if(cvar(k) >= stof(v))
334 else if((o = strstrofs(s, "==", 0)) >= 0)
336 k = substring(s, 0, o);
337 v = substring(s, o+2, -1);
338 if(cvar(k) != stof(v))
341 else if((o = strstrofs(s, "!=", 0)) >= 0)
343 k = substring(s, 0, o);
344 v = substring(s, o+2, -1);
345 if(cvar(k) == stof(v))
348 else if((o = strstrofs(s, "===", 0)) >= 0)
350 k = substring(s, 0, o);
351 v = substring(s, o+2, -1);
352 if(cvar_string(k) != v)
355 else if((o = strstrofs(s, "!==", 0)) >= 0)
357 k = substring(s, 0, o);
358 v = substring(s, o+2, -1);
359 if(cvar_string(k) == v)
362 else if(substring(s, 0, 1) == "!")
364 k = substring(s, 1, -1);
377 // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it
380 //print("cvarfilter fail\n");
386 // support special -1 and -2 angle from radiant
387 if (self.angles == '0 -1 0')
388 self.angles = '-90 0 0';
389 else if (self.angles == '0 -2 0')
390 self.angles = '+90 0 0';
392 if(self.originjitter_x != 0)
393 self.origin_x = self.origin_x + (random() * 2 - 1) * self.originjitter_x;
394 if(self.originjitter_y != 0)
395 self.origin_y = self.origin_y + (random() * 2 - 1) * self.originjitter_y;
396 if(self.originjitter_z != 0)
397 self.origin_z = self.origin_z + (random() * 2 - 1) * self.originjitter_z;
398 if(self.anglesjitter_x != 0)
399 self.angles_x = self.angles_x + (random() * 2 - 1) * self.anglesjitter_x;
400 if(self.anglesjitter_y != 0)
401 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglesjitter_y;
402 if(self.anglesjitter_z != 0)
403 self.angles_z = self.angles_z + (random() * 2 - 1) * self.anglesjitter_z;
404 if(self.anglejitter != 0)
405 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglejitter;
407 if(MUTATOR_CALLHOOK(OnEntityPreSpawn))