From 69e5cf82055cc7b00cf984ccebbc25c51466e0f3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 1 May 2020 23:44:03 -0400 Subject: [PATCH] Bots can use bubble shield and flame shield, albiet a bit simplisticly This means they can now use ALL items! --- src/k_bot.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/k_kart.c | 4 +++ 2 files changed, 88 insertions(+) diff --git a/src/k_bot.c b/src/k_bot.c index 047fc917a..7af7869cc 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -1881,6 +1881,90 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } } break; + case KITEM_BUBBLESHIELD: + { + boolean hold = false; + + if (player->kartstuff[k_bubbleblowup] <= 0) + { + UINT8 i; + + player->botvars.itemconfirm++; + + if (player->kartstuff[k_bubblecool] <= 0) + { + const fixed_t radius = 192 * player->mo->scale; + + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *target = NULL; + fixed_t dist = INT32_MAX; + + if (!playeringame[i]) + { + continue; + } + + target = &players[i]; + + if (target->mo == NULL || P_MobjWasRemoved(target->mo) + || player == target || target->spectator + || target->powers[pw_flashing]) + { + continue; + } + + dist = P_AproxDistance(P_AproxDistance( + player->mo->x - target->mo->x, + player->mo->y - target->mo->y), + (player->mo->z - target->mo->z) / 4 + ); + + if (dist <= radius) + { + hold = true; + break; + } + } + } + } + else if (player->kartstuff[k_bubbleblowup] >= bubbletime) + { + if (player->botvars.itemconfirm >= 10*TICRATE) + { + hold = true; + } + } + else if (player->kartstuff[k_bubbleblowup] < bubbletime) + { + hold = true; + } + + if (hold && player->kartstuff[k_holdready]) + { + cmd->buttons |= BT_ATTACK; + } + } + break; + case KITEM_FLAMESHIELD: + if (player->botvars.itemconfirm > 0) + { + player->botvars.itemconfirm--; + } + else if (player->kartstuff[k_holdready]) + { + INT32 flamemax = player->kartstuff[k_flamelength] * flameseg; + + if (player->kartstuff[k_flamemeter] < flamemax || flamemax == 0) + { + cmd->buttons |= BT_ATTACK; + } + else + { + player->botvars.itemconfirm = 3*flamemax/4; + } + } + break; default: if (player->kartstuff[k_itemtype] != KITEM_NONE && !(player->pflags & PF_ATTACKDOWN)) cmd->buttons |= BT_ATTACK; diff --git a/src/k_kart.c b/src/k_kart.c index 2f53570ce..7a394399b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -938,6 +938,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp #define COOLDOWNONSTART (leveltime < (30*TICRATE)+starttime) + /* if (bot) { // TODO: Item use on bots should all be passed-in functions. @@ -961,6 +962,8 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp case KITEM_HYUDORO: case KITEM_SUPERRING: case KITEM_THUNDERSHIELD: + case KITEM_BUBBLESHIELD: + case KITEM_FLAMESHIELD: case KRITEM_TRIPLESNEAKER: case KRITEM_TRIPLEBANANA: case KRITEM_TENFOLDBANANA: @@ -972,6 +975,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp return 0; } } + */ switch (item) {