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);
14 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)
16 if (!(self.flags & FL_INWATER))
18 self.flags |= FL_INWATER;
22 if(!vehic && !projectile) // vehicles and projectiles don't drown
24 if (self.waterlevel != WATERLEVEL_SUBMERGED)
26 if(self.air_finished < time)
27 PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
28 self.air_finished = time + autocvar_g_balance_contents_drowndelay;
31 else if (self.air_finished < time)
34 if (self.pain_finished < time)
36 Damage (self, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN, self.origin, '0 0 0');
37 self.pain_finished = time + 0.5;
42 if (self.dmgtime < time)
44 self.dmgtime = time + autocvar_g_balance_contents_damagerate;
48 if (self.watertype == CONTENT_LAVA)
50 if (self.watersound_finished < time)
52 self.watersound_finished = time + 0.5;
53 sound (self, CH_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
55 Damage (self, world, world, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
57 else if (self.watertype == CONTENT_SLIME)
59 if (self.watersound_finished < time)
61 self.watersound_finished = time + 0.5;
62 sound (self, CH_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
64 Damage (self, world, world, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
67 else if ((self.watertype == CONTENT_LAVA) || (self.watertype == CONTENT_SLIME))
69 Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
75 if (self.flags & FL_INWATER)
77 // play leave water sound
78 self.flags &~= FL_INWATER;
81 self.air_finished = time + 12;
85 if(!vehic && !projectile) // vehicles don't get falling damage
87 // check for falling damage
88 float velocity_len = vlen(self.velocity);
89 if(!self.hook.state && !g_ca && !(g_cts && !autocvar_g_cts_selfdamage))
91 dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
93 dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
95 dm = min((dm - autocvar_g_balance_falldamage_minspeed) * autocvar_g_balance_falldamage_factor, autocvar_g_balance_falldamage_maxdamage);
97 Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
100 if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
101 Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
102 // play stupid sounds
105 if (self.flags & FL_ONGROUND)
106 if (velocity_len > autocvar_sv_maxspeed * 0.6)
108 if (time < self.lastground + 0.2)
110 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
112 self.nextstep = time + 0.3 + random() * 0.1;
113 trace_dphitq3surfaceflags = 0;
114 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
116 if(trace_fraction == 1)
119 dprint(ftos(trace_dphitq3surfaceflags), "\n");
121 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
123 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
124 GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
126 GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
132 self.oldvelocity = self.velocity;
142 Called before each frame by the server
147 float game_delay_last;
149 void RuneMatchGivePoints();
150 float RedirectionThink();
151 entity SelectSpawnPoint (float anypoint);
152 void StartFrame (void)
154 remove = remove_unsafely; // not during spawning!
155 serverprevtime = servertime;
157 serverframetime = frametime;
160 if(time > client_cefc_accumulatortime + 1)
162 float t, pp, c_seeing, c_seen;
164 t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
165 print("CEFC time: ", ftos(t * 1000), "ms; ");
170 if(clienttype(cl) == CLIENTTYPE_REAL)
172 if(cl.classname == "player")
175 print("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
176 print("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
178 client_cefc_accumulatortime = time;
179 client_cefc_accumulator = 0;
184 for(e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
185 CSQCProjectile_Check(e);
187 if(RedirectionThink())
190 UncustomizeEntitiesRun();
191 InitializeEntitiesRun();
193 WarpZone_StartFrame();
195 sys_frametime = autocvar_sys_ticrate * autocvar_slowmo;
196 if(sys_frametime <= 0)
197 sys_frametime = 1.0 / 60.0; // somewhat safe fallback
199 if (timeout_status == TIMEOUT_LEADTIME) // just before the timeout (when timeout_status will be TIMEOUT_ACTIVE)
200 orig_slowmo = autocvar_slowmo; // slowmo will be restored after the timeout
202 skill = autocvar_skill;
207 // detect when the pre-game countdown (if any) has ended and the game has started
208 game_delay = (time < game_starttime) ? TRUE : FALSE;
210 if(game_delay_last == TRUE)
211 if(game_delay == FALSE)
212 if(autocvar_sv_eventlog)
213 GameLogEcho(":startdelay_ended");
215 game_delay_last = game_delay;
217 // if in warmup stage and limit for warmup is hit start match
219 if ((g_warmup_limit > 0 && time >= g_warmup_limit)
220 || (g_warmup_limit == 0 && autocvar_timelimit != 0 && time >= autocvar_timelimit * 60))
231 RuneMatchGivePoints();
234 FOR_EACH_PLAYER(self)
235 self.porto_forbidden = max(0, self.porto_forbidden - 1);
237 MUTATOR_CALLHOOK(SV_StartFrame);
240 .vector originjitter;
241 .vector anglesjitter;
243 .string gametypefilter;
245 float DoesQ3ARemoveThisEntity();
246 void SV_OnEntityPreSpawnFunction()
249 if (self.gametypefilter != "")
250 if not(isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
255 if(self.cvarfilter != "")
262 if(substring(s, 0, 1) == "+")
264 s = substring(s, 1, -1);
266 else if(substring(s, 0, 1) == "-")
269 s = substring(s, 1, -1);
272 n = tokenize_console(s);
273 for(i = 0; i < n; ++i)
285 if((o = strstrofs(s, ">=", 0)) >= 0)
287 k = substring(s, 0, o);
288 v = substring(s, o+2, -1);
289 if(cvar(k) < stof(v))
292 else if((o = strstrofs(s, "<=", 0)) >= 0)
294 k = substring(s, 0, o);
295 v = substring(s, o+2, -1);
296 if(cvar(k) > stof(v))
299 else if((o = strstrofs(s, ">", 0)) >= 0)
301 k = substring(s, 0, o);
302 v = substring(s, o+1, -1);
303 if(cvar(k) <= stof(v))
306 else if((o = strstrofs(s, "<", 0)) >= 0)
308 k = substring(s, 0, o);
309 v = substring(s, o+1, -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+2, -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+2, -1);
331 if(cvar_string(k) != 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_string(k) == v)
341 else if(substring(s, 0, 1) == "!")
343 k = substring(s, 1, -1);
356 // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it
359 //print("cvarfilter fail\n");
365 if(DoesQ3ARemoveThisEntity())
371 // support special -1 and -2 angle from radiant
372 if (self.angles == '0 -1 0')
373 self.angles = '-90 0 0';
374 else if (self.angles == '0 -2 0')
375 self.angles = '+90 0 0';
377 if(self.originjitter_x != 0)
378 self.origin_x = self.origin_x + (random() * 2 - 1) * self.originjitter_x;
379 if(self.originjitter_y != 0)
380 self.origin_y = self.origin_y + (random() * 2 - 1) * self.originjitter_y;
381 if(self.originjitter_z != 0)
382 self.origin_z = self.origin_z + (random() * 2 - 1) * self.originjitter_z;
383 if(self.anglesjitter_x != 0)
384 self.angles_x = self.angles_x + (random() * 2 - 1) * self.anglesjitter_x;
385 if(self.anglesjitter_y != 0)
386 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglesjitter_y;
387 if(self.anglesjitter_z != 0)
388 self.angles_z = self.angles_z + (random() * 2 - 1) * self.anglesjitter_z;
389 if(self.anglejitter != 0)
390 self.angles_y = self.angles_y + (random() * 2 - 1) * self.anglejitter;
392 if(MUTATOR_CALLHOOK(OnEntityPreSpawn))
399 void WarpZone_PostInitialize_Callback(void)
401 // create waypoint links for warpzones
403 for(e = world; (e = find(e, classname, "trigger_warpzone")); )
406 src = (e.absmin + e.absmax) * 0.5;
407 makevectors(e.warpzone_angles);
408 src = src + ((e.warpzone_origin - src) * v_forward) * v_forward + 16 * v_right;
409 dst = (e.enemy.absmin + e.enemy.absmax) * 0.5;
410 makevectors(e.enemy.warpzone_angles);
411 dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right;
412 waypoint_spawnforteleporter_v(e, src, dst, 0);