Make bot mashing more dynamic

Instead of being based on a fixed range of tiers, it is now based on a sine curve. The larger the useodds is the more they mash. Also don't calculate if you are going to be forced to mash anyway.
This commit is contained in:
NepDisk 2026-02-24 07:56:04 -05:00
parent 50ad49eba0
commit 21cab921fa

View file

@ -1129,41 +1129,12 @@ static UINT32 K_BotCalculateUseodds(const player_t *player)
static void K_BotItemRouletteMash(botdata_t *bd, const player_t *player)
{
boolean mash = false;
UINT32 useodds = 0;
if (bd->itemwasdown)
{
return;
}
// Mash based on useodds to approximate bots in the back mashing like players would.
if (player->position > 1)
{
useodds = K_BotCalculateUseodds(player);
if (useodds >= 4 && useodds < 8)
{
// Around 25% chance to mash
if (M_RandomChance(FRACUNIT/4))
{
mash = true;
}
}
else if (useodds >= 8 && useodds < 12)
{
// Around 50% chance to mash
if (M_RandomChance(FRACUNIT/2))
{
mash = true;
}
}
else if (useodds >= 12)
{
// We are too far back!
mash = true;
}
}
if (player->rings < 0 && K_ItemResultEnabled(K_GetKartResult("superring")))
{
// Uh oh, we need a loan!
@ -1171,6 +1142,24 @@ static void K_BotItemRouletteMash(botdata_t *bd, const player_t *player)
mash = true;
}
// Mash based on useodds to approximate bots in the back mashing like players would.
if (mash == false)
{
const fixed_t minuseodds = 4*FRACUNIT;
const fixed_t maxuseodds = 15*FRACUNIT;
fixed_t useodds = K_BotCalculateUseodds(player)*FRACUNIT;
if (useodds > minuseodds)
{
fixed_t chance = CLAMP(FixedDiv(useodds - minuseodds, maxuseodds - minuseodds), 0, FRACUNIT);
chance = Easing_InSine(chance, 0, FRACUNIT);
if (M_RandomChance(chance))
mash = true;
}
}
if (mash == true)
{
bd->itemdown = true;