Sliptide-aware camera steering, fix countersteer easing

This commit is contained in:
AJ Martinez 2023-04-11 00:15:44 -07:00
parent 94cf9fc47b
commit b4ffc33fcb
2 changed files with 23 additions and 5 deletions

View file

@ -8859,9 +8859,13 @@ INT16 K_UpdateSteeringValue(INT16 inputSteering, INT16 destSteering)
INT16 outputSteering = inputSteering;
// We switched steering directions, lighten up on easing for a more responsive countersteer.
// (Don't do this for steering 0, let digital inputs tap-adjust!)
if ((inputSteering > 0 && destSteering < 0) || (inputSteering < 0 && destSteering > 0))
{
amount = max(min(KART_FULLTURN, abs(inputSteering)), amount);
// Don't let small turns in direction X allow instant turns in direction Y.
INT16 countersteer = min(KART_FULLTURN, abs(inputSteering)); // The farthest we should go is to 0 -- neutral.
amount = max(countersteer, amount); // But don't reduce turning strength from baseline either.
}

View file

@ -2235,16 +2235,30 @@ static void P_UpdatePlayerAngle(player_t *player)
angle_t leniency = (4*ANG1/3) * min(player->cmd.latency, 6);
// Don't force another turning tic, just give them the desired angle!
if (targetDelta == angleChange || K_Sliptiding(player) || (maxTurnRight == 0 && maxTurnLeft == 0))
if (targetDelta == angleChange || (maxTurnRight == 0 && maxTurnLeft == 0))
{
// Either we're dead on, we can't steer, or we're in a special handling state.
// Stuff like sliptiding requires some blind-faith steering:
// if a camera correction stops our turn input, the sliptide randomly fails!
// Either we're dead on or we can't steer at all.
player->steering = targetsteering;
}
else
{
// We're off. Try to legally steer the player towards their camera.
if (K_Sliptiding(player) && P_IsObjectOnGround(player->mo) && (player->cmd.turning != 0) && ((player->cmd.turning > 0) == (player->aizdriftstrat > 0)))
{
// Don't change handling direction if someone's inputs are sliptiding, you'll break the sliptide!
if (player->cmd.turning > 0)
{
steeringRight = max(steeringRight, max(steeringLeft, 1));
steeringLeft = max(steeringLeft, 1);
}
else
{
steeringLeft = min(steeringLeft, max(steeringRight, -1));
steeringRight = min(steeringLeft, -1);
}
}
player->steering = P_FindClosestTurningForAngle(player, targetDelta, steeringLeft, steeringRight);
angleChange = K_GetKartTurnValue(player, player->steering) << TICCMD_REDUCE;