Bot grip experiment

This commit is contained in:
Antonio Martinez 2025-05-22 16:35:53 -04:00
parent 5f95ad933f
commit 219f8d74a0
5 changed files with 20 additions and 4 deletions

View file

@ -420,6 +420,8 @@ struct botvars_t
UINT8 roulettePriority; // What items to go for on the roulette
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?
};
// player_t struct for round-specific condition tracking

View file

@ -1427,10 +1427,11 @@ static INT32 K_HandleBotTrack(const player_t *player, ticcmd_t *cmd, botpredicti
I_Assert(predict != nullptr);
destangle = K_BotSmoothLanding(player, destangle);
moveangle = player->mo->angle + K_GetUnderwaterTurnAdjust(player);
anglediff = AngleDeltaSigned(moveangle, destangle);
cmd->angle = std::min(destangle - moveangle, moveangle - destangle) >> TICCMD_REDUCE;
if (anglediff < 0)
{
turnsign = 1;
@ -1712,7 +1713,7 @@ static void K_BuildBotPodiumTiccmd(const player_t *player, ticcmd_t *cmd)
Build ticcmd for bots with a style of BOT_STYLE_NORMAL
--------------------------------------------------*/
static void K_BuildBotTiccmdNormal(const player_t *player, ticcmd_t *cmd)
static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd)
{
precise_t t = 0;
@ -1724,6 +1725,9 @@ static void K_BuildBotTiccmdNormal(const player_t *player, ticcmd_t *cmd)
UINT8 spindash = 0;
INT32 turnamt = 0;
cmd->angle = 0; // For bots, this is used to transmit prediction error to gamelogic.
// Will be overwritten by K_HandleBotTrack if we have a destination.
if (!(gametyperules & GTR_BOTS) // No bot behaviors
|| K_GetNumWaypoints() == 0 // No waypoints
|| leveltime <= introtime // During intro camera

View file

@ -6689,6 +6689,8 @@ static void K_DrawBotDebugger(void)
V_DrawSmallString(8, 66, 0, va("Complexity: %d", K_GetTrackComplexity()));
V_DrawSmallString(8, 70, 0, va("Bot modifier: %.2f", FixedToFloat(K_BotMapModifier())));
V_DrawSmallString(8, 76, 0, va("Prediction error: %d", bot->botvars.predictionError));
}
static void K_DrawGPRankDebugger(void)

View file

@ -13022,14 +13022,19 @@ fixed_t K_PlayerBaseFriction(const player_t *player, fixed_t original)
// A bit extra friction to help them without drifting.
// Remove this line once they can drift.
frict -= extraFriction;
// frict -= extraFriction;
angle_t MAXERROR = 45*ANG1;
fixed_t errorfrict = Easing_Linear(min(FRACUNIT, FixedDiv(player->botvars.predictionError, MAXERROR)), 0, FRACUNIT>>2);
frict -= errorfrict;
// Bots gain more traction as they rubberband.
const fixed_t traction_value = FixedMul(player->botvars.rubberband, max(FRACUNIT, K_BotMapModifier()));
if (traction_value > FRACUNIT)
{
const fixed_t traction_mul = traction_value - FRACUNIT;
frict -= FixedMul(extraFriction, traction_mul);
// frict -= FixedMul(extraFriction, traction_mul);
}
}
}

View file

@ -2321,6 +2321,9 @@ static void P_UpdatePlayerAngle(player_t *player)
{
// You're a bot. Go where you're supposed to go
player->steering = targetsteering;
// But the "angle" field of this ticcmd stores your prediction error,
// which we use to apply friction. Transfer it!
player->botvars.predictionError = player->cmd.angle << TICCMD_REDUCE;
}
else if ((!(player->cmd.flags & TICCMD_RECEIVED)) && (!!(player->oldcmd.flags && TICCMD_RECEIVED)))
{