From a2d9b1361abc0e50960ea14f26eb7193e8d91a85 Mon Sep 17 00:00:00 2001
From: AJ Martinez <aj@worldsbe.st>
Date: Tue, 21 Nov 2023 22:08:25 -0700
Subject: [PATCH] Never adjust bot ringboost gain below player ringboost gain
 (fixes runaway bot underflow)

---
 src/k_kart.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/k_kart.c b/src/k_kart.c
index 00952992d1..8d3e446410 100644
--- a/src/k_kart.c
+++ b/src/k_kart.c
@@ -9547,7 +9547,12 @@ void K_UpdateDistanceFromFinishLine(player_t *const player)
 INT32 K_GetKartRingPower(player_t *player, boolean boosted)
 {
 	fixed_t ringPower = ((9 - player->kartspeed) + (9 - player->kartweight)) * (FRACUNIT/2);
+	fixed_t basePower = ringPower;
 
+	// FIXME: Bot ringboost adjustments can award negative ringboost per ring, which seems bad.
+	// Revisit these values if bot ringboost needs to respond to low-complexity maps better,
+	// but for now we're just lazily making sure that bots never have their ringboost "boosted"
+	// below the value that a player would have when playing the same stat combo.
 	if (boosted == true && K_PlayerUsesBotMovement(player))
 	{
 		// x2.0 for Lv. 9
@@ -9562,7 +9567,7 @@ INT32 K_GetKartRingPower(player_t *player, boolean boosted)
 		}
 	}
 
-	return ringPower / FRACUNIT;
+	return max(ringPower, basePower) / FRACUNIT;
 }
 
 // Returns false if this player being placed here causes them to collide with any other player
-- 
GitLab