- Duke: Allow reversing while moving forwards to act as the brake.

* Much more intuitive for controllers.
This commit is contained in:
Mitchell Richters 2023-04-25 11:29:39 +10:00
parent 6d2e114dec
commit 52ab0fae19
2 changed files with 7 additions and 4 deletions

View file

@ -230,13 +230,14 @@ void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleA
// Velocity setup.
const auto turnVel = (!attenuate && (isTurboTurnTime() || hidLeft || hidRight)) ? (baseVel) : (baseVel * velScale);
const auto mouseVel = abs(turnVel * mouseInput.X * m_yaw) * (45.f / 2048.f) / scaleAdjust;
const auto maxVel = abs(turnVel * 1.5f);
// Apply inputs.
thisInput.avel += ((mouseVel > 1) ? sqrtf(mouseVel) : mouseVel) * Sgn(turnVel) * Sgn(mouseInput.X) * Sgn(m_yaw);
thisInput.avel -= turnVel * joyAxes[JOYAXIS_Yaw];
thisInput.avel += turnVel * kbdDir;
thisInput.avel *= scaleAdjust;
inputBuffer.avel = clamp(inputBuffer.avel + thisInput.avel, -turnVel * 1.5f, turnVel * 1.5f);
inputBuffer.avel = clamp(inputBuffer.avel + thisInput.avel, -maxVel, maxVel);
if (kbdDir) updateTurnHeldAmt(scaleAdjust); else turnheldtime = 0;
}
else

View file

@ -713,7 +713,7 @@ static unsigned outVehicleFlags(player_struct* p, ESyncBits& actions)
flags += VEH_REVERSE * (p->sync.fvel < 0);
flags += VEH_TURNLEFT * (p->sync.avel < 0);
flags += VEH_TURNRIGHT * (p->sync.avel > 0);
flags += VEH_BRAKING * !!(actions & SB_CROUCH);
flags += VEH_BRAKING * (!!(actions & SB_CROUCH) || (p->sync.fvel < 0 && p->MotoSpeed > 0));
actions &= ~SB_CROUCH;
return flags;
}
@ -728,7 +728,7 @@ static void doVehicleTilting(player_struct* const p, const bool canTilt)
{
const auto pact = p->GetActor();
auto adj = DAngle::fromDeg(p->sync.avel * 0.279625 * canTilt);
if (p->OnMotorcycle) adj *= 5;
if (p->OnMotorcycle) adj *= 5 * Sgn(p->MotoSpeed);
if (cl_rrvehicletilting) adj *= cl_viewtiltscale;
p->oTiltStatus = p->TiltStatus;
@ -906,7 +906,9 @@ static void doVehicleThrottling(player_struct* p, DDukeActor* pact, unsigned& fl
}
else if ((flags & VEH_BRAKING) && p->MotoSpeed > 0)
{
p->MotoSpeed -= brakeSpeed;
const auto kbdBraking = brakeSpeed * !!(flags & VEH_BRAKING);
const auto hidBraking = brakeSpeed * p->sync.fvel * (p->sync.fvel < 0);
p->MotoSpeed -= clamp<double>(kbdBraking - hidBraking, -brakeSpeed, brakeSpeed);
if (p->MotoSpeed < 0)
p->MotoSpeed = 0;
p->VBumpTarget = vBmpBrake;