Implement crouch jumping and separate crouch/uncrouch speeds.

This commit is contained in:
Mari the Deer 2024-01-17 14:07:32 +01:00
commit 8cdfa2ad89
3 changed files with 14 additions and 3 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1090 \cu(Wed 17 Jan 12:39:00 CET 2024)\c-";
SWWM_SHORTVER="\cw1.3pre r1090 \cu(2024-01-17 12:39:00)\c-";
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1091 \cu(Wed 17 Jan 14:07:32 CET 2024)\c-";
SWWM_SHORTVER="\cw1.3pre r1091 \cu(2024-01-17 14:07:32)\c-";

View file

@ -669,7 +669,7 @@ extend Class Demolitionist
{
double defaultheight = FullHeight;
double savedheight = Height;
double crouchspeed = direction*CROUCHSPEED*.8; // slow down slightly so it matches the animation
double crouchspeed = direction*CROUCHSPEED*((direction>0)?.65:.9); // match animation speed
double oldheight = player.viewheight;
player.crouchdir = direction;
player.crouchfactor += crouchspeed;

View file

@ -193,7 +193,18 @@ extend Class Demolitionist
PoisonDurationReceived = 0;
PoisonPeriodReceived = 0;
PoisonDamageReceived = 0;
double PrevHeight = Height;
Super.Tick();
double HeightDiff = Height-PrevHeight;
// shift vertically around center of gravity if crouching while airborne (crouch jumping)
if ( player && (player.mo == self) && CanCrouch() && (player.playerstate != PST_DEAD) && !player.onground && (abs(HeightDiff) > 0) )
{
double oldz = pos.z;
SetZ(pos.z-HeightDiff*.5);
// note: even with this check, clipping through sloped 3D floors may still happen
// (honestly, sloped 3d floors are a source of many troubles)
if ( !TryMove(pos.xy,false) ) SetZ(oldz);
}
if ( (gamestate != GS_LEVEL) || !player || (player.mo != self) || (freezetics > 0) ) return;
UpdateFace();
UpdateTags();