From 4669f113857fe573a11623f8146d6d24a1ed535b Mon Sep 17 00:00:00 2001 From: NepDisk Date: Mon, 27 Apr 2026 15:58:30 -0400 Subject: [PATCH] Let bots block items with thundershield --- src/k_bot.h | 6 +++--- src/k_botitem.cpp | 4 ++-- src/k_botsearch.cpp | 42 +++++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/k_bot.h b/src/k_bot.h index 3e4998352..f980a0ee8 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -361,9 +361,9 @@ INT32 K_PositionBully(const player_t *player); /*-------------------------------------------------- - boolean K_GetBlockedBubbleItem(const player_t *player, , fixed_t radius) + boolean K_GetBlockedShieldItem(const player_t *player, , fixed_t radius) - Searches the blockmap for items to block with the Bubble Shield + Searches the blockmap for items to block with Shields Input Arguments:- player - Bot to run this for. @@ -373,7 +373,7 @@ INT32 K_PositionBully(const player_t *player); false if couldn't find anything, otherwise true to attempt blocking item. --------------------------------------------------*/ -boolean K_GetBlockedBubbleItem(const player_t *player, fixed_t radius); +boolean K_GetBlockedShieldItem(const player_t *player, fixed_t radius); /*-------------------------------------------------- void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd); diff --git a/src/k_botitem.cpp b/src/k_botitem.cpp index 8967ad0c4..5892c8d1f 100644 --- a/src/k_botitem.cpp +++ b/src/k_botitem.cpp @@ -936,7 +936,7 @@ static void K_BotItemLightning(botdata_t *bd, const player_t *player) if (K_BotUseItemNearPlayer(bd, player, radius) == false) { - if (bd->itemconfirm > 10*TICRATE) + if (K_GetBlockedShieldItem(player, radius) || bd->itemconfirm > 10*TICRATE) { K_BotGenericPressItem(bd, 0); } @@ -971,7 +971,7 @@ static void K_BotItemBubble(botdata_t *bd, const player_t *player) { fixed_t radius = 192 * player->mo->scale; radius = Easing_Linear(FRACUNIT * player->botvars.difficulty / MAXBOTDIFFICULTY, 2*radius, radius); - hold = K_GetBlockedBubbleItem(player, radius); + hold = K_GetBlockedShieldItem(player, radius); } else if (player->bubblecool < bubbletime) { diff --git a/src/k_botsearch.cpp b/src/k_botsearch.cpp index e1c999846..5b9330a0d 100644 --- a/src/k_botsearch.cpp +++ b/src/k_botsearch.cpp @@ -983,13 +983,13 @@ INT32 K_PositionBully(const player_t *player) return KART_FULLTURN; } -static mobj_t *bubbleSource; -static fixed_t bubbleDist; -static boolean bubbleBlock; +static mobj_t *shieldSource = NULL; +static fixed_t shieldDist = 0; +static boolean shieldBlock = 0; -static inline BlockItReturn_t PIT_BubbleShieldBlock(mobj_t *thing) +static inline BlockItReturn_t PIT_ShieldBlock(mobj_t *thing) { - if (bubbleSource == NULL || P_MobjWasRemoved(bubbleSource)) + if (shieldSource == NULL || P_MobjWasRemoved(shieldSource)) { // Invalid? return BMIT_ABORT; @@ -1001,7 +1001,7 @@ static inline BlockItReturn_t PIT_BubbleShieldBlock(mobj_t *thing) return BMIT_ABORT; } - if (thing == bubbleSource) + if (thing == shieldSource) { // Don't block yourself!! return BMIT_CONTINUE; @@ -1026,9 +1026,9 @@ static inline BlockItReturn_t PIT_BubbleShieldBlock(mobj_t *thing) } if (P_AproxDistance(P_AproxDistance( - bubbleSource->x - thing->x, - bubbleSource->y - thing->y), - (bubbleSource->z - thing->z) / 4) > bubbleDist) + shieldSource->x - thing->x, + shieldSource->y - thing->y), + (shieldSource->z - thing->z) / 4) > shieldDist) { // Too far away return BMIT_CONTINUE; @@ -1042,30 +1042,30 @@ static inline BlockItReturn_t PIT_BubbleShieldBlock(mobj_t *thing) } #endif - bubbleBlock = true; + shieldBlock = true; return BMIT_CONTINUE; } -// Searches the blockmap for items to block with the Bubble Shield -boolean K_GetBlockedBubbleItem(const player_t *player, fixed_t radius) +// Searches the blockmap for items to block with Shields +boolean K_GetBlockedShieldItem(const player_t *player, fixed_t radius) { INT32 bx, by, xl, xh, yl, yh; - bubbleSource = player->mo; - bubbleDist = radius; - bubbleBlock = false; + shieldSource = player->mo; + shieldDist = radius; + shieldBlock = false; // Use blockmap to check for nearby harmful items. - yh = (unsigned)(bubbleSource->y + bubbleDist - bmaporgy)>>MAPBLOCKSHIFT; - yl = (unsigned)(bubbleSource->y - bubbleDist - bmaporgy)>>MAPBLOCKSHIFT; - xh = (unsigned)(bubbleSource->x + bubbleDist - bmaporgx)>>MAPBLOCKSHIFT; - xl = (unsigned)(bubbleSource->x - bubbleDist - bmaporgx)>>MAPBLOCKSHIFT; + yh = (unsigned)(shieldSource->y + shieldDist - bmaporgy)>>MAPBLOCKSHIFT; + yl = (unsigned)(shieldSource->y - shieldDist - bmaporgy)>>MAPBLOCKSHIFT; + xh = (unsigned)(shieldSource->x + shieldDist - bmaporgx)>>MAPBLOCKSHIFT; + xl = (unsigned)(shieldSource->x - shieldDist - bmaporgx)>>MAPBLOCKSHIFT; BMBOUNDFIX (xl, xh, yl, yh); for (by = yl; by <= yh; by++) for (bx = xl; bx <= xh; bx++) - P_BlockThingsIterator(bx, by, PIT_BubbleShieldBlock); + P_BlockThingsIterator(bx, by, PIT_ShieldBlock); - return bubbleBlock; + return shieldBlock; }