Implement custom gravity and remove swimming.
This commit is contained in:
parent
83934ddd81
commit
5a8c32f4ae
2 changed files with 82 additions and 46 deletions
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.20 r10 \cu(Wed 1 Jun 18:32:08 CEST 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.2.20 r10 \cu(2022-06-01 18:32:08)\c-";
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.20 r11 \cu(Wed 1 Jun 18:32:20 CEST 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.2.20 r11 \cu(2022-06-01 18:32:20)\c-";
|
||||
|
|
|
|||
|
|
@ -500,13 +500,14 @@ Class Demolitionist : PlayerPawn
|
|||
}
|
||||
void A_BoostUp( bool initial = false )
|
||||
{
|
||||
vel += (0,0,1)*dashboost*clamp(dashfuel/10.,0,1.);
|
||||
vel.z += .25*dashboost*clamp(dashfuel/20.,0,1.);
|
||||
player.vel *= 0.;
|
||||
if ( dashboost < .2 ) dashboost = 0.;
|
||||
else
|
||||
{
|
||||
if ( swwm_extraalert ) A_AlertMonsters(swwm_uncapalert?0:800);
|
||||
dashboost *= (player.cmd.buttons&BT_JUMP)?.95:.4;
|
||||
if ( player.cmd.buttons&BT_JUMP ) dashboost = min(5.,dashboost*1.01);
|
||||
else dashboost *= .4;
|
||||
last_boost = level.maptime+1;
|
||||
}
|
||||
double fueluse = (dashfuel-max(0.,dashfuel-dashboost))/60.;
|
||||
|
|
@ -895,7 +896,7 @@ Class Demolitionist : PlayerPawn
|
|||
diffy = abs(diffy)**.5*sgn;
|
||||
}
|
||||
// don't do inertial sway when in 6dof mode, causes issues
|
||||
if ( !swwm_fly6dof || !((waterlevel < 2) && bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2)) )
|
||||
if ( !swwm_fly6dof || !(bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2)) )
|
||||
{
|
||||
cur.x += diffang;
|
||||
cur.y -= diffpitch;
|
||||
|
|
@ -1075,33 +1076,48 @@ Class Demolitionist : PlayerPawn
|
|||
else lagready = lagready*.4;
|
||||
lagvel = lagvel*.8+vel*.2;
|
||||
double traveldist = level.Vec3Diff(oldpos,pos).length();
|
||||
if ( waterlevel < 2 )
|
||||
if ( !player.onground || bNoGravity )
|
||||
{
|
||||
if ( !player.onground || bNoGravity )
|
||||
if ( waterlevel > 1 )
|
||||
{
|
||||
cairtime = 0;
|
||||
mystats.swimdist += traveldist;
|
||||
}
|
||||
else
|
||||
{
|
||||
cairtime++;
|
||||
if ( cairtime > mystats.airtime ) mystats.airtime = cairtime;
|
||||
mystats.airdist += traveldist;
|
||||
if ( (vel.z < -fallingscreamminspeed) && (vel.z > -fallingscreammaxspeed) && (player == players[consoleplayer]) )
|
||||
SWWMHandler.AddOneliner("falling",2,30);
|
||||
}
|
||||
else
|
||||
if ( (vel.z < -fallingscreamminspeed) && (vel.z > -fallingscreammaxspeed) && (player == players[consoleplayer]) )
|
||||
SWWMHandler.AddOneliner("falling",2,30);
|
||||
}
|
||||
else
|
||||
{
|
||||
SWWMHandler.CancelOneliner("falling");
|
||||
airscreamtime = 0;
|
||||
cairtime = 0;
|
||||
mystats.grounddist += traveldist;
|
||||
SWWMUtility.AchievementProgressIncDouble("travel",traveldist/32000.,player);
|
||||
}
|
||||
// spawn bubbles while underwater
|
||||
if ( (waterlevel > 1) && !Random[ExploS](0,5) )
|
||||
{
|
||||
int numpt = Random[ExploS](-2,2);
|
||||
for ( int i=0; i<numpt; i++ )
|
||||
{
|
||||
SWWMHandler.CancelOneliner("falling");
|
||||
airscreamtime = 0;
|
||||
cairtime = 0;
|
||||
mystats.grounddist += traveldist;
|
||||
SWWMUtility.AchievementProgressIncDouble("travel",traveldist/32000.,player);
|
||||
let p = Spawn("SWWMBubble",Vec3Offset(FRandom[ExploS](-radius,radius)*.8,FRandom[ExploS](-radius,radius)*.8,FRandom[ExploS](height*.1,height*.9)));
|
||||
p.scale *= FRandom[ExploS](.02,.2);
|
||||
p.vel += vel*.2;
|
||||
}
|
||||
}
|
||||
else mystats.swimdist += traveldist;
|
||||
CheckUnderwaterAmb();
|
||||
SenseItems();
|
||||
if ( vel.length() > mystats.topspeed ) mystats.topspeed = vel.length();
|
||||
if ( vel.length() > ((3600*GameTicRate)/32000.) )
|
||||
SWWMUtility.AchievementProgress("sanic",int((vel.length()*3600*GameTicRate)/32000.),player);
|
||||
if ( !myvoice ) myvoice = CVar.GetCVar('swwm_voicetype',player);
|
||||
if ( player.onground && !bNoGravity && !lastground && (waterlevel < 2) )
|
||||
if ( player.onground && !bNoGravity && !lastground )
|
||||
{
|
||||
// bump down weapon
|
||||
bumpvelz.Push(-lastvelz);
|
||||
|
|
@ -1245,7 +1261,7 @@ Class Demolitionist : PlayerPawn
|
|||
prevvelz = vel.z;
|
||||
bool isdashing = InStateSequence(CurState,FindState("Dash"));
|
||||
bool isboosting = InStateSequence(CurState,FindState("Boost"));
|
||||
bNOFRICTION = (((waterlevel<2)&&(bFly&&!bFlyCheat&&!(player.cheats&CF_NOCLIP2)))||isdashing);
|
||||
bNOFRICTION = ((bFly&&!bFlyCheat&&!(player.cheats&CF_NOCLIP2))||isdashing);
|
||||
if ( fuelcooldown == 1 ) A_StartSound("demolitionist/fuelregen",CHAN_FUELREGEN,CHANF_LOOP,.35,4.,.5);
|
||||
else if ( fuelcooldown > 1 ) A_StopSound(CHAN_FUELREGEN);
|
||||
fuelcooldown = max(0,fuelcooldown-1);
|
||||
|
|
@ -1789,7 +1805,7 @@ Class Demolitionist : PlayerPawn
|
|||
}
|
||||
override void CheckPitch()
|
||||
{
|
||||
if ( (waterlevel < 2) && bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) )
|
||||
if ( bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) )
|
||||
return; // handled in moveplayer
|
||||
Super.CheckPitch();
|
||||
}
|
||||
|
|
@ -1797,7 +1813,7 @@ Class Demolitionist : PlayerPawn
|
|||
{
|
||||
if ( InStateSequence(CurState,FindState("Dash")) )
|
||||
player.cmd.upmove = 0;
|
||||
if ( (waterlevel < 2) && bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) )
|
||||
if ( bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) )
|
||||
{
|
||||
double fs = TweakSpeed();
|
||||
Vector3 x, y, z;
|
||||
|
|
@ -1834,7 +1850,7 @@ Class Demolitionist : PlayerPawn
|
|||
}
|
||||
bool isdashing = InStateSequence(CurState,FindState("Dash"));
|
||||
if ( isdashing ) player.cmd.forwardmove = player.cmd.sidemove = 0;
|
||||
if ( (waterlevel < 2) && bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) )
|
||||
if ( bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) )
|
||||
{
|
||||
player.onground = false;
|
||||
if ( player.turnticks )
|
||||
|
|
@ -1907,7 +1923,7 @@ Class Demolitionist : PlayerPawn
|
|||
double friction, movefactor;
|
||||
[friction, movefactor] = GetFriction();
|
||||
bobfactor = (friction<ORIG_FRICTION)?movefactor:ORIG_FRICTION_FACTOR;
|
||||
if ( !player.onground && !bNoGravity && !waterlevel )
|
||||
if ( !player.onground && !bNoGravity )
|
||||
{
|
||||
// no air control here, done afterwards
|
||||
movefactor *= 0.;
|
||||
|
|
@ -1924,20 +1940,20 @@ Class Demolitionist : PlayerPawn
|
|||
bobfactor *= player.crouchfactor;
|
||||
}
|
||||
nmove *= movefactor;
|
||||
if ( (waterlevel || bNOGRAVITY) && !player.GetClassicFlight() )
|
||||
if ( bNOGRAVITY && !player.GetClassicFlight() )
|
||||
{
|
||||
double zpush = nmove.x*sin(pitch);
|
||||
if ( waterlevel && (waterlevel < 2) && (zpush < 0) ) zpush = 0;
|
||||
vel.z -= zpush;
|
||||
vel.xy += RotateVector(nmove,angle)*cos(pitch);
|
||||
player.vel += RotateVector(nmove,angle)*bobfactor*cos(pitch)*16.;
|
||||
}
|
||||
else
|
||||
{ vel.xy += RotateVector(nmove,angle);
|
||||
{
|
||||
vel.xy += RotateVector(nmove,angle);
|
||||
player.vel += RotateVector(nmove,angle)*bobfactor*16.;
|
||||
}
|
||||
// override air control because we REALLY need the extra mobility
|
||||
if ( !player.onground && !bNOGRAVITY && !waterlevel )
|
||||
if ( !player.onground && !bNOGRAVITY )
|
||||
{
|
||||
nmove = NormalizedMove();
|
||||
double fs = TweakSpeed();
|
||||
|
|
@ -1964,7 +1980,7 @@ Class Demolitionist : PlayerPawn
|
|||
guidepitch *= .9;
|
||||
guideroll *= .9;
|
||||
// anchor to ground when going down steps
|
||||
if ( lastground && !player.onground && !bFly && !bFlyCheat && (waterlevel < 2) && (abs(pos.z-floorz) <= maxdropoffheight) && (player.jumptics == 0) && (vel.z < 0) && !isdashing )
|
||||
if ( lastground && !player.onground && !bFly && !bFlyCheat && (abs(pos.z-floorz) <= maxdropoffheight) && (player.jumptics == 0) && (vel.z < 0) && !isdashing )
|
||||
{
|
||||
// test for gap crossing (i.e: climbing up platforms with holes between them)
|
||||
Vector3 storepos = pos;
|
||||
|
|
@ -2000,10 +2016,10 @@ Class Demolitionist : PlayerPawn
|
|||
if ( player.cmd.buttons&BT_CROUCH ) dodge = (0,0,-1); // death from above
|
||||
if ( dodge == (0,0,0) )
|
||||
{
|
||||
if ( !player.onground || bNOGRAVITY || (waterlevel > 2) || (player.cheats&CF_NOCLIP2) ) dodge = X;
|
||||
if ( !player.onground || bNOGRAVITY || (player.cheats&CF_NOCLIP2) ) dodge = X;
|
||||
else dodge.xy = RotateVector((1,0),angle);
|
||||
}
|
||||
if ( player.onground && !bNOGRAVITY && (waterlevel < 2) && !(player.cheats&CF_NOCLIP2) )
|
||||
if ( player.onground && !bNOGRAVITY && !(player.cheats&CF_NOCLIP2) )
|
||||
{
|
||||
dodge.z = max(0,dodge.z);
|
||||
if ( !level.IsJumpingAllowed() ) dodge.z = min(0,dodge.z);
|
||||
|
|
@ -2128,8 +2144,7 @@ Class Demolitionist : PlayerPawn
|
|||
jumpactor = null;
|
||||
}
|
||||
if ( player.crouchoffset ) player.crouching = 1;
|
||||
else if ( waterlevel >= 2 ) vel.z = 4*Speed;
|
||||
else if ( (waterlevel < 2) && bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) ) return;
|
||||
else if ( bFly && !bFlyCheat && !(player.cheats&CF_NOCLIP2) ) return;
|
||||
else if ( bNoGravity ) vel.z = 3;
|
||||
else if ( level.IsJumpingAllowed()
|
||||
&& ((player.onground && (player.jumptics == 0))
|
||||
|
|
@ -2351,7 +2366,7 @@ Class Demolitionist : PlayerPawn
|
|||
return;
|
||||
}
|
||||
if ( player.health <= 0 ) return;
|
||||
if ( !bNoGravity && player.onground && (waterlevel < 3) )
|
||||
if ( !bNoGravity && player.onground )
|
||||
{
|
||||
// Ground
|
||||
if ( player.crouchdir == -1 )
|
||||
|
|
@ -2399,7 +2414,7 @@ Class Demolitionist : PlayerPawn
|
|||
SetStateLabel("SwimEnd");
|
||||
}
|
||||
}
|
||||
else if ( !bNoGravity && (waterlevel < 1) )
|
||||
else if ( !bNoGravity )
|
||||
{
|
||||
// Falling
|
||||
if ( player.crouchdir == -1 )
|
||||
|
|
@ -2503,7 +2518,7 @@ Class Demolitionist : PlayerPawn
|
|||
return;
|
||||
}
|
||||
if ( player.health <= 0 ) return;
|
||||
if ( !bNoGravity && player.onground && (waterlevel < 3) )
|
||||
if ( !bNoGravity && player.onground )
|
||||
{
|
||||
// Ground
|
||||
if ( player.crouchdir == -1 )
|
||||
|
|
@ -2568,7 +2583,7 @@ Class Demolitionist : PlayerPawn
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( !bNoGravity && (waterlevel < 1) )
|
||||
else if ( !bNoGravity )
|
||||
{
|
||||
// Falling
|
||||
PlayIdle();
|
||||
|
|
@ -3017,11 +3032,8 @@ Class Demolitionist : PlayerPawn
|
|||
override void CheckCrouch( bool totallyfrozen )
|
||||
{
|
||||
// crouch to swim/float down
|
||||
if ( !totallyfrozen && (player.cmd.buttons&BT_CROUCH) )
|
||||
{
|
||||
if ( waterlevel >= 2 ) vel.z = -4*Speed;
|
||||
else if ( bNOGRAVITY ) vel.z = -3;
|
||||
}
|
||||
if ( !totallyfrozen && (player.cmd.buttons&BT_CROUCH) && bNOGRAVITY )
|
||||
vel.z = -3;
|
||||
bool wascrouching = !!(player.cmd.buttons&BT_CROUCH);
|
||||
if ( !AllowCrouch() ) player.cmd.buttons &= ~BT_CROUCH;
|
||||
if ( CanCrouch() && (player.health > 0) && level.IsCrouchingAllowed() )
|
||||
|
|
@ -3175,6 +3187,30 @@ Class Demolitionist : PlayerPawn
|
|||
if ( l && l.thelamp )
|
||||
CompanionLamp(l.thelamp).justteleport = true;
|
||||
}
|
||||
// let's customize our gravity
|
||||
override void FallAndSink( double grav, double oldfloorz )
|
||||
{
|
||||
if ( !player || (player.mo != self) || (player.cheats&CF_TOTALLYFROZEN) )
|
||||
{
|
||||
Super.FallAndSink(grav,oldfloorz);
|
||||
return;
|
||||
}
|
||||
// do nothing if standing on ground or "floating"
|
||||
if ( player.onground || bNOGRAVITY ) return;
|
||||
// ensure we don't pass terminal velocity just from falling
|
||||
if ( vel.z < -50 ) return;
|
||||
// we don't care about "the doom way" here, gravity is
|
||||
// ALWAYS in effect when not standing on solid ground
|
||||
if ( waterlevel > 1 )
|
||||
{
|
||||
// sink faster
|
||||
grav *= .35;
|
||||
}
|
||||
// reduce gravity while we're boosting
|
||||
else if ( InStateSequence(CurState,FindState("Dash")) || InStateSequence(CurState,FindState("Boost")) )
|
||||
grav *= .25;
|
||||
vel.z -= grav;
|
||||
}
|
||||
override void MarkPrecacheSounds()
|
||||
{
|
||||
Super.MarkPrecacheSounds();
|
||||
|
|
@ -3338,7 +3374,7 @@ Class Demolitionist : PlayerPawn
|
|||
#### # 2;
|
||||
XZW3 IJKLMNO 2
|
||||
{
|
||||
if ( player.onground||bNoGravity||(waterlevel>=3) )
|
||||
if ( player.onground||bNoGravity )
|
||||
return ResolveState("BoostEnd");
|
||||
A_BoostUp(true);
|
||||
return ResolveState(null);
|
||||
|
|
@ -3346,7 +3382,7 @@ Class Demolitionist : PlayerPawn
|
|||
// keep boost
|
||||
XZW3 P 1
|
||||
{
|
||||
if ( player.onground||bNoGravity||(waterlevel>=3) )
|
||||
if ( player.onground||bNoGravity )
|
||||
return ResolveState("BoostEnd");
|
||||
A_BoostUp(false);
|
||||
return ResolveState(null);
|
||||
|
|
@ -3360,17 +3396,17 @@ Class Demolitionist : PlayerPawn
|
|||
Goto Spawn+1;
|
||||
Jump:
|
||||
#### # 2;
|
||||
XZWJ ABCDEF 2 A_JumpIf(player.onground&&!bNoGravity&&(waterlevel<3),"FallEnd");
|
||||
XZWJ ABCDEF 2 A_JumpIf(player.onground&&!bNoGravity,"FallEnd");
|
||||
Goto FallLoop;
|
||||
Fall:
|
||||
// start fall
|
||||
#### # 4;
|
||||
XZW3 XYZ 2 A_JumpIf(player.onground&&!bNoGravity&&(waterlevel<3),"FallEnd");
|
||||
XZW4 AB 2 A_JumpIf(player.onground&&!bNoGravity&&(waterlevel<3),"FallEnd");
|
||||
XZW3 XYZ 2 A_JumpIf(player.onground&&!bNoGravity,"FallEnd");
|
||||
XZW4 AB 2 A_JumpIf(player.onground&&!bNoGravity,"FallEnd");
|
||||
Goto FallLoop;
|
||||
FallLoop:
|
||||
// falling
|
||||
XZW4 CDEFGH 3 A_JumpIf(player.onground&&!bNoGravity&&(waterlevel<3),"FallEnd");
|
||||
XZW4 CDEFGH 3 A_JumpIf(player.onground&&!bNoGravity,"FallEnd");
|
||||
Goto FallLoop;
|
||||
FallEnd:
|
||||
// landing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue