Straight slowdown attempt 2: use momentum angle

This commit is contained in:
Antonio Martinez 2025-06-21 19:23:39 -04:00
parent a8ef3d0204
commit d4c8fac82d
6 changed files with 47 additions and 20 deletions

View file

@ -430,7 +430,8 @@ 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)
angle_t recentDeflection; // How long have we been going straight? (See k_bot.h)
angle_t lastAngle;
};
// player_t struct for round-specific condition tracking

View file

@ -586,7 +586,7 @@ const botcontroller_t *K_GetBotController(const mobj_t *mobj)
fixed_t K_BotMapModifier(void)
{
// fuck it we ball
// return 10*FRACUNIT/10;
return 5*FRACUNIT/10;
constexpr INT32 complexity_scale = 10000;
fixed_t modifier_max = (10 * FRACUNIT / 10) - FRACUNIT;
@ -690,9 +690,9 @@ fixed_t K_BotRubberband(const player_t *player)
// Allow the status quo to assert itself a bit. Bots get most of their speed from their
// mechanics adjustments, not from items, so kill some bot speed if they've got bad EXP.
if (player->gradingfactor < FRACUNIT && !(player->botvars.rival))
if (player->gradingfactor < FRACUNIT && !(player->botvars.rival) && player->botvars.difficulty > 1)
{
UINT8 levelreduce = 3; // How much to drop the "effective level" of bots that are consistently behind
UINT8 levelreduce = std::min<UINT8>(3, player->botvars.difficulty); // How much to drop the "effective level" of bots that are consistently behind
expreduce = Easing_Linear((K_EffectiveGradingFactor(player) - MINGRADINGFACTOR) * 2, levelreduce*FRACUNIT, 0);
}
@ -823,7 +823,17 @@ 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 deflect = player->botvars.recentDeflection;
if (deflect > BOTMAXDEFLECTION)
deflect = BOTMAXDEFLECTION;
dest = FixedMul(dest, Easing_Linear(
FixedDiv(deflect, BOTMAXDEFLECTION),
BOTSTRAIGHTSPEED,
BOTTURNSPEED
));
fixed_t ret = player->botvars.rubberband;
UINT8 ease_soften = 8;
@ -2124,13 +2134,20 @@ void K_UpdateBotGameplayVars(player_t *player)
}
}
if (player->botvars.predictionError <= BOTSTRAIGHTANGLE)
player->botvars.straightawayTime++;
angle_t mangle = K_MomentumAngleEx(player->mo, 5*mapobjectscale); // magic threshold
angle_t langle = player->botvars.lastAngle;
angle_t dangle = 0;
if (mangle >= langle)
dangle = mangle - langle;
else
player->botvars.straightawayTime -= 5;
dangle = langle - mangle;
// Writing this made me move my tongue around in my mouth
player->botvars.straightawayTime = std::min<INT16>(player->botvars.straightawayTime, BOTSTRAIGHTTIME);
player->botvars.straightawayTime = std::max<INT16>(player->botvars.straightawayTime, -1 * BOTSTRAIGHTTIME);
UINT32 smo = BOTANGLESAMPLES - 1;
player->botvars.recentDeflection = (smo * player->botvars.recentDeflection / BOTANGLESAMPLES) + (dangle / BOTANGLESAMPLES);
player->botvars.lastAngle = mangle;
const botcontroller_t *botController = K_GetBotController(player->mo);
if (K_TryRingShooter(player, botController) == true)

View file

@ -35,7 +35,7 @@ extern "C" {
// 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 4
#define BOTTURNCONFIRM 1
// How many tics with only one spindash-viable condition before we'll let you spindash.
#define BOTSPINDASHCONFIRM (4*TICRATE)
@ -46,9 +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)
#define BOTSTRAIGHTSPEED (80*FRACUNIT/100) // How fast we move when at 0 deflection.
#define BOTTURNSPEED (100*FRACUNIT/100) // How fast we move when at MAXDEFLECTION deflection.
#define BOTANGLESAMPLES (TICRATE) // Time period to average over. Higher values produce lower peaks that last longer.
#define BOTMAXDEFLECTION (ANG1*3) // Measured in "degrees per tic" here, use debugbots.
// Point for bots to aim for
struct botprediction_t

View file

@ -7095,8 +7095,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));
V_DrawSmallString(8, 80, 0, va("Straight: %d", bot->botvars.straightawayTime));
V_DrawSmallString(8, 76, 0, va("Prediction error: %.2fdeg", FIXED_TO_FLOAT(FixedDiv(bot->botvars.predictionError, ANG1))));
V_DrawSmallString(8, 80, 0, va("Recent deflection: %.2fdeg", FIXED_TO_FLOAT(FixedDiv(bot->botvars.recentDeflection, ANG1))));
}
static void K_DrawGPRankDebugger(void)

View file

@ -757,7 +757,9 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT32(save->p, players[i].botvars.respawnconfirm);
WRITEUINT8(save->p, players[i].botvars.roulettePriority);
WRITEINT32(save->p, players[i].botvars.rouletteTimeout);
WRITEINT16(save->p, players[i].botvars.straightawayTime);
WRITEUINT32(save->p, players[i].botvars.predictionError);
WRITEUINT32(save->p, players[i].botvars.recentDeflection);
WRITEUINT32(save->p, players[i].botvars.lastAngle);
// itemroulette_t
WRITEUINT8(save->p, players[i].itemRoulette.active);
@ -1410,7 +1412,9 @@ 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);
players[i].botvars.predictionError = READUINT32(save->p);
players[i].botvars.recentDeflection = READUINT32(save->p);
players[i].botvars.lastAngle = READUINT32(save->p);
// itemroulette_t
players[i].itemRoulette.active = (boolean)READUINT8(save->p);

View file

@ -1206,11 +1206,15 @@ void P_ButteredSlope(mobj_t *mo)
// Let's get the gravity strength for the object...
thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo)));
if (mo->friction != ORIG_FRICTION)
fixed_t basefriction = ORIG_FRICTION;
if (mo->player && false)
basefriction = K_PlayerBaseFriction(mo->player, ORIG_FRICTION);
if (mo->friction != basefriction && basefriction != 0)
{
// ... and its friction against the ground for good measure.
// (divided by original friction to keep behaviour for normal slopes the same)
thrust = FixedMul(thrust, FixedDiv(mo->friction, ORIG_FRICTION));
thrust = FixedMul(thrust, FixedDiv(mo->friction, basefriction));
// Sal: Also consider movefactor of players.
// We want ice to make slopes *really* funnel you in a specific direction.