mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
WIP: do bot error friction as friction adjustment instead of base friction
This commit is contained in:
parent
ab58b27873
commit
a8f326a08e
2 changed files with 42 additions and 30 deletions
|
|
@ -581,7 +581,7 @@ const botcontroller_t *K_GetBotController(const mobj_t *mobj)
|
||||||
fixed_t K_BotMapModifier(void)
|
fixed_t K_BotMapModifier(void)
|
||||||
{
|
{
|
||||||
// fuck it we ball
|
// fuck it we ball
|
||||||
return 5*FRACUNIT/10;
|
return 10*FRACUNIT/10;
|
||||||
|
|
||||||
constexpr INT32 complexity_scale = 10000;
|
constexpr INT32 complexity_scale = 10000;
|
||||||
fixed_t modifier_max = (9 * FRACUNIT / 10) - FRACUNIT;
|
fixed_t modifier_max = (9 * FRACUNIT / 10) - FRACUNIT;
|
||||||
|
|
|
||||||
70
src/k_kart.c
70
src/k_kart.c
|
|
@ -13244,35 +13244,6 @@ fixed_t K_PlayerBaseFriction(const player_t *player, fixed_t original)
|
||||||
// Remove this line once they can drift.
|
// Remove this line once they can drift.
|
||||||
frict -= extraFriction;
|
frict -= extraFriction;
|
||||||
|
|
||||||
// If bots are moving in the wrong direction relative to where they want to look, add some extra grip.
|
|
||||||
angle_t MAXERROR = ANGLE_45;
|
|
||||||
angle_t MINERROR = ANGLE_45;
|
|
||||||
fixed_t errorfrict = Easing_Linear(min(FRACUNIT, FixedDiv(player->botvars.predictionError, MAXERROR)), 0, FRACUNIT>>2);
|
|
||||||
|
|
||||||
if (player->currentwaypoint && player->currentwaypoint->mobj)
|
|
||||||
{
|
|
||||||
INT16 myradius = FixedDiv(player->currentwaypoint->mobj->radius, mapobjectscale) / FRACUNIT;
|
|
||||||
INT16 SMALL_WAYPOINT = 450;
|
|
||||||
|
|
||||||
if (myradius < SMALL_WAYPOINT)
|
|
||||||
errorfrict *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
errorfrict = min(errorfrict, frict/4);
|
|
||||||
|
|
||||||
if (player->mo && !P_MobjWasRemoved(player->mo) && player->mo->movefactor < FRACUNIT)
|
|
||||||
{
|
|
||||||
// Reduce error friction on low-friction surfaces
|
|
||||||
errorfrict = FixedMul(errorfrict, player->mo->movefactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player->botvars.predictionError >= MINERROR)
|
|
||||||
{
|
|
||||||
// CONS_Printf("%d: friction was %d, is ", leveltime, frict);
|
|
||||||
frict -= errorfrict;
|
|
||||||
// CONS_Printf("%d\n", frict);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bots gain more traction as they rubberband.
|
// Bots gain more traction as they rubberband.
|
||||||
const fixed_t traction_value = FixedMul(player->botvars.rubberband, K_BotMapModifier());
|
const fixed_t traction_value = FixedMul(player->botvars.rubberband, K_BotMapModifier());
|
||||||
if (traction_value > FRACUNIT)
|
if (traction_value > FRACUNIT)
|
||||||
|
|
@ -13354,6 +13325,47 @@ void K_AdjustPlayerFriction(player_t *player)
|
||||||
player->mo->friction = FRACUNIT;
|
player->mo->friction = FRACUNIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (K_PlayerUsesBotMovement(player))
|
||||||
|
{
|
||||||
|
fixed_t frict = 0;
|
||||||
|
|
||||||
|
// If bots are moving in the wrong direction relative to where they want to look, add some extra grip.
|
||||||
|
angle_t MAXERROR = ANGLE_45;
|
||||||
|
angle_t MINERROR = 0;
|
||||||
|
fixed_t errorfrict = Easing_InCubic(min(FRACUNIT, FixedDiv(player->botvars.predictionError, MAXERROR)), 0, FRACUNIT>>4);
|
||||||
|
|
||||||
|
if (player->currentwaypoint && player->currentwaypoint->mobj)
|
||||||
|
{
|
||||||
|
INT16 myradius = FixedDiv(player->currentwaypoint->mobj->radius, mapobjectscale) / FRACUNIT;
|
||||||
|
INT16 SMALL_WAYPOINT = 450;
|
||||||
|
|
||||||
|
if (myradius < SMALL_WAYPOINT)
|
||||||
|
errorfrict *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// errorfrict = min(errorfrict, frict/4);
|
||||||
|
|
||||||
|
if (player->mo && !P_MobjWasRemoved(player->mo) && player->mo->movefactor < FRACUNIT)
|
||||||
|
{
|
||||||
|
// Reduce error friction on low-friction surfaces
|
||||||
|
errorfrict = FixedMul(errorfrict, player->mo->movefactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player->botvars.predictionError >= MINERROR)
|
||||||
|
{
|
||||||
|
// CONS_Printf("%d: friction was %d, is ", leveltime, frict);
|
||||||
|
frict -= errorfrict;
|
||||||
|
// CONS_Printf("%d\n", frict);
|
||||||
|
}
|
||||||
|
|
||||||
|
player->mo->friction += frict;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (player->cmd.buttons & BT_ATTACK)
|
||||||
|
player->mo->friction -= FRACUNIT/2;
|
||||||
|
*/
|
||||||
|
|
||||||
// Cap between intended values
|
// Cap between intended values
|
||||||
if (player->mo->friction > FRACUNIT)
|
if (player->mo->friction > FRACUNIT)
|
||||||
player->mo->friction = FRACUNIT;
|
player->mo->friction = FRACUNIT;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue