]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_physics.qc
My first GIT commit :) Implements UT2k4 style air-jumping (jumping again in mid air...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
1 .float race_penalty;
2 .float restart_jump;
3
4 float sv_accelerate;
5 float sv_friction;
6 float sv_maxspeed;
7 float sv_airaccelerate;
8 float sv_maxairspeed;
9 float sv_stopspeed;
10 float sv_gravity;
11 float sv_airaccel_sideways_friction;
12 float sv_airaccel_qw;
13 float sv_airstopaccelerate;
14 float sv_airstrafeaccelerate;
15 float sv_maxairstrafespeed;
16 float sv_aircontrol;
17 float sv_warsowbunny_airforwardaccel;
18 float sv_warsowbunny_accel;
19 float sv_warsowbunny_topspeed;
20 float sv_warsowbunny_turnaccel;
21 float sv_warsowbunny_backtosideratio;
22
23 .float ladder_time;
24 .entity ladder_entity;
25 .float gravity;
26 .float swamp_slowdown;
27 .float lastflags;
28 .float lastground;
29 .float wasFlying;
30 .float spectatorspeed;
31
32 .float multijump_count;
33 .float multijump_delay;
34 .float multijump_ready;
35
36 /*
37 =============
38 PlayerJump
39
40 When you press the jump key
41 =============
42 */
43 void PlayerJump (void)
44 {
45         float mjumpheight;
46
47         mjumpheight = cvar("sv_jumpvelocity");
48         if (self.waterlevel >= WATERLEVEL_SWIMMING)
49         {
50                 if (self.watertype == CONTENT_WATER)
51                         self.velocity_z = 200;
52                 else if (self.watertype == CONTENT_SLIME)
53                         self.velocity_z = 80;
54                 else
55                         self.velocity_z = 50;
56
57                 return;
58         }
59
60         if (cvar("g_multijump"))
61         {
62                 if ((self.flags & FL_JUMPRELEASED) && !(self.flags & FL_ONGROUND))
63                         self.multijump_ready = TRUE;  // this is necessary to check that we released the jump button and pressed it again
64                 else if (self.flags & FL_ONGROUND)
65                 {
66                         if (cvar("g_multijump") > 0)
67                                 self.multijump_count = 0;
68                         else
69                                 self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller
70                         self.multijump_ready = FALSE;
71                 }
72         }
73
74         if(self.multijump_ready && time > self.multijump_delay && self.multijump_count < cvar("g_multijump") && self.velocity_z > cvar("g_multijump_speed"))
75         {
76                 if (cvar("g_multijump") > 0)
77                         self.multijump_count += 1;
78                 self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
79         }
80         else if (!(self.flags & FL_ONGROUND))
81                 return;
82
83         if(!sv_pogostick)
84                 if (!(self.flags & FL_JUMPRELEASED))
85                         return;
86
87         if(self.health <= g_bloodloss)
88                 return;
89
90         if(g_runematch)
91         {
92                 if(self.runes & RUNE_SPEED)
93                 {
94                         if(self.runes & CURSE_SLOW)
95                                 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_combo_jumpheight");
96                         else
97                                 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_jumpheight");
98                 }
99                 else if(self.runes & CURSE_SLOW)
100                 {
101                         mjumpheight = mjumpheight * cvar("g_balance_curse_slow_jumpheight");
102                 }
103         }
104
105         if(g_minstagib && (self.items & IT_INVINCIBLE))
106         {
107                 mjumpheight = mjumpheight * cvar("g_minstagib_speed_jumpheight");
108         }
109
110         if(cvar_string("sv_jumpspeedcap_min") != "")
111                 self.velocity_z = max(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_min"), self.velocity_z);
112         if(cvar_string("sv_jumpspeedcap_max") != "") {
113                 if(trace_fraction < 1 && trace_plane_normal_z < 0.98 && cvar("sv_jumpspeedcap_max_disable_on_ramps")) {
114                         // don't do jump speedcaps on ramps to preserve old xonotic ramjump style
115                         //print("Trace plane normal z: ", ftos(trace_plane_normal_z), ", disabling speed cap!\n");
116                 }
117                 else
118                         self.velocity_z = min(cvar("sv_jumpvelocity") * cvar("sv_jumpspeedcap_max"), self.velocity_z) + trace_ent.velocity_z;
119         }
120
121         if(!(self.lastflags & FL_ONGROUND))
122         {
123                 if(cvar("speedmeter"))
124                         dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
125                 if(self.lastground < time - 0.3)
126                 {
127                         self.velocity_x *= (1 - cvar("sv_friction_on_land"));
128                         self.velocity_y *= (1 - cvar("sv_friction_on_land"));
129                 }
130                 if(self.jumppadcount > 1)
131                         dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
132                 self.jumppadcount = 0;
133         }
134
135         self.velocity_z = self.velocity_z + mjumpheight;
136         self.oldvelocity_z = self.velocity_z;
137
138         self.flags &~= FL_ONGROUND;
139         self.flags &~= FL_JUMPRELEASED;
140
141         if (cvar("g_multijump"))
142                 self.multijump_delay = time + cvar("g_multijump_delay");
143
144         if (self.crouch)
145                 setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE);
146         else
147                 setanim(self, self.anim_jump, FALSE, TRUE, TRUE);
148
149         if(g_jump_grunt)
150                 PlayerSound(playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
151
152         self.restart_jump = -1; // restart jump anim next time
153         // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
154 }
155
156 void CheckWaterJump()
157 {
158         local vector start, end;
159
160 // check for a jump-out-of-water
161         makevectors (self.angles);
162         start = self.origin;
163         start_z = start_z + 8;
164         v_forward_z = 0;
165         normalize(v_forward);
166         end = start + v_forward*24;
167         traceline (start, end, TRUE, self);
168         if (trace_fraction < 1)
169         {       // solid at waist
170                 start_z = start_z + self.maxs_z - 8;
171                 end = start + v_forward*24;
172                 self.movedir = trace_plane_normal * -50;
173                 traceline (start, end, TRUE, self);
174                 if (trace_fraction == 1)
175                 {       // open at eye level
176                         self.flags |= FL_WATERJUMP;
177                         self.velocity_z = 225;
178                         self.flags &~= FL_JUMPRELEASED;
179                         self.teleport_time = time + 2;  // safety net
180                         return;
181                 }
182         }
183 };
184
185 float racecar_angle(float forward, float down)
186 {
187         float ret, angle_mult;
188
189         if(forward < 0)
190         {
191                 forward = -forward;
192                 down = -down;
193         }
194
195         ret = vectoyaw('0 1 0' * down + '1 0 0' * forward);
196
197         angle_mult = forward / (800 + forward);
198
199         if(ret > 180)
200                 return ret * angle_mult + 360 * (1 - angle_mult);
201         else
202                 return ret * angle_mult;
203 }
204
205 void RaceCarPhysics()
206 {
207         // using this move type for "big rigs"
208         // the engine does not push the entity!
209
210         float accel, steer, f;
211         vector angles_save, rigvel;
212
213         angles_save = self.angles;
214         accel = bound(-1, self.movement_x / sv_maxspeed, 1);
215         steer = bound(-1, self.movement_y / sv_maxspeed, 1);
216
217         if(g_bugrigs_reverse_speeding)
218         {
219                 if(accel < 0)
220                 {
221                         // back accel is DIGITAL
222                         // to prevent speedhack
223                         if(accel < -0.5)
224                                 accel = -1;
225                         else
226                                 accel = 0;
227                 }
228         }
229
230         self.angles_x = 0;
231         self.angles_z = 0;
232         makevectors(self.angles); // new forward direction!
233
234         if(self.flags & FL_ONGROUND || g_bugrigs_air_steering)
235         {
236                 float myspeed, upspeed, steerfactor, accelfactor;
237
238                 myspeed = self.velocity * v_forward;
239                 upspeed = self.velocity * v_up;
240
241                 // responsiveness factor for steering and acceleration
242                 f = 1 / (1 + pow(max(-myspeed, myspeed) / g_bugrigs_speed_ref, g_bugrigs_speed_pow));
243                 //MAXIMA: f(v) := 1 / (1 + (v / g_bugrigs_speed_ref) ^ g_bugrigs_speed_pow);
244
245                 if(myspeed < 0 && g_bugrigs_reverse_spinning)
246                         steerfactor = -myspeed * g_bugrigs_steer;
247                 else
248                         steerfactor = -myspeed * f * g_bugrigs_steer;
249
250                 if(myspeed < 0 && g_bugrigs_reverse_speeding)
251                         accelfactor = g_bugrigs_accel;
252                 else
253                         accelfactor = f * g_bugrigs_accel;
254                 //MAXIMA: accel(v) := f(v) * g_bugrigs_accel;
255
256                 if(accel < 0)
257                 {
258                         if(myspeed > 0)
259                         {
260                                 myspeed = max(0, myspeed - frametime * (g_bugrigs_friction_floor - g_bugrigs_friction_brake * accel));
261                         }
262                         else
263                         {
264                                 if(!g_bugrigs_reverse_speeding)
265                                         myspeed = min(0, myspeed + frametime * g_bugrigs_friction_floor);
266                         }
267                 }
268                 else
269                 {
270                         if(myspeed >= 0)
271                         {
272                                 myspeed = max(0, myspeed - frametime * g_bugrigs_friction_floor);
273                         }
274                         else
275                         {
276                                 if(g_bugrigs_reverse_stopping)
277                                         myspeed = 0;
278                                 else
279                                         myspeed = min(0, myspeed + frametime * (g_bugrigs_friction_floor + g_bugrigs_friction_brake * accel));
280                         }
281                 }
282                 // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
283                 //MAXIMA: friction(v) := g_bugrigs_friction_floor;
284
285                 self.angles_y += steer * frametime * steerfactor; // apply steering
286                 makevectors(self.angles); // new forward direction!
287
288                 myspeed += accel * accelfactor * frametime;
289
290                 rigvel = myspeed * v_forward + '0 0 1' * upspeed;
291         }
292         else
293         {
294                 myspeed = vlen(self.velocity);
295
296                 // responsiveness factor for steering and acceleration
297                 f = 1 / (1 + pow(max(0, myspeed / g_bugrigs_speed_ref), g_bugrigs_speed_pow));
298                 steerfactor = -myspeed * f;
299                 self.angles_y += steer * frametime * steerfactor; // apply steering
300
301                 rigvel = self.velocity;
302                 makevectors(self.angles); // new forward direction!
303         }
304
305         rigvel = rigvel * max(0, 1 - vlen(rigvel) * g_bugrigs_friction_air * frametime);
306         //MAXIMA: airfriction(v) := v * v * g_bugrigs_friction_air;
307         //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
308         //MAXIMA: solve(total_acceleration(v) = 0, v);
309
310         if(g_bugrigs_planar_movement)
311         {
312                 vector rigvel_xy, neworigin, up;
313                 float mt;
314
315                 rigvel_z -= frametime * sv_gravity; // 4x gravity plays better
316                 rigvel_xy = rigvel;
317                 rigvel_xy_z = 0;
318
319                 if(g_bugrigs_planar_movement_car_jumping && !g_touchexplode) // touchexplode is a better way to handle collisions
320                         mt = MOVE_NORMAL;
321                 else
322                         mt = MOVE_NOMONSTERS;
323
324                 tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', mt, self);
325                 up = trace_endpos - self.origin;
326
327                 // BUG RIGS: align the move to the surface instead of doing collision testing
328                 // can we move?
329                 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * frametime, mt, self);
330
331                 // align to surface
332                 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * frametime, mt, self);
333
334                 if(trace_fraction < 0.5)
335                 {
336                         trace_fraction = 1;
337                         neworigin = self.origin;
338                 }
339                 else
340                         neworigin = trace_endpos;
341
342                 if(trace_fraction < 1)
343                 {
344                         // now set angles_x so that the car points parallel to the surface
345                         self.angles = vectoangles(
346                                         '1 0 0' * v_forward_x * trace_plane_normal_z
347                                         +
348                                         '0 1 0' * v_forward_y * trace_plane_normal_z
349                                         +
350                                         '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
351                                         );
352                         self.flags |= FL_ONGROUND;
353                 }
354                 else
355                 {
356                         // now set angles_x so that the car points forward, but is tilted in velocity direction
357                         self.flags &~= FL_ONGROUND;
358                 }
359
360                 self.velocity = (neworigin - self.origin) * (1.0 / frametime);
361                 self.movetype = MOVETYPE_NOCLIP;
362         }
363         else
364         {
365                 rigvel_z -= frametime * sv_gravity; // 4x gravity plays better
366                 self.velocity = rigvel;
367                 self.movetype = MOVETYPE_FLY;
368         }
369
370         trace_fraction = 1;
371         tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
372         if(trace_fraction != 1)
373         {
374                 self.angles = vectoangles2(
375                                 '1 0 0' * v_forward_x * trace_plane_normal_z
376                                 +
377                                 '0 1 0' * v_forward_y * trace_plane_normal_z
378                                 +
379                                 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y),
380                                 trace_plane_normal
381                                 );
382         }
383         else
384         {
385                 vector vel_local;
386
387                 vel_local_x = v_forward * self.velocity;
388                 vel_local_y = v_right * self.velocity;
389                 vel_local_z = v_up * self.velocity;
390
391                 self.angles_x = racecar_angle(vel_local_x, vel_local_z);
392                 self.angles_z = racecar_angle(-vel_local_y, vel_local_z);
393         }
394
395         // smooth the angles
396         vector vf1, vu1, smoothangles;
397         makevectors(self.angles);
398         f = bound(0, frametime * g_bugrigs_angle_smoothing, 1);
399         if(f == 0)
400                 f = 1;
401         vf1 = v_forward * f;
402         vu1 = v_up * f;
403         makevectors(angles_save);
404         vf1 = vf1 + v_forward * (1 - f);
405         vu1 = vu1 + v_up * (1 - f);
406         smoothangles = vectoangles2(vf1, vu1);
407         self.angles_x = -smoothangles_x;
408         self.angles_z =  smoothangles_z;
409 }
410
411 float IsMoveInDirection(vector mv, float angle) // key mix factor
412 {
413         if(mv_x == 0 && mv_y == 0)
414                 return 0; // avoid division by zero
415         angle = RAD2DEG * atan2(mv_y, mv_x);
416         angle = remainder(angle, 360) / 45;
417         if(angle >  1)
418                 return 0;
419         if(angle < -1)
420                 return 0;
421         return 1 - fabs(angle);
422 }
423
424 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
425 {
426         float zspeed, xyspeed, dot, k;
427
428 #if 0
429         // this doesn't play well with analog input
430         if(self.movement_x == 0 || self.movement_y != 0)
431                 return; // can't control movement if not moving forward or backward
432         k = 32;
433 #else
434         k = 32 * (2 * IsMoveInDirection(self.movement, 0) - 1);
435         if(k <= 0)
436                 return;
437 #endif
438
439         k *= bound(0, wishspeed / sv_maxairspeed, 1);
440
441         zspeed = self.velocity_z;
442         self.velocity_z = 0;
443         xyspeed = vlen(self.velocity); self.velocity = normalize(self.velocity);
444
445         dot = self.velocity * wishdir;
446         k *= sv_aircontrol*dot*dot*frametime;
447
448         if(dot > 0) // we can't change direction while slowing down
449         {
450                 self.velocity = normalize(self.velocity * xyspeed + wishdir * k);
451         }
452
453         self.velocity = self.velocity * xyspeed;
454         self.velocity_z = zspeed;
455 }
456
457 // example config for alternate speed clamping:
458 //   sv_airaccel_qw 0.8
459 //   sv_airaccel_sideways_friction 0
460 //   prvm_globalset server speedclamp_mode 1
461 //     (or 2)
462 void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float sidefric)
463 {
464         float vel_straight;
465         float vel_z;
466         vector vel_perpend;
467         float step;
468
469         vector vel_xy;
470         float vel_xy_current;
471         float vel_xy_backward, vel_xy_forward;
472         float speedclamp;
473
474         speedclamp = (accelqw < 0);
475         if(speedclamp)
476                 accelqw = -accelqw;
477
478         if(cvar("sv_gameplayfix_q2airaccelerate"))
479                 wishspeed0 = wishspeed;
480
481         vel_straight = self.velocity * wishdir;
482         vel_z = self.velocity_z;
483         vel_xy = self.velocity - vel_z * '0 0 1';
484         vel_perpend = vel_xy - vel_straight * wishdir;
485
486         step = accel * frametime * wishspeed0;
487
488         vel_xy_current  = vlen(vel_xy);
489         vel_xy_forward  = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
490         vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw);
491         if(vel_xy_backward < 0)
492                 vel_xy_backward = 0; // not that it REALLY occurs that this would cause wrong behaviour afterwards
493
494         vel_straight = vel_straight + bound(0, wishspeed - vel_straight, step) * accelqw + step * (1 - accelqw);
495
496         if(sidefric < 0 && (vel_perpend*vel_perpend))
497                 // negative: only apply so much sideways friction to stay below the speed you could get by "braking"
498         {
499                 float f, fminimum;
500                 f = max(0, 1 + frametime * wishspeed * sidefric);
501                 fminimum = (vel_xy_backward*vel_xy_backward - vel_straight*vel_straight) / (vel_perpend*vel_perpend);
502                 // this cannot be > 1
503                 if(fminimum <= 0)
504                         vel_perpend = vel_perpend * max(0, f);
505                 else
506                 {
507                         fminimum = sqrt(fminimum);
508                         vel_perpend = vel_perpend * max(fminimum, f);
509                 }
510         }
511         else
512                 vel_perpend = vel_perpend * max(0, 1 - frametime * wishspeed * sidefric);
513         
514         vel_xy = vel_straight * wishdir + vel_perpend;
515         
516         if(speedclamp)
517         {
518                 // ensure we don't get too fast or decelerate faster than we should
519                 vel_xy_current = min(vlen(vel_xy), vel_xy_forward);
520                 if(vel_xy_current > 0) // prevent division by zero
521                         vel_xy = normalize(vel_xy) * vel_xy_current;
522         }
523
524         self.velocity = vel_xy + vel_z * '0 0 1';
525 }
526
527 void PM_AirAccelerate(vector wishdir, float wishspeed)
528 {
529         vector curvel, wishvel, acceldir, curdir;
530         float addspeed, accelspeed, curspeed, f;
531         float dot;
532
533         if(wishspeed == 0)
534                 return;
535
536         curvel = self.velocity;
537         curvel_z = 0;
538         curspeed = vlen(curvel);
539
540         if(wishspeed > curspeed * 1.01)
541         {
542                 wishspeed = min(wishspeed, curspeed + sv_warsowbunny_airforwardaccel * sv_maxspeed * frametime);
543         }
544         else
545         {
546                 f = max(0, (sv_warsowbunny_topspeed - curspeed) / (sv_warsowbunny_topspeed - sv_maxspeed));
547                 wishspeed = max(curspeed, sv_maxspeed) + sv_warsowbunny_accel * f * sv_maxspeed * frametime;
548         }
549         wishvel = wishdir * wishspeed;
550         acceldir = wishvel - curvel;
551         addspeed = vlen(acceldir);
552         acceldir = normalize(acceldir);
553
554         accelspeed = min(addspeed, sv_warsowbunny_turnaccel * sv_maxspeed * frametime);
555
556         if(sv_warsowbunny_backtosideratio < 1)
557         {
558                 curdir = normalize(curvel);
559                 dot = acceldir * curdir;
560                 if(dot < 0)
561                         acceldir = acceldir - (1 - sv_warsowbunny_backtosideratio) * dot * curdir;
562         }
563
564         self.velocity += accelspeed * acceldir;
565 }
566
567 .vector movement_old;
568 .float buttons_old;
569 .vector v_angle_old;
570 .string lastclassname;
571
572 .float() PlayerPhysplug;
573
574 string specialcommand = "xwxwxsxsxaxdxaxdx1x ";
575 .float specialcommand_pos;
576 void SpecialCommand()
577 {
578 #ifdef TETRIS
579         TetrisImpulse();
580 #else
581         if(!CheatImpulse(99))
582                 print("A hollow voice says \"Plugh\".\n");
583 #endif
584 }
585
586 float speedaward_speed;
587 string speedaward_holder;
588 void race_send_speedaward(float msg)
589 {
590         // send the best speed of the round
591         WriteByte(msg, SVC_TEMPENTITY);
592         WriteByte(msg, TE_CSQC_RACE);
593         WriteByte(msg, RACE_NET_SPEED_AWARD);
594         WriteInt24_t(msg, floor(speedaward_speed+0.5));
595         WriteString(msg, speedaward_holder);
596 }
597
598 float speedaward_alltimebest;
599 string speedaward_alltimebest_holder;
600 void race_send_speedaward_alltimebest(float msg)
601 {
602         // send the best speed
603         WriteByte(msg, SVC_TEMPENTITY);
604         WriteByte(msg, TE_CSQC_RACE);
605         WriteByte(msg, RACE_NET_SPEED_AWARD_BEST);
606         WriteInt24_t(msg, floor(speedaward_alltimebest+0.5));
607         WriteString(msg, speedaward_alltimebest_holder);
608 }
609
610 string GetMapname(void);
611 float speedaward_lastupdate;
612 float speedaward_lastsent;
613 .float jumppadusetime;
614 void SV_PlayerPhysics()
615 {
616         local vector wishvel, wishdir, v;
617         local float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, buttons;
618         string temps;
619         float buttons_prev;
620         float not_allowed_to_move;
621         string c;
622
623     if(self.PlayerPhysplug)
624         if(self.PlayerPhysplug())
625             return;
626
627         self.race_movetime_frac += frametime;
628         f = floor(self.race_movetime_frac);
629         self.race_movetime_frac -= f;
630         self.race_movetime_count += f;
631         self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
632
633         anticheat_physics();
634
635         buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * self.BUTTON_USE + 128 * (self.movement_x < 0) + 256 * (self.movement_x > 0) + 512 * (self.movement_y < 0) + 1024 * (self.movement_y > 0);
636
637         if(!buttons)
638                 c = "x";
639         else if(buttons == 1)
640                 c = "1";
641         else if(buttons == 2)
642                 c = " ";
643         else if(buttons == 128)
644                 c = "s";
645         else if(buttons == 256)
646                 c = "w";
647         else if(buttons == 512)
648                 c = "a";
649         else if(buttons == 1024)
650                 c = "d";
651         else
652                 c = "?";
653
654         if(c == substring(specialcommand, self.specialcommand_pos, 1))
655         {
656                 self.specialcommand_pos += 1;
657                 if(self.specialcommand_pos >= strlen(specialcommand))
658                 {
659                         self.specialcommand_pos = 0;
660                         SpecialCommand();
661                         return;
662                 }
663         }
664         else if(self.specialcommand_pos && (c != substring(specialcommand, self.specialcommand_pos - 1, 1)))
665                 self.specialcommand_pos = 0;
666
667         if(!sv_maxidle_spectatorsareidle || self.movetype == MOVETYPE_WALK)
668         {
669                 if(buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
670                         self.parm_idlesince = time;
671         }
672         buttons_prev = self.buttons_old;
673         self.buttons_old = buttons;
674         self.movement_old = self.movement;
675         self.v_angle_old = self.v_angle;
676
677         if(time < self.nickspamtime)
678         if(self.nickspamcount >= cvar("g_nick_flood_penalty_yellow"))
679         {
680                 // slight annoyance for nick change scripts
681                 self.movement = -1 * self.movement;
682                 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
683
684                 if(self.nickspamcount >= cvar("g_nick_flood_penalty_red")) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
685                 {
686                         self.angles_x = random() * 360;
687                         self.angles_y = random() * 360;
688                         // at least I'm not forcing retardedview by also assigning to angles_z
689                         self.fixangle = 1;
690                 }
691         }
692
693         if (self.punchangle != '0 0 0')
694         {
695                 f = vlen(self.punchangle) - 10 * frametime;
696                 if (f > 0)
697                         self.punchangle = normalize(self.punchangle) * f;
698                 else
699                         self.punchangle = '0 0 0';
700         }
701
702         if (self.punchvector != '0 0 0')
703         {
704                 f = vlen(self.punchvector) - 30 * frametime;
705                 if (f > 0)
706                         self.punchvector = normalize(self.punchvector) * f;
707                 else
708                         self.punchvector = '0 0 0';
709         }
710
711         if (clienttype(self) == CLIENTTYPE_BOT)
712         {
713                 if(playerdemo_read())
714                         return;
715                 bot_think();
716         }
717         
718         self.items &~= IT_USING_JETPACK;
719
720         if(self.classname == "player")
721         {
722                 if(self.race_penalty)
723                         if(time > self.race_penalty)
724                                 self.race_penalty = 0;
725
726                 not_allowed_to_move = 0;
727                 if(self.race_penalty)
728                         not_allowed_to_move = 1;
729                 if(!cvar("sv_ready_restart_after_countdown"))
730                 if(time < game_starttime)
731                         not_allowed_to_move = 1;
732
733                 if(not_allowed_to_move)
734                 {
735                         self.velocity = '0 0 0';
736                         self.movetype = MOVETYPE_NONE;
737                         self.disableclientprediction = 2;
738                 }
739                 else if(self.disableclientprediction == 2)
740                 {
741                         if(self.movetype == MOVETYPE_NONE)
742                                 self.movetype = MOVETYPE_WALK;
743                         self.disableclientprediction = 0;
744                 }
745         }
746
747         if (self.movetype == MOVETYPE_NONE)
748                 return;
749
750         maxspd_mod = 1;
751
752         if(g_runematch)
753         {
754                 if(self.runes & RUNE_SPEED)
755                 {
756                         if(self.runes & CURSE_SLOW)
757                                 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_combo_moverate");
758                         else
759                                 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_moverate");
760                 }
761                 else if(self.runes & CURSE_SLOW)
762                 {
763                         maxspd_mod = maxspd_mod * cvar("g_balance_curse_slow_moverate");
764                 }
765         }
766
767         if(g_minstagib && (self.items & IT_INVINCIBLE))
768         {
769                 maxspd_mod = cvar("g_minstagib_speed_moverate");
770         }
771
772         if(g_nexball && self.ballcarried)
773         {
774                 maxspd_mod = cvar("g_nexball_basketball_carrier_speed");
775         }
776
777         swampspd_mod = 1;
778         if(self.in_swamp) {
779                 swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
780         }
781
782         if(self.classname != "player")
783         {
784                 maxspd_mod = cvar("sv_spectator_speed_multiplier");
785                 if(!self.spectatorspeed)
786                         self.spectatorspeed = maxspd_mod;
787                 if(self.impulse && self.impulse <= 19)
788                 {
789                         if(self.lastclassname != "player")
790                         {
791                                 if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
792                                         self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
793                                 else if(self.impulse == 11)
794                                         self.spectatorspeed = maxspd_mod;
795                                 else if(self.impulse == 12 || self.impulse == 16  || self.impulse == 19)
796                                         self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
797                                 else if(self.impulse >= 1 && self.impulse <= 9)
798                                         self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
799                         } // otherwise just clear
800                         self.impulse = 0;
801                 }
802                 maxspd_mod = self.spectatorspeed;
803         }
804
805         spd = max(sv_maxspeed, sv_maxairspeed) * maxspd_mod * swampspd_mod;
806         if(self.speed != spd)
807         {
808                 self.speed = spd;
809                 temps = ftos(spd);
810                 stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
811                 stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
812                 stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
813                 stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
814         }
815
816         maxspd_mod *= swampspd_mod; // only one common speed modder please!
817         swampspd_mod = 1;
818
819         // if dead, behave differently
820         if (self.deadflag)
821                 goto end;
822
823         if (!self.fixangle && !g_bugrigs)
824         {
825                 self.angles_x = 0;
826                 self.angles_y = self.v_angle_y;
827                 self.angles_z = 0;
828         }
829
830         if(self.flags & FL_ONGROUND)
831         if(self.wasFlying)
832         {
833                 self.wasFlying = 0;
834
835                 if(self.waterlevel < WATERLEVEL_SWIMMING)
836                 if(time >= self.ladder_time)
837                 if not(self.hook)
838                 {
839                         self.nextstep = time + 0.3 + random() * 0.1;
840                         trace_dphitq3surfaceflags = 0;
841                         tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
842                         if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
843                         {
844                                 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
845                                         GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
846                                 else
847                                         GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
848                         }
849                 }
850         }
851
852         if(IsFlying(self))
853                 self.wasFlying = 1;
854
855         if(self.classname == "player")
856         {
857                 if(sv_doublejump && time - self.jumppadusetime > 2 * sys_frametime)
858                 {
859                         tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
860                         self.flags &~= FL_ONGROUND;
861                         if(trace_fraction < 1 && trace_plane_normal_z > 0.7)
862                                 self.flags |= FL_ONGROUND;
863                 }
864
865                 if (self.BUTTON_JUMP)
866                         PlayerJump ();
867                 else
868                         self.flags |= FL_JUMPRELEASED;
869
870                 if (self.waterlevel == WATERLEVEL_SWIMMING)
871                         CheckWaterJump ();
872         }
873
874         if (self.flags & FL_WATERJUMP )
875         {
876                 self.velocity_x = self.movedir_x;
877                 self.velocity_y = self.movedir_y;
878                 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
879                 {
880                         self.flags &~= FL_WATERJUMP;
881                         self.teleport_time = 0;
882                 }
883         }
884         else if (g_bugrigs && self.classname == "player")
885         {
886                 RaceCarPhysics();
887         }
888         else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
889         {
890                 // noclipping or flying
891                 self.flags &~= FL_ONGROUND;
892
893                 self.velocity = self.velocity * (1 - frametime * sv_friction);
894                 makevectors(self.v_angle);
895                 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
896                 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
897                 // acceleration
898                 wishdir = normalize(wishvel);
899                 wishspeed = vlen(wishvel);
900                 if (wishspeed > sv_maxspeed*maxspd_mod)
901                         wishspeed = sv_maxspeed*maxspd_mod;
902                 if (time >= self.teleport_time)
903                         PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
904         }
905         else if (self.waterlevel >= WATERLEVEL_SWIMMING)
906         {
907                 // swimming
908                 self.flags &~= FL_ONGROUND;
909
910                 makevectors(self.v_angle);
911                 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
912                 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
913                 if (wishvel == '0 0 0')
914                         wishvel = '0 0 -60'; // drift towards bottom
915
916                 wishdir = normalize(wishvel);
917                 wishspeed = vlen(wishvel);
918                 if (wishspeed > sv_maxspeed*maxspd_mod)
919                         wishspeed = sv_maxspeed*maxspd_mod;
920                 wishspeed = wishspeed * 0.7;
921
922                 // water friction
923                 self.velocity = self.velocity * (1 - frametime * sv_friction);
924
925                 // water acceleration
926                 PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
927         }
928         else if (time < self.ladder_time)
929         {
930                 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
931                 self.flags &~= FL_ONGROUND;
932
933                 self.velocity = self.velocity * (1 - frametime * sv_friction);
934                 makevectors(self.v_angle);
935                 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
936                 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
937                 if (self.gravity)
938                         self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime;
939                 else
940                         self.velocity_z = self.velocity_z + sv_gravity * frametime;
941                 if (self.ladder_entity.classname == "func_water")
942                 {
943                         f = vlen(wishvel);
944                         if (f > self.ladder_entity.speed)
945                                 wishvel = wishvel * (self.ladder_entity.speed / f);
946
947                         self.watertype = self.ladder_entity.skin;
948                         f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
949                         if ((self.origin_z + self.view_ofs_z) < f)
950                                 self.waterlevel = WATERLEVEL_SUBMERGED;
951                         else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
952                                 self.waterlevel = WATERLEVEL_SWIMMING;
953                         else if ((self.origin_z + self.mins_z + 1) < f)
954                                 self.waterlevel = WATERLEVEL_WETFEET;
955                         else
956                         {
957                                 self.waterlevel = WATERLEVEL_NONE;
958                                 self.watertype = CONTENT_EMPTY;
959                         }
960                 }
961                 // acceleration
962                 wishdir = normalize(wishvel);
963                 wishspeed = vlen(wishvel);
964                 if (wishspeed > sv_maxspeed*maxspd_mod)
965                         wishspeed = sv_maxspeed*maxspd_mod;
966                 if (time >= self.teleport_time)
967                 {
968                         // water acceleration
969                         PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
970                 }
971         }
972         else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!cvar("g_jetpack_fuel") || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO))
973         {
974                 //makevectors(self.v_angle_y * '0 1 0');
975                 makevectors(self.v_angle);
976                 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
977                 // add remaining speed as Z component
978                 maxairspd = sv_maxairspeed*max(1, maxspd_mod);
979                 // fix speedhacks :P
980                 wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1);
981                 // add the unused velocity as up component
982                 wishvel_z = 0;
983
984                 // if(self.BUTTON_JUMP)
985                         wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
986
987                 // it is now normalized, so...
988                 float a_side, a_up, a_add, a_diff;
989                 a_side = cvar("g_jetpack_acceleration_side");
990                 a_up = cvar("g_jetpack_acceleration_up");
991                 a_add = cvar("g_jetpack_antigravity") * sv_gravity;
992
993                 wishvel_x *= a_side;
994                 wishvel_y *= a_side;
995                 wishvel_z *= a_up;
996                 wishvel_z += a_add;
997
998                 float best;
999                 best = 0;
1000                 //////////////////////////////////////////////////////////////////////////////////////
1001                 // finding the maximum over all vectors of above form
1002                 // with wishvel having an absolute value of 1
1003                 //////////////////////////////////////////////////////////////////////////////////////
1004                 // we're finding the maximum over
1005                 //   f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
1006                 // for z in the range from -1 to 1
1007                 //////////////////////////////////////////////////////////////////////////////////////
1008                 // maximum is EITHER attained at the single extreme point:
1009                 a_diff = a_side * a_side - a_up * a_up;
1010                 if(a_diff != 0)
1011                 {
1012                         f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
1013                         if(f > -1 && f < 1) // can it be attained?
1014                         {
1015                                 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
1016                                 //print("middle\n");
1017                         }
1018                 }
1019                 // OR attained at z = 1:
1020                 f = (a_up + a_add) * (a_up + a_add);
1021                 if(f > best)
1022                 {
1023                         best = f;
1024                         //print("top\n");
1025                 }
1026                 // OR attained at z = -1:
1027                 f = (a_up - a_add) * (a_up - a_add);
1028                 if(f > best)
1029                 {
1030                         best = f;
1031                         //print("bottom\n");
1032                 }
1033                 best = sqrt(best);
1034                 //////////////////////////////////////////////////////////////////////////////////////
1035
1036                 //print("best possible acceleration: ", ftos(best), "\n");
1037
1038                 float fxy, fz;
1039                 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / cvar("g_jetpack_maxspeed_side"), 1);
1040                 if(wishvel_z - sv_gravity > 0)
1041                         fz = bound(0, 1 - self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
1042                 else
1043                         fz = bound(0, 1 + self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
1044
1045                 float fvel;
1046                 fvel = vlen(wishvel);
1047                 wishvel_x *= fxy;
1048                 wishvel_y *= fxy;
1049                 wishvel_z = (wishvel_z - sv_gravity) * fz + sv_gravity;
1050
1051                 fvel = min(1, vlen(wishvel) / best);
1052                 if(cvar("g_jetpack_fuel") && !(self.items & IT_UNLIMITED_WEAPON_AMMO))
1053                         f = min(1, self.ammo_fuel / (cvar("g_jetpack_fuel") * frametime * fvel));
1054                 else
1055                         f = 1;
1056
1057                 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
1058
1059                 if (f > 0 && wishvel != '0 0 0')
1060                 {
1061                         self.velocity = self.velocity + wishvel * f * frametime;
1062                         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
1063                                 self.ammo_fuel -= cvar("g_jetpack_fuel") * frametime * fvel * f;
1064                         self.flags &~= FL_ONGROUND;
1065                         self.items |= IT_USING_JETPACK;
1066
1067                         // jetpack also inhibits health regeneration, but only for 1 second
1068                         self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
1069                 }
1070         }
1071         else if (self.flags & FL_ONGROUND)
1072         {
1073                 // we get here if we ran out of ammo
1074                 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
1075                         sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1076
1077                 // walking
1078                 makevectors(self.v_angle_y * '0 1 0');
1079                 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
1080
1081                 if(!(self.lastflags & FL_ONGROUND))
1082                 {
1083                         if(cvar("speedmeter"))
1084                                 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
1085                         if(self.lastground < time - 0.3)
1086                                 self.velocity = self.velocity * (1 - cvar("sv_friction_on_land"));
1087                         if(self.jumppadcount > 1)
1088                                 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
1089                         self.jumppadcount = 0;
1090                 }
1091
1092 #ifdef LETS_TEST_FTEQCC
1093                 if(self.velocity_x || self.velocity_y)
1094                 {
1095                         // good
1096                 }
1097                 else
1098                 {
1099                         if(self.velocity_x)
1100                                 checkclient();
1101                         if(self.velocity_y)
1102                                 checkclient();
1103                 }
1104 #endif
1105
1106                 v = self.velocity;
1107                 v_z = 0;
1108                 f = vlen(v);
1109                 if(f > 0)
1110                 {
1111                         if (f < sv_stopspeed)
1112                                 f = 1 - frametime * (sv_stopspeed / f) * sv_friction;
1113                         else
1114                                 f = 1 - frametime * sv_friction;
1115                         if (f > 0)
1116                                 self.velocity = self.velocity * f;
1117                         else
1118                                 self.velocity = '0 0 0';
1119                 }
1120
1121                 // acceleration
1122                 wishdir = normalize(wishvel);
1123                 wishspeed = vlen(wishvel);
1124                 if (wishspeed > sv_maxspeed*maxspd_mod)
1125                         wishspeed = sv_maxspeed*maxspd_mod;
1126                 if (self.crouch)
1127                         wishspeed = wishspeed * 0.5;
1128                 if (time >= self.teleport_time)
1129                         PM_Accelerate(wishdir, wishspeed, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
1130         }
1131         else
1132         {
1133                 float wishspeed0;
1134                 // we get here if we ran out of ammo
1135                 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
1136                         sprint(self, "You don't have any fuel for the ^2Jetpack\n");
1137
1138                 if(maxspd_mod < 1)
1139                 {
1140                         maxairspd = sv_maxairspeed*maxspd_mod;
1141                         airaccel = sv_airaccelerate*maxspd_mod;
1142                 }
1143                 else
1144                 {
1145                         maxairspd = sv_maxairspeed;
1146                         airaccel = sv_airaccelerate;
1147                 }
1148                 // airborn
1149                 makevectors(self.v_angle_y * '0 1 0');
1150                 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
1151                 // acceleration
1152                 wishdir = normalize(wishvel);
1153                 wishspeed = wishspeed0 = vlen(wishvel);
1154                 if (wishspeed0 > sv_maxspeed*maxspd_mod)
1155                         wishspeed0 = sv_maxspeed*maxspd_mod;
1156                 if (wishspeed > maxairspd)
1157                         wishspeed = maxairspd;
1158                 if (self.crouch)
1159                         wishspeed = wishspeed * 0.5;
1160                 if (time >= self.teleport_time)
1161                 {
1162                         float accelerating;
1163                         float wishspeed2;
1164                         float airaccelqw;
1165
1166                         airaccelqw = sv_airaccel_qw;
1167                         accelerating = (self.velocity * wishdir > 0);
1168                         wishspeed2 = wishspeed;
1169
1170                         // CPM
1171                         if(sv_airstopaccelerate)
1172                                 if(self.velocity * wishdir < 0)
1173                                         airaccel = sv_airstopaccelerate*maxspd_mod;
1174                         // this doesn't play well with analog input, but can't r
1175                         // fixed like the AirControl can. So, don't set the maxa
1176                         // cvars when you want to support analog input.
1177                         if(self.movement_x == 0 && self.movement_y != 0)
1178                         {
1179                                 if(sv_maxairstrafespeed)
1180                                 {
1181                                         wishspeed = min(wishspeed, sv_maxairstrafespeed*maxspd_mod);
1182                                         if(sv_maxairstrafespeed < sv_maxairspeed)
1183                                                 airaccelqw = 1;
1184                                 }
1185                                 if(sv_airstrafeaccelerate)
1186                                 {
1187                                         airaccel = sv_airstrafeaccelerate*maxspd_mod;
1188                                         if(sv_airstrafeaccelerate > sv_airaccelerate)
1189                                                 airaccelqw = 1;
1190                                 }
1191                         }
1192                         // !CPM
1193
1194                         if(sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement_x != 0)
1195                                 PM_AirAccelerate(wishdir, wishspeed);
1196                         else
1197                                 PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, sv_airaccel_sideways_friction / maxairspd);
1198
1199                         if(sv_aircontrol)
1200                                 CPM_PM_Aircontrol(wishdir, wishspeed2);
1201                 }
1202         }
1203
1204         if((g_cts || g_race) && self.classname != "observer") {
1205                 if(vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) {
1206                         speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
1207                         speedaward_holder = self.netname;
1208                         speedaward_lastupdate = time;
1209                 }
1210                 if(speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1) {
1211                         string rr;
1212                         if(g_cts)
1213                                 rr = CTS_RECORD;
1214                         else
1215                                 rr = RACE_RECORD;
1216                         race_send_speedaward(MSG_ALL);
1217                         speedaward_lastsent = speedaward_speed;
1218                         if (speedaward_speed > speedaward_alltimebest) {
1219                                 speedaward_alltimebest = speedaward_speed;
1220                                 speedaward_alltimebest_holder = speedaward_holder;
1221                                 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
1222                                 db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/netname"), speedaward_alltimebest_holder);
1223                                 race_send_speedaward_alltimebest(MSG_ALL);
1224                         }
1225                 }
1226         }
1227 :end
1228         if(self.flags & FL_ONGROUND)
1229                 self.lastground = time;
1230
1231         self.lastflags = self.flags;
1232         self.lastclassname = self.classname;
1233 };