mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-23 05:51:58 +00:00
Fixed friction being applied incorrectly
Kart's manual player friction adjustments were being called after movefactor was reset, meaning friction changed but movefactor was default, essentially creating old 2.1 friction again
This commit is contained in:
parent
e19cffa819
commit
58d9ac899d
4 changed files with 97 additions and 85 deletions
137
src/k_kart.c
137
src/k_kart.c
|
|
@ -6248,7 +6248,7 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue)
|
|||
}
|
||||
|
||||
p_maxspeed = K_GetKartSpeed(player, false);
|
||||
p_speed = min(player->speed, (p_maxspeed * 2));
|
||||
p_speed = min(FixedHypot(player->mo->momx, player->mo->momy), (p_maxspeed * 2));
|
||||
weightadjust = FixedDiv((p_maxspeed * 3) - p_speed, (p_maxspeed * 3) + (player->kartweight * FRACUNIT));
|
||||
|
||||
if (K_PlayerUsesBotMovement(player))
|
||||
|
|
@ -6785,6 +6785,81 @@ static void K_KartSpindash(player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// K_AdjustPlayerFriction
|
||||
//
|
||||
void K_AdjustPlayerFriction(player_t *player)
|
||||
{
|
||||
fixed_t prevfriction = player->mo->friction;
|
||||
|
||||
if (P_IsObjectOnGround(player->mo) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Reduce friction after hitting a horizontal spring
|
||||
if (player->kartstuff[k_tiregrease])
|
||||
{
|
||||
player->mo->friction += ((FRACUNIT - prevfriction) / greasetics) * player->kartstuff[k_tiregrease];
|
||||
}
|
||||
|
||||
/*
|
||||
if (K_PlayerEBrake(player) == true)
|
||||
{
|
||||
player->mo->friction -= 1024;
|
||||
}
|
||||
else if (player->speed > 0 && cmd->forwardmove < 0)
|
||||
{
|
||||
player->mo->friction -= 512;
|
||||
}
|
||||
*/
|
||||
|
||||
// Karma ice physics
|
||||
if (gametype == GT_BATTLE && player->kartstuff[k_bumper] <= 0)
|
||||
{
|
||||
player->mo->friction += 1228;
|
||||
}
|
||||
|
||||
// Water gets ice physics too
|
||||
if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))
|
||||
{
|
||||
player->mo->friction += 614;
|
||||
}
|
||||
|
||||
// Wipeout slowdown
|
||||
if (player->kartstuff[k_spinouttimer] && player->kartstuff[k_wipeoutslow])
|
||||
{
|
||||
if (player->kartstuff[k_offroad])
|
||||
player->mo->friction -= 4912;
|
||||
if (player->kartstuff[k_wipeoutslow] == 1)
|
||||
player->mo->friction -= 9824;
|
||||
}
|
||||
|
||||
// Cap between intended values
|
||||
if (player->mo->friction > FRACUNIT)
|
||||
player->mo->friction = FRACUNIT;
|
||||
if (player->mo->friction < 0)
|
||||
player->mo->friction = 0;
|
||||
|
||||
// Friction was changed, so we must recalculate movefactor
|
||||
if (player->mo->friction != prevfriction)
|
||||
{
|
||||
player->mo->movefactor = FixedDiv(ORIG_FRICTION, player->mo->friction);
|
||||
|
||||
if (player->mo->movefactor < FRACUNIT)
|
||||
player->mo->movefactor = 19*player->mo->movefactor - 18*FRACUNIT;
|
||||
else
|
||||
player->mo->movefactor = FRACUNIT;
|
||||
}
|
||||
|
||||
// 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_MoveKartPlayer
|
||||
//
|
||||
|
|
@ -7467,66 +7542,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
|
|||
}
|
||||
|
||||
K_KartDrift(player, P_IsObjectOnGround(player->mo)); // Not using onground, since we don't want this affected by spring pads
|
||||
|
||||
if (onground)
|
||||
{
|
||||
fixed_t prevfriction = player->mo->friction;
|
||||
|
||||
// Reduce friction after hitting a horizontal spring
|
||||
if (player->kartstuff[k_tiregrease])
|
||||
player->mo->friction += ((FRACUNIT - prevfriction) / greasetics) * player->kartstuff[k_tiregrease];
|
||||
|
||||
/*
|
||||
if (K_PlayerEBrake(player) == true)
|
||||
player->mo->friction -= 1024;
|
||||
else if (player->speed > 0 && cmd->forwardmove < 0)
|
||||
player->mo->friction -= 512;
|
||||
*/
|
||||
|
||||
// Karma ice physics
|
||||
if (gametype == GT_BATTLE && player->kartstuff[k_bumper] <= 0)
|
||||
player->mo->friction += 1228;
|
||||
|
||||
if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))
|
||||
player->mo->friction += 614;
|
||||
|
||||
// Wipeout slowdown
|
||||
if (player->kartstuff[k_spinouttimer] && player->kartstuff[k_wipeoutslow])
|
||||
{
|
||||
if (player->kartstuff[k_offroad])
|
||||
player->mo->friction -= 4912;
|
||||
if (player->kartstuff[k_wipeoutslow] == 1)
|
||||
player->mo->friction -= 9824;
|
||||
}
|
||||
|
||||
// Cap between intended values
|
||||
if (player->mo->friction > FRACUNIT)
|
||||
player->mo->friction = FRACUNIT;
|
||||
if (player->mo->friction < 0)
|
||||
player->mo->friction = 0;
|
||||
|
||||
// Friction was changed, so we must recalculate movefactor
|
||||
if (player->mo->friction != prevfriction)
|
||||
{
|
||||
player->mo->movefactor = FixedDiv(ORIG_FRICTION, player->mo->friction);
|
||||
|
||||
if (player->mo->movefactor < FRACUNIT)
|
||||
player->mo->movefactor = 19*player->mo->movefactor - 18*FRACUNIT;
|
||||
else
|
||||
player->mo->movefactor = FRACUNIT;
|
||||
|
||||
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_KartSpindash(player);
|
||||
|
||||
// Squishing
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ UINT16 K_GetKartFlashing(player_t *player);
|
|||
SINT8 K_GetForwardMove(player_t *player);
|
||||
fixed_t K_3dKartMovement(player_t *player, boolean onground);
|
||||
boolean K_PlayerEBrake(player_t *player);
|
||||
void K_AdjustPlayerFriction(player_t *player);
|
||||
void K_MoveKartPlayer(player_t *player, boolean onground);
|
||||
void K_CheckSpectateStatus(void);
|
||||
|
||||
|
|
|
|||
18
src/p_mobj.c
18
src/p_mobj.c
|
|
@ -1291,8 +1291,16 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy)
|
|||
}
|
||||
else
|
||||
{
|
||||
mo->momx = FixedMul(mo->momx, mo->friction);
|
||||
mo->momy = FixedMul(mo->momy, mo->friction);
|
||||
if (oldx == mo->x && oldy == mo->y)
|
||||
{
|
||||
mo->momx = FixedMul(mo->momx, ORIG_FRICTION);
|
||||
mo->momy = FixedMul(mo->momy, ORIG_FRICTION);
|
||||
}
|
||||
else
|
||||
{
|
||||
mo->momx = FixedMul(mo->momx, mo->friction);
|
||||
mo->momy = FixedMul(mo->momy, mo->friction);
|
||||
}
|
||||
|
||||
mo->friction = ORIG_FRICTION;
|
||||
}
|
||||
|
|
@ -1751,9 +1759,6 @@ void P_XYMovement(mobj_t *mo)
|
|||
if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE || mo->type == MT_PENGUINATOR)
|
||||
return; // no friction for missiles ever
|
||||
|
||||
if (player && player->homing) // no friction for homing
|
||||
return;
|
||||
|
||||
if ((mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED)
|
||||
&& (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes
|
||||
return;
|
||||
|
|
@ -1762,7 +1767,8 @@ void P_XYMovement(mobj_t *mo)
|
|||
if (mo->type == MT_FLINGRING || mo->type == MT_BALLHOG || mo->type == MT_BUBBLESHIELDTRAP)
|
||||
return;
|
||||
|
||||
if (player && (player->kartstuff[k_spinouttimer] && !player->kartstuff[k_wipeoutslow]) && player->speed <= FixedDiv(20*mapobjectscale, player->kartstuff[k_offroad] + FRACUNIT))
|
||||
if (player && (player->kartstuff[k_spinouttimer] && !player->kartstuff[k_wipeoutslow])
|
||||
&& player->speed <= FixedDiv(20*mapobjectscale, player->kartstuff[k_offroad] + FRACUNIT))
|
||||
return;
|
||||
//}
|
||||
|
||||
|
|
|
|||
26
src/p_user.c
26
src/p_user.c
|
|
@ -1842,7 +1842,6 @@ static void P_DoBubbleBreath(player_t *player)
|
|||
//#define OLD_MOVEMENT_CODE 1
|
||||
static void P_3dMovement(player_t *player)
|
||||
{
|
||||
ticcmd_t *cmd;
|
||||
angle_t movepushangle; // Analog
|
||||
fixed_t movepushforward = 0;
|
||||
angle_t dangle; // replaces old quadrants bits
|
||||
|
|
@ -1855,8 +1854,6 @@ static void P_3dMovement(player_t *player)
|
|||
// Get the old momentum; this will be needed at the end of the function! -SH
|
||||
oldMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0);
|
||||
|
||||
cmd = &player->cmd;
|
||||
|
||||
if (player->kartstuff[k_drift] != 0)
|
||||
movepushangle = player->mo->angle-(ANGLE_45/5)*player->kartstuff[k_drift];
|
||||
else if (player->kartstuff[k_spinouttimer] || player->kartstuff[k_wipeoutslow]) // if spun out, use the boost angle
|
||||
|
|
@ -1919,7 +1916,7 @@ static void P_3dMovement(player_t *player)
|
|||
// SRB2Kart: pogo spring and speed bumps are supposed to control like you're on the ground
|
||||
onground = (P_IsObjectOnGround(player->mo) || (player->kartstuff[k_pogospring]));
|
||||
|
||||
player->aiming = cmd->aiming<<FRACBITS;
|
||||
K_AdjustPlayerFriction(player);
|
||||
|
||||
// Forward movement
|
||||
if (!P_PlayerInPain(player))
|
||||
|
|
@ -1934,10 +1931,12 @@ static void P_3dMovement(player_t *player)
|
|||
totalthrust.x += P_ReturnThrustX(player->mo, movepushangle, movepushforward);
|
||||
totalthrust.y += P_ReturnThrustY(player->mo, movepushangle, movepushforward);
|
||||
}
|
||||
else
|
||||
{
|
||||
K_MomentumToFacing(player);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!P_PlayerInPain(player) && !onground)
|
||||
|| (K_PlayerUsesBotMovement(player) == true))
|
||||
{
|
||||
K_MomentumToFacing(player);
|
||||
}
|
||||
|
||||
if ((totalthrust.x || totalthrust.y)
|
||||
|
|
@ -1957,11 +1956,6 @@ static void P_3dMovement(player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
if (K_PlayerUsesBotMovement(player))
|
||||
{
|
||||
K_MomentumToFacing(player);
|
||||
}
|
||||
|
||||
player->mo->momx += totalthrust.x;
|
||||
player->mo->momy += totalthrust.y;
|
||||
|
||||
|
|
@ -2049,7 +2043,7 @@ static void P_UpdatePlayerAngle(player_t *player)
|
|||
player->angleturn += angleChange;
|
||||
P_SetLocalAngle(player, P_GetLocalAngle(player) + angleChange);
|
||||
|
||||
if (!cv_allowmlook.value)
|
||||
if (!cv_allowmlook.value || player->spectator == false)
|
||||
{
|
||||
player->aiming = 0;
|
||||
}
|
||||
|
|
@ -2087,10 +2081,6 @@ static void P_SpectatorMovement(player_t *player)
|
|||
if (player->mo->z < player->mo->floorz)
|
||||
player->mo->z = player->mo->floorz;
|
||||
|
||||
// Aiming needed for SEENAMES, etc.
|
||||
// We may not need to fire as a spectator, but this is still handy!
|
||||
player->aiming = cmd->aiming<<FRACBITS;
|
||||
|
||||
player->mo->momx = player->mo->momy = player->mo->momz = 0;
|
||||
if (cmd->forwardmove != 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue