diff --git a/src/d_player.h b/src/d_player.h index 5cb2f7afc..5e2dddb0b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -430,6 +430,7 @@ struct botvars_t tic_t rouletteTimeout; // If it takes too long to decide, try lowering priority until we find something valid. angle_t predictionError; // How bad is our momentum angle relative to where we're trying to go? + INT16 straightawayTime; // How long have we been going straight? (See k_bot.h) }; // player_t struct for round-specific condition tracking diff --git a/src/k_bot.cpp b/src/k_bot.cpp index 3918a2e6b..ce321c43f 100644 --- a/src/k_bot.cpp +++ b/src/k_bot.cpp @@ -823,6 +823,7 @@ fixed_t K_BotRubberband(const player_t *player) fixed_t K_UpdateRubberband(player_t *player) { fixed_t dest = K_BotRubberband(player); + dest = (player->botvars.straightawayTime > 0) ? FixedMul(BOTSTRAIGHTSTRENGTH, dest) : dest; fixed_t ret = player->botvars.rubberband; UINT8 ease_soften = 8; @@ -2123,6 +2124,14 @@ void K_UpdateBotGameplayVars(player_t *player) } } + if (player->botvars.predictionError <= BOTSTRAIGHTANGLE) + player->botvars.straightawayTime++; + else + player->botvars.straightawayTime -= 5; + + player->botvars.straightawayTime = std::min(player->botvars.straightawayTime, BOTSTRAIGHTTIME); + player->botvars.straightawayTime = std::max(player->botvars.straightawayTime, -1 * BOTSTRAIGHTTIME); + const botcontroller_t *botController = K_GetBotController(player->mo); if (K_TryRingShooter(player, botController) == true) { diff --git a/src/k_bot.h b/src/k_bot.h index 6044bbd92..ac3092c8b 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -46,6 +46,10 @@ extern "C" { // How long it takes for a Lv.1 bot to decide to pick an item. #define BOT_ITEM_DECISION_TIME (2*TICRATE) +#define BOTSTRAIGHTTIME (TICRATE/2) +#define BOTSTRAIGHTSTRENGTH (85*FRACUNIT/100) +#define BOTSTRAIGHTANGLE (ANG10) + // Point for bots to aim for struct botprediction_t { diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 1bf954bec..1a39d56b2 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -7096,6 +7096,7 @@ static void K_DrawBotDebugger(void) V_DrawSmallString(8, 70, 0, va("Bot modifier: %.2f", FixedToFloat(K_BotMapModifier()))); V_DrawSmallString(8, 76, 0, va("Prediction error: %d", bot->botvars.predictionError)); + V_DrawSmallString(8, 80, 0, va("Straight: %d", bot->botvars.straightawayTime)); } static void K_DrawGPRankDebugger(void) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 8e6bcc6e8..e0c2d88b9 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -756,7 +756,8 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT32(save->p, players[i].botvars.spindashconfirm); WRITEUINT32(save->p, players[i].botvars.respawnconfirm); WRITEUINT8(save->p, players[i].botvars.roulettePriority); - WRITEUINT32(save->p, players[i].botvars.rouletteTimeout); + WRITEINT32(save->p, players[i].botvars.rouletteTimeout); + WRITEINT16(save->p, players[i].botvars.straightawayTime); // itemroulette_t WRITEUINT8(save->p, players[i].itemRoulette.active); @@ -1409,6 +1410,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].botvars.respawnconfirm = READUINT32(save->p); players[i].botvars.roulettePriority = READUINT8(save->p); players[i].botvars.rouletteTimeout = READUINT32(save->p); + players[i].botvars.straightawayTime = READINT16(save->p); // itemroulette_t players[i].itemRoulette.active = (boolean)READUINT8(save->p);