Rewrite NormalizedMove() now that I know how the raw axes work.

This commit is contained in:
Mari the Deer 2022-09-13 15:18:33 +02:00
commit d99d772b0c
2 changed files with 10 additions and 8 deletions

View file

@ -311,16 +311,18 @@ Class Demolitionist : PlayerPawn
}
return 4;
}
// oof
// directional movement without straferunning
Vector2 NormalizedMove()
{
if ( !(player.cmd.forwardmove|player.cmd.sidemove) )
return (0,0);
Vector2 mvec = (player.cmd.forwardmove,-player.cmd.sidemove/.96);
double maxval = max(abs(mvec.x),abs(mvec.y));
// sorry, we don't use that here specifically, that's for tweakspeed to handle
if ( !(player.cmd.buttons&BT_RUN) ) maxval *= 2.;
return mvec.unit()*maxval;
int idx = !!(player.cmd.buttons&BT_RUN);
// ratio between forwardmove and sidemove (depending on BT_RUN state)
double fs = gameinfo.normforwardmove[idx]/gameinfo.normsidemove[idx];
// raw axes scaled to 1:1 ratio
Vector2 mvec = (player.cmd.forwardmove,-player.cmd.sidemove*fs);
// multiply unit vector back to "raw" running speed (as TweakSpeed handles the "true" scaling for us later)
return mvec.unit()*gameinfo.normforwardmove[1]*256.;
}
double TweakSpeed()
{