Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Pyramid Encounter fixes #4326

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/battle_pyramid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,27 +1401,32 @@ void GenerateBattlePyramidWildMon(void)

if (reqs->nMoves != 0)
moves = AllocZeroed(sizeof(u16) * reqs->nMoves);

if (reqs->nAbilities != 0)
abilities = AllocZeroed(sizeof(u16) * reqs->nAbilities);

if (round >= TOTAL_PYRAMID_ROUNDS)
round = TOTAL_PYRAMID_ROUNDS - 1;

id = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL) - 1; // index in table (0-11) -> higher index is lower probability
bstLim = 450 + (25*round) + (5*id); // higher BST limit for 'rarer' wild mon rolls

while (1)
{
species = Random() % FORMS_START;
species = Random() % NUM_SPECIES;

// check if base species
if (!GET_BASE_SPECIES_ID(species))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't GET_BASE_SPECIES_ID return a species ID? So shouldn't this be if (GET_BASE_SPECIES_ID(species) != species) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. sorry, should be fixed now.

continue;

// check type
if (reqs->type != TYPE_MYSTERY && gSpeciesInfo[species].types[0] != reqs->type && gSpeciesInfo[species].types[1] != reqs->type)
continue;

// check base stat total
if (GetTotalBaseStat(species) > bstLim)
continue;

// check moves
if (reqs->nMoves != 0)
{
Expand All @@ -1438,7 +1443,7 @@ void GenerateBattlePyramidWildMon(void)
if (moveCount == 0)
continue;
}

// check abilities
if (reqs->nAbilities != 0)
{
Expand All @@ -1460,9 +1465,9 @@ void GenerateBattlePyramidWildMon(void)
continue;
}
// check evos
if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evoItems, reqs->nEvoItems))
if (reqs->evoItems != NULL && !CheckBattlePyramidEvoRequirement(species, reqs->evoItems, reqs->nEvoItems))
continue;

// we found a species we can use!
break;
}
Expand All @@ -1471,7 +1476,7 @@ void GenerateBattlePyramidWildMon(void)
SetMonData(&gEnemyParty[0], MON_DATA_SPECIES, &species);
StringCopy(name, GetSpeciesName(species));
SetMonData(&gEnemyParty[0], MON_DATA_NICKNAME, &name);

// set level
if (lvl != FRONTIER_LVL_50)
{
Expand Down Expand Up @@ -1507,7 +1512,7 @@ void GenerateBattlePyramidWildMon(void)
}
Free(moves);
}

// Initialize a random ability num
if (gSpeciesInfo[species].abilities[1])
{
Expand All @@ -1519,7 +1524,7 @@ void GenerateBattlePyramidWildMon(void)
i = 0;
SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &i);
}

// Try to replace with desired ability
if (abilities != NULL)
{
Expand All @@ -1533,12 +1538,15 @@ void GenerateBattlePyramidWildMon(void)
{
// Set this ability num
SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &id);
break;
}
}
if (id >= NUM_ABILITY_SLOTS - 1)
break;
}
Free(abilities);
}

if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[gSaveBlock2Ptr->frontier.lvlMode] >= 140)
{
id = (Random() % 17) + 15;
Expand Down
Loading