From f18dee3db79b28af948abe23df21c9ff302ce277 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Tue, 24 Feb 2026 08:51:23 -0500 Subject: [PATCH] Allow bots to stack sneakers When stacking is on bots will attempt to stack them together. Their timing is based on their difficulty, less skilled bots are more wasteful while better bots are less wasteful. Also adjusts Rocket sneakers to also use this logic. --- src/k_botitem.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/k_botitem.cpp b/src/k_botitem.cpp index d0edcfc75..6d86d571c 100644 --- a/src/k_botitem.cpp +++ b/src/k_botitem.cpp @@ -14,6 +14,7 @@ #include +#include "d_netcmd.h" #include "doomdef.h" #include "d_player.h" #include "g_game.h" @@ -414,6 +415,15 @@ static void K_BotItemGenericOrbitShield(botdata_t *bd, const player_t *player) K_BotGenericPressItem(bd, 0); } +// Less skilled bots stack wastefully, low enough bots don't stack at all. +static SINT8 K_BotSneakerStackThreshold(SINT8 difficulty) +{ + if (difficulty < 5) + return 0; + + return 10 - ((difficulty-1)*5) / 13 + 1; +} + // Item usage for sneakers. static void K_BotItemSneaker(botdata_t *bd, const player_t *player) { @@ -425,13 +435,17 @@ static void K_BotItemSneaker(botdata_t *bd, const player_t *player) return; } + boolean stack = K_StackingActive() && (cv_kartstacking_sneaker_maxgrade.value > 1); + const SINT8 stacktime = K_BotSneakerStackThreshold(player->botvars.difficulty); + if ((player->offroad && K_ApplyOffroad(player)) // Stuck in offroad, use it NOW || K_GetWaypointIsShortcut(player->nextwaypoint) == true // Going toward a shortcut! || player->speed < K_GetKartSpeed(player, false, true) / 2 // Being slowed down too much - || player->speedboost > (FRACUNIT/8) // Have another type of boost (tethering) + || (!stack && player->speedboost > (FRACUNIT/8)) // Have another type of boost (drafting) + || (stack && player->sneakertimer < stacktime && player->sneakertimer > 0) // Stack them sneakers! || bd->itemconfirm > 4*TICRATE) // Held onto it for too long { - if (player->sneakertimer == 0 && !bd->itemwasdown) + if (((stack && player->sneakertimer < stacktime) || player->sneakertimer == 0) && !bd->itemwasdown) { bd->itemdown = true; //bd->itemconfirm = 2*TICRATE; @@ -456,10 +470,17 @@ static void K_BotItemRocketSneaker(botdata_t *bd, const player_t *player) if (bd->itemconfirm > TICRATE) { - if (player->sneakertimer == 0 && !bd->itemwasdown) + if (player->sneakertimer > 0 && K_StackingActive()) { - bd->itemdown = true; - //bd->itemconfirm = 0; + K_BotItemSneaker(bd, player); + } + else + { + if (player->sneakertimer == 0 && !bd->itemwasdown) + { + bd->itemdown = true; + //bd->itemconfirm = 0; + } } } else