3 #ifdef SVQC // NOTE: disabled on the client side until prediction can be fixed! 14 void bugrigs_SetVars();
30 #define PHYS_BUGRIGS(s) STAT(BUGRIGS, s) 31 #define PHYS_BUGRIGS_ACCEL(s) STAT(BUGRIGS_ACCEL, s) 32 #define PHYS_BUGRIGS_AIR_STEERING(s) STAT(BUGRIGS_AIR_STEERING, s) 33 #define PHYS_BUGRIGS_ANGLE_SMOOTHING(s) STAT(BUGRIGS_ANGLE_SMOOTHING, s) 34 #define PHYS_BUGRIGS_CAR_JUMPING(s) STAT(BUGRIGS_CAR_JUMPING, s) 35 #define PHYS_BUGRIGS_FRICTION_AIR(s) STAT(BUGRIGS_FRICTION_AIR, s) 36 #define PHYS_BUGRIGS_FRICTION_BRAKE(s) STAT(BUGRIGS_FRICTION_BRAKE, s) 37 #define PHYS_BUGRIGS_FRICTION_FLOOR(s) STAT(BUGRIGS_FRICTION_FLOOR, s) 38 #define PHYS_BUGRIGS_PLANAR_MOVEMENT(s) STAT(BUGRIGS_PLANAR_MOVEMENT, s) 39 #define PHYS_BUGRIGS_REVERSE_SPEEDING(s) STAT(BUGRIGS_REVERSE_SPEEDING, s) 40 #define PHYS_BUGRIGS_REVERSE_SPINNING(s) STAT(BUGRIGS_REVERSE_SPINNING, s) 41 #define PHYS_BUGRIGS_REVERSE_STOPPING(s) STAT(BUGRIGS_REVERSE_STOPPING, s) 42 #define PHYS_BUGRIGS_SPEED_POW(s) STAT(BUGRIGS_SPEED_POW, s) 43 #define PHYS_BUGRIGS_SPEED_REF(s) STAT(BUGRIGS_SPEED_REF, s) 44 #define PHYS_BUGRIGS_STEER(s) STAT(BUGRIGS_STEER, s) 46 #define PHYS_BUGRIGS(s) g_bugrigs 47 #define PHYS_BUGRIGS_ACCEL(s) g_bugrigs_accel 48 #define PHYS_BUGRIGS_AIR_STEERING(s) g_bugrigs_air_steering 49 #define PHYS_BUGRIGS_ANGLE_SMOOTHING(s) g_bugrigs_angle_smoothing 50 #define PHYS_BUGRIGS_CAR_JUMPING(s) g_bugrigs_planar_movement_car_jumping 51 #define PHYS_BUGRIGS_FRICTION_AIR(s) g_bugrigs_friction_air 52 #define PHYS_BUGRIGS_FRICTION_BRAKE(s) g_bugrigs_friction_brake 53 #define PHYS_BUGRIGS_FRICTION_FLOOR(s) g_bugrigs_friction_floor 54 #define PHYS_BUGRIGS_PLANAR_MOVEMENT(s) g_bugrigs_planar_movement 55 #define PHYS_BUGRIGS_REVERSE_SPEEDING(s) g_bugrigs_reverse_speeding 56 #define PHYS_BUGRIGS_REVERSE_SPINNING(s) g_bugrigs_reverse_spinning 57 #define PHYS_BUGRIGS_REVERSE_STOPPING(s) g_bugrigs_reverse_stopping 58 #define PHYS_BUGRIGS_SPEED_POW(s) g_bugrigs_speed_pow 59 #define PHYS_BUGRIGS_SPEED_REF(s) g_bugrigs_speed_ref 60 #define PHYS_BUGRIGS_STEER(s) g_bugrigs_steer 65 void bugrigs_SetVars()
67 g_bugrigs =
cvar(
"g_bugrigs");
68 g_bugrigs_planar_movement =
cvar(
"g_bugrigs_planar_movement");
69 g_bugrigs_planar_movement_car_jumping =
cvar(
"g_bugrigs_planar_movement_car_jumping");
70 g_bugrigs_reverse_spinning =
cvar(
"g_bugrigs_reverse_spinning");
71 g_bugrigs_reverse_speeding =
cvar(
"g_bugrigs_reverse_speeding");
72 g_bugrigs_reverse_stopping =
cvar(
"g_bugrigs_reverse_stopping");
73 g_bugrigs_air_steering =
cvar(
"g_bugrigs_air_steering");
74 g_bugrigs_angle_smoothing =
cvar(
"g_bugrigs_angle_smoothing");
75 g_bugrigs_friction_floor =
cvar(
"g_bugrigs_friction_floor");
76 g_bugrigs_friction_brake =
cvar(
"g_bugrigs_friction_brake");
77 g_bugrigs_friction_air =
cvar(
"g_bugrigs_friction_air");
78 g_bugrigs_accel =
cvar(
"g_bugrigs_accel");
79 g_bugrigs_speed_ref =
cvar(
"g_bugrigs_speed_ref");
80 g_bugrigs_speed_pow =
cvar(
"g_bugrigs_speed_pow");
81 g_bugrigs_steer =
cvar(
"g_bugrigs_steer");
86 float racecar_angle(
float forward,
float down)
94 float ret =
vectoyaw(
'0 1 0' * down +
'1 0 0' * forward);
96 float angle_mult = forward / (800 + forward);
99 return ret * angle_mult + 360 * (1 - angle_mult);
101 return ret * angle_mult;
104 void RaceCarPhysics(
entity this,
float dt)
115 if (PHYS_BUGRIGS_REVERSE_SPEEDING(
this))
132 if (
IS_ONGROUND(
this) || PHYS_BUGRIGS_AIR_STEERING(
this))
138 float f = 1 / (1 + ((
max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(
this)) ** PHYS_BUGRIGS_SPEED_POW(
this)));
142 if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPINNING(
this))
143 steerfactor = -myspeed * PHYS_BUGRIGS_STEER(
this);
145 steerfactor = -myspeed * f * PHYS_BUGRIGS_STEER(
this);
148 if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPEEDING(
this))
149 accelfactor = PHYS_BUGRIGS_ACCEL(
this);
151 accelfactor = f * PHYS_BUGRIGS_ACCEL(
this);
158 myspeed =
max(0, myspeed - dt * (PHYS_BUGRIGS_FRICTION_FLOOR(
this) - PHYS_BUGRIGS_FRICTION_BRAKE(
this) * accel));
162 if (!PHYS_BUGRIGS_REVERSE_SPEEDING(
this))
163 myspeed =
min(0, myspeed + dt * PHYS_BUGRIGS_FRICTION_FLOOR(
this));
170 myspeed =
max(0, myspeed - dt * PHYS_BUGRIGS_FRICTION_FLOOR(
this));
174 if (PHYS_BUGRIGS_REVERSE_STOPPING(
this))
177 myspeed =
min(0, myspeed + dt * (PHYS_BUGRIGS_FRICTION_FLOOR(
this) + PHYS_BUGRIGS_FRICTION_BRAKE(
this) * accel));
183 this.angles_y += steer * dt * steerfactor;
186 myspeed += accel * accelfactor * dt;
188 rigvel = myspeed * v_forward +
'0 0 1' * upspeed;
195 float f = 1 / (1 + (
max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(
this)) ** PHYS_BUGRIGS_SPEED_POW(
this)));
196 float steerfactor = -myspeed * f;
197 this.angles_y += steer * dt * steerfactor;
203 rigvel *=
max(0, 1 -
vlen(rigvel) * PHYS_BUGRIGS_FRICTION_AIR(
this) * dt);
208 if (PHYS_BUGRIGS_PLANAR_MOVEMENT(
this))
210 vector rigvel_xy, neworigin, up;
213 rigvel_z -= dt * PHYS_GRAVITY(
this);
214 rigvel_xy =
vec2(rigvel);
216 if (PHYS_BUGRIGS_CAR_JUMPING(
this))
262 rigvel_z -= dt * PHYS_GRAVITY(
this);
271 this.
angles = vectoangles2(
284 vel_local.x = v_forward * this.
velocity;
288 this.angles_x = racecar_angle(vel_local.x, vel_local.z);
289 this.angles_z = racecar_angle(-vel_local.y, vel_local.z);
293 vector vf1, vu1, smoothangles;
295 float f =
bound(0, dt * PHYS_BUGRIGS_ANGLE_SMOOTHING(
this), 1);
301 vf1 = vf1 + v_forward * (1 - f);
302 vu1 = vu1 + v_up * (1 - f);
303 smoothangles = vectoangles2(vf1, vu1);
304 this.angles_x = -smoothangles.x;
305 this.angles_z = smoothangles.z;
309 .vector bugrigs_prevangles;
314 float dt =
M_ARGV(2,
float);
316 if(!PHYS_BUGRIGS(player) || !
IS_PLAYER(player)) {
return; }
319 player.angles = player.bugrigs_prevangles;
322 RaceCarPhysics(player, dt);
331 player.bugrigs_prevangles = player.angles;
333 player.disableclientprediction = 2;
343 stuffcmd(player,
"cl_cmd settemp chase_active 1\n");
void ClientConnect(entity this)
ClientConnect
#define REGISTER_MUTATOR(id, dependence)
#define UNSET_ONGROUND(s)
const float MOVE_NOMONSTERS
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector trace_plane_normal
#define MUTATOR_HOOKFUNCTION(...)
void set_movetype(entity this, int mt)