From dbc30da69ff8284309e7444f6423a82acdf31d47 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 24 May 2020 15:55:10 -0400 Subject: [PATCH] Dial back the bot steering changes a bit --- src/k_bot.c | 40 +++++++++------------------------------- src/k_bot.h | 2 +- src/k_botsearch.c | 7 ++----- 3 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 927fc357a..01767054f 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -395,13 +395,11 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) const INT16 handling = K_GetKartTurnValue(player, KART_FULLTURN); // Reduce prediction based on how fast you can turn const INT16 normal = KART_FULLTURN; // "Standard" handling to compare to - const fixed_t topspeed = K_GetKartSpeed(player, false); - const fixed_t speed = P_AproxDistance(player->mo->momx, player->mo->momy) + (topspeed / 4); - const fixed_t distreduce = K_BotReducePrediction(player); fixed_t radreduce = min(distreduce + FRACUNIT/4, FRACUNIT); const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict + const fixed_t speed = P_AproxDistance(player->mo->momx, player->mo->momy); const INT32 distance = (FixedMul(speed, distreduce) / FRACUNIT) * futuresight; botprediction_t *predict = Z_Calloc(sizeof(botprediction_t), PU_LEVEL, NULL); @@ -418,12 +416,6 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) // This prevents looking too far ahead if the closest waypoint is really far away. distanceleft -= P_AproxDistance(player->mo->x - wp->mobj->x, player->mo->y - wp->mobj->y) / FRACUNIT; - if (speed > topspeed) - { - // Play more in the center when going fast. - radreduce = FixedDiv(radreduce, speed / topspeed); - } - // We don't want to look ahead at all, just go to the first waypoint. if (distanceleft <= 0) { @@ -495,8 +487,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) } } } - - // Save angle for the next loop's oldangle + angletonext = R_PointToAngle2( wp->mobj->x, wp->mobj->y, wp->nextwaypoints[nwp]->mobj->x, wp->nextwaypoints[nwp]->mobj->y @@ -651,13 +642,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // Full speed ahead! cmd->forwardmove = 50; - if (anglediff > 60) - { - // Actually, don't go too fast... - cmd->forwardmove /= 2; - cmd->buttons |= BT_BRAKE; - } - if (dirdist <= rad) { fixed_t speedmul = FixedMul(player->speed, K_GetKartSpeed(player, false)); @@ -690,7 +674,13 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } } - if (anglediff < 60) + if (anglediff > 60) + { + // Actually, don't go too fast... + cmd->forwardmove /= 2; + cmd->buttons |= BT_BRAKE; + } + else if (dirdist <= realrad) { // Steer towards/away from objects! turnamt += K_BotFindObjects(player, turnamt); @@ -714,12 +704,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) if (turnamt > 0) { - if (player->botvars.turnconfirm < 0) - { - // Reset turn confirm - player->botvars.turnconfirm = 0; - } - if (player->botvars.turnconfirm < BOTTURNCONFIRM) { player->botvars.turnconfirm++; @@ -727,12 +711,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } else if (turnamt < 0) { - if (player->botvars.turnconfirm > 0) - { - // Reset turn confirm - player->botvars.turnconfirm = 0; - } - if (player->botvars.turnconfirm > -BOTTURNCONFIRM) { player->botvars.turnconfirm--; diff --git a/src/k_bot.h b/src/k_bot.h index 81257ecbf..bbd2dedcd 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -20,7 +20,7 @@ // How many tics in a row do you need to turn in this direction before we'll let you turn. // Made it as small as possible without making it look like the bots are twitching constantly. -#define BOTTURNCONFIRM 7 +#define BOTTURNCONFIRM 4 // Point for bots to aim for typedef struct botprediction_s { diff --git a/src/k_botsearch.c b/src/k_botsearch.c index 28bef819e..2a95da738 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -95,7 +95,6 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y) { INT32 xl, xh, yl, yh, bx, by; - memset(&globalsmuggle, 0, sizeof (struct globalsmuggle)); globalsmuggle.eggboxx = x; globalsmuggle.eggboxy = y; globalsmuggle.distancetocheck = (mapobjectscale * 256); @@ -347,9 +346,8 @@ fixed_t K_BotReducePrediction(player_t *player) { INT32 xl, xh, yl, yh, bx, by; - memset(&globalsmuggle, 0, sizeof (struct globalsmuggle)); globalsmuggle.botmo = player->mo; - globalsmuggle.distancetocheck = (player->mo->radius * 8) + (player->speed * 4); + globalsmuggle.distancetocheck = (player->mo->radius * 16); globalsmuggle.closestlinedist = INT32_MAX; tmx = player->mo->x; @@ -724,11 +722,10 @@ INT16 K_BotFindObjects(player_t *player, INT16 turn) { INT32 xl, xh, yl, yh, bx, by; - memset(&globalsmuggle, 0, sizeof (struct globalsmuggle)); globalsmuggle.steer = 0; globalsmuggle.botmo = player->mo; globalsmuggle.curturn = turn; - globalsmuggle.distancetocheck = 2048*mapobjectscale; + globalsmuggle.distancetocheck = (player->mo->radius * 32) + (player->speed * 4); xl = (unsigned)(globalsmuggle.botmo->x - globalsmuggle.distancetocheck - bmaporgx)>>MAPBLOCKSHIFT; xh = (unsigned)(globalsmuggle.botmo->x + globalsmuggle.distancetocheck - bmaporgx)>>MAPBLOCKSHIFT;