4 float sv_airaccelerate;
8 float sv_airaccel_sideways_friction;
10 float sv_airstopaccelerate;
11 float sv_airstrafeaccelerate;
12 float sv_maxairstrafespeed;
15 .entity ladder_entity;
17 .float swamp_slowdown;
21 .float spectatorspeed;
23 #define SHTEST_DELTA 10
24 #define SHTEST_THRESHOLD 1.1
26 .float shtest_accumulator;
32 When you press the jump key
35 void PlayerJump (void)
39 mjumpheight = cvar("sv_jumpvelocity");
40 if (self.waterlevel >= WATERLEVEL_SWIMMING)
42 if (self.watertype == CONTENT_WATER)
43 self.velocity_z = 200;
44 else if (self.watertype == CONTENT_SLIME)
53 if (!(self.flags & FL_ONGROUND))
57 if (!(self.flags & FL_JUMPRELEASED))
60 if(self.health <= g_bloodloss)
65 if(self.runes & RUNE_SPEED)
67 if(self.runes & CURSE_SLOW)
68 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_combo_jumpheight");
70 mjumpheight = mjumpheight * cvar("g_balance_rune_speed_jumpheight");
72 else if(self.runes & CURSE_SLOW)
74 mjumpheight = mjumpheight * cvar("g_balance_curse_slow_jumpheight");
78 if(g_minstagib && (self.items & IT_INVINCIBLE))
80 mjumpheight = mjumpheight * cvar("g_minstagib_speed_jumpheight");
83 self.velocity_z = self.velocity_z + mjumpheight;
84 self.oldvelocity_z = self.velocity_z;
86 self.flags &~= FL_ONGROUND;
87 self.flags &~= FL_JUMPRELEASED;
90 setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE);
92 setanim(self, self.anim_jump, FALSE, TRUE, TRUE);
95 PlayerSound(playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
100 local vector start, end;
102 // check for a jump-out-of-water
103 makevectors (self.angles);
105 start_z = start_z + 8;
107 normalize(v_forward);
108 end = start + v_forward*24;
109 traceline (start, end, TRUE, self);
110 if (trace_fraction < 1)
112 start_z = start_z + self.maxs_z - 8;
113 end = start + v_forward*24;
114 self.movedir = trace_plane_normal * -50;
115 traceline (start, end, TRUE, self);
116 if (trace_fraction == 1)
117 { // open at eye level
118 self.flags |= FL_WATERJUMP;
119 self.velocity_z = 225;
120 self.flags &~= FL_JUMPRELEASED;
121 self.teleport_time = time + 2; // safety net
127 float racecar_angle(float forward, float down)
129 float ret, angle_mult;
137 ret = vectoyaw('0 1 0' * down + '1 0 0' * forward);
139 angle_mult = forward / (800 + forward);
142 return ret * angle_mult + 360 * (1 - angle_mult);
144 return ret * angle_mult;
147 void RaceCarPhysics()
149 // using this move type for "big rigs"
150 // the engine does not push the entity!
152 float accel, steer, f;
153 vector angles_save, rigvel;
155 angles_save = self.angles;
156 accel = bound(-1, self.movement_x / sv_maxspeed, 1);
157 steer = bound(-1, self.movement_y / sv_maxspeed, 1);
159 if(g_bugrigs_reverse_speeding)
163 // back accel is DIGITAL
164 // to prevent speedhack
174 makevectors(self.angles); // new forward direction!
176 if(self.flags & FL_ONGROUND || g_bugrigs_air_steering)
178 float myspeed, upspeed, steerfactor, accelfactor;
180 myspeed = self.velocity * v_forward;
181 upspeed = self.velocity * v_up;
183 // responsiveness factor for steering and acceleration
184 f = 1 / (1 + pow(max(-myspeed, myspeed) / g_bugrigs_speed_ref, g_bugrigs_speed_pow));
185 //MAXIMA: f(v) := 1 / (1 + (v / g_bugrigs_speed_ref) ^ g_bugrigs_speed_pow);
187 if(myspeed < 0 && g_bugrigs_reverse_spinning)
188 steerfactor = -myspeed * g_bugrigs_steer;
190 steerfactor = -myspeed * f * g_bugrigs_steer;
192 if(myspeed < 0 && g_bugrigs_reverse_speeding)
193 accelfactor = g_bugrigs_accel;
195 accelfactor = f * g_bugrigs_accel;
196 //MAXIMA: accel(v) := f(v) * g_bugrigs_accel;
202 myspeed = max(0, myspeed - frametime * (g_bugrigs_friction_floor - g_bugrigs_friction_brake * accel));
206 if(!g_bugrigs_reverse_speeding)
207 myspeed = min(0, myspeed + frametime * g_bugrigs_friction_floor);
214 myspeed = max(0, myspeed - frametime * g_bugrigs_friction_floor);
218 if(g_bugrigs_reverse_stopping)
221 myspeed = min(0, myspeed + frametime * (g_bugrigs_friction_floor + g_bugrigs_friction_brake * accel));
224 // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
225 //MAXIMA: friction(v) := g_bugrigs_friction_floor;
227 self.angles_y += steer * frametime * steerfactor; // apply steering
228 makevectors(self.angles); // new forward direction!
230 myspeed += accel * accelfactor * frametime;
232 rigvel = myspeed * v_forward + '0 0 1' * upspeed;
236 myspeed = vlen(self.velocity);
238 // responsiveness factor for steering and acceleration
239 f = 1 / (1 + pow(max(0, myspeed / g_bugrigs_speed_ref), g_bugrigs_speed_pow));
240 steerfactor = -myspeed * f;
241 self.angles_y += steer * frametime * steerfactor; // apply steering
243 rigvel = self.velocity;
244 makevectors(self.angles); // new forward direction!
247 rigvel = rigvel * max(0, 1 - vlen(rigvel) * g_bugrigs_friction_air * frametime);
248 //MAXIMA: airfriction(v) := v * v * g_bugrigs_friction_air;
249 //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
250 //MAXIMA: solve(total_acceleration(v) = 0, v);
252 if(g_bugrigs_planar_movement)
254 vector rigvel_xy, neworigin, up;
257 rigvel_z -= frametime * sv_gravity; // 4x gravity plays better
261 if(g_bugrigs_planar_movement_car_jumping && !g_touchexplode) // touchexplode is a better way to handle collisions
264 mt = MOVE_NOMONSTERS;
266 tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', mt, self);
267 up = trace_endpos - self.origin;
269 // BUG RIGS: align the move to the surface instead of doing collision testing
271 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * frametime, mt, self);
274 tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * frametime, mt, self);
276 if(trace_fraction < 0.5)
279 neworigin = self.origin;
282 neworigin = trace_endpos;
284 if(trace_fraction < 1)
286 // now set angles_x so that the car points parallel to the surface
287 self.angles = vectoangles(
288 '1 0 0' * v_forward_x * trace_plane_normal_z
290 '0 1 0' * v_forward_y * trace_plane_normal_z
292 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
294 self.flags |= FL_ONGROUND;
298 // now set angles_x so that the car points forward, but is tilted in velocity direction
299 self.flags &~= FL_ONGROUND;
302 self.velocity = (neworigin - self.origin) * (1.0 / frametime);
303 self.movetype = MOVETYPE_NOCLIP;
307 rigvel_z -= frametime * sv_gravity; // 4x gravity plays better
308 self.velocity = rigvel;
309 self.movetype = MOVETYPE_FLY;
313 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self);
314 if(trace_fraction != 1)
316 self.angles = vectoangles2(
317 '1 0 0' * v_forward_x * trace_plane_normal_z
319 '0 1 0' * v_forward_y * trace_plane_normal_z
321 '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y),
329 vel_local_x = v_forward * self.velocity;
330 vel_local_y = v_right * self.velocity;
331 vel_local_z = v_up * self.velocity;
333 self.angles_x = racecar_angle(vel_local_x, vel_local_z);
334 self.angles_z = racecar_angle(-vel_local_y, vel_local_z);
338 vector vf1, vu1, smoothangles;
339 makevectors(self.angles);
340 f = bound(0, frametime * g_bugrigs_angle_smoothing, 1);
345 makevectors(angles_save);
346 vf1 = vf1 + v_forward * (1 - f);
347 vu1 = vu1 + v_up * (1 - f);
348 smoothangles = vectoangles2(vf1, vu1);
349 self.angles_x = -smoothangles_x;
350 self.angles_z = smoothangles_z;
353 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
355 float zspeed, xyspeed, dot, k;
357 if(self.movement_x == 0 || self.movement_y != 0)
358 return; // can't control movement if not moving forward or backward
360 zspeed = self.velocity_z;
362 xyspeed = vlen(self.velocity);
363 self.velocity = normalize(self.velocity);
365 dot = self.velocity * wishdir;
367 k *= sv_aircontrol*dot*dot*frametime;
369 if(dot > 0) // we can't change direction while slowing down
370 self.velocity = normalize(self.velocity * xyspeed + wishdir * k);
372 self.velocity = self.velocity * xyspeed;
373 self.velocity_z = zspeed;
376 .vector movement_old;
379 .string lastclassname;
381 void Nixnex_GiveCurrentWeapon();
382 void SV_PlayerPhysics()
384 local vector wishvel, wishdir, v;
385 local float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, shtest_score, buttons;
389 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;
390 if(!sv_maxidle_spectatorsareidle || self.movetype == MOVETYPE_WALK)
392 if(buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
393 self.parm_idlesince = time;
395 buttons_prev = self.buttons_old;
396 self.buttons_old = buttons;
397 self.movement_old = self.movement;
398 self.v_angle_old = self.v_angle;
400 if(time < self.nickspamtime)
401 if(self.nickspamcount >= cvar("g_nick_flood_penalty_yellow"))
403 // slight annoyance for nick change scripts
404 self.movement = -1 * self.movement;
405 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
407 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!
409 self.angles_x = random() * 360;
410 self.angles_y = random() * 360;
411 // at least I'm not forcing retardedview by also assigning to angles_z
416 if(time > self.shtest_next)
418 if(self.shtest_next > 0)
420 // self.shtest_accumulator:
421 // started at time - SHTEST_DELTA
422 // should be at SHTEST_DELTA
423 shtest_score = self.shtest_accumulator / (SHTEST_DELTA + time - self.shtest_next);
424 if(shtest_score > SHTEST_THRESHOLD)
425 print("TIME PARADOX: shtest for ", self.netname, " said ", ftos(shtest_score), "\n");
426 else if(cvar("developer_shtest"))
427 dprint("okay: shtest for ", self.netname, " said ", ftos(shtest_score), "\n");
429 self.shtest_next = time + SHTEST_DELTA;
430 self.shtest_accumulator = 0;
432 self.shtest_accumulator += frametime;
434 if (clienttype(self) == CLIENTTYPE_BOT)
437 self.items &~= IT_USING_JETPACK;
439 if (self.movetype == MOVETYPE_NONE && self.disableclientprediction != 2)
442 if (self.punchangle != '0 0 0')
444 f = vlen(self.punchangle) - 10 * frametime;
446 self.punchangle = normalize(self.punchangle) * f;
448 self.punchangle = '0 0 0';
451 if (self.punchvector != '0 0 0')
453 f = vlen(self.punchvector) - 30 * frametime;
455 self.punchvector = normalize(self.punchvector) * f;
457 self.punchvector = '0 0 0';
464 if(self.runes & RUNE_SPEED)
466 if(self.runes & CURSE_SLOW)
467 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_combo_moverate");
469 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_moverate");
471 else if(self.runes & CURSE_SLOW)
473 maxspd_mod = maxspd_mod * cvar("g_balance_curse_slow_moverate");
477 if(g_minstagib && (self.items & IT_INVINCIBLE))
479 maxspd_mod = cvar("g_minstagib_speed_moverate");
484 swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
487 if(self.classname != "player")
489 maxspd_mod = cvar("sv_spectator_speed_multiplier");
490 if(!self.spectatorspeed)
491 self.spectatorspeed = maxspd_mod;
492 if(self.impulse && self.impulse <= 19)
494 if(self.lastclassname != "player")
496 if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
497 self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
498 else if(self.impulse == 11)
499 self.spectatorspeed = maxspd_mod;
500 else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19)
501 self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
502 else if(self.impulse >= 1 && self.impulse <= 9)
503 self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
504 } // otherwise just clear
507 maxspd_mod = self.spectatorspeed;
510 spd = sv_maxspeed * maxspd_mod * swampspd_mod;
512 if(self.speed != spd)
516 stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
517 stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
518 stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
519 stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
521 temps = ftos(sv_accelerate * maxspd_mod);
522 stuffcmd(self, strcat("cl_movement_accelerate ", temps, "\n"));
525 // if dead, behave differently
529 if (!self.fixangle && !g_bugrigs)
532 self.angles_y = self.v_angle_y;
536 if(self.flags & FL_ONGROUND)
541 if(self.waterlevel < WATERLEVEL_SWIMMING)
542 if(time >= self.ladder_time)
545 self.nextstep = time + 0.3 + random() * 0.1;
546 trace_dphitq3surfaceflags = 0;
547 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
548 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
550 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
551 GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
553 GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
561 if(self.classname == "player")
565 self.flags &~= FL_ONGROUND;
566 tracebox(self.origin + '0 0 1', self.mins, self.maxs, self.origin - '0 0 2', MOVE_NORMAL, self);
567 if(trace_fraction < 1 && trace_plane_normal_z > 0.7)
568 self.flags |= FL_ONGROUND;
571 if (self.BUTTON_JUMP)
574 self.flags |= FL_JUMPRELEASED;
576 if (self.waterlevel == WATERLEVEL_SWIMMING)
580 if (self.flags & FL_WATERJUMP )
582 self.velocity_x = self.movedir_x;
583 self.velocity_y = self.movedir_y;
584 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
586 self.flags &~= FL_WATERJUMP;
587 self.teleport_time = 0;
590 else if (g_bugrigs && self.classname == "player")
594 else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
596 // noclipping or flying
597 self.flags &~= FL_ONGROUND;
599 self.velocity = self.velocity * (1 - frametime * sv_friction);
600 makevectors(self.v_angle);
601 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
602 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
604 wishdir = normalize(wishvel);
605 wishspeed = vlen(wishvel);
606 if (wishspeed > sv_maxspeed*maxspd_mod)
607 wishspeed = sv_maxspeed*maxspd_mod;
608 if (time >= self.teleport_time)
610 f = wishspeed - (self.velocity * wishdir);
612 self.velocity = self.velocity + wishdir * min(f, sv_accelerate*maxspd_mod * frametime * wishspeed);
615 else if (self.waterlevel >= WATERLEVEL_SWIMMING)
618 self.flags &~= FL_ONGROUND;
620 makevectors(self.v_angle);
621 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
622 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
623 if (wishvel == '0 0 0')
624 wishvel = '0 0 -60'; // drift towards bottom
626 wishdir = normalize(wishvel);
627 wishspeed = vlen(wishvel);
628 if (wishspeed > sv_maxspeed*maxspd_mod)
629 wishspeed = sv_maxspeed*maxspd_mod;
630 wishspeed = wishspeed * 0.7;
633 self.velocity = self.velocity * (1 - frametime * sv_friction);
635 // water acceleration
636 f = wishspeed - (self.velocity * wishdir);
638 self.velocity = self.velocity + wishdir * min(f, sv_accelerate*maxspd_mod * frametime * wishspeed);
640 else if (time < self.ladder_time)
642 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
643 self.flags &~= FL_ONGROUND;
645 self.velocity = self.velocity * (1 - frametime * sv_friction);
646 makevectors(self.v_angle);
647 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
648 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
650 self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime;
652 self.velocity_z = self.velocity_z + sv_gravity * frametime;
653 if (self.ladder_entity.classname == "func_water")
656 if (f > self.ladder_entity.speed)
657 wishvel = wishvel * (self.ladder_entity.speed / f);
659 self.watertype = self.ladder_entity.skin;
660 f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
661 if ((self.origin_z + self.view_ofs_z) < f)
662 self.waterlevel = WATERLEVEL_SUBMERGED;
663 else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
664 self.waterlevel = WATERLEVEL_SWIMMING;
665 else if ((self.origin_z + self.mins_z + 1) < f)
666 self.waterlevel = WATERLEVEL_WETFEET;
669 self.waterlevel = WATERLEVEL_NONE;
670 self.watertype = CONTENT_EMPTY;
674 wishdir = normalize(wishvel);
675 wishspeed = vlen(wishvel);
676 if (wishspeed > sv_maxspeed)
677 wishspeed = sv_maxspeed;
678 if (time >= self.teleport_time)
680 f = wishspeed - (self.velocity * wishdir);
682 self.velocity = self.velocity + wishdir * min(f, sv_accelerate*maxspd_mod * frametime * wishspeed);
685 else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!cvar("g_jetpack_fuel") || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO))
687 //makevectors(self.v_angle_y * '0 1 0');
688 makevectors(self.v_angle);
689 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
690 // add remaining speed as Z component
691 maxairspd = sv_maxairspeed*max(1, maxspd_mod);
693 wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1);
694 // add the unused velocity as up component
697 // if(self.BUTTON_JUMP)
698 wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
700 // it is now normalized, so...
701 float a_side, a_up, a_add, a_diff;
702 a_side = cvar("g_jetpack_acceleration_side");
703 a_up = cvar("g_jetpack_acceleration_up");
704 a_add = cvar("g_jetpack_antigravity") * sv_gravity;
713 //////////////////////////////////////////////////////////////////////////////////////
714 // finding the maximum over all vectors of above form
715 // with wishvel having an absolute value of 1
716 //////////////////////////////////////////////////////////////////////////////////////
717 // we're finding the maximum over
718 // f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
719 // for z in the range from -1 to 1
720 //////////////////////////////////////////////////////////////////////////////////////
721 // maximum is EITHER attained at the single extreme point:
722 a_diff = a_side * a_side - a_up * a_up;
725 f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
726 if(f > -1 && f < 1) // can it be attained?
728 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
732 // OR attained at z = 1:
733 f = (a_up + a_add) * (a_up + a_add);
739 // OR attained at z = -1:
740 f = (a_up - a_add) * (a_up - a_add);
747 //////////////////////////////////////////////////////////////////////////////////////
749 //print("best possible acceleration: ", ftos(best), "\n");
752 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / cvar("g_jetpack_maxspeed_side"), 1);
753 if(wishvel_z - sv_gravity > 0)
754 fz = bound(0, 1 - self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
756 fz = bound(0, 1 + self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
759 fvel = vlen(wishvel);
762 wishvel_z = (wishvel_z - sv_gravity) * fz + sv_gravity;
764 fvel = min(1, vlen(wishvel) / best);
765 if(cvar("g_jetpack_fuel") && !(self.items & IT_UNLIMITED_WEAPON_AMMO))
766 f = min(1, self.ammo_fuel / (cvar("g_jetpack_fuel") * frametime * fvel));
770 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
772 if (f > 0 && wishvel != '0 0 0')
774 self.velocity = self.velocity + wishvel * f * frametime;
775 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
776 self.ammo_fuel -= cvar("g_jetpack_fuel") * frametime * fvel * f;
777 self.flags &~= FL_ONGROUND;
778 self.items |= IT_USING_JETPACK;
780 // jetpack also inhibits health regeneration, but only for 1 second
781 self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
784 else if (self.flags & FL_ONGROUND)
786 // we get here if we ran out of ammo
787 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
788 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
791 makevectors(self.v_angle_y * '0 1 0');
792 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
794 if(!(self.lastflags & FL_ONGROUND))
796 if(cvar("speedmeter"))
797 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
798 if(self.lastground < time - 0.3)
799 self.velocity = self.velocity * (1 - cvar("sv_friction_on_land"));
800 if(self.jumppadcount > 1)
801 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
802 self.jumppadcount = 0;
805 if (self.velocity_x || self.velocity_y)
806 if (!(self.flags & FL_JUMPRELEASED) || !self.BUTTON_JUMP)
811 if (f < sv_stopspeed)
812 f = 1 - frametime * (sv_stopspeed / f) * sv_friction;
814 f = 1 - frametime * sv_friction;
816 self.velocity = self.velocity * f;
818 self.velocity = '0 0 0';
821 wishdir = normalize(wishvel);
822 wishspeed = vlen(wishvel);
823 if (wishspeed > sv_maxspeed*maxspd_mod)
824 wishspeed = sv_maxspeed*maxspd_mod;
826 wishspeed = wishspeed * 0.5;
827 if (time >= self.teleport_time)
829 f = wishspeed - (self.velocity * wishdir);
831 self.velocity = self.velocity + wishdir * min(f, sv_accelerate*maxspd_mod * frametime * wishspeed);
836 // we get here if we ran out of ammo
837 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
838 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
842 maxairspd = sv_maxairspeed*maxspd_mod;
843 airaccel = sv_airaccelerate*maxspd_mod;
847 maxairspd = sv_maxairspeed;
848 airaccel = sv_airaccelerate;
851 makevectors(self.v_angle_y * '0 1 0');
852 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
854 wishdir = normalize(wishvel);
855 wishspeed = vlen(wishvel);
856 if (wishspeed > maxairspd)
857 wishspeed = maxairspd;
859 wishspeed = wishspeed * 0.5;
860 if (time >= self.teleport_time)
864 wishspeed2 = wishspeed;
865 if(sv_airstopaccelerate)
866 if(self.velocity * wishdir < 0)
867 airaccel = sv_airstopaccelerate;
868 if(self.movement_x == 0 && self.movement_y != 0)
870 if(sv_maxairstrafespeed)
871 wishspeed = min(wishspeed, sv_maxairstrafespeed);
872 if(sv_airstrafeaccelerate)
873 airaccel = sv_airstrafeaccelerate;
877 // NOTE: this does the same as the commented out old code if:
879 // sv_airaccel_sideways_friction 0
884 vel_straight = self.velocity * wishdir;
885 vel_z = self.velocity_z;
886 vel_perpend = self.velocity - vel_straight * wishdir - vel_z * '0 0 1';
888 f = wishspeed - vel_straight;
890 vel_straight = vel_straight + min(f, airaccel * frametime * wishspeed) * sv_airaccel_qw;
892 vel_straight = vel_straight + min(wishspeed, airaccel * frametime * wishspeed) * (1 - sv_airaccel_qw);
894 // anti-sideways friction to fix QW-style bunnyhopping
895 vel_perpend = vel_perpend * (1 - frametime * (wishspeed / maxairspd) * sv_airaccel_sideways_friction);
897 self.velocity = vel_straight * wishdir + vel_z * '0 0 1' + vel_perpend;
900 CPM_PM_Aircontrol(wishdir, wishspeed2);
903 f = wishspeed;// - (self.velocity * wishdir);
905 self.velocity = self.velocity + wishdir * min(f, airaccel * frametime * wishspeed);
911 if(self.flags & FL_ONGROUND)
912 self.lastground = time;
914 self.lastflags = self.flags;
915 self.lastclassname = self.classname;