mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Dial back the bot steering changes a bit
This commit is contained in:
parent
02605a5ace
commit
dbc30da69f
3 changed files with 12 additions and 37 deletions
40
src/k_bot.c
40
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--;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue