Let bots block items with thundershield

This commit is contained in:
NepDisk 2026-04-27 15:58:30 -04:00
parent 0578050179
commit 4669f11385
3 changed files with 26 additions and 26 deletions

View file

@ -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);

View file

@ -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)
{

View file

@ -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;
}