mirror of
https://github.com/resetes12/pokeemerald
synced 2025-10-06 00:12:45 +02:00
Mirage island also checks PC Pkm
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user