From 6ae28c4cdbb424beaeb1dface9060b9d67ac3d97 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 4 Mar 2023 16:16:37 -0500 Subject: [PATCH 1/3] Add final position as a ranking requirement 1st is a large bonus, 2nd is a medium bonus, 3rd place is no bonus, and everything below is a penalty. This will help make Loser Valley grades never be above a C at most. --- src/k_hud.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 2ee8fa7e0..94b401618 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4846,7 +4846,7 @@ static void K_DrawGPRankDebugger(void) default: { break; } } - V_DrawThinString(0, 80, V_SNAPTOTOP|V_SNAPTOLEFT|V_6WIDTHSPACE|V_ALLOWLOWERCASE|V_YELLOWMAP, + V_DrawThinString(0, 90, V_SNAPTOTOP|V_SNAPTOLEFT|V_6WIDTHSPACE|V_ALLOWLOWERCASE|V_YELLOWMAP, va(" ** FINAL GRADE: %c", gradeChar)); } From 63d156b9427205392ec093af74710466d33cd7a1 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 6 Mar 2023 00:46:43 -0500 Subject: [PATCH 2/3] Reduce waypoint radius for bots on turns --- src/k_bot.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index cb0b57eb0..b76423438 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -634,6 +634,60 @@ fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t return R_PointToDist2(px, py, startx + vx, starty + vy); } +/*-------------------------------------------------- + static fixed_t K_GetBotWaypointRadius(waypoint_t *waypoint) + + Calculates a new waypoint radius size to use, making it + thinner depending on how harsh the turn is. + + Input Arguments:- + waypoint - Waypoint to retrieve the radius of. + + Return:- + New radius value. +--------------------------------------------------*/ +static fixed_t K_GetBotWaypointRadius(waypoint_t *const waypoint) +{ + static const fixed_t maxReduce = FRACUNIT/32; + static const angle_t maxDelta = ANGLE_45; + + fixed_t radius = waypoint->mobj->radius; + fixed_t reduce = FRACUNIT; + angle_t delta = 0; + + size_t i, j; + + for (i = 0; i < waypoint->numnextwaypoints; i++) + { + const waypoint_t *next = waypoint->nextwaypoints[i]; + const angle_t nextAngle = R_PointToAngle2( + waypoint->mobj->x, waypoint->mobj->y, + next->mobj->x, next->mobj->y + ); + + for (j = 0; j < waypoint->numprevwaypoints; j++) + { + const waypoint_t *prev = waypoint->prevwaypoints[j]; + const angle_t prevAngle = R_PointToAngle2( + prev->mobj->x, prev->mobj->y, + waypoint->mobj->x, waypoint->mobj->y + ); + + delta = max(delta, AngleDelta(nextAngle, prevAngle)); + } + } + + if (delta > maxDelta) + { + delta = maxDelta; + } + + reduce = FixedDiv(delta, maxDelta); + reduce = FRACUNIT + FixedMul(reduce, maxReduce - FRACUNIT); + + return FixedMul(radius, reduce); +} + /*-------------------------------------------------- static botprediction_t *K_CreateBotPrediction(player_t *player) @@ -695,6 +749,8 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) { for (i = 0; i < pathtofinish.numnodes; i++) { + fixed_t radius = 0; + wp = (waypoint_t *)pathtofinish.array[i].nodedata; if (i == 0) @@ -716,9 +772,10 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) radreduce = FRACUNIT >> 1; } - if (wp->mobj->radius < smallestradius) + radius = K_GetBotWaypointRadius(wp); + if (radius < smallestradius) { - smallestradius = wp->mobj->radius; + smallestradius = radius; } distanceleft -= disttonext; @@ -1386,7 +1443,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) return; } - if (botController != NULL && (botController->args[1] & TMBOT_NOCONTROL)) // FIXME: UDMF-ify + if (botController != NULL && (botController->args[1] & TMBOT_NOCONTROL)) { // Disable bot controls entirely. return; @@ -1394,7 +1451,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) destangle = player->mo->angle; - if (botController != NULL && (botController->args[1] & TMBOT_FORCEDIR)) // FIXME: UDMF-ify + if (botController != NULL && (botController->args[1] & TMBOT_FORCEDIR)) { const fixed_t dist = DEFAULT_WAYPOINT_RADIUS * player->mo->scale; From 9561ec69bfa3609cec6007bbd3b9a5c9bb5b48a2 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 6 Mar 2023 03:15:28 -0500 Subject: [PATCH 3/3] Give bots friction rubberband again --- src/k_kart.c | 20 +++++++++++++++++--- src/k_kart.h | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3231f47cd..44e57bb25 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3453,7 +3453,7 @@ fixed_t K_GetNewSpeed(player_t *player) // 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), K_PlayerBaseFriction(ORIG_FRICTION)); + newspeed = FixedDiv(FixedDiv(FixedMul(oldspeed, accelmax - p_accel) + FixedMul(p_speed, p_accel), accelmax), K_PlayerBaseFriction(player, ORIG_FRICTION)); finalspeed = newspeed - oldspeed; @@ -10014,7 +10014,7 @@ static void K_AirFailsafe(player_t *player) // // K_PlayerBaseFriction // -fixed_t K_PlayerBaseFriction(fixed_t original) +fixed_t K_PlayerBaseFriction(player_t *player, fixed_t original) { fixed_t frict = original; @@ -10022,6 +10022,20 @@ fixed_t K_PlayerBaseFriction(fixed_t original) { frict -= FRACUNIT >> 4; } + else if (K_PlayerUsesBotMovement(player) == true) + { + // A bit extra friction to help them without drifting. + // Remove this line once they can drift. + frict -= FRACUNIT >> 5; + + // Bots gain more traction as they rubberband. + if (player->botvars.rubberband > FRACUNIT) + { + static const fixed_t extraFriction = FRACUNIT >> 5; + const fixed_t mul = player->botvars.rubberband - FRACUNIT; + frict -= FixedMul(extraFriction, mul); + } + } if (frict > FRACUNIT) { frict = FRACUNIT; } if (frict < 0) { frict = 0; } @@ -10034,7 +10048,7 @@ fixed_t K_PlayerBaseFriction(fixed_t original) // void K_AdjustPlayerFriction(player_t *player) { - const fixed_t prevfriction = K_PlayerBaseFriction(player->mo->friction); + const fixed_t prevfriction = K_PlayerBaseFriction(player, player->mo->friction); if (P_IsObjectOnGround(player->mo) == false) { diff --git a/src/k_kart.h b/src/k_kart.h index fc364624a..70ab93998 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -177,7 +177,7 @@ fixed_t K_3dKartMovement(player_t *player); boolean K_PlayerEBrake(player_t *player); SINT8 K_Sliptiding(player_t *player); boolean K_FastFallBounce(player_t *player); -fixed_t K_PlayerBaseFriction(fixed_t original); +fixed_t K_PlayerBaseFriction(player_t *player, fixed_t original); void K_AdjustPlayerFriction(player_t *player); void K_MoveKartPlayer(player_t *player, boolean onground); void K_CheckSpectateStatus(void);