Roulette speed adjustments

- Speeds up the farther in the course you are
- Speeds up the further in the front you are
- Slows down before the 20 second mark
This commit is contained in:
Sally Coolatta 2022-12-12 04:01:09 -05:00
parent 10145b75d1
commit c8f3533b00

View file

@ -62,11 +62,15 @@
#define SPBFORCEDIST (14*DISTVAR) #define SPBFORCEDIST (14*DISTVAR)
// Distance when the game stops giving you bananas // Distance when the game stops giving you bananas
#define ENDDIST (12*DISTVAR) #define ENDDIST (18*DISTVAR)
// Consistent seed used for item reels // Consistent seed used for item reels
#define ITEM_REEL_SEED (0x22D5FAA8) #define ITEM_REEL_SEED (0x22D5FAA8)
#define ROULETTE_SPEED_SLOWEST (12)
#define ROULETTE_SPEED_FASTEST (2)
#define ROULETTE_SPEED_DIST (224*DISTVAR)
static UINT8 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = static UINT8 K_KartItemOddsRace[NUMKARTRESULTS-1][8] =
{ {
{ 0, 0, 2, 3, 4, 0, 0, 0 }, // Sneaker { 0, 0, 2, 3, 4, 0, 0, 0 }, // Sneaker
@ -759,17 +763,66 @@ static void K_PushToRouletteItemList(itemroulette_t *const roulette, kartitems_t
roulette->itemListLen++; roulette->itemListLen++;
} }
static void K_CalculateRouletteSpeed(player_t *const player, itemroulette_t *const roulette, UINT8 playing) static void K_CalculateRouletteSpeed(player_t *const player, itemroulette_t *const roulette)
{ {
// TODO: Change speed based on two factors: // TODO: Change speed based on two factors:
// - Get faster when your distancetofinish is closer to 1st place's distancetofinish. (winning) // - Get faster when your distancetofinish is closer to 1st place's distancetofinish. (winning)
// - Get faster based on overall distancetofinish (race progress) // - Get faster based on overall distancetofinish (race progress)
// Slowest speed should be 12 tics, fastest should be 3 tics. // Slowest speed should be 12 tics, fastest should be 3 tics.
(void)player; fixed_t frontRun = 0;
(void)playing; fixed_t progress = 0;
fixed_t total = 0;
roulette->tics = roulette->speed = 7; UINT8 playing = 0;
UINT32 firstDist = UINT32_MAX;
UINT32 ourDist = UINT32_MAX;
size_t i;
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] == false || players[i].spectator == true)
{
continue;
}
playing++;
if (players[i].position == 1)
{
firstDist = players[i].distancetofinish;
}
}
ourDist = K_ScaleItemDistance(player->distancetofinish, playing);
firstDist = K_ScaleItemDistance(firstDist, playing);
if (ourDist > ENDDIST)
{
// Being farther in the course makes your roulette faster.
progress = min(FRACUNIT, FixedDiv(ourDist - ENDDIST, ROULETTE_SPEED_DIST));
}
if (ourDist > firstDist)
{
// Frontrunning makes your roulette faster.
frontRun = min(FRACUNIT, FixedDiv(ourDist - firstDist, ENDDIST));
}
// Combine our two factors together.
total = min(FRACUNIT, (frontRun / 2) + (progress / 2));
if (leveltime < starttime + 20*TICRATE)
{
// Don't impact as much at the start.
// This makes it so that everyone gets to enjoy the lowest speed at the start.
fixed_t lerp = FRACUNIT - FixedDiv(max(0, leveltime - starttime), 10*TICRATE);
total += FixedMul(lerp, FRACUNIT - total);
}
roulette->tics = roulette->speed = ROULETTE_SPEED_FASTEST + FixedMul(ROULETTE_SPEED_SLOWEST - ROULETTE_SPEED_FASTEST, total);
} }
void K_StartItemRoulette(player_t *const player, itemroulette_t *const roulette) void K_StartItemRoulette(player_t *const player, itemroulette_t *const roulette)
@ -785,18 +838,7 @@ void K_StartItemRoulette(player_t *const player, itemroulette_t *const roulette)
size_t i; size_t i;
K_InitRoulette(roulette); K_InitRoulette(roulette);
K_CalculateRouletteSpeed(player, roulette);
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] == false || players[i].spectator == true)
{
continue;
}
playing++;
}
K_CalculateRouletteSpeed(player, roulette, playing);
// SPECIAL CASE No. 1: // SPECIAL CASE No. 1:
// Give only the debug item if specified // Give only the debug item if specified
@ -808,6 +850,16 @@ void K_StartItemRoulette(player_t *const player, itemroulette_t *const roulette)
// SPECIAL CASE No. 2: // SPECIAL CASE No. 2:
// Use a special, pre-determined item reel for Time Attack / Free Play // Use a special, pre-determined item reel for Time Attack / Free Play
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] == false || players[i].spectator == true)
{
continue;
}
playing++;
}
if (bossinfo.boss == true) if (bossinfo.boss == true)
{ {
for (i = 0; K_KartItemReelBoss[i] != KITEM_NONE; i++) for (i = 0; K_KartItemReelBoss[i] != KITEM_NONE; i++)