diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 4f36a0425..b3cfe61ec 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -61,9 +61,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) @@ -79,6 +80,12 @@ 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 spindashconfirm; + SINT8 itemconfirm; + } bot; } ATTRPACK; #if defined(_MSC_VER) diff --git a/src/g_demo.c b/src/g_demo.c index 3a6bd1430..5de64ce40 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -139,8 +139,13 @@ 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_SPINDASH 0x0002 +#define ZT_BOT_ITEM 0x0004 + #define DEMOMARKER 0x80 // demobuf.end UINT8 demo_extradata[MAXPLAYERS]; @@ -544,6 +549,18 @@ 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_SPINDASH) + oldcmd[playernum].bot.spindashconfirm = 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) @@ -558,10 +575,12 @@ 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; @@ -621,8 +640,45 @@ 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.spindashconfirm != oldcmd[playernum].bot.spindashconfirm) + { + WRITESINT8(demobuf.p, cmd->bot.spindashconfirm); + oldcmd[playernum].bot.spindashconfirm = cmd->bot.spindashconfirm; + botziptic |= ZT_BOT_SPINDASH; + } + + 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) @@ -1243,6 +1299,16 @@ readghosttic: 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_SPINDASH) + 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 01e7f0f88..316280198 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -997,6 +997,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.cpp b/src/k_bot.cpp index 171800a08..a3b0f41cc 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -331,11 +331,11 @@ void K_UpdateMatchRaceBots(void) } /*-------------------------------------------------- - boolean K_PlayerUsesBotMovement(player_t *player) + boolean K_PlayerUsesBotMovement(const player_t *player) See header file for description. --------------------------------------------------*/ -boolean K_PlayerUsesBotMovement(player_t *player) +boolean K_PlayerUsesBotMovement(const player_t *player) { if (K_PodiumSequence() == true) return true; @@ -354,7 +354,7 @@ boolean K_PlayerUsesBotMovement(player_t *player) See header file for description. --------------------------------------------------*/ -boolean K_BotCanTakeCut(player_t *player) +boolean K_BotCanTakeCut(const player_t *player) { if ( #if 1 @@ -374,7 +374,7 @@ boolean K_BotCanTakeCut(player_t *player) } /*-------------------------------------------------- - static fixed_t K_BotSpeedScaled(player_t *player, fixed_t speed) + static fixed_t K_BotSpeedScaled(const player_t *player, fixed_t speed) What the bot "thinks" their speed is, for predictions. Mainly to make bots brake earlier when on friction sectors. @@ -386,7 +386,7 @@ boolean K_BotCanTakeCut(player_t *player) Return:- The bot's speed value for calculations. --------------------------------------------------*/ -static fixed_t K_BotSpeedScaled(player_t *player, fixed_t speed) +static fixed_t K_BotSpeedScaled(const player_t *player, fixed_t speed) { fixed_t result = speed; @@ -441,11 +441,11 @@ static fixed_t K_BotSpeedScaled(player_t *player, fixed_t speed) } /*-------------------------------------------------- - const botcontroller_t *K_GetBotController(mobj_t *mobj) + const botcontroller_t *K_GetBotController(const mobj_t *mobj) See header file for description. --------------------------------------------------*/ -const botcontroller_t *K_GetBotController(mobj_t *mobj) +const botcontroller_t *K_GetBotController(const mobj_t *mobj) { botcontroller_t *ret = nullptr; @@ -507,7 +507,7 @@ fixed_t K_BotMapModifier(void) } /*-------------------------------------------------- - static UINT32 K_BotRubberbandDistance(player_t *player) + static UINT32 K_BotRubberbandDistance(const player_t *player) Calculates the distance away from 1st place that the bot should rubberband to. @@ -518,7 +518,7 @@ fixed_t K_BotMapModifier(void) Return:- Distance to add, as an integer. --------------------------------------------------*/ -static UINT32 K_BotRubberbandDistance(player_t *player) +static UINT32 K_BotRubberbandDistance(const player_t *player) { const UINT32 spacing = FixedDiv(640 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)) / FRACUNIT; const UINT8 portpriority = player - players; @@ -560,11 +560,11 @@ static UINT32 K_BotRubberbandDistance(player_t *player) } /*-------------------------------------------------- - fixed_t K_BotRubberband(player_t *player) + fixed_t K_BotRubberband(const player_t *player) See header file for description. --------------------------------------------------*/ -fixed_t K_BotRubberband(player_t *player) +fixed_t K_BotRubberband(const player_t *player) { constexpr fixed_t rubberdeltabase = FRACUNIT / 4; // +/- x0.25 @@ -784,7 +784,7 @@ static fixed_t K_ScaleWPDistWithSlope(fixed_t disttonext, angle_t angletonext, c } /*-------------------------------------------------- - static botprediction_t *K_CreateBotPrediction(player_t *player) + static botprediction_t *K_CreateBotPrediction(const player_t *player) Calculates a point further along the track to attempt to drive towards. @@ -794,7 +794,7 @@ static fixed_t K_ScaleWPDistWithSlope(fixed_t disttonext, angle_t angletonext, c Return:- Bot prediction struct. --------------------------------------------------*/ -static botprediction_t *K_CreateBotPrediction(player_t *player) +static botprediction_t *K_CreateBotPrediction(const player_t *player) { const precise_t time = I_GetPreciseTime(); @@ -915,7 +915,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) } /*-------------------------------------------------- - static UINT8 K_TrySpindash(player_t *player) + static UINT8 K_TrySpindash(const player_t *player, ticcmd_t *cmd) Determines conditions where the bot should attempt to spindash. @@ -926,7 +926,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) 0 to make the bot drive normally, 1 to e-brake, 2 to e-brake & charge spindash. (TODO: make this an enum) --------------------------------------------------*/ -static UINT8 K_TrySpindash(player_t *player) +static UINT8 K_TrySpindash(const player_t *player, ticcmd_t *cmd) { const tic_t difficultyModifier = (TICRATE/6); @@ -939,7 +939,7 @@ static UINT8 K_TrySpindash(player_t *player) if (player->spindashboost || player->tiregrease // You just released a spindash, you don't need to try again yet, jeez. || P_IsObjectOnGround(player->mo) == false) // Not in a state where we want 'em to spindash. { - player->botvars.spindashconfirm = 0; + cmd->bot.spindashconfirm = 0; return 0; } @@ -997,7 +997,7 @@ static UINT8 K_TrySpindash(player_t *player) anyCondition = true;\ if (player->botvars.spindashconfirm < BOTSPINDASHCONFIRM) \ { \ - player->botvars.spindashconfirm++; \ + cmd->bot.spindashconfirm++; \ } \ } @@ -1039,7 +1039,7 @@ static UINT8 K_TrySpindash(player_t *player) { if (player->botvars.spindashconfirm > 0) { - player->botvars.spindashconfirm--; + cmd->bot.spindashconfirm--; } } } @@ -1049,7 +1049,7 @@ static UINT8 K_TrySpindash(player_t *player) } /*-------------------------------------------------- - static boolean K_TryRingShooter(player_t *player) + static boolean K_TryRingShooter(const player_t *player) Determines conditions where the bot should attempt to respawn. @@ -1059,7 +1059,7 @@ static UINT8 K_TrySpindash(player_t *player) Return:- true if we want to hold the respawn button, otherwise false. --------------------------------------------------*/ -static boolean K_TryRingShooter(player_t *player) +static boolean K_TryRingShooter(const player_t *player) { if (player->respawn.state != RESPAWNST_NONE) { @@ -1079,15 +1079,11 @@ static boolean K_TryRingShooter(player_t *player) return false; } - // Our anti-grief system is already a perfect system - // for determining if we're not making progress, so - // lets reuse it for bot respawning! - P_IncrementGriefValue(player, &player->botvars.respawnconfirm, BOTRESPAWNCONFIRM); - return (player->botvars.respawnconfirm >= BOTRESPAWNCONFIRM); + return true; } /*-------------------------------------------------- - static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player) + static void K_DrawPredictionDebug(botprediction_t *predict, const player_t *player) Draws objects to show where the viewpoint bot is trying to go. @@ -1098,7 +1094,7 @@ static boolean K_TryRingShooter(player_t *player) Return:- None --------------------------------------------------*/ -static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player) +static void K_DrawPredictionDebug(botprediction_t *predict, const player_t *player) { mobj_t *debugMobj = nullptr; angle_t sideAngle = ANGLE_MAX; @@ -1151,7 +1147,7 @@ static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player) } /*-------------------------------------------------- - static void K_BotTrick(player_t *player, ticcmd_t *cmd, const botcontroller_t *botController) + static void K_BotTrick(const player_t *player, ticcmd_t *cmd, const botcontroller_t *botController) Determines inputs for trick panels. @@ -1163,7 +1159,7 @@ static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player) Return:- None --------------------------------------------------*/ -static void K_BotTrick(player_t *player, ticcmd_t *cmd, const botcontroller_t *botController) +static void K_BotTrick(const player_t *player, ticcmd_t *cmd, const botcontroller_t *botController) { // Trick panel state -- do nothing until a controller line is found, in which case do a trick. if (botController == nullptr) @@ -1192,7 +1188,7 @@ static void K_BotTrick(player_t *player, ticcmd_t *cmd, const botcontroller_t *b } /*-------------------------------------------------- - static angle_t K_BotSmoothLanding(player_t *player, angle_t destangle) + static angle_t K_BotSmoothLanding(const player_t *player, angle_t destangle) Calculates a new destination angle while in the air, to be able to successfully smooth land. @@ -1204,7 +1200,7 @@ static void K_BotTrick(player_t *player, ticcmd_t *cmd, const botcontroller_t *b Return:- New destination angle. --------------------------------------------------*/ -static angle_t K_BotSmoothLanding(player_t *player, angle_t destangle) +static angle_t K_BotSmoothLanding(const player_t *player, angle_t destangle) { angle_t newAngle = destangle; boolean air = !P_IsObjectOnGround(player->mo); @@ -1241,7 +1237,7 @@ static angle_t K_BotSmoothLanding(player_t *player, angle_t destangle) } /*-------------------------------------------------- - static INT32 K_HandleBotTrack(player_t *player, ticcmd_t *cmd, botprediction_t *predict) + static INT32 K_HandleBotTrack(const player_t *player, ticcmd_t *cmd, botprediction_t *predict) Determines inputs for standard track driving. @@ -1253,7 +1249,7 @@ static angle_t K_BotSmoothLanding(player_t *player, angle_t destangle) Return:- New value for turn amount. --------------------------------------------------*/ -static INT32 K_HandleBotTrack(player_t *player, ticcmd_t *cmd, botprediction_t *predict, angle_t destangle) +static INT32 K_HandleBotTrack(const player_t *player, ticcmd_t *cmd, botprediction_t *predict, angle_t destangle) { // Handle steering towards waypoints! INT32 turnamt = 0; @@ -1341,7 +1337,7 @@ static INT32 K_HandleBotTrack(player_t *player, ticcmd_t *cmd, botprediction_t * } /*-------------------------------------------------- - static INT32 K_HandleBotReverse(player_t *player, ticcmd_t *cmd, botprediction_t *predict) + static INT32 K_HandleBotReverse(const player_t *player, ticcmd_t *cmd, botprediction_t *predict) Determines inputs for reversing. @@ -1353,7 +1349,7 @@ static INT32 K_HandleBotTrack(player_t *player, ticcmd_t *cmd, botprediction_t * Return:- New value for turn amount. --------------------------------------------------*/ -static INT32 K_HandleBotReverse(player_t *player, ticcmd_t *cmd, botprediction_t *predict, angle_t destangle) +static INT32 K_HandleBotReverse(const player_t *player, ticcmd_t *cmd, botprediction_t *predict, angle_t destangle) { // Handle steering towards waypoints! INT32 turnamt = 0; @@ -1486,11 +1482,11 @@ static INT32 K_HandleBotReverse(player_t *player, ticcmd_t *cmd, botprediction_t } /*-------------------------------------------------- - static void K_BotPodiumTurning(player_t *player, ticcmd_t *cmd) + static void K_BotPodiumTurning(const player_t *player, ticcmd_t *cmd) Calculates bot turning for the podium cutscene. --------------------------------------------------*/ -static void K_BotPodiumTurning(player_t *player, ticcmd_t *cmd) +static void K_BotPodiumTurning(const player_t *player, ticcmd_t *cmd) { const angle_t destAngle = R_PointToAngle2( player->mo->x, player->mo->y, @@ -1514,11 +1510,11 @@ static void K_BotPodiumTurning(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BuildBotPodiumTiccmd(player_t *player, ticcmd_t *cmd) + static void K_BuildBotPodiumTiccmd(const player_t *player, ticcmd_t *cmd) Calculates all bot movement for the podium cutscene. --------------------------------------------------*/ -static void K_BuildBotPodiumTiccmd(player_t *player, ticcmd_t *cmd) +static void K_BuildBotPodiumTiccmd(const player_t *player, ticcmd_t *cmd) { if (player->currentwaypoint == nullptr) { @@ -1543,11 +1539,11 @@ static void K_BuildBotPodiumTiccmd(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) + static void K_BuildBotTiccmdNormal(const player_t *player, ticcmd_t *cmd) Build ticcmd for bots with a style of BOT_STYLE_NORMAL --------------------------------------------------*/ -static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) +static void K_BuildBotTiccmdNormal(const player_t *player, ticcmd_t *cmd) { precise_t t = 0; @@ -1597,7 +1593,7 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) return; } - if (K_TryRingShooter(player) == true) + if (K_TryRingShooter(player) == true && player->botvars.respawnconfirm >= BOTRESPAWNCONFIRM) { // We want to respawn. Simply hold Y and stop here! cmd->buttons |= (BT_RESPAWN | BT_EBRAKEMASK); @@ -1751,7 +1747,7 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) if (trySpindash == true) { // Spindashing - spindash = K_TrySpindash(player); + spindash = K_TrySpindash(player, cmd); if (spindash > 0) { @@ -1790,7 +1786,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) @@ -1798,7 +1794,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 @@ -1806,11 +1802,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--; } } @@ -1836,7 +1832,9 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd) See header file for description. --------------------------------------------------*/ -void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) +void K_BuildBotTiccmd( + player_t *player, // annoyingly NOT const because of LUA_HookTiccmd... grumble grumble + ticcmd_t *cmd) { // Remove any existing controls memset(cmd, 0, sizeof(ticcmd_t)); @@ -1855,9 +1853,12 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // their own :) if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)) == true) { + cmd->flags |= TICCMD_BOT; return; } + cmd->flags |= TICCMD_BOT; + if (K_PodiumSequence() == true) { K_BuildBotPodiumTiccmd(player, cmd); @@ -1895,4 +1896,17 @@ void K_UpdateBotGameplayVars(player_t *player) } player->botvars.rubberband = K_UpdateRubberband(player); + + player->botvars.turnconfirm += player->cmd.bot.turnconfirm; + player->botvars.spindashconfirm += player->cmd.bot.spindashconfirm; + + if (K_TryRingShooter(player) == true) + { + // Our anti-grief system is already a perfect system + // for determining if we're not making progress, so + // lets reuse it for bot respawning! + P_IncrementGriefValue(player, &player->botvars.respawnconfirm, BOTRESPAWNCONFIRM); + } + + K_UpdateBotGameplayVarsItemUsage(player); } diff --git a/src/k_bot.h b/src/k_bot.h index 34210550a..86e985475 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -56,7 +56,7 @@ struct botprediction_t /*-------------------------------------------------- - boolean K_PlayerUsesBotMovement(player_t *player); + boolean K_PlayerUsesBotMovement(const player_t *player); Tells if this player is being controlled via bot movement code (is a bot, or is exiting). @@ -67,11 +67,11 @@ struct botprediction_t true if using bot movement code, otherwise false. --------------------------------------------------*/ -boolean K_PlayerUsesBotMovement(player_t *player); +boolean K_PlayerUsesBotMovement(const player_t *player); /*-------------------------------------------------- - boolean K_BotCanTakeCut(player_t *player); + boolean K_BotCanTakeCut(const player_t *player); Tells if this bot is able to take shortcuts (currently unaffected by offroad, or has certain items ready). @@ -83,11 +83,11 @@ boolean K_PlayerUsesBotMovement(player_t *player); true if able to take shortcuts, otherwise false. --------------------------------------------------*/ -boolean K_BotCanTakeCut(player_t *player); +boolean K_BotCanTakeCut(const player_t *player); /*-------------------------------------------------- - const botcontroller_t *K_GetBotController(mobj_t *mobj); + const botcontroller_t *K_GetBotController(const mobj_t *mobj); Retrieves the current bot controller values from the player's current sector. @@ -99,7 +99,7 @@ boolean K_BotCanTakeCut(player_t *player); Pointer to the sector's bot controller struct. --------------------------------------------------*/ -const botcontroller_t *K_GetBotController(mobj_t *mobj); +const botcontroller_t *K_GetBotController(const mobj_t *mobj); /*-------------------------------------------------- @@ -123,7 +123,7 @@ fixed_t K_BotMapModifier(void); /*-------------------------------------------------- - fixed_t K_BotRubberband(player_t *player); + fixed_t K_BotRubberband(const player_t *player); Gives a multiplier for a bot's rubberbanding. Meant to be used for acceleration and handling. @@ -135,7 +135,7 @@ fixed_t K_BotMapModifier(void); A multiplier in fixed point scale. --------------------------------------------------*/ -fixed_t K_BotRubberband(player_t *player); +fixed_t K_BotRubberband(const player_t *player); /*-------------------------------------------------- @@ -259,7 +259,7 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y); true if avoiding this sector, false otherwise. --------------------------------------------------*/ -boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y); +boolean K_BotHatesThisSector(const player_t *player, sector_t *sec, fixed_t x, fixed_t y); /*-------------------------------------------------- @@ -275,11 +275,11 @@ boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t None --------------------------------------------------*/ -void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player); +void K_NudgePredictionTowardsObjects(botprediction_t *predict, const player_t *player); /*-------------------------------------------------- - INT32 K_PositionBully(player_t *player) + INT32 K_PositionBully(const player_t *player) Calculates a turn value to reach a player that can be bullied. @@ -290,7 +290,7 @@ void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player) INT32_MAX if couldn't find anything, otherwise a steering value. --------------------------------------------------*/ -INT32 K_PositionBully(player_t *player); +INT32 K_PositionBully(const player_t *player); /*-------------------------------------------------- @@ -310,6 +310,23 @@ INT32 K_PositionBully(player_t *player); void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd); +/*-------------------------------------------------- + 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); + + /*-------------------------------------------------- void K_UpdateBotGameplayVars(player_t *player); @@ -327,7 +344,7 @@ void K_UpdateBotGameplayVars(player_t *player); /*-------------------------------------------------- - void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt); + void K_BotItemUsage(const player_t *player, ticcmd_t *cmd, INT16 turnamt); Item usage part of ticcmd generation. @@ -340,7 +357,7 @@ void K_UpdateBotGameplayVars(player_t *player); None --------------------------------------------------*/ -void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt); +void K_BotItemUsage(const player_t *player, ticcmd_t *cmd, INT16 turnamt); /*-------------------------------------------------- diff --git a/src/k_botitem.c b/src/k_botitem.c index ee9fe577e..9f23fd92a 100644 --- a/src/k_botitem.c +++ b/src/k_botitem.c @@ -29,7 +29,7 @@ #include "k_roulette.h" /*-------------------------------------------------- - static inline boolean K_ItemButtonWasDown(player_t *player) + static inline boolean K_ItemButtonWasDown(const player_t *player) Looks for players around the bot, and presses the item button if there is one in range. @@ -40,13 +40,13 @@ Return:- true if the item button was pressed last tic, otherwise false. --------------------------------------------------*/ -static inline boolean K_ItemButtonWasDown(player_t *player) +static inline boolean K_ItemButtonWasDown(const player_t *player) { return (player->oldcmd.buttons & BT_ATTACK); } /*-------------------------------------------------- - static boolean K_BotUseItemNearPlayer(player_t *player, ticcmd_t *cmd, fixed_t radius) + static boolean K_BotUseItemNearPlayer(const player_t *player, ticcmd_t *cmd, fixed_t radius) Looks for players around the bot, and presses the item button if there is one in range. @@ -59,7 +59,7 @@ static inline boolean K_ItemButtonWasDown(player_t *player) Return:- true if a player was found & we can press the item button, otherwise false. --------------------------------------------------*/ -static boolean K_BotUseItemNearPlayer(player_t *player, ticcmd_t *cmd, fixed_t radius) +static boolean K_BotUseItemNearPlayer(const player_t *player, ticcmd_t *cmd, fixed_t radius) { UINT8 i; @@ -104,7 +104,7 @@ static boolean K_BotUseItemNearPlayer(player_t *player, ticcmd_t *cmd, fixed_t r } /*-------------------------------------------------- - static player_t *K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t radius) + static player_t *K_PlayerNearSpot(const player_t *player, fixed_t x, fixed_t y, fixed_t radius) Looks for players around a specified x/y coordinate. @@ -117,7 +117,7 @@ static boolean K_BotUseItemNearPlayer(player_t *player, ticcmd_t *cmd, fixed_t r Return:- The player we found, NULL if nothing was found. --------------------------------------------------*/ -static player_t *K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t radius) +static player_t *K_PlayerNearSpot(const player_t *player, fixed_t x, fixed_t y, fixed_t radius) { UINT8 i; @@ -155,7 +155,7 @@ static player_t *K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_ } /*-------------------------------------------------- - static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra) + static player_t *K_PlayerPredictThrow(const player_t *player, UINT8 extra) Looks for players around the predicted coordinates of their thrown item. @@ -166,7 +166,7 @@ static player_t *K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_ Return:- The player we're trying to throw at, NULL if none was found. --------------------------------------------------*/ -static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra) +static player_t *K_PlayerPredictThrow(const player_t *player, UINT8 extra) { const fixed_t dist = (30 + (extra * 10)) * player->mo->scale; const UINT32 airtime = FixedDiv(dist + player->mo->momz, gravity); @@ -177,7 +177,7 @@ static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra) } /*-------------------------------------------------- - static player_t *K_PlayerInCone(player_t *player, UINT16 cone, boolean flip) + static player_t *K_PlayerInCone(const player_t *player, UINT16 cone, boolean flip) Looks for players in the . @@ -190,7 +190,7 @@ static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra) Return:- true if a player was found in the cone, otherwise false. --------------------------------------------------*/ -static player_t *K_PlayerInCone(player_t *player, fixed_t radius, UINT16 cone, boolean flip) +static player_t *K_PlayerInCone(const player_t *player, fixed_t radius, UINT16 cone, boolean flip) { UINT8 i; @@ -257,7 +257,7 @@ static player_t *K_PlayerInCone(player_t *player, fixed_t radius, UINT16 cone, b } /*-------------------------------------------------- - static boolean K_RivalBotAggression(player_t *bot, player_t *target) + static boolean K_RivalBotAggression(const player_t *bot, const player_t *target) Returns if a bot is a rival & wants to be aggressive to a player. @@ -268,7 +268,7 @@ static player_t *K_PlayerInCone(player_t *player, fixed_t radius, UINT16 cone, b Return:- false if not the rival. false if the target is another bot. Otherwise, true. --------------------------------------------------*/ -static boolean K_RivalBotAggression(player_t *bot, player_t *target) +static boolean K_RivalBotAggression(const player_t *bot, const player_t *target) { if (bot == NULL || target == NULL) { @@ -299,19 +299,20 @@ static boolean K_RivalBotAggression(player_t *bot, player_t *target) } /*-------------------------------------------------- - static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amount) + static void K_ItemConfirmForTarget(const player_t *bot, ticcmd_t *cmd, const player_t *target, UINT16 amount) Handles updating item confirm values for offense items. Input Arguments:- bot - Bot to check. + cmd - Bot's ticcmd to edit. target - Who the bot wants to attack. amount - Amount to increase item confirm time by. Return:- None --------------------------------------------------*/ -static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amount) +static void K_ItemConfirmForTarget(const player_t *bot, ticcmd_t *cmd, const player_t *target, UINT16 amount) { if (bot == NULL || target == NULL) { @@ -321,17 +322,17 @@ 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; } } /*-------------------------------------------------- - static boolean K_BotGenericPressItem(player_t *player, ticcmd_t *cmd, SINT8 dir) + static boolean K_BotGenericPressItem(const player_t *player, ticcmd_t *cmd, SINT8 dir) Presses the item button & aim buttons for the bot. @@ -343,7 +344,7 @@ static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amoun Return:- true if we could press, false if not. --------------------------------------------------*/ -static boolean K_BotGenericPressItem(player_t *player, ticcmd_t *cmd, SINT8 dir) +static boolean K_BotGenericPressItem(const player_t *player, ticcmd_t *cmd, SINT8 dir) { if (K_ItemButtonWasDown(player) == true) { @@ -352,12 +353,12 @@ 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; } /*-------------------------------------------------- - static void K_BotItemGenericTap(player_t *player, ticcmd_t *cmd) + static void K_BotItemGenericTap(const player_t *player, ticcmd_t *cmd) Item usage for generic items that you need to tap. @@ -368,17 +369,17 @@ static boolean K_BotGenericPressItem(player_t *player, ticcmd_t *cmd, SINT8 dir) Return:- None --------------------------------------------------*/ -static void K_BotItemGenericTap(player_t *player, ticcmd_t *cmd) +static void K_BotItemGenericTap(const player_t *player, ticcmd_t *cmd) { if (K_ItemButtonWasDown(player) == false) { cmd->buttons |= BT_ATTACK; - player->botvars.itemconfirm = 0; + //player->botvars.itemconfirm = 0; } } /*-------------------------------------------------- - static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean mine) + static boolean K_BotRevealsGenericTrap(const player_t *player, INT16 turnamt, boolean mine) Decides if a bot is ready to reveal their trap item or not. @@ -390,7 +391,7 @@ static void K_BotItemGenericTap(player_t *player, ticcmd_t *cmd) Return:- true if we want the bot to reveal their banana, otherwise false. --------------------------------------------------*/ -static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean mine) +static boolean K_BotRevealsGenericTrap(const player_t *player, INT16 turnamt, boolean mine) { const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); @@ -425,7 +426,7 @@ static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean } /*-------------------------------------------------- - static void K_BotItemGenericTrapShield(player_t *player, ticcmd_t *cmd, INT16 turnamt, boolean mine) + static void K_BotItemGenericTrapShield(const player_t *player, ticcmd_t *cmd, INT16 turnamt, boolean mine) Item usage for Eggman shields. @@ -438,21 +439,23 @@ static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean Return:- None --------------------------------------------------*/ -static void K_BotItemGenericTrapShield(player_t *player, ticcmd_t *cmd, INT16 turnamt, boolean mine) +static void K_BotItemGenericTrapShield(const player_t *player, ticcmd_t *cmd, INT16 turnamt, boolean mine) { if (player->itemflags & IF_ITEMOUT) { return; } - if (K_BotRevealsGenericTrap(player, turnamt, mine) || (player->botvars.itemconfirm++ > 5*TICRATE)) + cmd->bot.itemconfirm++; + + if (K_BotRevealsGenericTrap(player, turnamt, mine) || (player->botvars.itemconfirm > 5*TICRATE)) { K_BotGenericPressItem(player, cmd, 0); } } /*-------------------------------------------------- - static void K_BotItemGenericOrbitShield(player_t *player, ticcmd_t *cmd) + static void K_BotItemGenericOrbitShield(const player_t *player, ticcmd_t *cmd) Item usage for orbitting shields. @@ -463,7 +466,7 @@ static void K_BotItemGenericTrapShield(player_t *player, ticcmd_t *cmd, INT16 tu Return:- None --------------------------------------------------*/ -static void K_BotItemGenericOrbitShield(player_t *player, ticcmd_t *cmd) +static void K_BotItemGenericOrbitShield(const player_t *player, ticcmd_t *cmd) { if (player->itemflags & IF_ITEMOUT) { @@ -474,7 +477,7 @@ static void K_BotItemGenericOrbitShield(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemSneaker(player_t *player, ticcmd_t *cmd) + static void K_BotItemSneaker(const player_t *player, ticcmd_t *cmd) Item usage for sneakers. @@ -485,7 +488,7 @@ static void K_BotItemGenericOrbitShield(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemSneaker(player_t *player, ticcmd_t *cmd) +static void K_BotItemSneaker(const player_t *player, ticcmd_t *cmd) { if (P_IsObjectOnGround(player->mo) == false) { @@ -502,12 +505,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++; } } @@ -523,7 +526,7 @@ static void K_BotItemSneaker(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemRocketSneaker(player_t *player, ticcmd_t *cmd) +static void K_BotItemRocketSneaker(const player_t *player, ticcmd_t *cmd) { if (P_IsObjectOnGround(player->mo) == false) { @@ -536,12 +539,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++; } } @@ -558,26 +561,26 @@ static void K_BotItemRocketSneaker(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) +static void K_BotItemBanana(const player_t *player, ticcmd_t *cmd, INT16 turnamt) { const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); SINT8 throwdir = -1; 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 @@ -586,7 +589,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; } } @@ -615,25 +618,25 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) Return:- None --------------------------------------------------*/ -static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) +static void K_BotItemMine(const player_t *player, ticcmd_t *cmd, INT16 turnamt) { const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); SINT8 throwdir = 0; 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; } @@ -642,14 +645,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; } } @@ -678,22 +681,22 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) Return:- None --------------------------------------------------*/ -static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) +static void K_BotItemLandmine(const 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; } @@ -715,7 +718,7 @@ static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) Return:- None --------------------------------------------------*/ -static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) +static void K_BotItemEggman(const player_t *player, ticcmd_t *cmd) { const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y); @@ -723,26 +726,26 @@ 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; } if (stealth > 1 || player->itemRoulette.active == true) { - player->botvars.itemconfirm += player->botvars.difficulty * 4; + cmd->bot.itemconfirm += player->botvars.difficulty * 4; throwdir = -1; } @@ -758,7 +761,7 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static boolean K_BotRevealsEggbox(player_t *player) + static boolean K_BotRevealsEggbox(const player_t *player) Decides if a bot is ready to place their Eggman item or not. @@ -768,7 +771,7 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) Return:- true if we want the bot to reveal their eggbox, otherwise false. --------------------------------------------------*/ -static boolean K_BotRevealsEggbox(player_t *player) +static boolean K_BotRevealsEggbox(const player_t *player) { const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y); @@ -798,7 +801,7 @@ static boolean K_BotRevealsEggbox(player_t *player) } /*-------------------------------------------------- - static void K_BotItemEggmanShield(player_t *player, ticcmd_t *cmd) + static void K_BotItemEggmanShield(const player_t *player, ticcmd_t *cmd) Item usage for Eggman shields. @@ -809,21 +812,23 @@ static boolean K_BotRevealsEggbox(player_t *player) Return:- None --------------------------------------------------*/ -static void K_BotItemEggmanShield(player_t *player, ticcmd_t *cmd) +static void K_BotItemEggmanShield(const player_t *player, ticcmd_t *cmd) { if (player->itemflags & IF_EGGMANOUT) { return; } - if (K_BotRevealsEggbox(player) == true || (player->botvars.itemconfirm++ > 20*TICRATE)) + cmd->bot.itemconfirm++; + + if (K_BotRevealsEggbox(player) == true || (player->botvars.itemconfirm > 20*TICRATE)) { K_BotGenericPressItem(player, cmd, 0); } } /*-------------------------------------------------- - static void K_BotItemEggmanExplosion(player_t *player, ticcmd_t *cmd) + static void K_BotItemEggmanExplosion(const player_t *player, ticcmd_t *cmd) Item usage for Eggman explosions. @@ -834,7 +839,7 @@ static void K_BotItemEggmanShield(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemEggmanExplosion(player_t *player, ticcmd_t *cmd) +static void K_BotItemEggmanExplosion(const player_t *player, ticcmd_t *cmd) { if (player->position == 1) { @@ -847,7 +852,7 @@ static void K_BotItemEggmanExplosion(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) + static void K_BotItemOrbinaut(const player_t *player, ticcmd_t *cmd) Item usage for Orbinaut throwing. @@ -858,7 +863,7 @@ static void K_BotItemEggmanExplosion(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) +static void K_BotItemOrbinaut(const player_t *player, ticcmd_t *cmd) { const fixed_t topspeed = K_GetKartSpeed(player, false, true); fixed_t radius = FixedMul(2560 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); @@ -873,12 +878,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 @@ -887,7 +892,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; } @@ -905,7 +910,7 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemBallhog(player_t *player, ticcmd_t *cmd) + static void K_BotItemBallhog(const player_t *player, ticcmd_t *cmd) Item usage for Ballhog throwing. @@ -916,7 +921,7 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemBallhog(player_t *player, ticcmd_t *cmd) +static void K_BotItemBallhog(const player_t *player, ticcmd_t *cmd) { const fixed_t topspeed = K_GetKartSpeed(player, false, true); fixed_t radius = FixedMul(2560 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); @@ -935,7 +940,7 @@ static void K_BotItemBallhog(player_t *player, ticcmd_t *cmd) 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 @@ -944,7 +949,7 @@ static void K_BotItemBallhog(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; } @@ -967,7 +972,7 @@ static void K_BotItemBallhog(player_t *player, ticcmd_t *cmd) // If we've been waiting for too long though, then // we'll go for the full charge :) - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; hold = (player->botvars.itemconfirm > 10*TICRATE); } @@ -979,7 +984,7 @@ static void K_BotItemBallhog(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemDropTarget(player_t *player, ticcmd_t *cmd, INT16 turnamt) + static void K_BotItemDropTarget(const player_t *player, ticcmd_t *cmd, INT16 turnamt) Item usage for Drop Target throwing. @@ -991,7 +996,7 @@ static void K_BotItemBallhog(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemDropTarget(player_t *player, ticcmd_t *cmd, INT16 turnamt) +static void K_BotItemDropTarget(const player_t *player, ticcmd_t *cmd, INT16 turnamt) { const fixed_t topspeed = K_GetKartSpeed(player, false, true); fixed_t radius = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); @@ -1006,18 +1011,18 @@ static void K_BotItemDropTarget(player_t *player, ticcmd_t *cmd, INT16 turnamt) 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 @@ -1026,7 +1031,7 @@ static void K_BotItemDropTarget(player_t *player, ticcmd_t *cmd, INT16 turnamt) if (target != NULL) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty); throwdir = -1; tryLookback = true; } @@ -1044,7 +1049,7 @@ static void K_BotItemDropTarget(player_t *player, ticcmd_t *cmd, INT16 turnamt) } /*-------------------------------------------------- - static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) + static void K_BotItemJawz(const player_t *player, ticcmd_t *cmd) Item usage for Jawz throwing. @@ -1055,7 +1060,7 @@ static void K_BotItemDropTarget(player_t *player, ticcmd_t *cmd, INT16 turnamt) Return:- None --------------------------------------------------*/ -static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) +static void K_BotItemJawz(const player_t *player, ticcmd_t *cmd) { const fixed_t topspeed = K_GetKartSpeed(player, false, true); fixed_t radius = FixedMul(2560 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); @@ -1071,12 +1076,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; } @@ -1107,7 +1112,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; } } @@ -1124,7 +1129,7 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemLightning(player_t *player, ticcmd_t *cmd) + static void K_BotItemLightning(const player_t *player, ticcmd_t *cmd) Item usage for Lightning Shield. @@ -1135,7 +1140,7 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemLightning(player_t *player, ticcmd_t *cmd) +static void K_BotItemLightning(const player_t *player, ticcmd_t *cmd) { if (K_BotUseItemNearPlayer(player, cmd, 192*player->mo->scale) == false) { @@ -1145,13 +1150,13 @@ static void K_BotItemLightning(player_t *player, ticcmd_t *cmd) } else { - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; } } } /*-------------------------------------------------- - static void K_BotItemBubble(player_t *player, ticcmd_t *cmd) + static void K_BotItemBubble(const player_t *player, ticcmd_t *cmd) Item usage for Bubble Shield. @@ -1162,7 +1167,7 @@ static void K_BotItemLightning(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemBubble(player_t *player, ticcmd_t *cmd) +static void K_BotItemBubble(const player_t *player, ticcmd_t *cmd) { boolean hold = false; @@ -1170,7 +1175,7 @@ static void K_BotItemBubble(player_t *player, ticcmd_t *cmd) { UINT8 i; - player->botvars.itemconfirm++; + cmd->bot.itemconfirm++; if (player->bubblecool <= 0) { @@ -1228,7 +1233,7 @@ static void K_BotItemBubble(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemFlame(player_t *player, ticcmd_t *cmd) + static void K_BotItemFlame(const player_t *player, ticcmd_t *cmd) Item usage for Flame Shield. @@ -1239,11 +1244,11 @@ static void K_BotItemBubble(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemFlame(player_t *player, ticcmd_t *cmd) +static void K_BotItemFlame(const player_t *player, ticcmd_t *cmd) { if (player->botvars.itemconfirm > 0) { - player->botvars.itemconfirm--; + cmd->bot.itemconfirm--; } else if (player->itemflags & IF_HOLDREADY) { @@ -1255,13 +1260,13 @@ static void K_BotItemFlame(player_t *player, ticcmd_t *cmd) } else { - player->botvars.itemconfirm = 3*flamemax/4; + //player->botvars.itemconfirm = 3*flamemax/4; } } } /*-------------------------------------------------- - static void K_BotItemGardenTopDeploy(player_t *player, ticcmd_t *cmd) + static void K_BotItemGardenTopDeploy(const player_t *player, ticcmd_t *cmd) Item usage for deploying the Garden Top. @@ -1272,17 +1277,19 @@ static void K_BotItemFlame(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemGardenTopDeploy(player_t *player, ticcmd_t *cmd) +static void K_BotItemGardenTopDeploy(const player_t *player, ticcmd_t *cmd) { + cmd->bot.itemconfirm++; + //if (player->curshield != KSHIELD_TOP) - if (player->botvars.itemconfirm++ > 2*TICRATE) + if (player->botvars.itemconfirm > 2*TICRATE) { K_BotGenericPressItem(player, cmd, 0); } } /*-------------------------------------------------- - static void K_BotItemGardenTop(player_t *player, ticcmd_t *cmd, INT16 turnamt) + static void K_BotItemGardenTop(const player_t *player, ticcmd_t *cmd, INT16 turnamt) Item usage for Garden Top movement. @@ -1294,7 +1301,7 @@ static void K_BotItemGardenTopDeploy(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemGardenTop(player_t *player, ticcmd_t *cmd, INT16 turnamt) +static void K_BotItemGardenTop(const player_t *player, ticcmd_t *cmd, INT16 turnamt) { const fixed_t topspeed = K_GetKartSpeed(player, false, true); fixed_t radius = FixedMul(2560 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); @@ -1308,12 +1315,12 @@ static void K_BotItemGardenTop(player_t *player, ticcmd_t *cmd, INT16 turnamt) snipeMul = 2; // 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; } @@ -1347,7 +1354,7 @@ static void K_BotItemGardenTop(player_t *player, ticcmd_t *cmd, INT16 turnamt) } /*-------------------------------------------------- - static void K_BotItemRings(player_t *player, ticcmd_t *cmd) + static void K_BotItemRings(const player_t *player, ticcmd_t *cmd) Item usage for rings. @@ -1358,7 +1365,7 @@ static void K_BotItemGardenTop(player_t *player, ticcmd_t *cmd, INT16 turnamt) Return:- None --------------------------------------------------*/ -static void K_BotItemRings(player_t *player, ticcmd_t *cmd) +static void K_BotItemRings(const player_t *player, ticcmd_t *cmd) { INT32 saferingsval = 16 - K_GetKartRingPower(player, false); @@ -1393,7 +1400,7 @@ static void K_BotItemRings(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - static void K_BotItemInstashield(player_t *player, ticcmd_t *cmd) + static void K_BotItemInstashield(const player_t *player, ticcmd_t *cmd) Item usage for instashield. @@ -1404,7 +1411,7 @@ static void K_BotItemRings(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemInstashield(player_t *player, ticcmd_t *cmd) +static void K_BotItemInstashield(const player_t *player, ticcmd_t *cmd) { const fixed_t radius = FixedMul(mobjinfo[MT_INSTAWHIP].radius, player->mo->scale); size_t i = SIZE_MAX; @@ -1449,7 +1456,7 @@ static void K_BotItemInstashield(player_t *player, ticcmd_t *cmd) if (dist <= radius) { - K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); + K_ItemConfirmForTarget(player, cmd, target, player->botvars.difficulty * 2); } } @@ -1457,12 +1464,30 @@ static void K_BotItemInstashield(player_t *player, ticcmd_t *cmd) { // Use it!! cmd->buttons |= BT_ATTACK; - player->botvars.itemconfirm = 0; + //player->botvars.itemconfirm = 0; } } /*-------------------------------------------------- - static void K_BotItemRouletteMash(player_t *player, ticcmd_t *cmd) + static tic_t K_BotItemRouletteMashConfirm(const player_t *player) + + How long this bot waits before selecting an item for + the item roulette. + + Input Arguments:- + player - Bot to do this for. + + Return:- + Time to wait, in tics. +--------------------------------------------------*/ +static tic_t K_BotItemRouletteMashConfirm(const player_t *player) +{ + // 24 tics late for Lv.1, frame-perfect for Lv.MAX + return (MAXBOTDIFFICULTY - player->botvars.difficulty) * 2; +} + +/*-------------------------------------------------- + static void K_BotItemRouletteMash(const player_t *player, ticcmd_t *cmd) Item usage for item roulette mashing. @@ -1473,51 +1498,15 @@ static void K_BotItemInstashield(player_t *player, ticcmd_t *cmd) Return:- None --------------------------------------------------*/ -static void K_BotItemRouletteMash(player_t *player, ticcmd_t *cmd) +static void K_BotItemRouletteMash(const player_t *player, ticcmd_t *cmd) { - // 24 tics late for Lv.1, frame-perfect for Lv.MAX - const tic_t confirmTime = (MAXBOTDIFFICULTY - player->botvars.difficulty) * 2; + const tic_t confirmTime = K_BotItemRouletteMashConfirm(player); if (K_ItemButtonWasDown(player) == true) { return; } - if (player->botvars.roulettePriority == BOT_ITEM_PR__FALLBACK) - { - // No items were part of our list, so set immediately. - player->botvars.itemconfirm = confirmTime + 1; - } - else if (player->botvars.itemconfirm > 0) - { - // Delaying our reaction time a bit... - player->botvars.itemconfirm++; - } - else - { - botItemPriority_e currentPriority = K_GetBotItemPriority( - player->itemRoulette.itemList[ player->itemRoulette.index ] - ); - - if (player->botvars.roulettePriority == currentPriority) - { - // This is the item we want! Start timing! - player->botvars.itemconfirm++; - } - else - { - // Not the time we want... if we take too long, - // reduce priority until we get to a valid one. - player->botvars.rouletteTimeout++; - - if (player->botvars.rouletteTimeout > player->itemRoulette.itemListLen * player->itemRoulette.speed) - { - player->botvars.roulettePriority--; - player->botvars.rouletteTimeout = 0; - } - } - } - if (player->botvars.itemconfirm > confirmTime) { // We've waited out our reaction time -- press the button now! @@ -1526,11 +1515,11 @@ static void K_BotItemRouletteMash(player_t *player, ticcmd_t *cmd) } /*-------------------------------------------------- - void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) + void K_BotItemUsage(const player_t *player, ticcmd_t *cmd, INT16 turnamt) See header file for description. --------------------------------------------------*/ -void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) +void K_BotItemUsage(const player_t *player, ticcmd_t *cmd, INT16 turnamt) { if (player->itemflags & IF_USERINGS) { @@ -1549,8 +1538,6 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) { if (player->botvars.itemdelay) { - player->botvars.itemdelay--; - player->botvars.itemconfirm = 0; return; } @@ -1585,7 +1572,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: @@ -1693,6 +1680,81 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) } } +/*-------------------------------------------------- + static void K_UpdateBotGameplayVarsItemUsageMash(player_t *player) + + Thinker function used by K_UpdateBotGameplayVarsItemUsage for + deterimining item rolls. +--------------------------------------------------*/ +static void K_UpdateBotGameplayVarsItemUsageMash(player_t *player) +{ + const tic_t confirmTime = K_BotItemRouletteMashConfirm(player); + + if (player->botvars.roulettePriority == BOT_ITEM_PR__FALLBACK) + { + // No items were part of our list, so set immediately. + player->botvars.itemconfirm = confirmTime + 1; + } + else if (player->botvars.itemconfirm > 0) + { + // Delaying our reaction time a bit... + player->botvars.itemconfirm++; + } + else + { + botItemPriority_e currentPriority = K_GetBotItemPriority( + player->itemRoulette.itemList[ player->itemRoulette.index ] + ); + + if (player->botvars.roulettePriority == currentPriority) + { + // This is the item we want! Start timing! + player->botvars.itemconfirm++; + } + else + { + // Not the time we want... if we take too long, + // reduce priority until we get to a valid one. + player->botvars.rouletteTimeout++; + + if (player->botvars.rouletteTimeout > player->itemRoulette.itemListLen * player->itemRoulette.speed) + { + player->botvars.roulettePriority--; + player->botvars.rouletteTimeout = 0; + } + } + } +} + +/*-------------------------------------------------- + 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; + + if (player->itemRoulette.active == true) + { + // Mashing behaviors + K_UpdateBotGameplayVarsItemUsageMash(player); + return; + } +} + /*-------------------------------------------------- void K_BotPickItemPriority(player_t *player) diff --git a/src/k_botsearch.c b/src/k_botsearch.c index 8d0fc1bc7..78b2b3df5 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -117,7 +117,7 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y) } /*-------------------------------------------------- - static boolean K_BotHatesThisSectorsSpecial(player_t *player, sector_t *sec) + static boolean K_BotHatesThisSectorsSpecial(const player_t *player, sector_t *sec) Tells us if a bot will play more careful around this sector's special type. @@ -129,7 +129,7 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y) Return:- true if avoiding this sector special, false otherwise. --------------------------------------------------*/ -static boolean K_BotHatesThisSectorsSpecial(player_t *player, sector_t *sec, const boolean flip) +static boolean K_BotHatesThisSectorsSpecial(const player_t *player, sector_t *sec, const boolean flip) { terrain_t *terrain = K_GetTerrainForFlatNum(flip ? sec->ceilingpic : sec->floorpic); @@ -162,11 +162,11 @@ static boolean K_BotHatesThisSectorsSpecial(player_t *player, sector_t *sec, con } /*-------------------------------------------------- - boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) + boolean K_BotHatesThisSector(const player_t *player, sector_t *sec, fixed_t x, fixed_t y) See header file for description. --------------------------------------------------*/ -boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) +boolean K_BotHatesThisSector(const player_t *player, sector_t *sec, fixed_t x, fixed_t y) { const boolean flip = (player->mo->eflags & MFE_VERTICALFLIP); fixed_t highestfloor = INT32_MAX; @@ -664,11 +664,11 @@ static BlockItReturn_t K_FindObjectsForNudging(mobj_t *thing) } /*-------------------------------------------------- - void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player) + void K_NudgePredictionTowardsObjects(botprediction_t *predict, const player_t *player) See header file for description. --------------------------------------------------*/ -void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player) +void K_NudgePredictionTowardsObjects(botprediction_t *predict, const player_t *player) { const precise_t time = I_GetPreciseTime(); @@ -948,11 +948,11 @@ static BlockItReturn_t K_FindPlayersToBully(mobj_t *thing) } /*-------------------------------------------------- - INT32 K_PositionBully(player_t *player) + INT32 K_PositionBully(const player_t *player) See header file for description. --------------------------------------------------*/ -INT32 K_PositionBully(player_t *player) +INT32 K_PositionBully(const player_t *player) { INT32 xl, xh, yl, yh, bx, by; diff --git a/src/k_kart.c b/src/k_kart.c index b03fbd652..4521d56e0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2830,7 +2830,7 @@ void K_MomentumToFacing(player_t *player) player->mo->momy = FixedMul(player->mo->momy - player->cmomy, player->mo->friction) + player->cmomy; } -boolean K_ApplyOffroad(player_t *player) +boolean K_ApplyOffroad(const player_t *player) { if (player->invincibilitytimer || player->hyudorotimer || player->sneakertimer) return false; @@ -2839,7 +2839,7 @@ boolean K_ApplyOffroad(player_t *player) return true; } -boolean K_SlopeResistance(player_t *player) +boolean K_SlopeResistance(const player_t *player) { if (player->invincibilitytimer || player->sneakertimer || player->tiregrease || player->flamedash) return true; @@ -2848,7 +2848,7 @@ boolean K_SlopeResistance(player_t *player) return false; } -tripwirepass_t K_TripwirePassConditions(player_t *player) +tripwirepass_t K_TripwirePassConditions(const player_t *player) { if ( player->invincibilitytimer || @@ -2871,7 +2871,7 @@ tripwirepass_t K_TripwirePassConditions(player_t *player) return TRIPWIRE_NONE; } -boolean K_TripwirePass(player_t *player) +boolean K_TripwirePass(const player_t *player) { return (player->tripwirePass != TRIPWIRE_NONE); } @@ -3156,7 +3156,7 @@ void K_SpawnWaterRunParticles(mobj_t *mobj) } } -boolean K_IsRidingFloatingTop(player_t *player) +boolean K_IsRidingFloatingTop(const player_t *player) { if (player->curshield != KSHIELD_TOP) { @@ -3166,7 +3166,7 @@ boolean K_IsRidingFloatingTop(player_t *player) return !Obj_GardenTopPlayerIsGrinding(player); } -boolean K_IsHoldingDownTop(player_t *player) +boolean K_IsHoldingDownTop(const player_t *player) { if (player->curshield != KSHIELD_TOP) { @@ -3181,7 +3181,7 @@ boolean K_IsHoldingDownTop(player_t *player) return true; } -mobj_t *K_GetGardenTop(player_t *player) +mobj_t *K_GetGardenTop(const player_t *player) { if (player->curshield != KSHIELD_TOP) { @@ -3202,14 +3202,14 @@ static fixed_t K_FlameShieldDashVar(INT32 val) return (3*FRACUNIT/4) + (((val * FRACUNIT) / TICRATE)); } -INT16 K_GetSpindashChargeTime(player_t *player) +INT16 K_GetSpindashChargeTime(const player_t *player) { // more charge time for higher speed // Tails = 1.7s, Knuckles = 2.2s, Metal = 2.7s return ((player->kartspeed + 8) * TICRATE) / 6; } -fixed_t K_GetSpindashChargeSpeed(player_t *player) +fixed_t K_GetSpindashChargeSpeed(const player_t *player) { // more speed for higher weight & speed // Tails = +16.94%, Fang = +34.94%, Mighty = +34.94%, Metal = +43.61% @@ -3406,7 +3406,7 @@ static void K_GetKartBoostPower(player_t *player) player->numboosts = numboosts; } -fixed_t K_GrowShrinkSpeedMul(player_t *player) +fixed_t K_GrowShrinkSpeedMul(const player_t *player) { fixed_t scaleDiff = player->mo->scale - mapobjectscale; fixed_t playerScale = FixedDiv(player->mo->scale, mapobjectscale); @@ -3442,7 +3442,7 @@ fixed_t K_GetKartSpeedFromStat(UINT8 kartspeed) return finalspeed; } -fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower, boolean dorubberband) +fixed_t K_GetKartSpeed(const player_t *player, boolean doboostpower, boolean dorubberband) { const boolean mobjValid = (player->mo != NULL && P_MobjWasRemoved(player->mo) == false); const fixed_t physicsScale = mobjValid ? K_GrowShrinkSpeedMul(player) : FRACUNIT; @@ -3506,7 +3506,7 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower, boolean dorubberb return finalspeed; } -fixed_t K_GetKartAccel(player_t *player) +fixed_t K_GetKartAccel(const player_t *player) { fixed_t k_accel = 121; UINT8 stat = (9 - player->kartspeed); @@ -3537,7 +3537,7 @@ fixed_t K_GetKartAccel(player_t *player) return k_accel; } -UINT16 K_GetKartFlashing(player_t *player) +UINT16 K_GetKartFlashing(const player_t *player) { UINT16 tics = flashingtics; @@ -3555,7 +3555,7 @@ UINT16 K_GetKartFlashing(player_t *player) return tics; } -boolean K_PlayerShrinkCheat(player_t *player) +boolean K_PlayerShrinkCheat(const player_t *player) { return ( (player->pflags & PF_SHRINKACTIVE) @@ -3583,20 +3583,20 @@ void K_UpdateShrinkCheat(player_t *player) } } -boolean K_KartKickstart(player_t *player) +boolean K_KartKickstart(const player_t *player) { return ((player->pflags & PF_KICKSTARTACCEL) && (!K_PlayerUsesBotMovement(player)) && (player->kickstartaccel >= ACCEL_KICKSTART)); } -UINT16 K_GetKartButtons(player_t *player) +UINT16 K_GetKartButtons(const player_t *player) { return (player->cmd.buttons | (K_KartKickstart(player) ? BT_ACCELERATE : 0)); } -SINT8 K_GetForwardMove(player_t *player) +SINT8 K_GetForwardMove(const player_t *player) { SINT8 forwardmove = player->cmd.forwardmove; @@ -3644,7 +3644,7 @@ SINT8 K_GetForwardMove(player_t *player) return forwardmove; } -fixed_t K_GetNewSpeed(player_t *player) +fixed_t K_GetNewSpeed(const player_t *player) { const fixed_t accelmax = 4000; fixed_t p_speed = K_GetKartSpeed(player, true, true); @@ -3675,7 +3675,7 @@ fixed_t K_GetNewSpeed(player_t *player) return finalspeed; } -fixed_t K_3dKartMovement(player_t *player) +fixed_t K_3dKartMovement(const player_t *player) { fixed_t finalspeed = K_GetNewSpeed(player); @@ -8128,7 +8128,7 @@ static void K_UpdateTripwire(player_t *player) } } -boolean K_PressingEBrake(player_t *player) +boolean K_PressingEBrake(const player_t *player) { return ((K_GetKartButtons(player) & BT_EBRAKEMASK) == BT_EBRAKEMASK); } @@ -9607,7 +9607,7 @@ void K_UpdateDistanceFromFinishLine(player_t *const player) } } -INT32 K_GetKartRingPower(player_t *player, boolean boosted) +INT32 K_GetKartRingPower(const player_t *player, boolean boosted) { fixed_t ringPower = ((9 - player->kartspeed) + (9 - player->kartweight)) * (FRACUNIT/2); fixed_t basePower = ringPower; @@ -9657,7 +9657,7 @@ boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y) // countersteer is how strong the controls are telling us we are turning // turndir is the direction the controls are telling us to turn, -1 if turning right and 1 if turning left -static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) +static INT16 K_GetKartDriftValue(const player_t *player, fixed_t countersteer) { INT16 basedrift, driftadjust; fixed_t driftweight = player->kartweight*14; // 12 @@ -9733,7 +9733,7 @@ INT16 K_UpdateSteeringValue(INT16 inputSteering, INT16 destSteering) return outputSteering; } -static fixed_t K_GetUnderwaterStrafeMul(player_t *player) +static fixed_t K_GetUnderwaterStrafeMul(const player_t *player) { const fixed_t minSpeed = 11 * player->mo->scale; fixed_t baseline = INT32_MAX; @@ -9743,7 +9743,7 @@ static fixed_t K_GetUnderwaterStrafeMul(player_t *player) return max(0, FixedDiv(player->speed - minSpeed, baseline - minSpeed)); } -INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) +INT16 K_GetKartTurnValue(const player_t *player, INT16 turnvalue) { fixed_t turnfixed = turnvalue * FRACUNIT; @@ -9877,7 +9877,7 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) return (turnfixed / FRACUNIT); } -INT32 K_GetUnderwaterTurnAdjust(player_t *player) +INT32 K_GetUnderwaterTurnAdjust(const player_t *player) { if (player->mo->eflags & MFE_UNDERWATER) { @@ -9893,12 +9893,12 @@ INT32 K_GetUnderwaterTurnAdjust(player_t *player) return 0; } -INT32 K_GetKartDriftSparkValue(player_t *player) +INT32 K_GetKartDriftSparkValue(const player_t *player) { return (26*4 + player->kartspeed*2 + (9 - player->kartweight))*8; } -INT32 K_GetKartDriftSparkValueForStage(player_t *player, UINT8 stage) +INT32 K_GetKartDriftSparkValueForStage(const player_t *player, UINT8 stage) { fixed_t mul = FRACUNIT; @@ -10625,7 +10625,7 @@ static INT32 K_FlameShieldMax(player_t *player) return min(FLAMESHIELD_MAX, (FLAMESHIELD_MAX / 16) + (disttofinish / distv)); // Ditto for this minimum, old value was 1/16 } -boolean K_PlayerEBrake(player_t *player) +boolean K_PlayerEBrake(const player_t *player) { if (player->respawn.state != RESPAWNST_NONE && (player->respawn.init == true || player->respawn.fromRingShooter == true)) @@ -10656,7 +10656,7 @@ boolean K_PlayerEBrake(player_t *player) return false; } -boolean K_PlayerGuard(player_t *player) +boolean K_PlayerGuard(const player_t *player) { if (player->guardCooldown != 0) { @@ -10697,7 +10697,7 @@ boolean K_PlayerGuard(player_t *player) return false; } -SINT8 K_Sliptiding(player_t *player) +SINT8 K_Sliptiding(const player_t *player) { /* if (player->mo->eflags & MFE_UNDERWATER) @@ -11197,7 +11197,7 @@ static void K_AirFailsafe(player_t *player) // // K_PlayerBaseFriction // -fixed_t K_PlayerBaseFriction(player_t *player, fixed_t original) +fixed_t K_PlayerBaseFriction(const player_t *player, fixed_t original) { const fixed_t factor = FixedMul( FixedDiv(FRACUNIT - original, FRACUNIT - ORIG_FRICTION), @@ -11567,6 +11567,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { whip->flags2 |= MF2_AMBUSH; } + + player->botvars.itemconfirm = 0; } } else if (!(player->instaWhipCharge >= INSTAWHIP_CHARGETIME && P_PlayerInPain(player))) // Allow reversal whip @@ -11599,7 +11601,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) @@ -11610,6 +11615,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 @@ -11623,6 +11629,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->rocketsneakertimer = 1; else player->rocketsneakertimer -= 3*TICRATE; + player->botvars.itemconfirm = 2*TICRATE; } } else if (player->itemamount == 0) @@ -11639,6 +11646,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: @@ -11672,6 +11680,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetTarget(&prev->hnext, mo); prev = mo; } + player->botvars.itemconfirm = 0; } break; case KITEM_INVINCIBILITY: @@ -11680,6 +11689,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: @@ -11711,6 +11721,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)) // Banana x3 thrown { @@ -11718,6 +11729,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemamount--; K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_EGGMAN: @@ -11739,6 +11751,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: @@ -11774,6 +11787,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 { @@ -11781,6 +11795,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemamount--; K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_JAWZ: @@ -11815,6 +11830,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 { @@ -11822,6 +11838,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); player->itemamount--; K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_MINE: @@ -11841,6 +11858,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)) { @@ -11849,6 +11867,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; player->itemflags &= ~IF_ITEMOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } break; case KITEM_LANDMINE: @@ -11857,6 +11876,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: @@ -11876,6 +11896,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)) { @@ -11884,6 +11905,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; player->itemflags &= ~IF_ITEMOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } break; case KITEM_BALLHOG: @@ -11966,6 +11988,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->ballhogcharge = 0; player->itemflags &= ~IF_HOLDREADY; + player->botvars.itemconfirm = 0; } } } @@ -11976,6 +11999,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; K_ThrowKartItem(player, true, MT_SPB, 1, 0, 0); K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_GROW: @@ -12011,6 +12035,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: @@ -12019,6 +12044,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_LIGHTNINGSHIELD: @@ -12043,6 +12069,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // ...:dumbestass: player->itemamount--; K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } } break; @@ -12050,6 +12077,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->curshield == KSHIELD_TOP && K_GetGardenTop(player) == NULL) { Obj_GardenTopDeploy(player->mo); + player->botvars.itemconfirm = 0; } else if (ATTACK_IS_DOWN && NO_HYUDORO) { @@ -12085,6 +12113,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_PlayAttackTaunt(player->mo); } } + + player->botvars.itemconfirm = 0; } break; case KITEM_BUBBLESHIELD: @@ -12121,6 +12151,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->bubblecool = 0; player->itemflags &= ~IF_HOLDREADY; player->itemamount--; + player->botvars.itemconfirm = 0; } } else @@ -12207,6 +12238,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) else { player->itemflags |= IF_HOLDREADY; + player->botvars.itemconfirm = 3*flamemax/4; if (!(gametyperules & GTR_CLOSERPLAYERS) || leveltime % 6 == 0) { @@ -12216,7 +12248,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (!player->flamemeter) S_StopSoundByID(player->mo, sfx_fshld3); } - } if (player->flamelength > destlen) @@ -12240,6 +12271,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) //K_DoHyudoroSteal(player); // yes. yes they do. Obj_HyudoroDeploy(player->mo); K_PlayAttackTaunt(player->mo); + player->botvars.itemconfirm = 0; } break; case KITEM_POGOSPRING: @@ -12249,6 +12281,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) //K_DoPogoSpring(player->mo, 32<mo, 0, 0, 0, MT_POGOSPRING); player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_SUPERRING: @@ -12256,6 +12289,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { K_AwardPlayerRings(player, 20, true); player->itemamount--; + player->botvars.itemconfirm = 0; } break; case KITEM_KITCHENSINK: @@ -12275,6 +12309,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 { @@ -12283,6 +12318,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->itemamount--; player->itemflags &= ~IF_ITEMOUT; K_UpdateHnextList(player, true); + player->botvars.itemconfirm = 0; } break; case KITEM_GACHABOM: @@ -12296,6 +12332,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) ? 1 : 0xFF ); K_UpdateHnextList(player, false); + player->botvars.itemconfirm = 0; } break; case KITEM_SAD: @@ -12304,6 +12341,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { player->sadtimer = stealtime; player->itemamount--; + player->botvars.itemconfirm = 0; } break; default: diff --git a/src/k_kart.h b/src/k_kart.h index cb5e52474..b9fbd46d2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -99,7 +99,7 @@ void K_SpawnBumpEffect(mobj_t *mo); void K_KartMoveAnimation(player_t *player); void K_KartPlayerHUDUpdate(player_t *player); void K_KartResetPlayerColor(player_t *player); -boolean K_PressingEBrake(player_t *player); +boolean K_PressingEBrake(const player_t *player); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); void K_KartPlayerAfterThink(player_t *player); angle_t K_MomentumAngleEx(const mobj_t *mo, const fixed_t threshold); @@ -151,15 +151,15 @@ void K_DropHnextList(player_t *player); void K_RepairOrbitChain(mobj_t *orbit); void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t height, boolean flip, boolean player); mobj_t *K_FindJawzTarget(mobj_t *actor, player_t *source, angle_t range); -INT32 K_GetKartRingPower(player_t *player, boolean boosted); +INT32 K_GetKartRingPower(const player_t *player, boolean boosted); void K_UpdateDistanceFromFinishLine(player_t *const player); boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y); INT16 K_UpdateSteeringValue(INT16 inputSteering, INT16 destSteering); -INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue); -INT32 K_GetUnderwaterTurnAdjust(player_t *player); -INT32 K_GetKartDriftSparkValue(player_t *player); +INT16 K_GetKartTurnValue(const player_t *player, INT16 turnvalue); +INT32 K_GetUnderwaterTurnAdjust(const player_t *player); +INT32 K_GetKartDriftSparkValue(const player_t *player); INT32 K_StairJankFlip(INT32 value); -INT32 K_GetKartDriftSparkValueForStage(player_t *player, UINT8 stage); +INT32 K_GetKartDriftSparkValueForStage(const player_t *player, UINT8 stage); void K_SpawnDriftBoostExplosion(player_t *player, int stage); void K_SpawnDriftElectricSparks(player_t *player, int color, boolean shockwave); void K_KartUpdatePosition(player_t *player); @@ -175,37 +175,37 @@ void K_DropKitchenSink(player_t *player); void K_StripItems(player_t *player); void K_StripOther(player_t *player); void K_MomentumToFacing(player_t *player); -boolean K_ApplyOffroad(player_t *player); -boolean K_SlopeResistance(player_t *player); -tripwirepass_t K_TripwirePassConditions(player_t *player); -boolean K_TripwirePass(player_t *player); +boolean K_ApplyOffroad(const player_t *player); +boolean K_SlopeResistance(const player_t *player); +tripwirepass_t K_TripwirePassConditions(const player_t *player); +boolean K_TripwirePass(const player_t *player); boolean K_MovingHorizontally(mobj_t *mobj); boolean K_WaterRun(mobj_t *mobj); boolean K_WaterSkip(mobj_t *mobj); void K_SpawnWaterRunParticles(mobj_t *mobj); -boolean K_IsRidingFloatingTop(player_t *player); -boolean K_IsHoldingDownTop(player_t *player); -mobj_t *K_GetGardenTop(player_t *player); +boolean K_IsRidingFloatingTop(const player_t *player); +boolean K_IsHoldingDownTop(const player_t *player); +mobj_t *K_GetGardenTop(const player_t *player); void K_ApplyTripWire(player_t *player, tripwirestate_t state); -INT16 K_GetSpindashChargeTime(player_t *player); -fixed_t K_GetSpindashChargeSpeed(player_t *player); -fixed_t K_GrowShrinkSpeedMul(player_t *player); +INT16 K_GetSpindashChargeTime(const player_t *player); +fixed_t K_GetSpindashChargeSpeed(const player_t *player); +fixed_t K_GrowShrinkSpeedMul(const player_t *player); fixed_t K_GetKartSpeedFromStat(UINT8 kartspeed); -fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower, boolean dorubberbanding); -fixed_t K_GetKartAccel(player_t *player); -UINT16 K_GetKartFlashing(player_t *player); -boolean K_PlayerShrinkCheat(player_t *player); +fixed_t K_GetKartSpeed(const player_t *player, boolean doboostpower, boolean dorubberbanding); +fixed_t K_GetKartAccel(const player_t *player); +UINT16 K_GetKartFlashing(const player_t *player); +boolean K_PlayerShrinkCheat(const player_t *player); void K_UpdateShrinkCheat(player_t *player); -boolean K_KartKickstart(player_t *player); -UINT16 K_GetKartButtons(player_t *player); -SINT8 K_GetForwardMove(player_t *player); -fixed_t K_GetNewSpeed(player_t *player); -fixed_t K_3dKartMovement(player_t *player); -boolean K_PlayerEBrake(player_t *player); -boolean K_PlayerGuard(player_t *player); -SINT8 K_Sliptiding(player_t *player); +boolean K_KartKickstart(const player_t *player); +UINT16 K_GetKartButtons(const player_t *player); +SINT8 K_GetForwardMove(const player_t *player); +fixed_t K_GetNewSpeed(const player_t *player); +fixed_t K_3dKartMovement(const player_t *player); +boolean K_PlayerEBrake(const player_t *player); +boolean K_PlayerGuard(const player_t *player); +SINT8 K_Sliptiding(const player_t *player); boolean K_FastFallBounce(player_t *player); -fixed_t K_PlayerBaseFriction(player_t *player, fixed_t original); +fixed_t K_PlayerBaseFriction(const player_t *player, fixed_t original); void K_AdjustPlayerFriction(player_t *player); void K_MoveKartPlayer(player_t *player, boolean onground); void K_CheckSpectateStatus(boolean considermapreset); diff --git a/src/k_objects.h b/src/k_objects.h index 8e5d34014..a8b9edef6 100644 --- a/src/k_objects.h +++ b/src/k_objects.h @@ -26,7 +26,7 @@ mobj_t *Obj_GardenTopDestroy(player_t *player); void Obj_GardenTopThink(mobj_t *top); void Obj_GardenTopSparkThink(mobj_t *spark); void Obj_GardenTopArrowThink(mobj_t *arrow); -boolean Obj_GardenTopPlayerIsGrinding(player_t *player); +boolean Obj_GardenTopPlayerIsGrinding(const player_t *player); /* Shrink */ void Obj_PohbeeThinker(mobj_t *pohbee); @@ -135,7 +135,7 @@ void Obj_ChargeExtraThink(mobj_t *extra); /* Ring Shooter */ boolean Obj_RingShooterThinker(mobj_t *mo); -boolean Obj_PlayerRingShooterFreeze(player_t *const player); +boolean Obj_PlayerRingShooterFreeze(const player_t *player); void Obj_RingShooterInput(player_t *player); void Obj_PlayerUsedRingShooter(mobj_t *base, player_t *player); void Obj_RingShooterDelete(mobj_t *mo); diff --git a/src/objects/gardentop.c b/src/objects/gardentop.c index 71283a73e..143dca17f 100644 --- a/src/objects/gardentop.c +++ b/src/objects/gardentop.c @@ -681,7 +681,7 @@ Obj_GardenTopArrowThink (mobj_t *arrow) } boolean -Obj_GardenTopPlayerIsGrinding (player_t *player) +Obj_GardenTopPlayerIsGrinding (const player_t *player) { mobj_t *top = K_GetGardenTop(player); diff --git a/src/objects/ring-shooter.c b/src/objects/ring-shooter.c index c9812a6b8..eee9a6d80 100644 --- a/src/objects/ring-shooter.c +++ b/src/objects/ring-shooter.c @@ -638,7 +638,7 @@ static void SpawnRingShooter(player_t *player) rs_base_playerface(base) = (player - players); } -static boolean AllowRingShooter(player_t *player) +static boolean AllowRingShooter(const player_t *player) { const fixed_t minSpeed = 6 * player->mo->scale; @@ -667,9 +667,9 @@ static boolean AllowRingShooter(player_t *player) return false; } -boolean Obj_PlayerRingShooterFreeze(player_t *const player) +boolean Obj_PlayerRingShooterFreeze(const player_t *player) { - mobj_t *const base = player->ringShooter; + const mobj_t *base = player->ringShooter; if (AllowRingShooter(player) == true && (player->cmd.buttons & BT_RESPAWN) == BT_RESPAWN diff --git a/src/p_local.h b/src/p_local.h index 115ccc2ef..15383f6c6 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -154,7 +154,7 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ToggleDemoCamera(UINT8 viewnum); -boolean P_PlayerInPain(player_t *player); +boolean P_PlayerInPain(const player_t *player); void P_ResetPlayer(player_t *player); boolean P_PlayerCanDamage(player_t *player, mobj_t *thing); @@ -166,12 +166,12 @@ void P_SetPlayerAngle(player_t *player, angle_t angle); void P_ForceLocalAngle(player_t *player, angle_t angle); boolean P_PlayerFullbright(player_t *player); -boolean P_IsObjectInGoop(mobj_t *mo); -boolean P_IsObjectOnGround(mobj_t *mo); -boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec); -boolean P_IsObjectOnRealGround(mobj_t *mo, sector_t *sec); // SRB2Kart +boolean P_IsObjectInGoop(const mobj_t *mo); +boolean P_IsObjectOnGround(const mobj_t *mo); +boolean P_IsObjectOnGroundIn(const mobj_t *mo, const sector_t *sec); +boolean P_IsObjectOnRealGround(const mobj_t *mo, const sector_t *sec); // SRB2Kart #define P_IsObjectFlipped(o) (((o)->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP) -boolean P_InQuicksand(mobj_t *mo); +boolean P_InQuicksand(const mobj_t *mo); boolean P_PlayerHitFloor(player_t *player, boolean fromAir, angle_t oldPitch, angle_t oldRoll); void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative); @@ -276,8 +276,8 @@ void P_PushableThinker(mobj_t *mobj); void P_SceneryThinker(mobj_t *mobj); -fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); -fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); +fixed_t P_MobjFloorZ(const mobj_t *mobj, const sector_t *sector, const sector_t *boundsec, fixed_t x, fixed_t y, const line_t *line, boolean lowest, boolean perfect); +fixed_t P_MobjCeilingZ(const mobj_t *mobj, const sector_t *sector, const sector_t *boundsec, fixed_t x, fixed_t y, const line_t *line, boolean lowest, boolean perfect); #define P_GetFloorZ(mobj, sector, x, y, line) P_MobjFloorZ(mobj, sector, NULL, x, y, line, false, false) #define P_GetCeilingZ(mobj, sector, x, y, line) P_MobjCeilingZ(mobj, sector, NULL, x, y, line, true, false) #define P_GetFOFTopZ(mobj, sector, fof, x, y, line) P_MobjCeilingZ(mobj, sectors + fof->secnum, sector, x, y, line, false, false) diff --git a/src/p_mobj.c b/src/p_mobj.c index 55a94c149..70bb818b6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -633,7 +633,7 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) // Supply boundsec ONLY when checking for specials! It should be the "in-level" sector, and sector the control sector (if separate). // If set, then this function will iterate through boundsec's linedefs to find the highest contact point on the slope. Non-special-checking // usage will handle that later. -static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, pslope_t *slope, boolean actuallylowest) +static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, const line_t *line, const pslope_t *slope, boolean actuallylowest) { // Alright, so we're sitting on a line that contains our slope sector, and need to figure out the highest point we're touching... // The solution is simple! Get the line's vertices, and pull each one in along its line until it touches the object's bounding box @@ -731,7 +731,7 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, ); } -fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) +fixed_t P_MobjFloorZ(const mobj_t *mobj, const sector_t *sector, const sector_t *boundsec, fixed_t x, fixed_t y, const line_t *line, boolean lowest, boolean perfect) { I_Assert(mobj != NULL); I_Assert(sector != NULL); @@ -808,7 +808,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t return sector->floorheight; } -fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) +fixed_t P_MobjCeilingZ(const mobj_t *mobj, const sector_t *sector, const sector_t *boundsec, fixed_t x, fixed_t y, const line_t *line, boolean lowest, boolean perfect) { I_Assert(mobj != NULL); I_Assert(sector != NULL); diff --git a/src/p_user.c b/src/p_user.c index f5914711f..f8bdfe8b5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -459,7 +459,7 @@ UINT8 P_FindHighestLap(void) // Is player in pain?? // Checks for painstate and flashing, if both found return true // -boolean P_PlayerInPain(player_t *player) +boolean P_PlayerInPain(const player_t *player) { if (player->spinouttimer || (player->tumbleBounces > 0) || (player->pflags & PF_FAULT) || player->icecube.frozen) return true; @@ -831,7 +831,7 @@ void P_InvincGrowMusic(void) // Returns true if the object is inside goop water. // (Spectators and objects otherwise without gravity cannot have goop gravity!) // -boolean P_IsObjectInGoop(mobj_t *mo) +boolean P_IsObjectInGoop(const mobj_t *mo) { if (mo->player && mo->player->spectator) return false; @@ -849,7 +849,7 @@ boolean P_IsObjectInGoop(mobj_t *mo) // on the ground. Takes reverse // gravity and FOFs into account. // -boolean P_IsObjectOnGround(mobj_t *mo) +boolean P_IsObjectOnGround(const mobj_t *mo) { if (P_IsObjectInGoop(mo)) { @@ -894,7 +894,7 @@ boolean P_IsObjectOnGround(mobj_t *mo) // on the ground in a specific sector. Takes reverse // gravity and FOFs into account. // -boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec) +boolean P_IsObjectOnGroundIn(const mobj_t *mo, const sector_t *sec) { ffloor_t *rover; @@ -981,7 +981,7 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec) // Really simple, but personally I think it's also incredibly helpful. I think this is fine in p_user.c // -- Sal -boolean P_IsObjectOnRealGround(mobj_t *mo, sector_t *sec) +boolean P_IsObjectOnRealGround(const mobj_t *mo, const sector_t *sec) { // Is the object in reverse gravity? if (mo->eflags & MFE_VERTICALFLIP) @@ -1471,7 +1471,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean fromAir, angle_t oldPitch, an return clipmomz; } -boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand +boolean P_InQuicksand(const mobj_t *mo) // Returns true if you are in quicksand { sector_t *sector = mo->subsector->sector; fixed_t topheight, bottomheight;