Rework loops to be better then they previously were here

This commit is contained in:
NepDisk 2025-08-12 19:55:55 -04:00
parent 497fe4bcac
commit 0dc7f87b7e
5 changed files with 62 additions and 13 deletions

View file

@ -7992,8 +7992,24 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->outruntime > 0)
player->outruntime--;
if (player->tiregrease > 0)
player->tiregrease--;
if (player->tiregrease)
{
// Remove grease faster if players are moving slower; players that are recovering
// from mistakes (or who got sprung purely for track traversal) need steering!
// Up to 4x degrease speed below 10FU/t (speed at which you lose drift sparks).
INT16 toDegrease = 1;
INT16 driftSpeedIncrements = player->speed / (10 * player->mo->scale); // Same breakpoints used for driftcharge stages.
toDegrease += max(3 - driftSpeedIncrements, 0);
if (player->tiregrease <= toDegrease)
{
player->tiregrease = 0;
}
else
{
player->tiregrease -= toDegrease;
}
}
if (player->chaintimer)
player->chaintimer--;
@ -9528,6 +9544,11 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer)
basedrift = 83*player->drift - (driftweight - 14)*player->drift/5; // 415 - 303
driftangle = abs((252 - driftweight)*player->drift/5);
if (player->tiregrease > 0) // Buff drift-steering while in greasemode
{
basedrift += (basedrift / greasetics) * player->tiregrease;
}
return basedrift + FixedMul(driftangle, countersteer);
}
@ -10598,6 +10619,27 @@ static void K_AdjustPlayerFriction(player_t *player)
player->mo->friction = prevfriction;
// Reduce friction after exiting a loop.
if (player->tiregrease)
{
player->mo->friction += ((FRACUNIT - prevfriction) / greasetics) * player->tiregrease;
if (player->mo->friction > FRACUNIT)
player->mo->friction = FRACUNIT;
if (player->mo->friction < 0)
player->mo->friction = 0;
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;
}
// Friction
if (!player->offroad)
{
@ -10608,12 +10650,6 @@ static void K_AdjustPlayerFriction(player_t *player)
if (player->speed > 0 && player->cmd.forwardmove < 0) // change friction while braking no matter what, otherwise it's not any more effective than just letting go off accel
player->mo->friction -= 2048;
// Reduce friction after exiting a loop.
if (player->tiregrease)
{
player->mo->friction += ((FRACUNIT - prevfriction) / greasetics) * player->tiregrease;
}
// Karma ice physics
if ((gametyperules & GTR_KARMA) && player->bumper <= 0)
{
@ -10630,7 +10666,7 @@ static void K_AdjustPlayerFriction(player_t *player)
if (player->mo->movefactor < FRACUNIT)
player->mo->movefactor = 19*player->mo->movefactor - 18*FRACUNIT;
else
player->mo->movefactor = FRACUNIT; //player->mo->movefactor = ((player->mo->friction - 0xDB34)*(0xA))/0x80;
player->mo->movefactor = FRACUNIT;
if (player->mo->movefactor < 32)
player->mo->movefactor = 32;
@ -10654,6 +10690,13 @@ void K_SetTireGrease(player_t *player, tic_t tics)
player->tiregrease = tics;
}
boolean K_SlopeResistance(player_t *player)
{
if (player->tiregrease)
return true;
return false;
}
void K_SetItemOut(player_t *player)
{
player->itemflags |= IF_ITEMOUT;

View file

@ -274,6 +274,7 @@ boolean K_WaterRun(mobj_t *mobj);
void K_SpawnWaterTrail(mobj_t *mobj);
boolean K_ItemMobjAllowedtoWaterRun(mobj_t *item);
void K_SetTireGrease(player_t *player, tic_t tics);
boolean K_SlopeResistance(player_t *player);
void K_SquishPlayer(player_t *player, mobj_t *inflictor, mobj_t *source);
void K_ApplyTripWire(player_t *player, tripwirestate_t state);
fixed_t K_GetKartSpeedFromStat(UINT8 kartspeed, boolean karmabomb);

View file

@ -5013,6 +5013,7 @@ static luaL_Reg lib[] = {
{"K_AwardScaledPlayerRings", lib_kAwardScaledPlayerRings},
// k_waypoint
{"K_NextRespawnWaypointIndex", lib_kNextRespawnWaypointIndex},
{"K_GetFinishLineWaypoint", lib_kGetFinishLineWaypoint},
{"K_GetStartingWaypoint", lib_kGetStartingWaypoint},
{"K_GetWaypointIsFinishline", lib_kGetWaypointIsFinishline},

View file

@ -86,9 +86,8 @@ void P_ExitPlayerOrbit(player_t *player)
}
// tiregrease gives less friction, extends momentum
K_SetTireGrease(player, TICRATE*2);
player->outruntime = TICRATE*2;
K_SetTireGrease(player, 3*TICRATE);
P_HaltPlayerOrbit(player);
}

View file

@ -1798,6 +1798,11 @@ static void P_3dMovement(player_t *player)
totalthrust.x = totalthrust.y = 0; // I forget if this is needed
totalthrust.z = FRACUNIT*P_MobjFlip(player->mo)/3; // A bit of extra push-back on slopes
if (K_SlopeResistance(player) == true)
{
totalthrust.z = -(totalthrust.z);
}
cmd = &player->cmd;
@ -1949,7 +1954,7 @@ static void P_3dMovement(player_t *player)
// If "no" to 1, we're not reaching any limits yet, so ignore this entirely!
// -Shadow Hog
newMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0);
if ((player->outruntime == 0) || (player->offroad > 0))
if (player->offroad > 0 || !player->outruntime)
{
if (newMagnitude > K_GetKartSpeed(player, true, true)) //topspeed)
{