1 void CreatureFrame (void)
7 for(self = world; (self = findfloat(self, damagedbycontents, TRUE)); )
9 if (self.movetype == MOVETYPE_NOCLIP) { continue; }
11 float vehic = (self.vehicle_flags & VHF_ISVEHICLE);
12 float projectile = (self.flags & FL_PROJECTILE);
13 float monster = (self.flags & FL_MONSTER);
15 if (self.watertype <= CONTENT_WATER && self.waterlevel > 0) // workaround a retarded bug made by id software :P (yes, it's that old of a bug)
17 if (!(self.flags & FL_INWATER))
19 self.flags |= FL_INWATER;
23 if(!vehic && !projectile && !monster) // vehicles, monsters and projectiles don't drown
25 if (self.waterlevel != WATERLEVEL_SUBMERGED)
27 if(self.air_finished < time)
28 PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
29 self.air_finished = time + autocvar_g_balance_contents_drowndelay;
32 else if (self.air_finished < time)
35 if (self.pain_finished < time)
37 Damage (self, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN, self.origin, '0 0 0');
38 self.pain_finished = time + 0.5;
43 if (self.dmgtime < time)
45 self.dmgtime = time + autocvar_g_balance_contents_damagerate;
49 if (self.watertype == CONTENT_LAVA)
51 Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
53 else if (self.watertype == CONTENT_SLIME)
55 Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
60 if (self.watertype == CONTENT_LAVA)
62 if (self.watersound_finished < time)
64 self.watersound_finished = time + 0.5;
65 sound (self, CH_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
67 Damage (self, world, world, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
69 else if (self.watertype == CONTENT_SLIME)
71 if (self.watersound_finished < time)
73 self.watersound_finished = time + 0.5;
74 sound (self, CH_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
76 Damage (self, world, world, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
83 if (self.flags & FL_INWATER)
85 // play leave water sound
86 self.flags &~= FL_INWATER;
89 self.air_finished = time + 12;
93 if(!vehic && !projectile) // vehicles don't get falling damage
95 // check for falling damage
96 float velocity_len = vlen(self.velocity);
97 if(!self.hook.state && !g_ca && !(g_cts && !autocvar_g_cts_selfdamage))
99 dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
101 dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
103 dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
105 Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
108 if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
109 Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
110 // play stupid sounds
113 if (self.flags & FL_ONGROUND)
114 if (velocity_len > autocvar_sv_maxspeed * 0.6)
116 if (time < self.lastground + 0.2)
118 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
120 self.nextstep = time + 0.3 + random() * 0.1;
121 trace_dphitq3surfaceflags = 0;
122 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
124 if(trace_fraction == 1)
127 dprint(ftos(trace_dphitq3surfaceflags), "\n");
129 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
131 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
132 GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
134 GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
140 self.oldvelocity = self.velocity;
150 Called before each frame by the server
155 float game_delay_last;
157 void RuneMatchGivePoints();
158 float RedirectionThink();
159 entity SelectSpawnPoint (float anypoint);
160 void StartFrame (void)
162 execute_next_frame();
164 remove = remove_unsafely; // not during spawning!
165 serverprevtime = servertime;
167 serverframetime = frametime;
170 if(time > client_cefc_accumulatortime + 1)
172 float t, pp, c_seeing, c_seen;
174 t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
175 print("CEFC time: ", ftos(t * 1000), "ms; ");
180 if(clienttype(cl) == CLIENTTYPE_REAL)
182 if(cl.classname == "player")
185 print("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
186 print("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
188 client_cefc_accumulatortime = time;
189 client_cefc_accumulator = 0;
194 for(e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
195 CSQCProjectile_Check(e);
197 if(RedirectionThink())
200 UncustomizeEntitiesRun();
201 InitializeEntitiesRun();
203 WarpZone_StartFrame();
205 sys_frametime = autocvar_sys_ticrate * autocvar_slowmo;
206 if(sys_frametime <= 0)
207 sys_frametime = 1.0 / 60.0; // somewhat safe fallback
209 if (timeout_status == TIMEOUT_LEADTIME) // just before the timeout (when timeout_status will be TIMEOUT_ACTIVE)
210 orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
212 skill = autocvar_skill;
215 if(g_ca || g_freezetag)
216 count_alive_players();
220 // detect when the pre-game countdown (if any) has ended and the game has started
221 game_delay = (time < game_starttime) ? TRUE : FALSE;
223 if(game_delay_last == TRUE)
224 if(game_delay == FALSE)
225 if(autocvar_sv_eventlog)
226 GameLogEcho(":startdelay_ended");
228 game_delay_last = game_delay;
230 // if in warmup stage and limit for warmup is hit start match
232 if ((g_warmup_limit > 0 && time >= g_warmup_limit)
233 || (g_warmup_limit == 0 && autocvar_timelimit != 0 && time >= autocvar_timelimit * 60))
242 RuneMatchGivePoints();
245 FOR_EACH_PLAYER(self)
246 self.porto_forbidden = max(0, self.porto_forbidden - 1);
248 MUTATOR_CALLHOOK(SV_StartFrame);
251 .vector originjitter;
252 .vector anglesjitter;
254 .string gametypefilter;
256 float DoesQ3ARemoveThisEntity();
257 void SV_OnEntityPreSpawnFunction()
260 if (self.gametypefilter != "")
261 if not(isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
266 if(self.cvarfilter != "")
273 if(substring(s, 0, 1) == "+")
275 s = substring(s, 1, -1);
277 else if(substring(s, 0, 1) == "-")
280 s = substring(s, 1, -1);
283 n = tokenize_console(s);
284 for(i = 0; i < n; ++i)
296 if((o = strstrofs(s, ">=", 0)) >= 0)
298 k = substring(s, 0, o);
299 v = substring(s, o+2, -1);
300 if(cvar(k) < stof(v))
303 else if((o = strstrofs(s, "<=", 0)) >= 0)
305 k = substring(s, 0, o);
306 v = substring(s, o+2, -1);
307 if(cvar(k) > stof(v))
310 else if((o = strstrofs(s, ">", 0)) >= 0)
312 k = substring(s, 0, o);
313 v = substring(s, o+1, -1);
314 if(cvar(k) <= stof(v))
317 else if((o = strstrofs(s, "<", 0)) >= 0)
319 k = substring(s, 0, o);
320 v = substring(s, o+1, -1);
321 if(cvar(k) >= stof(v))
324 else if((o = strstrofs(s, "==", 0)) >= 0)
326 k = substring(s, 0, o);
327 v = substring(s, o+2, -1);
328 if(cvar(k) != stof(v))
331 else if((o = strstrofs(s, "!=", 0)) >= 0)
333 k = substring(s, 0, o);
334 v = substring(s, o+2, -1);
335 if(cvar(k) == stof(v))
338 else if((o = strstrofs(s, "===", 0)) >= 0)
340 k = substring(s, 0, o);
341 v = substring(s, o+2, -1);
342 if(cvar_string(k) != v)
345 else if((o = strstrofs(s, "!==", 0)) >= 0)
347 k = substring(s, 0, o);
348 v = substring(s, o+2, -1);
349 if(cvar_string(k) == v)
352 else if(substring(s, 0, 1) == "!")
354 k = substring(s, 1, -1);
367 // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it
370 //print("cvarfilter fail\n");
376 if(DoesQ3ARemoveThisEntity())
382 // support special -1 and -2 angle from radiant
383 if (self.angles == '0 -1 0')
384 self.angles = '-90 0 0';
385 else if (self.angles == '0 -2 0')
386 self.angles = '+90 0 0';
388 if(self.originjitter_x != 0)
389 self.origin_x = self.origin_x + (random() * 2 - 1) * self.originjitter_x;
390 if(self.originjitter_y != 0)
391 self.origin_y = self.origin_y + (random() * 2 - 1) * self.originjitter_y;
392 if(self.originjitter_z != 0)
393 self.origin_z = self.origin_z + (random() * 2 - 1) * self.originjitter_z;
394 if(self.anglesjitter_x != 0)
395 self.angles_x = self.angles_x + (random() * 2 - 1) * self.anglesjitter_x;
396 if(self.anglesjitter_y != 0)
397 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglesjitter_y;
398 if(self.anglesjitter_z != 0)
399 self.angles_z = self.angles_z + (random() * 2 - 1) * self.anglesjitter_z;
400 if(self.anglejitter != 0)
401 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglejitter;
403 if(MUTATOR_CALLHOOK(OnEntityPreSpawn))
410 void WarpZone_PostInitialize_Callback(void)
412 // create waypoint links for warpzones
414 for(e = world; (e = find(e, classname, "trigger_warpzone")); )
417 src = (e.absmin + e.absmax) * 0.5;
418 makevectors(e.warpzone_angles);
419 src = src + ((e.warpzone_origin - src) * v_forward) * v_forward + 16 * v_right;
420 dst = (e.enemy.absmin + e.enemy.absmax) * 0.5;
421 makevectors(e.enemy.warpzone_angles);
422 dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right;
423 waypoint_spawnforteleporter_v(e, src, dst, 0);