Mirage island also checks PC Pkm

This commit is contained in:
resetes12
2025-02-22 17:14:45 +01:00
parent 056435c741
commit 2425a0d639
2 changed files with 35 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
#define GUARD_TIME_EVENTS_H
void UpdateMirageRnd(u16);
u8 IsMirageIslandPresent(void);
bool32 IsMirageIslandPresent(void);
void UpdateBirchState(u16);
#endif // GUARD_TIME_EVENTS_H

View File

@@ -8,6 +8,8 @@
#include "rtc.h"
#include "script.h"
#include "task.h"
#include "pokemon_storage_system.h"
#include "load_save.h"
static u32 GetMirageRnd(void)
{
@@ -39,16 +41,43 @@ void UpdateMirageRnd(u16 days)
SetMirageRnd(rnd);
}
bool8 IsMirageIslandPresent(void)
bool32 IsMirageIslandPresent(void)
{
u16 rnd = GetMirageRnd() >> 16;
int i;
u32 hi = gSaveBlock1Ptr->vars[VAR_MIRAGE_RND_H - VARS_START];
u32 lo = gSaveBlock1Ptr->vars[VAR_MIRAGE_RND_L - VARS_START];
u32 rnd = ((hi << 16) | lo) >> 16;
bool32 species;
u32 personality;
int i, j;
struct Pokemon * curMon = &gPlayerParty[0];
struct Pokemon * partyEnd = &gPlayerParty[PARTY_SIZE];
for (i = 0; i < PARTY_SIZE; i++)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && (GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY) & 0xFFFF) == rnd)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) == SPECIES_MEW)
return TRUE;
else if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) == SPECIES_MEW)
do
{
species = curMon->box.hasSpecies;
if (!species)
break;
personality = curMon->box.personality & 0xFFFF;
if (personality == rnd)
return TRUE;
} while (++curMon < partyEnd);
struct BoxPokemon * curBoxMon = &gPokemonStoragePtr->boxes[0];
struct BoxPokemon * boxMonEnd = &gPokemonStoragePtr->boxes[TOTAL_BOXES_COUNT * IN_BOX_COUNT];
do {
species = curBoxMon->hasSpecies;
if (species) {
personality = curBoxMon->personality & 0xffff;
if (personality == rnd) {
return TRUE;
}
}
} while (++curBoxMon < boxMonEnd);
return FALSE;
}