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 void PM_Accelerate(vector wishdir, float wishspeed, float accel, float accelqw, float sidefric)
383 vel_straight = self.velocity * wishdir;
384 vel_z = self.velocity_z;
385 vel_perpend = self.velocity - vel_straight * wishdir - vel_z * '0 0 1';
387 addspeed = wishspeed - vel_straight;
389 vel_straight = vel_straight + min(addspeed, accel * frametime * wishspeed) * accelqw;
391 vel_straight = vel_straight + min(wishspeed, accel * frametime * wishspeed) * (1 - accelqw);
393 vel_perpend = vel_perpend * (1 - frametime * wishspeed * sidefric);
395 self.velocity = vel_straight * wishdir + vel_z * '0 0 1' + vel_perpend;
398 .vector movement_old;
401 .string lastclassname;
403 void Nixnex_GiveCurrentWeapon();
404 void SV_PlayerPhysics()
406 local vector wishvel, wishdir, v;
407 local float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, shtest_score, buttons;
411 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;
412 if(!sv_maxidle_spectatorsareidle || self.movetype == MOVETYPE_WALK)
414 if(buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old)
415 self.parm_idlesince = time;
417 buttons_prev = self.buttons_old;
418 self.buttons_old = buttons;
419 self.movement_old = self.movement;
420 self.v_angle_old = self.v_angle;
422 if(time < self.nickspamtime)
423 if(self.nickspamcount >= cvar("g_nick_flood_penalty_yellow"))
425 // slight annoyance for nick change scripts
426 self.movement = -1 * self.movement;
427 self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
429 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!
431 self.angles_x = random() * 360;
432 self.angles_y = random() * 360;
433 // at least I'm not forcing retardedview by also assigning to angles_z
438 if(time > self.shtest_next)
440 if(self.shtest_next > 0)
442 // self.shtest_accumulator:
443 // started at time - SHTEST_DELTA
444 // should be at SHTEST_DELTA
445 shtest_score = self.shtest_accumulator / (SHTEST_DELTA + time - self.shtest_next);
446 if(shtest_score > SHTEST_THRESHOLD)
447 print("TIME PARADOX: shtest for ", self.netname, " said ", ftos(shtest_score), "\n");
448 else if(cvar("developer_shtest"))
449 dprint("okay: shtest for ", self.netname, " said ", ftos(shtest_score), "\n");
451 self.shtest_next = time + SHTEST_DELTA;
452 self.shtest_accumulator = 0;
454 self.shtest_accumulator += frametime;
456 if (clienttype(self) == CLIENTTYPE_BOT)
459 self.items &~= IT_USING_JETPACK;
461 if (self.movetype == MOVETYPE_NONE && self.disableclientprediction != 2)
464 if (self.punchangle != '0 0 0')
466 f = vlen(self.punchangle) - 10 * frametime;
468 self.punchangle = normalize(self.punchangle) * f;
470 self.punchangle = '0 0 0';
473 if (self.punchvector != '0 0 0')
475 f = vlen(self.punchvector) - 30 * frametime;
477 self.punchvector = normalize(self.punchvector) * f;
479 self.punchvector = '0 0 0';
486 if(self.runes & RUNE_SPEED)
488 if(self.runes & CURSE_SLOW)
489 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_combo_moverate");
491 maxspd_mod = maxspd_mod * cvar("g_balance_rune_speed_moverate");
493 else if(self.runes & CURSE_SLOW)
495 maxspd_mod = maxspd_mod * cvar("g_balance_curse_slow_moverate");
499 if(g_minstagib && (self.items & IT_INVINCIBLE))
501 maxspd_mod = cvar("g_minstagib_speed_moverate");
504 if(g_nexball && self.ballcarried)
506 maxspd_mod = cvar("g_nexball_basketball_carrier_speed");
511 swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
514 if(self.classname != "player")
516 maxspd_mod = cvar("sv_spectator_speed_multiplier");
517 if(!self.spectatorspeed)
518 self.spectatorspeed = maxspd_mod;
519 if(self.impulse && self.impulse <= 19)
521 if(self.lastclassname != "player")
523 if(self.impulse == 10 || self.impulse == 15 || self.impulse == 18)
524 self.spectatorspeed = bound(1, self.spectatorspeed + 0.5, 5);
525 else if(self.impulse == 11)
526 self.spectatorspeed = maxspd_mod;
527 else if(self.impulse == 12 || self.impulse == 16 || self.impulse == 19)
528 self.spectatorspeed = bound(1, self.spectatorspeed - 0.5, 5);
529 else if(self.impulse >= 1 && self.impulse <= 9)
530 self.spectatorspeed = 1 + 0.5 * (self.impulse - 1);
531 } // otherwise just clear
534 maxspd_mod = self.spectatorspeed;
537 spd = max(sv_maxspeed, sv_maxairspeed) * maxspd_mod * swampspd_mod;
538 if(self.speed != spd)
542 stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n"));
543 stuffcmd(self, strcat("cl_backspeed ", temps, "\n"));
544 stuffcmd(self, strcat("cl_sidespeed ", temps, "\n"));
545 stuffcmd(self, strcat("cl_upspeed ", temps, "\n"));
548 maxspd_mod *= swampspd_mod; // only one common speed modder please!
551 // if dead, behave differently
555 if (!self.fixangle && !g_bugrigs)
558 self.angles_y = self.v_angle_y;
562 if(self.flags & FL_ONGROUND)
567 if(self.waterlevel < WATERLEVEL_SWIMMING)
568 if(time >= self.ladder_time)
571 self.nextstep = time + 0.3 + random() * 0.1;
572 trace_dphitq3surfaceflags = 0;
573 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
574 if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
576 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
577 GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
579 GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
587 if(self.classname == "player")
591 self.flags &~= FL_ONGROUND;
592 tracebox(self.origin + '0 0 1', self.mins, self.maxs, self.origin - '0 0 2', MOVE_NORMAL, self);
593 if(trace_fraction < 1 && trace_plane_normal_z > 0.7)
594 self.flags |= FL_ONGROUND;
597 if (self.BUTTON_JUMP)
600 self.flags |= FL_JUMPRELEASED;
602 if (self.waterlevel == WATERLEVEL_SWIMMING)
606 if (self.flags & FL_WATERJUMP )
608 self.velocity_x = self.movedir_x;
609 self.velocity_y = self.movedir_y;
610 if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE)
612 self.flags &~= FL_WATERJUMP;
613 self.teleport_time = 0;
616 else if (g_bugrigs && self.classname == "player")
620 else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
622 // noclipping or flying
623 self.flags &~= FL_ONGROUND;
625 self.velocity = self.velocity * (1 - frametime * sv_friction);
626 makevectors(self.v_angle);
627 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
628 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
630 wishdir = normalize(wishvel);
631 wishspeed = vlen(wishvel);
632 if (wishspeed > sv_maxspeed*maxspd_mod)
633 wishspeed = sv_maxspeed*maxspd_mod;
634 if (time >= self.teleport_time)
635 PM_Accelerate(wishdir, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
637 else if (self.waterlevel >= WATERLEVEL_SWIMMING)
640 self.flags &~= FL_ONGROUND;
642 makevectors(self.v_angle);
643 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
644 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
645 if (wishvel == '0 0 0')
646 wishvel = '0 0 -60'; // drift towards bottom
648 wishdir = normalize(wishvel);
649 wishspeed = vlen(wishvel);
650 if (wishspeed > sv_maxspeed*maxspd_mod)
651 wishspeed = sv_maxspeed*maxspd_mod;
652 wishspeed = wishspeed * 0.7;
655 self.velocity = self.velocity * (1 - frametime * sv_friction);
657 // water acceleration
658 PM_Accelerate(wishdir, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
660 else if (time < self.ladder_time)
662 // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
663 self.flags &~= FL_ONGROUND;
665 self.velocity = self.velocity * (1 - frametime * sv_friction);
666 makevectors(self.v_angle);
667 //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
668 wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
670 self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime;
672 self.velocity_z = self.velocity_z + sv_gravity * frametime;
673 if (self.ladder_entity.classname == "func_water")
676 if (f > self.ladder_entity.speed)
677 wishvel = wishvel * (self.ladder_entity.speed / f);
679 self.watertype = self.ladder_entity.skin;
680 f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
681 if ((self.origin_z + self.view_ofs_z) < f)
682 self.waterlevel = WATERLEVEL_SUBMERGED;
683 else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
684 self.waterlevel = WATERLEVEL_SWIMMING;
685 else if ((self.origin_z + self.mins_z + 1) < f)
686 self.waterlevel = WATERLEVEL_WETFEET;
689 self.waterlevel = WATERLEVEL_NONE;
690 self.watertype = CONTENT_EMPTY;
694 wishdir = normalize(wishvel);
695 wishspeed = vlen(wishvel);
696 if (wishspeed > sv_maxspeed*maxspd_mod)
697 wishspeed = sv_maxspeed*maxspd_mod;
698 if (time >= self.teleport_time)
700 // water acceleration
701 PM_Accelerate(wishdir, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
704 else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!cvar("g_jetpack_fuel") || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO))
706 //makevectors(self.v_angle_y * '0 1 0');
707 makevectors(self.v_angle);
708 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
709 // add remaining speed as Z component
710 maxairspd = sv_maxairspeed*max(1, maxspd_mod);
712 wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1);
713 // add the unused velocity as up component
716 // if(self.BUTTON_JUMP)
717 wishvel_z = sqrt(max(0, 1 - wishvel * wishvel));
719 // it is now normalized, so...
720 float a_side, a_up, a_add, a_diff;
721 a_side = cvar("g_jetpack_acceleration_side");
722 a_up = cvar("g_jetpack_acceleration_up");
723 a_add = cvar("g_jetpack_antigravity") * sv_gravity;
732 //////////////////////////////////////////////////////////////////////////////////////
733 // finding the maximum over all vectors of above form
734 // with wishvel having an absolute value of 1
735 //////////////////////////////////////////////////////////////////////////////////////
736 // we're finding the maximum over
737 // f(a_side, a_up, a_add, z) := a_side * (1 - z^2) + (a_add + a_up * z)^2;
738 // for z in the range from -1 to 1
739 //////////////////////////////////////////////////////////////////////////////////////
740 // maximum is EITHER attained at the single extreme point:
741 a_diff = a_side * a_side - a_up * a_up;
744 f = a_add * a_up / a_diff; // this is the zero of diff(f(a_side, a_up, a_add, z), z)
745 if(f > -1 && f < 1) // can it be attained?
747 best = (a_diff + a_add * a_add) * (a_diff + a_up * a_up) / a_diff;
751 // OR attained at z = 1:
752 f = (a_up + a_add) * (a_up + a_add);
758 // OR attained at z = -1:
759 f = (a_up - a_add) * (a_up - a_add);
766 //////////////////////////////////////////////////////////////////////////////////////
768 //print("best possible acceleration: ", ftos(best), "\n");
771 fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / cvar("g_jetpack_maxspeed_side"), 1);
772 if(wishvel_z - sv_gravity > 0)
773 fz = bound(0, 1 - self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
775 fz = bound(0, 1 + self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
778 fvel = vlen(wishvel);
781 wishvel_z = (wishvel_z - sv_gravity) * fz + sv_gravity;
783 fvel = min(1, vlen(wishvel) / best);
784 if(cvar("g_jetpack_fuel") && !(self.items & IT_UNLIMITED_WEAPON_AMMO))
785 f = min(1, self.ammo_fuel / (cvar("g_jetpack_fuel") * frametime * fvel));
789 //print("this acceleration: ", ftos(vlen(wishvel) * f), "\n");
791 if (f > 0 && wishvel != '0 0 0')
793 self.velocity = self.velocity + wishvel * f * frametime;
794 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
795 self.ammo_fuel -= cvar("g_jetpack_fuel") * frametime * fvel * f;
796 self.flags &~= FL_ONGROUND;
797 self.items |= IT_USING_JETPACK;
799 // jetpack also inhibits health regeneration, but only for 1 second
800 self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
803 else if (self.flags & FL_ONGROUND)
805 // we get here if we ran out of ammo
806 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
807 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
810 makevectors(self.v_angle_y * '0 1 0');
811 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
813 if(!(self.lastflags & FL_ONGROUND))
815 if(cvar("speedmeter"))
816 dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
817 if(self.lastground < time - 0.3)
818 self.velocity = self.velocity * (1 - cvar("sv_friction_on_land"));
819 if(self.jumppadcount > 1)
820 dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
821 self.jumppadcount = 0;
824 if (self.velocity_x || self.velocity_y)
825 if (!(self.flags & FL_JUMPRELEASED) || !self.BUTTON_JUMP)
830 if (f < sv_stopspeed)
831 f = 1 - frametime * (sv_stopspeed / f) * sv_friction;
833 f = 1 - frametime * sv_friction;
835 self.velocity = self.velocity * f;
837 self.velocity = '0 0 0';
840 wishdir = normalize(wishvel);
841 wishspeed = vlen(wishvel);
842 if (wishspeed > sv_maxspeed*maxspd_mod)
843 wishspeed = sv_maxspeed*maxspd_mod;
845 wishspeed = wishspeed * 0.5;
846 if (time >= self.teleport_time)
847 PM_Accelerate(wishdir, wishspeed, sv_accelerate*maxspd_mod, 1, 0);
851 // we get here if we ran out of ammo
852 if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32))
853 sprint(self, "You don't have any fuel for the ^2Jetpack\n");
857 maxairspd = sv_maxairspeed*maxspd_mod;
858 airaccel = sv_airaccelerate*maxspd_mod;
862 maxairspd = sv_maxairspeed;
863 airaccel = sv_airaccelerate;
866 makevectors(self.v_angle_y * '0 1 0');
867 wishvel = v_forward * self.movement_x + v_right * self.movement_y;
869 wishdir = normalize(wishvel);
870 wishspeed = vlen(wishvel);
871 if (wishspeed > maxairspd)
872 wishspeed = maxairspd;
874 wishspeed = wishspeed * 0.5;
875 if (time >= self.teleport_time)
879 wishspeed2 = wishspeed;
880 if(sv_airstopaccelerate)
881 if(self.velocity * wishdir < 0)
882 airaccel = sv_airstopaccelerate;
883 if(self.movement_x == 0 && self.movement_y != 0)
885 if(sv_maxairstrafespeed)
886 wishspeed = min(wishspeed, sv_maxairstrafespeed);
887 if(sv_airstrafeaccelerate)
888 airaccel = sv_airstrafeaccelerate;
892 PM_Accelerate(wishdir, wishspeed, airaccel, sv_airaccel_qw, sv_airaccel_sideways_friction / maxairspd);
894 CPM_PM_Aircontrol(wishdir, wishspeed2);
897 f = wishspeed;// - (self.velocity * wishdir);
899 self.velocity = self.velocity + wishdir * min(f, airaccel * frametime * wishspeed);
905 if(self.flags & FL_ONGROUND)
906 self.lastground = time;
908 self.lastflags = self.flags;
909 self.lastclassname = self.classname;