Merge branch 'no-scams' into 'master'

No last-minute scams with Garden Top / Flame Shield (resolves #603)

Closes #603

See merge request KartKrew/Kart!1433
This commit is contained in:
James R 2023-08-27 10:27:22 +00:00
commit 92bc946d60

View file

@ -9933,7 +9933,7 @@ void K_KartUpdatePosition(player_t *player)
realplayers > 1)
{
/* grace period so you don't fall off INSTANTLY */
if (position == 1 && player->topinfirst < 2*TICRATE)
if (K_GetItemRouletteDistance(player, 8) < 2000 && player->topinfirst < 2*TICRATE) // "Why 8?" Literally no reason, but since we intend for constant-ish distance we choose a fake fixed playercount.
{
player->topinfirst++;
}
@ -10029,9 +10029,10 @@ void K_StripOther(player_t *player)
static INT32 K_FlameShieldMax(player_t *player)
{
UINT32 disttofinish = 0;
UINT32 distv = 2048;
UINT32 distv = 1024; // Pre no-scams: 2048
distv = distv * 16 / FLAMESHIELD_MAX; // Old distv was based on a 16-segment bar
UINT8 numplayers = 0;
UINT32 scamradius = 2000; // How close is close enough that we shouldn't be allowed to scam 1st?
UINT8 i;
if (gametyperules & GTR_CIRCUIT)
@ -10045,18 +10046,21 @@ static INT32 K_FlameShieldMax(player_t *player)
}
}
disttofinish = player->distancetofinish - disttofinish;
distv = FixedMul(distv, mapobjectscale);
if (numplayers <= 1)
{
return FLAMESHIELD_MAX; // max when alone, for testing
// and when in battle, for chaos
}
else if (player->position == 1)
else if (player->position == 1 || disttofinish < scamradius)
{
return 0; // minimum for first
}
disttofinish = player->distancetofinish - disttofinish;
distv = FixedMul(distv, mapobjectscale);
disttofinish = disttofinish - scamradius;
return min(FLAMESHIELD_MAX, (FLAMESHIELD_MAX / 16) + (disttofinish / distv)); // Ditto for this minimum, old value was 1/16
}