Adjustments to dashing.
This commit is contained in:
parent
b13e3db930
commit
cc1f1b8577
3 changed files with 50 additions and 30 deletions
|
|
@ -31,7 +31,6 @@ Class SWWMStatScreen : StatusScreen
|
|||
int flashcolor, tipflashcolor;
|
||||
|
||||
int hs, oldhs, oldwidth;
|
||||
Font mSmallFont;
|
||||
double bgfade;
|
||||
bool bFade;
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,21 @@ extend Class Demolitionist
|
|||
return true;
|
||||
}
|
||||
|
||||
private Vector3 GetGroundNormal()
|
||||
{
|
||||
// find closest 3d floor for its normal
|
||||
F3DFloor ff;
|
||||
for ( int i=0; i<floorsector.Get3DFloorCount(); i++ )
|
||||
{
|
||||
ff = floorsector.Get3DFloor(i);
|
||||
if ( !(ff.flags&F3DFloor.FF_SOLID) ) continue;
|
||||
if ( !(ff.top.ZAtPoint(pos.xy) ~== floorz) ) continue;
|
||||
return -ff.top.Normal;
|
||||
}
|
||||
// fall back to floorsector's normal
|
||||
return floorsector.floorplane.Normal;
|
||||
}
|
||||
|
||||
override void MovePlayer()
|
||||
{
|
||||
if ( !player || (player.mo != self) || (player.cheats&(CF_FROZEN|CF_TOTALLYFROZEN)) )
|
||||
|
|
@ -376,6 +391,10 @@ extend Class Demolitionist
|
|||
else lastairtic = level.maptime;
|
||||
if ( !(player.cheats & CF_PREDICTING) && !(player.cmd.forwardmove|player.cmd.sidemove) )
|
||||
PlayIdle();
|
||||
if ( !(player.cmd.buttons&BT_USER2) || (gamestate != GS_LEVEL) || (dashcooldown > 0) || (dashfuel < 20.) )
|
||||
return;
|
||||
if ( !player.onground && !bNOGRAVITY && !(player.cheats&CF_NOCLIP2) && !level.IsJumpingAllowed() )
|
||||
return;
|
||||
Vector3 dodge = (0,0,0);
|
||||
let [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll);
|
||||
int fm = player.cmd.forwardmove;
|
||||
|
|
@ -383,38 +402,40 @@ extend Class Demolitionist
|
|||
if ( !(fm|sm) ) fm = 1;
|
||||
if ( fm ) dodge += (fm>0)?X:-X;
|
||||
if ( sm ) dodge += (sm>0)?Y:-Y;
|
||||
if ( player.cmd.buttons&BT_CROUCH ) dodge = (0,0,-1); // death from above
|
||||
if ( dodge == (0,0,0) )
|
||||
{
|
||||
if ( !player.onground || bNOGRAVITY || (player.cheats&CF_NOCLIP2) ) dodge = X;
|
||||
else dodge.xy = RotateVector((1,0),angle);
|
||||
}
|
||||
if ( dodge == (0,0,0) ) dodge = X; // do we really need this?
|
||||
if ( player.onground && !bNOGRAVITY && !(player.cheats&CF_NOCLIP2) )
|
||||
{
|
||||
dodge.z = max(0,dodge.z);
|
||||
if ( !level.IsJumpingAllowed() ) dodge.z = min(0,dodge.z);
|
||||
}
|
||||
if ( (dodge.length() > 0) && (dashcooldown <= 0) && (dashfuel > 20.) && player.cmd.buttons&BT_USER2 && (player.onground || level.IsJumpingAllowed() || (player.cmd.buttons&BT_CROUCH)) && (gamestate == GS_LEVEL) )
|
||||
{
|
||||
fullfuel = (dashfuel >= default.dashfuel);
|
||||
dashdir = dodge.unit();
|
||||
dashcooldown = 10;
|
||||
dashboost = 20.;
|
||||
bOnMobj = false;
|
||||
if ( player.cheats & CF_REVERTPLEASE )
|
||||
Vector3 fnorm = GetGroundNormal();
|
||||
if ( !level.IsJumpingAllowed() || (dodge dot fnorm <= 0.) )
|
||||
{
|
||||
player.cheats &= ~CF_REVERTPLEASE;
|
||||
player.camera = player.mo;
|
||||
// recalc and project onto floor normal
|
||||
dodge = (0,0,0);
|
||||
Vector2 xdir = (cos(angle),sin(angle));
|
||||
Vector2 ydir = (sin(angle),-cos(angle));
|
||||
if ( fm ) dodge.xy += (fm>0)?xdir:-xdir;
|
||||
if ( sm ) dodge.xy += (sm>0)?ydir:-ydir;
|
||||
dodge = dodge-(dodge dot fnorm)*fnorm;
|
||||
}
|
||||
vel += dashdir*dashboost;
|
||||
vel.z += clamp(-vel.z*.4,0.,30.);
|
||||
player.jumptics = -1;
|
||||
SetStateLabel("Dash");
|
||||
A_StartSound("demolitionist/jet",CHAN_JETPACK,CHANF_LOOP);
|
||||
lastbump *= .95;
|
||||
mystats.dashcount++;
|
||||
BumpView(5.,vel);
|
||||
}
|
||||
if ( dodge.length() <= 0. ) return; // not sure if this can happen, really
|
||||
fullfuel = (dashfuel >= default.dashfuel);
|
||||
dashdir = dodge.unit();
|
||||
dashcooldown = 10;
|
||||
dashboost = 20.;
|
||||
bOnMobj = false;
|
||||
if ( player.cheats & CF_REVERTPLEASE )
|
||||
{
|
||||
player.cheats &= ~CF_REVERTPLEASE;
|
||||
player.camera = player.mo;
|
||||
}
|
||||
vel += dashdir*dashboost;
|
||||
vel.z += clamp(-vel.z*.4,0.,30.);
|
||||
player.jumptics = -1;
|
||||
SetStateLabel("Dash");
|
||||
A_StartSound("demolitionist/jet",CHAN_JETPACK,CHANF_LOOP);
|
||||
lastbump *= .95;
|
||||
mystats.dashcount++;
|
||||
BumpView(5.,vel);
|
||||
}
|
||||
|
||||
override void CheckJump()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue