diff --git a/src/d_player.h b/src/d_player.h index 606415a717692827b3b585899046becd994f1cee..24a0c0403e115470cac64c227824e7de2a0d3a8b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -290,6 +290,9 @@ typedef struct botvars_s UINT8 diffincrease; // In GP: bot difficulty will increase this much next round boolean rival; // If true, they're the GP rival + fixed_t rubberband; // Bot rubberband value + UINT16 controller; // Special bot controller linedef ID + tic_t itemdelay; // Delay before using item at all tic_t itemconfirm; // When high enough, they will use their item diff --git a/src/g_game.c b/src/g_game.c index 21467e592a5f23beb5d706bca87cbfdbab1f7825..13194abf98633ba80f6da7b0ca867413a071fc6d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2403,6 +2403,9 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->kickstartaccel = kickstartaccel; p->tripWireState = TRIP_NONE; + p->botvars.rubberband = FRACUNIT; + p->botvars.controller = UINT16_MAX; + memcpy(&p->respawn, &respawn, sizeof (p->respawn)); if (follower) diff --git a/src/k_bot.c b/src/k_bot.c index 0b8c7537151a6d838668aae1a1893c762bb60faf..f9dad809a2980813e0314446d0daeea2759feb7e 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -489,7 +489,6 @@ fixed_t K_BotRubberband(player_t *player) fixed_t rubberband = FRACUNIT; fixed_t rubbermax, rubbermin; player_t *firstplace = NULL; - line_t *botController = NULL; UINT8 i; if (player->exiting) @@ -498,14 +497,17 @@ fixed_t K_BotRubberband(player_t *player) return FRACUNIT; } - botController = K_FindBotController(player->mo); - - if (botController != NULL) + if (player->botvars.controller != UINT16_MAX) { - // No Climb Flag: Disable rubberbanding - if (botController->flags & ML_NOCLIMB) + const line_t *botController = &lines[player->botvars.controller]; + + if (botController != NULL) { - return FRACUNIT; + // No Climb Flag: Disable rubberbanding + if (botController->flags & ML_NOCLIMB) + { + return FRACUNIT; + } } } @@ -571,6 +573,22 @@ fixed_t K_BotRubberband(player_t *player) return rubberband; } +/*-------------------------------------------------- + fixed_t K_UpdateRubberband(player_t *player) + + See header file for description. +--------------------------------------------------*/ +fixed_t K_UpdateRubberband(player_t *player) +{ + fixed_t dest = K_BotRubberband(player); + fixed_t ret = player->botvars.rubberband; + + // Ease into the new value. + ret += (dest - player->botvars.rubberband) >> 3; + + return ret; +} + /*-------------------------------------------------- fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy) @@ -1269,6 +1287,16 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } botController = K_FindBotController(player->mo); + if (botController == NULL) + { + player->botvars.controller = UINT16_MAX; + } + else + { + player->botvars.controller = lines - botController; + } + + player->botvars.rubberband = K_UpdateRubberband(player); if (player->trickpanel != 0) { diff --git a/src/k_bot.h b/src/k_bot.h index 0762c86e9dd701fc28f7c48e25bbfcb9d8ca71d9..f03187205787827d78f9e63eb9c5c775ddcfad95 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -87,6 +87,22 @@ boolean K_BotCanTakeCut(player_t *player); fixed_t K_BotRubberband(player_t *player); +/*-------------------------------------------------- + fixed_t K_UpdateRubberband(player_t *player); + + Eases the current rubberbanding value to the + new one, calculated by K_BotRubberband. + + Input Arguments:- + player - Player to update. + + Return:- + The new rubberband multiplier, in fixed point scale. +--------------------------------------------------*/ + +fixed_t K_UpdateRubberband(player_t *player); + + /*-------------------------------------------------- fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy); diff --git a/src/k_kart.c b/src/k_kart.c index 609bb63232c40e4b79925b6bd72cc716d8383291..1248714eb49ff8ad9a445d5228d233f284cd75f5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3190,7 +3190,7 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower, boolean dorubberb if (dorubberband == true && K_PlayerUsesBotMovement(player) == true) { - finalspeed = FixedMul(finalspeed, K_BotRubberband(player)); + finalspeed = FixedMul(finalspeed, player->botvars.rubberband); } return finalspeed; diff --git a/src/p_saveg.c b/src/p_saveg.c index f6819eb9c3b889db65d9c3a0c818850db56170f1..bcd12e8e3018f9eabdd3750ec8c6fb7f754d4175 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -371,6 +371,8 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].botvars.difficulty); WRITEUINT8(save_p, players[i].botvars.diffincrease); WRITEUINT8(save_p, players[i].botvars.rival); + WRITEFIXED(save_p, players[i].botvars.rubberband); + WRITEUINT16(save_p, players[i].botvars.controller); WRITEUINT32(save_p, players[i].botvars.itemdelay); WRITEUINT32(save_p, players[i].botvars.itemconfirm); WRITESINT8(save_p, players[i].botvars.turnconfirm); @@ -647,6 +649,8 @@ static void P_NetUnArchivePlayers(void) players[i].botvars.difficulty = READUINT8(save_p); players[i].botvars.diffincrease = READUINT8(save_p); players[i].botvars.rival = (boolean)READUINT8(save_p); + players[i].botvars.rubberband = READFIXED(save_p); + players[i].botvars.controller = READUINT16(save_p); players[i].botvars.itemdelay = READUINT32(save_p); players[i].botvars.itemconfirm = READUINT32(save_p); players[i].botvars.turnconfirm = READSINT8(save_p); diff --git a/src/p_user.c b/src/p_user.c index 22d52b2583d5482bd901fc3b0ebff4f40641b46c..fde4465c378c42b9b76bad5cade3ad7365ebb24f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1939,7 +1939,7 @@ static void P_3dMovement(player_t *player) // Make rubberbanding bots slow down faster if (K_PlayerUsesBotMovement(player)) { - fixed_t rubberband = K_BotRubberband(player) - FRACUNIT; + fixed_t rubberband = player->botvars.rubberband - FRACUNIT; if (rubberband > 0) {