*/
void PlayerJump (void)
{
- if(g_freezetag && self.freezetag_frozen)
+ if(self.freezetag_frozen)
return; // no jumping in freezetag when frozen
float mjumpheight;
{
tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
+ {
doublejump = TRUE;
+
+ // we MUST clip velocity here!
+ float f;
+ f = self.velocity * trace_plane_normal;
+ if(f < 0)
+ self.velocity -= f * trace_plane_normal;
+ }
}
mjumpheight = autocvar_sv_jumpvelocity;
if(!doublejump && self.multijump_ready && self.multijump_count < autocvar_g_multijump && self.velocity_z > autocvar_g_multijump_speed)
{
// doublejump = FALSE; // checked above in the if
- if (autocvar_g_multijump > 0)
+ if (autocvar_g_multijump)
{
if (autocvar_g_multijump_add == 0) // in this case we make the z velocity == jumpvelocity
{
self.velocity_y = wishdir_y * curspeed;
// keep velocity_z unchanged!
}
- self.multijump_count += 1;
+ if (autocvar_g_multijump > 0)
+ self.multijump_count += 1;
}
}
self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
if (!(self.flags & FL_ONGROUND))
return;
- if(!sv_pogostick)
+ if(self.cvar_cl_movement_track_canjump)
if (!(self.flags & FL_JUMPRELEASED))
return;
if (self.crouch)
setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE);
- else
+ else if (self.animstate_startframe != self.anim_melee_x || (self.animstate_startframe == self.anim_melee_x && time - self.animstate_starttime >= 21/20)) // jump animation shouldn't override melee until we have animation blending (or until the anim finished, 21/20 = numframes/fps)
setanim(self, self.anim_jump, FALSE, TRUE, TRUE);
if(g_jump_grunt)
- PlayerSound(playersound_jump, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
+ PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
self.restart_jump = -1; // restart jump anim next time
// value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping)
}
-
void CheckWaterJump()
{
- local vector start, end;
+ vector start, end;
// check for a jump-out-of-water
makevectors (self.angles);
return;
}
}
-};
+}
+void CheckPlayerJump()
+{
+ if(self.flags & FL_ONGROUND)
+ {
+ if (autocvar_g_multijump > 0)
+ self.multijump_count = 0;
+ else
+ self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller
+ }
+
+ if (self.BUTTON_JUMP)
+ PlayerJump ();
+ else
+ self.flags |= FL_JUMPRELEASED;
+
+ if (self.waterlevel == WATERLEVEL_SWIMMING)
+ CheckWaterJump ();
+ self.prevjumpbutton = self.BUTTON_JUMP;
+}
float racecar_angle(float forward, float down)
{
// sv_airaccel_sideways_friction 0
// prvm_globalset server speedclamp_mode 1
// (or 2)
-void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float sidefric, float speedlimit)
+void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
{
float vel_straight;
float vel_z;
float vel_xy_backward, vel_xy_forward;
float speedclamp;
- speedclamp = (accelqw < 0);
- if(speedclamp)
+ if(stretchfactor > 0)
+ speedclamp = stretchfactor;
+ else if(accelqw < 0)
+ speedclamp = 1; // full clamping, no stretch
+ else
+ speedclamp = -1; // no clamping
+
+ if(accelqw < 0)
accelqw = -accelqw;
if(autocvar_sv_gameplayfix_q2airaccelerate)
vel_xy = vel_straight * wishdir + vel_perpend;
- if(speedclamp)
+ if(speedclamp >= 0)
{
- // ensure we don't get too fast or decelerate faster than we should
- vel_xy_current = min(vlen(vel_xy), vel_xy_forward);
- if(vel_xy_current > 0) // prevent division by zero
- vel_xy = normalize(vel_xy) * vel_xy_current;
+ float vel_xy_preclamp;
+ vel_xy_preclamp = vlen(vel_xy);
+ if(vel_xy_preclamp > 0) // prevent division by zero
+ {
+ vel_xy_current += (vel_xy_forward - vel_xy_current) * speedclamp;
+ if(vel_xy_current < vel_xy_preclamp)
+ vel_xy = vel_xy * (vel_xy_current / vel_xy_preclamp);
+ }
}
self.velocity = vel_xy + vel_z * '0 0 1';
float speedaward_lastsent;
void SV_PlayerPhysics()
{
- local vector wishvel, wishdir, v;
- local float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, buttons;
+ vector wishvel, wishdir, v;
+ float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, buttons;
string temps;
float buttons_prev;
float not_allowed_to_move;
string c;
+
+ WarpZone_PlayerPhysics_FixVAngle();
maxspd_mod = 1;
if(g_minstagib && (self.items & IT_INVINCIBLE))
maxspd_mod *= autocvar_g_movement_highspeed;
// fix physics stats for g_movement_highspeed
+ // TODO maybe rather use maxairspeed? needs testing
self.stat_sv_airaccel_qw = AdjustAirAccelQW(autocvar_sv_airaccel_qw, maxspd_mod);
if(autocvar_sv_airstrafeaccel_qw)
self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(autocvar_sv_airstrafeaccel_qw, maxspd_mod);
self.angles_x = random() * 360;
self.angles_y = random() * 360;
// at least I'm not forcing retardedview by also assigning to angles_z
- self.fixangle = 1;
+ self.fixangle = TRUE;
}
}
bot_think();
}
- MUTATOR_CALLHOOK(PlayerPhysics);
-
self.items &~= IT_USING_JETPACK;
if(self.classname == "player")
if (self.movetype == MOVETYPE_NONE)
return;
+ // when we get here, disableclientprediction cannot be 2
+ self.disableclientprediction = 0;
+ if(time < self.ladder_time)
+ self.disableclientprediction = 1;
+
+ MUTATOR_CALLHOOK(PlayerPhysics);
+
+ if(self.player_blocked)
+ {
+ self.movement = '0 0 0';
+ self.disableclientprediction = 1;
+ }
+
maxspd_mod = 1;
swampspd_mod = 1;
swampspd_mod = self.swamp_slowdown; //cvar("g_balance_swamp_moverate");
}
+ // conveyors: first fix velocity
+ if(self.conveyor.state)
+ self.velocity -= self.conveyor.movedir;
+
if(self.classname != "player")
{
maxspd_mod = autocvar_sv_spectator_speed_multiplier;
}
if(self.flags & FL_ONGROUND)
+ if(self.classname == "player") // no fall sounds for observers thank you very much
if(self.wasFlying)
{
self.wasFlying = 0;
if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
{
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
- GlobalSound(globalsound_metalfall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
else
- GlobalSound(globalsound_fall, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
}
}
}
self.wasFlying = 1;
if(self.classname == "player")
- {
- if(self.flags & FL_ONGROUND)
- {
- if (autocvar_g_multijump > 0)
- self.multijump_count = 0;
- else
- self.multijump_count = -2; // the cvar value for infinite jumps is -1, so this needs to be smaller
- }
-
- if (self.BUTTON_JUMP)
- PlayerJump ();
- else
- self.flags |= FL_JUMPRELEASED;
-
- if (self.waterlevel == WATERLEVEL_SWIMMING)
- CheckWaterJump ();
- self.prevjumpbutton = self.BUTTON_JUMP;
- }
+ CheckPlayerJump();
if (self.flags & FL_WATERJUMP )
{
{
RaceCarPhysics();
}
- else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
+ else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)
{
// noclipping or flying
self.flags &~= FL_ONGROUND;
if (wishspeed > self.stat_sv_maxspeed*maxspd_mod)
wishspeed = self.stat_sv_maxspeed*maxspd_mod;
if (time >= self.teleport_time)
- PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+ PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
}
else if (self.waterlevel >= WATERLEVEL_SWIMMING)
{
self.velocity = self.velocity * (1 - frametime * autocvar_sv_friction);
// water acceleration
- PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+ PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
}
else if (time < self.ladder_time)
{
// on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
self.flags &~= FL_ONGROUND;
+ float g;
+ g = autocvar_sv_gravity * frametime;
+ if(self.gravity)
+ g *= self.gravity;
+ if(autocvar_sv_gameplayfix_gravityunaffectedbyticrate)
+ {
+ g *= 0.5;
+ self.velocity_z += g;
+ }
+
self.velocity = self.velocity * (1 - frametime * autocvar_sv_friction);
makevectors(self.v_angle);
//wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
- if (self.gravity)
- self.velocity_z = self.velocity_z + self.gravity * autocvar_sv_gravity * frametime;
- else
- self.velocity_z = self.velocity_z + autocvar_sv_gravity * frametime;
+ self.velocity_z += g;
if (self.ladder_entity.classname == "func_water")
{
f = vlen(wishvel);
if (time >= self.teleport_time)
{
// water acceleration
- PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+ PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
}
}
else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!autocvar_g_jetpack_fuel || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO))
self.velocity = self.velocity * f;
else
self.velocity = '0 0 0';
+ /*
+ Mathematical analysis time!
+
+ Our goal is to invert this mess.
+
+ For the two cases we get:
+ v = v0 * (1 - frametime * (autocvar_sv_stopspeed / v0) * autocvar_sv_friction)
+ = v0 - frametime * autocvar_sv_stopspeed * autocvar_sv_friction
+ v0 = v + frametime * autocvar_sv_stopspeed * autocvar_sv_friction
+ and
+ v = v0 * (1 - frametime * autocvar_sv_friction)
+ v0 = v / (1 - frametime * autocvar_sv_friction)
+
+ These cases would be chosen ONLY if:
+ v0 < autocvar_sv_stopspeed
+ v + frametime * autocvar_sv_stopspeed * autocvar_sv_friction < autocvar_sv_stopspeed
+ v < autocvar_sv_stopspeed * (1 - frametime * autocvar_sv_friction)
+ and, respectively:
+ v0 >= autocvar_sv_stopspeed
+ v / (1 - frametime * autocvar_sv_friction) >= autocvar_sv_stopspeed
+ v >= autocvar_sv_stopspeed * (1 - frametime * autocvar_sv_friction)
+ */
}
// acceleration
if (self.crouch)
wishspeed = wishspeed * 0.5;
if (time >= self.teleport_time)
- PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+ PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
}
else
{
if(autocvar_sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement_x != 0)
PM_AirAccelerate(wishdir, wishspeed);
else
- PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, autocvar_sv_airaccel_sideways_friction / maxairspd, self.stat_sv_airspeedlimit_nonqw);
+ PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, autocvar_sv_airaccel_qw_stretchfactor, autocvar_sv_airaccel_sideways_friction / maxairspd, self.stat_sv_airspeedlimit_nonqw);
if(autocvar_sv_aircontrol)
CPM_PM_Aircontrol(wishdir, wishspeed2);
if(self.flags & FL_ONGROUND)
self.lastground = time;
+ // conveyors: then break velocity again
+ if(self.conveyor.state)
+ self.velocity += self.conveyor.movedir;
+
self.lastflags = self.flags;
self.lastclassname = self.classname;
-};
+}