Higher friction while rubberbanding

They are now x2 as difficult :)
This commit is contained in:
Sally Coolatta 2020-06-03 14:02:14 -04:00
parent c2dd06e053
commit 30df376d04
3 changed files with 55 additions and 5 deletions

View file

@ -453,6 +453,25 @@ fixed_t K_BotTopSpeedRubberband(player_t *player)
return rubberband;
}
/*--------------------------------------------------
fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict)
See header file for description.
--------------------------------------------------*/
fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict)
{
fixed_t rubberband = K_BotRubberband(player) - FRACUNIT;
if (rubberband <= 0)
{
// Never get stronger than normal friction
return frict;
}
// 128 is a magic number that felt good in-game
return FixedDiv(frict, FRACUNIT + (rubberband / 2));
}
/*--------------------------------------------------
fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy)

View file

@ -95,6 +95,23 @@ fixed_t K_BotRubberband(player_t *player);
fixed_t K_BotTopSpeedRubberband(player_t *player);
/*--------------------------------------------------
fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict);
Gives a multiplier for a bot's rubberbanding.
Adjusted from K_BotRubberband to be used for friction.
Input Arguments:-
player - Player to check.
frict - Friction value to adjust.
Return:-
The new friction value.
--------------------------------------------------*/
fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict);
/*--------------------------------------------------
fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy);

View file

@ -2412,19 +2412,25 @@ UINT16 K_GetKartFlashing(player_t *player)
fixed_t K_3dKartMovement(player_t *player, boolean onground, fixed_t forwardmove)
{
fixed_t accelmax = 4000;
const fixed_t accelmax = 4000;
const fixed_t p_speed = K_GetKartSpeed(player, true);
const fixed_t p_accel = K_GetKartAccel(player);
fixed_t newspeed, oldspeed, finalspeed;
fixed_t p_speed = K_GetKartSpeed(player, true);
fixed_t p_accel = K_GetKartAccel(player);
fixed_t orig = ORIG_FRICTION;
if (!onground) return 0; // If the player isn't on the ground, there is no change in speed
if (K_PlayerUsesBotMovement(player))
{
orig = K_BotFrictionRubberband(player, ORIG_FRICTION);
}
// ACCELCODE!!!1!11!
oldspeed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); // FixedMul(P_AproxDistance(player->rmomx, player->rmomy), player->mo->scale);
// Don't calculate the acceleration as ever being above top speed
if (oldspeed > p_speed)
oldspeed = p_speed;
newspeed = FixedDiv(FixedDiv(FixedMul(oldspeed, accelmax - p_accel) + FixedMul(p_speed, p_accel), accelmax), ORIG_FRICTION);
newspeed = FixedDiv(FixedDiv(FixedMul(oldspeed, accelmax - p_accel) + FixedMul(p_speed, p_accel), accelmax), orig);
if (player->kartstuff[k_pogospring]) // Pogo Spring minimum/maximum thrust
{
@ -7683,7 +7689,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
player->mo->friction += 4608;
}
if (player->speed > 0 && cmd->forwardmove < 0) // change friction while braking no matter what, otherwise it's not any more effective than just letting go off accel
// change friction while braking no matter what, otherwise it's not any more effective than just letting go off accel
if (player->speed > 0 && cmd->forwardmove < 0)
player->mo->friction -= 2048;
// Karma ice physics
@ -7720,6 +7727,13 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (player->mo->movefactor < 32)
player->mo->movefactor = 32;
}
// Don't go too far above your top speed when rubberbanding
// Down here, because we do NOT want to modify movefactor
if (K_PlayerUsesBotMovement(player))
{
player->mo->friction = K_BotFrictionRubberband(player, player->mo->friction);
}
}
K_KartDrift(player, P_IsObjectOnGround(player->mo)); // Not using onground, since we don't want this affected by spring pads