From a8f326a08e72f3a65ed1afdebb4864bdbddb3840 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 17 Jun 2025 17:01:48 -0400 Subject: [PATCH] WIP: do bot error friction as friction adjustment instead of base friction --- src/k_bot.cpp | 2 +- src/k_kart.c | 70 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/k_bot.cpp b/src/k_bot.cpp index f2e1ad981..38b481f28 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -581,7 +581,7 @@ const botcontroller_t *K_GetBotController(const mobj_t *mobj) fixed_t K_BotMapModifier(void) { // fuck it we ball - return 5*FRACUNIT/10; + return 10*FRACUNIT/10; constexpr INT32 complexity_scale = 10000; fixed_t modifier_max = (9 * FRACUNIT / 10) - FRACUNIT; diff --git a/src/k_kart.c b/src/k_kart.c index dbd4f05e0..78a6bdd58 100644 --- a/src/k_kart.c +++ b/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. 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. const fixed_t traction_value = FixedMul(player->botvars.rubberband, K_BotMapModifier()); if (traction_value > FRACUNIT) @@ -13354,6 +13325,47 @@ void K_AdjustPlayerFriction(player_t *player) 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 if (player->mo->friction > FRACUNIT) player->mo->friction = FRACUNIT;