mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Split powerItem etc conditions from K_KartGetItemOdds
This commit is contained in:
parent
aab661cad8
commit
a37eccd708
1 changed files with 77 additions and 47 deletions
124
src/k_roulette.c
124
src/k_roulette.c
|
|
@ -510,6 +510,62 @@ static fixed_t K_AdjustSPBOdds(const itemroulette_t *roulette, UINT8 position)
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
boolean powerItem;
|
||||
boolean cooldownOnStart;
|
||||
boolean notNearEnd;
|
||||
|
||||
// gameplay state
|
||||
boolean rival; // player is a bot Rival
|
||||
} itemconditions_t;
|
||||
|
||||
/*--------------------------------------------------
|
||||
static fixed_t K_AdjustItemOddsToConditions(fixed_t newOdds, const itemconditions_t *conditions, const itemroulette_t *roulette)
|
||||
|
||||
Adjust item odds to certain group conditions.
|
||||
|
||||
Input Arguments:-
|
||||
newOdds - The item odds to adjust.
|
||||
conditions - The conditions state.
|
||||
roulette - The roulette data that we intend to
|
||||
insert this item into.
|
||||
|
||||
Return:-
|
||||
New item odds.
|
||||
--------------------------------------------------*/
|
||||
static fixed_t K_AdjustItemOddsToConditions(fixed_t newOdds, const itemconditions_t *conditions, const itemroulette_t *roulette)
|
||||
{
|
||||
if ((conditions->cooldownOnStart == true) && (leveltime < (30*TICRATE) + starttime))
|
||||
{
|
||||
// This item should not appear at the beginning of a race. (Usually really powerful crowd-breaking items)
|
||||
newOdds = 0;
|
||||
}
|
||||
else if ((conditions->notNearEnd == true) && (roulette->baseDist < ENDDIST))
|
||||
{
|
||||
// This item should not appear at the end of a race. (Usually trap items that lose their effectiveness)
|
||||
newOdds = 0;
|
||||
}
|
||||
else if (conditions->powerItem == true)
|
||||
{
|
||||
// This item is a "power item". This activates "frantic item" toggle related functionality.
|
||||
if (franticitems == true)
|
||||
{
|
||||
// First, power items multiply their odds by 2 if frantic items are on; easy-peasy.
|
||||
newOdds *= 2;
|
||||
}
|
||||
|
||||
if (conditions->rival == true)
|
||||
{
|
||||
// The Rival bot gets frantic-like items, also :p
|
||||
newOdds *= 2;
|
||||
}
|
||||
|
||||
newOdds = FixedMul(newOdds, FRACUNIT + K_ItemOddsScale(roulette->playing));
|
||||
}
|
||||
|
||||
return newOdds;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette, UINT8 pos, kartitems_t item)
|
||||
|
||||
|
|
@ -518,12 +574,14 @@ static fixed_t K_AdjustSPBOdds(const itemroulette_t *roulette, UINT8 position)
|
|||
INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette, UINT8 pos, kartitems_t item)
|
||||
{
|
||||
boolean bot = false;
|
||||
boolean rival = false;
|
||||
UINT8 position = 0;
|
||||
|
||||
boolean powerItem = false;
|
||||
boolean cooldownOnStart = false;
|
||||
boolean notNearEnd = false;
|
||||
itemconditions_t conditions = {
|
||||
.powerItem = false,
|
||||
.cooldownOnStart = false,
|
||||
.notNearEnd = false,
|
||||
.rival = false,
|
||||
};
|
||||
|
||||
fixed_t newOdds = 0;
|
||||
|
||||
|
|
@ -535,7 +593,7 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
if (player != NULL)
|
||||
{
|
||||
bot = player->bot;
|
||||
rival = (bot == true && player->botvars.rival == true);
|
||||
conditions.rival = (bot == true && player->botvars.rival == true);
|
||||
position = player->position;
|
||||
}
|
||||
|
||||
|
|
@ -597,7 +655,7 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
case KITEM_EGGMAN:
|
||||
case KITEM_SUPERRING:
|
||||
{
|
||||
notNearEnd = true;
|
||||
conditions.notNearEnd = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -611,15 +669,15 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
case KRITEM_QUADORBINAUT:
|
||||
case KRITEM_DUALJAWZ:
|
||||
{
|
||||
powerItem = true;
|
||||
conditions.powerItem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case KITEM_HYUDORO:
|
||||
case KRITEM_TRIPLEBANANA:
|
||||
{
|
||||
powerItem = true;
|
||||
notNearEnd = true;
|
||||
conditions.powerItem = true;
|
||||
conditions.notNearEnd = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -629,15 +687,15 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
case KITEM_BUBBLESHIELD:
|
||||
case KITEM_FLAMESHIELD:
|
||||
{
|
||||
cooldownOnStart = true;
|
||||
powerItem = true;
|
||||
conditions.cooldownOnStart = true;
|
||||
conditions.powerItem = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case KITEM_SPB:
|
||||
{
|
||||
cooldownOnStart = true;
|
||||
notNearEnd = true;
|
||||
conditions.cooldownOnStart = true;
|
||||
conditions.notNearEnd = true;
|
||||
|
||||
if ((gametyperules & GTR_CIRCUIT) == 0)
|
||||
{
|
||||
|
|
@ -654,9 +712,9 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
|
||||
case KITEM_SHRINK:
|
||||
{
|
||||
cooldownOnStart = true;
|
||||
powerItem = true;
|
||||
notNearEnd = true;
|
||||
conditions.cooldownOnStart = true;
|
||||
conditions.powerItem = true;
|
||||
conditions.notNearEnd = true;
|
||||
|
||||
if (roulette->playing - 1 <= roulette->exiting)
|
||||
{
|
||||
|
|
@ -667,8 +725,8 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
|
||||
case KITEM_LIGHTNINGSHIELD:
|
||||
{
|
||||
cooldownOnStart = true;
|
||||
powerItem = true;
|
||||
conditions.cooldownOnStart = true;
|
||||
conditions.powerItem = true;
|
||||
|
||||
if (spbplace != -1)
|
||||
{
|
||||
|
|
@ -689,35 +747,7 @@ INT32 K_KartGetItemOdds(const player_t *player, itemroulette_t *const roulette,
|
|||
return newOdds;
|
||||
}
|
||||
|
||||
if ((cooldownOnStart == true) && (leveltime < (30*TICRATE)+starttime))
|
||||
{
|
||||
// This item should not appear at the beginning of a race. (Usually really powerful crowd-breaking items)
|
||||
newOdds = 0;
|
||||
}
|
||||
else if ((notNearEnd == true) && (roulette->baseDist < ENDDIST))
|
||||
{
|
||||
// This item should not appear at the end of a race. (Usually trap items that lose their effectiveness)
|
||||
newOdds = 0;
|
||||
}
|
||||
else if (powerItem == true)
|
||||
{
|
||||
// This item is a "power item". This activates "frantic item" toggle related functionality.
|
||||
if (franticitems == true)
|
||||
{
|
||||
// First, power items multiply their odds by 2 if frantic items are on; easy-peasy.
|
||||
newOdds *= 2;
|
||||
}
|
||||
|
||||
if (rival == true)
|
||||
{
|
||||
// The Rival bot gets frantic-like items, also :p
|
||||
newOdds *= 2;
|
||||
}
|
||||
|
||||
newOdds = FixedMul(newOdds, FRACUNIT + K_ItemOddsScale(roulette->playing));
|
||||
}
|
||||
|
||||
newOdds = FixedInt(FixedRound(newOdds));
|
||||
newOdds = FixedInt(FixedRound(K_AdjustItemOddsToConditions(newOdds, &conditions, roulette)));
|
||||
return newOdds;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue