Nice things

- Fix off-by-one error in shieldout code
- Added KartItemCVars array for anything to use
- More I_Asserts in item logic
This commit is contained in:
TehRealSalt 2019-05-20 14:17:16 -04:00
parent 480d56838f
commit 1e7b79144d
3 changed files with 48 additions and 63 deletions

View file

@ -649,10 +649,39 @@ fixed_t K_GetKartGameSpeedScalar(SINT8 value)
//{ SRB2kart Roulette Code - Position Based
consvar_t *KartItemCVars[NUMKARTRESULTS-1] =
{
&cv_sneaker,
&cv_rocketsneaker,
&cv_invincibility,
&cv_banana,
&cv_eggmanmonitor,
&cv_orbinaut,
&cv_jawz,
&cv_mine,
&cv_ballhog,
&cv_selfpropelledbomb,
&cv_grow,
&cv_shrink,
&cv_thundershield,
&cv_bubbleshield,
&cv_flameshield,
&cv_hyudoro,
&cv_pogospring,
&cv_superring,
&cv_kitchensink,
&cv_triplesneaker,
&cv_triplebanana,
&cv_decabanana,
&cv_tripleorbinaut,
&cv_quadorbinaut,
&cv_dualjawz
};
#define NUMKARTODDS 80
// Less ugly 2D arrays
static INT32 K_KartItemOddsRace[NUMKARTRESULTS][8] =
static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] =
{
//P-Odds 0 1 2 3 4 5 6 7
/*Sneaker*/ { 0, 0, 3, 5, 6, 0, 0, 0 }, // Sneaker
@ -682,7 +711,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS][8] =
/*Jawz x2*/ { 0, 0, 1, 2, 0, 0, 0, 0 } // Jawz x2
};
static INT32 K_KartItemOddsBattle[NUMKARTRESULTS][6] =
static INT32 K_KartItemOddsBattle[NUMKARTRESULTS-1][6] =
{
//P-Odds 0 1 2 3 4 5
/*Sneaker*/ { 3, 2, 2, 2, 0, 2 }, // Sneaker
@ -796,43 +825,23 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp
SINT8 first = -1, second = -1;
INT32 secondist = 0;
INT32 shieldtype = KSHIELD_NONE;
boolean itemenabled[NUMKARTRESULTS-1] = {
cv_sneaker.value,
cv_rocketsneaker.value,
cv_invincibility.value,
cv_banana.value,
cv_eggmanmonitor.value,
cv_orbinaut.value,
cv_jawz.value,
cv_mine.value,
cv_ballhog.value,
cv_selfpropelledbomb.value,
cv_grow.value,
cv_shrink.value,
cv_thundershield.value,
cv_bubbleshield.value,
cv_flameshield.value,
cv_hyudoro.value,
cv_pogospring.value,
cv_superring.value,
cv_kitchensink.value,
cv_triplesneaker.value,
cv_triplebanana.value,
cv_decabanana.value,
cv_tripleorbinaut.value,
cv_quadorbinaut.value,
cv_dualjawz.value
};
I_Assert(item > KITEM_NONE); // too many off by one scenarioes.
I_Assert(KartItemCVars[NUMKARTRESULTS-2] != NULL); // Make sure this exists
if (!itemenabled[item-1] && !modeattacking)
if (!KartItemCVars[item-1]->value && !modeattacking)
return 0;
if (G_BattleGametype())
{
I_Assert(pos < 6); // DO NOT allow positions past the bounds of the table
newodds = K_KartItemOddsBattle[item-1][pos];
}
else
{
I_Assert(pos < 8); // Ditto
newodds = K_KartItemOddsRace[item-1][pos];
}
// Base multiplication to ALL item odds to simulate fractional precision
newodds *= 4;
@ -875,7 +884,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp
// Don't allow more than one of each shield type at a time
shieldtype = K_GetShieldFromItem(item);
if (shieldout[shieldtype-1])
if (shieldtype != KSHIELD_NONE && shieldout[shieldtype-1])
return 0;
// POWERITEMODDS handles all of the "frantic item" related functionality, for all of our powerful items.

View file

@ -23,6 +23,9 @@ void K_RegisterKartStuff(void);
boolean K_IsPlayerLosing(player_t *player);
boolean K_IsPlayerWanted(player_t *player);
fixed_t K_GetKartGameSpeedScalar(SINT8 value);
consvar_t *KartItemCVars[NUMKARTRESULTS-1];
INT32 K_GetShieldFromItem(INT32 item);
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid);
void K_KartPainEnergyFling(player_t *player);

View file

@ -10608,33 +10608,6 @@ static void M_HandleVideoMode(INT32 ch)
// ===============
// Monitor Toggles
// ===============
static consvar_t *kartitemcvs[NUMKARTRESULTS-1] = {
&cv_sneaker,
&cv_rocketsneaker,
&cv_invincibility,
&cv_banana,
&cv_eggmanmonitor,
&cv_orbinaut,
&cv_jawz,
&cv_mine,
&cv_ballhog,
&cv_selfpropelledbomb,
&cv_grow,
&cv_shrink,
&cv_thundershield,
&cv_bubbleshield,
&cv_flameshield,
&cv_hyudoro,
&cv_pogospring,
&cv_superring,
&cv_kitchensink,
&cv_triplesneaker,
&cv_triplebanana,
&cv_decabanana,
&cv_tripleorbinaut,
&cv_quadorbinaut,
&cv_dualjawz
};
static tic_t shitsfree = 0;
@ -10703,7 +10676,7 @@ static void M_DrawMonitorToggles(void)
continue;
}
cv = kartitemcvs[currentMenu->menuitems[thisitem].alphaKey-1];
cv = KartItemCVars[currentMenu->menuitems[thisitem].alphaKey-1];
translucent = (cv->value ? 0 : V_TRANSLUCENT);
switch (currentMenu->menuitems[thisitem].alphaKey)
@ -10772,7 +10745,7 @@ static void M_DrawMonitorToggles(void)
}
else
{
cv = kartitemcvs[currentMenu->menuitems[itemOn].alphaKey-1];
cv = KartItemCVars[currentMenu->menuitems[itemOn].alphaKey-1];
translucent = (cv->value ? 0 : V_TRANSLUCENT);
switch (currentMenu->menuitems[itemOn].alphaKey)
@ -10888,14 +10861,14 @@ static void M_HandleMonitorToggles(INT32 choice)
S_StartSound(NULL, sfx_s1b4);
for (i = 0; i < NUMKARTRESULTS-1; i++)
{
if (kartitemcvs[i]->value == v)
CV_AddValue(kartitemcvs[i], 1);
if (KartItemCVars[i]->value == v)
CV_AddValue(KartItemCVars[i], 1);
}
}
else
{
S_StartSound(NULL, sfx_s1ba);
CV_AddValue(kartitemcvs[currentMenu->menuitems[itemOn].alphaKey-1], 1);
CV_AddValue(KartItemCVars[currentMenu->menuitems[itemOn].alphaKey-1], 1);
}
break;