Merge branch 'force-spb' into 'master'

Beyond a certain threshold, forcefully give 2nd a SPB if one's not already out.

See merge request KartKrew/Kart!119
This commit is contained in:
Sal 2018-12-05 21:43:59 -05:00
commit 261319b754
1 changed files with 43 additions and 32 deletions

View File

@ -493,31 +493,31 @@ boolean K_IsPlayerWanted(player_t *player)
#define NUMKARTODDS 80
// Less ugly 2D arrays
static INT32 K_KartItemOddsRace[NUMKARTRESULTS][9] =
static INT32 K_KartItemOddsRace[NUMKARTRESULTS][10] =
{
//P-Odds 0 1 2 3 4 5 6 7 8
/*Sneaker*/ {20, 0, 0, 4, 6, 6, 0, 0, 0 }, // Sneaker
/*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3 }, // Rocket Sneaker
/*Invincibility*/ { 0, 0, 0, 0, 0, 1, 4, 6,14 }, // Invincibility
/*Banana*/ { 0, 9, 4, 2, 1, 0, 0, 0, 0 }, // Banana
/*Eggman Monitor*/ { 0, 4, 3, 2, 0, 0, 0, 0, 0 }, // Eggman Monitor
/*Orbinaut*/ { 0, 6, 5, 3, 2, 0, 0, 0, 0 }, // Orbinaut
/*Jawz*/ { 0, 0, 3, 2, 1, 1, 0, 0, 0 }, // Jawz
/*Mine*/ { 0, 0, 2, 2, 1, 0, 0, 0, 0 }, // Mine
/*Ballhog*/ { 0, 0, 0, 2, 1, 0, 0, 0, 0 }, // Ballhog
/*Self-Propelled Bomb*/ { 0, 0, 1, 2, 3, 4, 2, 2, 0 }, // Self-Propelled Bomb
/*Grow*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3 }, // Grow
/*Shrink*/ { 0, 0, 0, 0, 0, 0, 0, 2, 0 }, // Shrink
/*Thunder Shield*/ { 0, 1, 2, 0, 0, 0, 0, 0, 0 }, // Thunder Shield
/*Hyudoro*/ { 0, 0, 0, 0, 1, 2, 1, 0, 0 }, // Hyudoro
/*Pogo Spring*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Pogo Spring
/*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink
/*Sneaker x3*/ { 0, 0, 0, 0, 3, 7, 9, 2, 0 }, // Sneaker x3
/*Banana x3*/ { 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // Banana x3
/*Banana x10*/ { 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // Banana x10
/*Orbinaut x3*/ { 0, 0, 0, 1, 0, 0, 0, 0, 0 }, // Orbinaut x3
/*Orbinaut x4*/ { 0, 0, 0, 0, 1, 1, 0, 0, 0 }, // Orbinaut x4
/*Jawz x2*/ { 0, 0, 0, 1, 2, 0, 0, 0, 0 } // Jawz x2
//P-Odds 0 1 2 3 4 5 6 7 8 9
/*Sneaker*/ {20, 0, 0, 4, 6, 6, 0, 0, 0, 0 }, // Sneaker
/*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3, 0 }, // Rocket Sneaker
/*Invincibility*/ { 0, 0, 0, 0, 0, 1, 4, 6,14, 0 }, // Invincibility
/*Banana*/ { 0, 9, 4, 2, 1, 0, 0, 0, 0, 0 }, // Banana
/*Eggman Monitor*/ { 0, 4, 3, 2, 0, 0, 0, 0, 0, 0 }, // Eggman Monitor
/*Orbinaut*/ { 0, 6, 5, 3, 2, 0, 0, 0, 0, 0 }, // Orbinaut
/*Jawz*/ { 0, 0, 3, 2, 1, 1, 0, 0, 0, 0 }, // Jawz
/*Mine*/ { 0, 0, 2, 2, 1, 0, 0, 0, 0, 0 }, // Mine
/*Ballhog*/ { 0, 0, 0, 2, 1, 0, 0, 0, 0, 0 }, // Ballhog
/*Self-Propelled Bomb*/ { 0, 0, 1, 2, 3, 4, 2, 2, 0,20 }, // Self-Propelled Bomb
/*Grow*/ { 0, 0, 0, 0, 0, 1, 3, 5, 3, 0 }, // Grow
/*Shrink*/ { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0 }, // Shrink
/*Thunder Shield*/ { 0, 1, 2, 0, 0, 0, 0, 0, 0, 0 }, // Thunder Shield
/*Hyudoro*/ { 0, 0, 0, 0, 1, 2, 1, 0, 0, 0 }, // Hyudoro
/*Pogo Spring*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Pogo Spring
/*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink
/*Sneaker x3*/ { 0, 0, 0, 0, 3, 7, 9, 2, 0, 0 }, // Sneaker x3
/*Banana x3*/ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 }, // Banana x3
/*Banana x10*/ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, // Banana x10
/*Orbinaut x3*/ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, // Orbinaut x3
/*Orbinaut x4*/ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 }, // Orbinaut x4
/*Jawz x2*/ { 0, 0, 0, 1, 2, 0, 0, 0, 0, 0 } // Jawz x2
};
static INT32 K_KartItemOddsBattle[NUMKARTRESULTS][6] =
@ -706,12 +706,13 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed)
break;
case KITEM_SPB:
//POWERITEMODDS(newodds);
if ((!cv_selfpropelledbomb.value)
if (((!cv_selfpropelledbomb.value)
|| (indirectitemcooldown > 0)
|| (pexiting > 0)
|| (secondist/distvar < (4+gamespeed)))
|| (secondist/distvar < 3))
&& (pos != 9)) // Force SPB
newodds = 0;
newodds *= min((secondist/distvar)-(3+gamespeed), 3);
newodds *= min((secondist/distvar)-4, 3);
break;
case KITEM_GROW:
POWERITEMODDS(newodds);
@ -770,16 +771,16 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed)
//{ SRB2kart Roulette Code - Distance Based, no waypoints
static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush)
static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT32 bestbumper, boolean spbrush, boolean dontforcespb)
{
const INT32 distvar = (64*14);
INT32 i;
INT32 pdis = 0, useodds = 0;
UINT8 disttable[14];
UINT8 distlen = 0;
boolean oddsvalid[9];
boolean oddsvalid[10];
for (i = 0; i < 9; i++)
for (i = 0; i < 10; i++)
{
INT32 j;
boolean available = false;
@ -860,6 +861,10 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3
useodds = 0;
else if (pdis <= 0) // (64*14) * 0 = 0
useodds = disttable[0];
else if (player->kartstuff[k_position] == 2 && pdis > (distvar*6)
&& spbplace == -1 && !indirectitemcooldown && !dontforcespb
&& oddsvalid[9]) // Force SPB in 2nd
useodds = 9;
else if (pdis > distvar * ((12 * distlen) / 14)) // (64*14) * 12 = 10752
useodds = disttable[distlen-1];
else
@ -892,6 +897,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
INT32 chance = 0, numchoices = 0;
INT32 bestbumper = 0;
fixed_t mashed = 0;
boolean dontforcespb = false;
// This makes the roulette cycle through items - if this is 0, you shouldn't be here.
if (player->kartstuff[k_itemroulette])
@ -905,6 +911,8 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
if (!playeringame[i] || players[i].spectator)
continue;
pingame++;
if (players[i].exiting)
dontforcespb = true;
if (players[i].kartstuff[k_bumper] > bestbumper)
bestbumper = players[i].kartstuff[k_bumper];
}
@ -987,7 +995,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
spawnchance[i] = 0;
// Split into another function for a debug function below
useodds = K_FindUseodds(player, mashed, pingame, bestbumper, (spbplace != -1 && player->kartstuff[k_position] == spbplace+1));
useodds = K_FindUseodds(player, mashed, pingame, bestbumper, (spbplace != -1 && player->kartstuff[k_position] == spbplace+1), dontforcespb);
#define SETITEMRESULT(itemnum) \
for (chance = 0; chance < K_KartGetItemOdds(useodds, itemnum, mashed); chance++) \
@ -7983,6 +7991,7 @@ static void K_drawDistributionDebugger(void)
INT32 pingame = 0, bestbumper = 0;
INT32 i;
INT32 x = -9, y = -9;
boolean dontforcespb = false;
if (stplyr != &players[displayplayer]) // only for p1
return;
@ -7993,11 +8002,13 @@ static void K_drawDistributionDebugger(void)
if (!playeringame[i] || players[i].spectator)
continue;
pingame++;
if (players[i].exiting)
dontforcespb = true;
if (players[i].kartstuff[k_bumper] > bestbumper)
bestbumper = players[i].kartstuff[k_bumper];
}
useodds = K_FindUseodds(stplyr, 0, pingame, bestbumper, (spbplace != -1 && stplyr->kartstuff[k_position] == spbplace+1));
useodds = K_FindUseodds(stplyr, 0, pingame, bestbumper, (spbplace != -1 && stplyr->kartstuff[k_position] == spbplace+1), dontforcespb);
for (i = 1; i < NUMKARTRESULTS; i++)
{