From d7c9aafd2b7da78f4784329bf615459b5af401ad Mon Sep 17 00:00:00 2001 From: NepDisk Date: Tue, 4 Feb 2025 21:38:13 -0500 Subject: [PATCH] Enforce const in bot ticcmds https://git.do.srb2.org/KartKrew/RingRacers/-/commit/710e561981529c2e9642f8e5cd23538794f13e7a --- src/d_ticcmd.h | 12 ++++-- src/g_demo.c | 55 ++++++++++++++++++++++++- src/g_game.c | 5 +++ src/k_bot.c | 16 +++++--- src/k_bot.h | 17 ++++++++ src/k_botitem.c | 107 +++++++++++++++++++++++++++++------------------- src/k_kart.c | 40 ++++++++++++++++-- 7 files changed, 198 insertions(+), 54 deletions(-) diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 6010aaf32..a4d0263ae 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -54,9 +54,10 @@ typedef enum #define TICCMD_LATENCYMASK 0xFF // ticcmd flags -#define TICCMD_RECEIVED 1 -#define TICCMD_TYPING 2/* chat window or console open */ -#define TICCMD_KEYSTROKE 4/* chat character input */ +#define TICCMD_RECEIVED (0x01) /* Actual tic recieved from client */ +#define TICCMD_TYPING (0x02) /* chat window or console open */ +#define TICCMD_KEYSTROKE (0x04) /* chat character input */ +#define TICCMD_BOT (0x80) /* generated by bot, demos write bot variables */ #if defined(_MSC_VER) #pragma pack(1) @@ -73,6 +74,11 @@ struct ticcmd_t UINT16 buttons; UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end? UINT8 flags; + struct + { + SINT8 turnconfirm; + SINT8 itemconfirm; + } bot; } ATTRPACK; #if defined(_MSC_VER) diff --git a/src/g_demo.c b/src/g_demo.c index 9e2366356..2e2a05149 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -137,8 +137,12 @@ demoghost *ghosts = NULL; #define ZT_AIMING 0x0040 #define ZT_LATENCY 0x0080 #define ZT_FLAGS 0x0100 +#define ZT_BOT 0x8000 // Ziptics are UINT16 now, go nuts +#define ZT_BOT_TURN 0x0001 +#define ZT_BOT_ITEM 0x0002 + #define DEMOMARKER 0x80 // demobuf.end UINT8 demo_extradata[MAXPLAYERS]; @@ -525,6 +529,16 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (ziptic & ZT_FLAGS) oldcmd[playernum].flags = READUINT8(demobuf.p); + if (ziptic & ZT_BOT) + { + UINT16 botziptic = READUINT16(demobuf.p); + + if (botziptic & ZT_BOT_TURN) + oldcmd[playernum].bot.turnconfirm = READSINT8(demobuf.p); + if (botziptic & ZT_BOT_ITEM) + oldcmd[playernum].bot.itemconfirm = READSINT8(demobuf.p); + } + G_CopyTiccmd(cmd, &oldcmd[playernum], 1); if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) @@ -539,10 +553,11 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) { UINT16 ziptic = 0; UINT8 *ziptic_p; - (void)playernum; + //(void)playernum; if (!demobuf.p) return; + ziptic_p = demobuf.p; // the ziptic, written at the end of this function demobuf.p += 2; @@ -609,8 +624,38 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) ziptic |= ZT_FLAGS; } + if (cmd->flags & TICCMD_BOT) + { + ziptic |= ZT_BOT; + } + WRITEUINT16(ziptic_p, ziptic); + if (ziptic & ZT_BOT) + { + UINT16 botziptic = 0; + UINT8 *botziptic_p; + + botziptic_p = demobuf.p; // the ziptic, written at the end of this function + demobuf.p += 2; + + if (cmd->bot.turnconfirm != oldcmd[playernum].bot.turnconfirm) + { + WRITESINT8(demobuf.p, cmd->bot.turnconfirm); + oldcmd[playernum].bot.turnconfirm = cmd->bot.turnconfirm; + botziptic |= ZT_BOT_TURN; + } + + if (cmd->bot.itemconfirm != oldcmd[playernum].bot.itemconfirm) + { + WRITESINT8(demobuf.p, cmd->bot.itemconfirm); + oldcmd[playernum].bot.itemconfirm = cmd->bot.itemconfirm; + botziptic |= ZT_BOT_ITEM; + } + + WRITEUINT16(botziptic_p, botziptic); + } + // attention here for the ticcmd size! // latest demos with mouse aiming byte in ticcmd if (!(demoflags & DF_GHOST) && ziptic_p > demobuf.end - 9) @@ -1178,6 +1223,14 @@ void G_GhostTicker(void) g->p++; if (ziptic & ZT_FLAGS) g->p++; + if (ziptic & ZT_BOT) + { + UINT16 botziptic = READUINT16(g->p); + if (botziptic & ZT_BOT_TURN) + g->p++; + if (botziptic & ZT_BOT_ITEM) + g->p++; + } // Grab ghost data. ziptic = READUINT8(g->p); diff --git a/src/g_game.c b/src/g_game.c index bb249b017..2b8bbd3f7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1272,6 +1272,11 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) dest[i].buttons = (UINT16)SHORT(src[i].buttons); dest[i].latency = src[i].latency; dest[i].flags = src[i].flags; + + if (dest[i].flags & TICCMD_BOT) + { + dest[i].bot.itemconfirm = src[i].bot.itemconfirm; + } } return dest; } diff --git a/src/k_bot.c b/src/k_bot.c index cdeb568d9..1f55f33c7 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -1051,8 +1051,6 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) player->botvars.controller = botController - lines; } - player->botvars.rubberband = K_UpdateRubberband(player); - if (botController != NULL && (botController->args[1] & TMBOT_NOCONTROL)) { // Disable bot controls entirely. @@ -1123,7 +1121,7 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) // Count up if (player->botvars.turnconfirm < BOTTURNCONFIRM) { - player->botvars.turnconfirm++; + cmd->bot.turnconfirm++; } } else if (turnamt < 0) @@ -1131,7 +1129,7 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) // Count down if (player->botvars.turnconfirm > -BOTTURNCONFIRM) { - player->botvars.turnconfirm--; + cmd->bot.turnconfirm--; } } else @@ -1139,11 +1137,11 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) // Back to neutral if (player->botvars.turnconfirm < 0) { - player->botvars.turnconfirm++; + cmd->bot.turnconfirm++; } else if (player->botvars.turnconfirm > 0) { - player->botvars.turnconfirm--; + cmd->bot.turnconfirm--; } } @@ -1186,9 +1184,12 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // Complete override of all ticcmd functionality if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)) == true) { + cmd->flags |= TICCMD_BOT; return; } + cmd->flags |= TICCMD_BOT; + switch (player->botvars.style) { case BOT_STYLE_STAY: @@ -1223,4 +1224,7 @@ void K_UpdateBotGameplayVars(player_t *player) player->botvars.controller = botController ? (botController - lines) : UINT16_MAX; player->botvars.rubberband = K_UpdateRubberband(player); + + player->botvars.turnconfirm += player->cmd.bot.turnconfirm; + K_UpdateBotGameplayVarsItemUsage(player); } diff --git a/src/k_bot.h b/src/k_bot.h index 06f18a375..cf1225762 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -272,6 +272,23 @@ void K_UpdateBotGameplayVars(player_t *player); void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt); +/*-------------------------------------------------- + void K_UpdateBotGameplayVarsItemUsage(player_t *player) + + Updates gamestate affecting botvars, relating to + item usage. This must be called for both client + and server. + + Input Arguments:- + player - Player to whom to update the botvars. + + Return:- + N/A +--------------------------------------------------*/ + +void K_UpdateBotGameplayVarsItemUsage(player_t *player); + + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/k_botitem.c b/src/k_botitem.c index 17ffd994c..2a2fae162 100644 --- a/src/k_botitem.c +++ b/src/k_botitem.c @@ -328,7 +328,7 @@ static boolean K_RivalBotAggression(player_t *bot, player_t *target) Return:- None --------------------------------------------------*/ -static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amount) +static void K_ItemConfirmForTarget(player_t *bot, ticcmd_t *cmd, player_t *target, UINT16 amount) { if (bot == NULL || target == NULL) { @@ -338,12 +338,12 @@ static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amoun if (K_RivalBotAggression(bot, target) == true) { // Double the rate when you're aggressive. - bot->botvars.itemconfirm += amount << 1; + cmd->bot.itemconfirm += amount << 1; } else { // Do as normal. - bot->botvars.itemconfirm += amount; + cmd->bot.itemconfirm += amount; } } @@ -369,7 +369,7 @@ static boolean K_BotGenericPressItem(player_t *player, ticcmd_t *cmd, SINT8 dir) cmd->throwdir = KART_FULLTURN * dir; cmd->buttons |= BT_ATTACK; - player->botvars.itemconfirm = 0; + //player->botvars.itemconfirm = 0; return true; } @@ -390,7 +390,7 @@ static void K_BotItemGenericTap(player_t *player, ticcmd_t *cmd) if (K_ItemButtonWasDown(player) == false) { cmd->buttons |= BT_ATTACK; - player->botvars.itemconfirm = 0; + //player->botvars.itemconfirm = 0; } } @@ -462,6 +462,8 @@ static void K_BotItemGenericTrapShield(player_t *player, ticcmd_t *cmd, INT16 tu return; } + cmd->bot.itemconfirm++; + if (K_BotRevealsGenericTrap(player, turnamt, mine) || (player->botvars.itemconfirm++ > 5*TICRATE)) { K_BotGenericPressItem(player, cmd, 0); @@ -519,12 +521,12 @@ static void K_BotItemSneaker(player_t *player, ticcmd_t *cmd) if (player->sneakertimer == 0 && K_ItemButtonWasDown(player) == false) { cmd->buttons |= BT_ATTACK; - player->botvars.itemconfirm = 2*TICRATE; + //player->botvars.itemconfirm = 2*TICRATE; } } else { - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; } } @@ -553,12 +555,12 @@ static void K_BotItemRocketSneaker(player_t *player, ticcmd_t *cmd) if (player->sneakertimer == 0 && K_ItemButtonWasDown(player) == false) { cmd->buttons |= BT_ATTACK; - player->botvars.itemconfirm = 0; + //player->botvars.itemconfirm = 0; } } else { - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; } } @@ -582,19 +584,19 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) boolean tryLookback = false; player_t *target = NULL; - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; target = K_PlayerInCone(player, coneDist, 15, true); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; tryLookback = true; } if (abs(turnamt) >= KART_FULLTURN/2) { - player->botvars.itemconfirm += player->botvars.difficulty / 2; + cmd->bot.itemconfirm += player->botvars.difficulty / 2; throwdir = -1; } else @@ -603,7 +605,7 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * 2); throwdir = 1; } } @@ -639,18 +641,18 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) boolean tryLookback = false; player_t *target = NULL; - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; target = K_PlayerInCone(player, coneDist, 15, true); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; } if (abs(turnamt) >= KART_FULLTURN/2) { - player->botvars.itemconfirm += player->botvars.difficulty / 2; + cmd->bot.itemconfirm += player->botvars.difficulty / 2; throwdir = -1; tryLookback = true; } @@ -659,14 +661,14 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) target = K_PlayerPredictThrow(player, 0); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * 2); throwdir = 0; } target = K_PlayerPredictThrow(player, 1); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * 2); throwdir = 1; } } @@ -700,17 +702,18 @@ static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); player_t *target = NULL; - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; if (abs(turnamt) >= KART_FULLTURN/2) { - player->botvars.itemconfirm += player->botvars.difficulty / 2; + cmd->bot.itemconfirm += player->botvars.difficulty / 2; } target = K_PlayerInCone(player, coneDist, 15, true); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); + cmd->buttons |= BT_LOOKBACK; } @@ -740,19 +743,19 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) boolean tryLookback = false; player_t *target = NULL; - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; target = K_PlayerPredictThrow(player, 0); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty / 2); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty / 2); throwdir = 1; } target = K_PlayerInCone(player, coneDist, 15, true); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; tryLookback = true; } @@ -833,6 +836,8 @@ static void K_BotItemEggmanShield(player_t *player, ticcmd_t *cmd) return; } + cmd->bot.itemconfirm++; + if (K_BotRevealsEggbox(player) == true || (player->botvars.itemconfirm++ > 20*TICRATE)) { K_BotGenericPressItem(player, cmd, 0); @@ -890,12 +895,12 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) snipeMul = 3; // Confirm faster when you'll throw it with a bunch of extra speed!! } - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; target = K_PlayerInCone(player, radius, 15, false); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * snipeMul); throwdir = 1; } else @@ -904,7 +909,7 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; tryLookback = true; } @@ -948,18 +953,18 @@ static void K_BotItemDropTarget(player_t *player, INT16 turnamt, ticcmd_t *cmd) snipeMul = 3; // Confirm faster when you'll throw it with a bunch of extra speed!! } - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; if (abs(turnamt) >= KART_FULLTURN/2) { - player->botvars.itemconfirm += player->botvars.difficulty / 2; + cmd->bot.itemconfirm += player->botvars.difficulty / 2; throwdir = -1; } target = K_PlayerInCone(player, radius, 15, false); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * snipeMul); throwdir = 1; } else @@ -968,7 +973,7 @@ static void K_BotItemDropTarget(player_t *player, INT16 turnamt, ticcmd_t *cmd) if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; tryLookback = true; } @@ -1013,12 +1018,12 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) snipeMul = 3; // Confirm faster when you'll throw it with a bunch of extra speed!! } - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; target = K_PlayerInCone(player, radius, 15, true); if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; tryLookback = true; } @@ -1049,7 +1054,7 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) if (targettedAlready == false) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * snipeMul); throwdir = 1; } } @@ -1087,7 +1092,7 @@ static void K_BotItemLightning(player_t *player, ticcmd_t *cmd) } else { - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; } } } @@ -1112,7 +1117,7 @@ static void K_BotItemBubble(player_t *player, ticcmd_t *cmd) { UINT8 i; - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; if (player->bubblecool <= 0) { @@ -1185,7 +1190,7 @@ static void K_BotItemFlame(player_t *player, ticcmd_t *cmd) { if (player->botvars.itemconfirm > 0) { - player->botvars.itemconfirm--; + cmd->bot.itemconfirm--; } else if (player->itemflags & IF_HOLDREADY) { @@ -1197,7 +1202,7 @@ static void K_BotItemFlame(player_t *player, ticcmd_t *cmd) } else { - player->botvars.itemconfirm = 3*flamemax/4; + //player->botvars.itemconfirm = 3*flamemax/4; } } } @@ -1293,8 +1298,6 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) { if (player->botvars.itemdelay) { - player->botvars.itemdelay--; - player->botvars.itemconfirm = 0; return; } @@ -1329,7 +1332,7 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) K_BotItemGenericTap(player, cmd); } - player->botvars.itemconfirm = 0; + //player->botvars.itemconfirm = 0; break; case KITEM_INVINCIBILITY: case KITEM_SPB: @@ -1420,3 +1423,25 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) } } } + +/*-------------------------------------------------- + void K_UpdateBotGameplayVarsItemUsage(player_t *player) + + See header file for description. +--------------------------------------------------*/ +void K_UpdateBotGameplayVarsItemUsage(player_t *player) +{ + if (player->itemflags & IF_USERINGS) + { + return; + } + + if (player->botvars.itemdelay) + { + player->botvars.itemdelay--; + player->botvars.itemconfirm = 0; + return; + } + + player->botvars.itemconfirm += player->cmd.bot.itemconfirm; +} diff --git a/src/k_kart.c b/src/k_kart.c index 3ec1a236e..f49ee5c55 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9129,7 +9129,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->eggmanexplode) { if (ATTACK_IS_DOWN && player->eggmanexplode <= 3*TICRATE && player->eggmanexplode > 1) + { player->eggmanexplode = 1; + player->botvars.itemconfirm = 0; + } } // Eggman Monitor throwing else if (player->itemflags & IF_EGGMANOUT) @@ -9140,6 +9143,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemflags &= ~IF_EGGMANOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } } // Rocket Sneaker usage @@ -9153,6 +9157,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->rocketsneakertimer = 1; else player->rocketsneakertimer -= 3*TICRATE; + player->botvars.itemconfirm = 0; } } // Grow Canceling @@ -9191,6 +9196,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_DoSneaker(player, 1); K_PlayBoostTaunt(player->mo); player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_ROCKETSNEAKER: @@ -9224,6 +9230,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&prev->hnext, mo); prev = mo; } + player->botvars.itemconfirm = 0; } break; case KITEM_INVINCIBILITY: @@ -9232,6 +9239,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_DoInvincibility(player, 10 * TICRATE); K_PlayPowerGloatSound(player->mo); player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_BANANA: @@ -9262,6 +9270,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&prev->hnext, mo); prev = mo; } + player->botvars.itemconfirm = 0; + } else if (ATTACK_IS_DOWN && (player->itemflags & IF_ITEMOUT)) // Banana x3 thrown { @@ -9269,6 +9279,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_ThrowKartItem(player, false, MT_BANANA, -1, 0); K_PlayAttackTaunt(player->mo); K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_EGGMAN: @@ -9289,6 +9300,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&mo->target, player->mo); P_SetTarget(&player->mo->hnext, mo); } + player->botvars.itemconfirm = 0; } break; case KITEM_ORBINAUT: @@ -9323,6 +9335,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&prev->hnext, mo); prev = mo; } + player->botvars.itemconfirm = 0; } else if (ATTACK_IS_DOWN && (player->itemflags & IF_ITEMOUT)) // Orbinaut x3 thrown { @@ -9330,6 +9343,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_ThrowKartItem(player, true, MT_ORBINAUT, 1, 0); K_PlayAttackTaunt(player->mo); K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_JAWZ: @@ -9363,6 +9377,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&prev->hnext, mo); prev = mo; } + player->botvars.itemconfirm = 0; } else if (ATTACK_IS_DOWN && HOLDING_ITEM && (player->itemflags & IF_ITEMOUT)) // Jawz thrown { @@ -9373,6 +9388,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_ThrowKartItem(player, true, MT_JAWZ_DUD, -1, 0); K_PlayAttackTaunt(player->mo); K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_MINE: @@ -9391,6 +9407,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&mo->target, player->mo); P_SetTarget(&player->mo->hnext, mo); } + player->botvars.itemconfirm = 0; } else if (ATTACK_IS_DOWN && (player->itemflags & IF_ITEMOUT)) { @@ -9399,6 +9416,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemflags &= ~IF_ITEMOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } break; case KITEM_LANDMINE: @@ -9407,6 +9425,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; K_ThrowLandMine(player); K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_DROPTARGET: @@ -9425,6 +9444,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&mo->target, player->mo); P_SetTarget(&player->mo->hnext, mo); } + player->botvars.itemconfirm = 0; } else if (ATTACK_IS_DOWN && (player->itemflags & IF_ITEMOUT)) { @@ -9433,6 +9453,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemflags &= ~IF_ITEMOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } break; case KITEM_BALLHOG: @@ -9441,6 +9462,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; K_ThrowKartItem(player, true, MT_BALLHOG, 1, 0); K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_SPB: @@ -9449,11 +9471,13 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; K_ThrowKartItem(player, true, MT_SPB, 1, 0); K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_GROW: if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) { + player->itemamount--; if (player->growshrinktimer < 0) { // If you're shrunk, then "grow" will just make you normal again. @@ -9491,7 +9515,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) S_StartSound(player->mo, sfx_kc5a); } - player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_SHRINK: @@ -9500,6 +9524,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_DoShrink(player); player->itemamount--; K_PlayPowerGloatSound(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_THUNDERSHIELD: @@ -9524,6 +9549,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // ...:dumbestass: player->itemamount--; K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } } break; @@ -9555,6 +9581,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->bubbleblowup = 0; player->bubblecool = 0; player->itemflags &= ~IF_HOLDREADY; + player->botvars.itemconfirm = 0; } } else @@ -9632,6 +9659,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) else { player->itemflags |= IF_HOLDREADY; + player->botvars.itemconfirm = 3*flamemax/4; // TODO: gametyperules if (gametype != GT_BATTLE || leveltime % 6 == 0) @@ -9660,15 +9688,17 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; K_DoHyudoroSteal(player); // yes. yes they do. K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_POGOSPRING: if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO && player->pogospring == 0) { + player->itemamount--; K_PlayBoostTaunt(player->mo); K_DoPogoSpring(player->mo, 32<pogospring = 1; - player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_SUPERRING: @@ -9676,6 +9706,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { SINT8 awardamount = 15; + player->itemamount--; if (player->position == 1) { awardamount = 5; @@ -9686,7 +9717,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } K_AwardPlayerRings(player, awardamount, true); - player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_KITCHENSINK: @@ -9705,6 +9736,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&mo->target, player->mo); P_SetTarget(&player->mo->hnext, mo); } + player->botvars.itemconfirm = 0; } else if (ATTACK_IS_DOWN && HOLDING_ITEM && (player->itemflags & IF_ITEMOUT)) // Sink thrown { @@ -9713,6 +9745,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemflags &= ~IF_ITEMOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } break; case KITEM_SAD: @@ -9721,6 +9754,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { player->sadtimer = stealtime; player->itemamount--; + player->botvars.itemconfirm = 0; } break; default: