-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Shiny Random Egg
judicornadamsfoster edited this page Sep 26, 2026
·
1 revision
This code gives a random shiny egg from a list if there is space in your party
This is an alternative interpretation of Daily Random Egg
Add at end of file, before #endif
bool8 CreateShinyEggFromList(void);
contants/daycare.hlinks to the "EGG_HATCH_LEVEL" define
`new_game.h" links to the "GetTrainerId" code
Add to top of the file after the #include lines
#include "constants/daycare.h"
#include "new_game.h"
Add to the bottom of the file.
#include "constants/daycare.h"
static const u16 sShinyEggSpeciesList[] =
{
SPECIES_BULBASAUR,
SPECIES_CHARMANDER,
SPECIES_SQUIRTLE,
SPECIES_CHIKORITA,
SPECIES_CYNDAQUIL,
SPECIES_TOTODILE,
SPECIES_TREEKO,
SPECIES_TORCHIC,
SPECIES_MUDKIP,
};
static bool8 IsPersonalityShiny(u32 personality, u32 otId)
{
u16 trainerId = otId;
u16 secretId = otId >> 16;
u16 personalityHi = personality >> 16;
u16 personalityLo = personality;
return ((trainerId ^ secretId ^ personalityHi ^ personalityLo) < 8);
}
static u32 GenerateShinyPersonality(u32 otId)
{
u32 personality;
while (TRUE)
{
personality = ((u32)Random() << 16) | Random();
if (IsPersonalityShiny(personality, otId))
return personality;
}
}
bool8 CreateShinyEggFromList(void)
{
struct Pokemon *mon;
u16 species;
u32 personality;
u32 otId;
u8 egg = TRUE;
u8 friendship = 1;
u32 speciesCount;
if (gPlayerPartyCount >= PARTY_SIZE)
return FALSE;
speciesCount = ARRAY_COUNT(sShinyEggSpeciesList);
species = sShinyEggSpeciesList[Random() % speciesCount];
otId = GetTrainerId(gSaveBlock2Ptr->playerTrainerId);
personality = GenerateShinyPersonality(otId);
mon = &gPlayerParty[gPlayerPartyCount];
CreateMon(mon,
species,
EGG_HATCH_LEVEL,
USE_RANDOM_IVS,
TRUE,
personality,
OT_ID_PLAYER_ID,
0);
SetMonData(mon, MON_DATA_IS_EGG, &egg);
SetMonData(mon, MON_DATA_FRIENDSHIP, &friendship);
gPlayerPartyCount++;
CalculatePlayerPartyCount();
return TRUE;
}
rename an unused flag (0x4F in this example)
#define FLAG_RECEIVED_SHINY_RANDOM_EGG 0x4F
if you want to give the shiny egg daily, chose a daily flag instead
Add at end of file
bool8 CreateShinyEggFromList(void);
void GiveRandomShinyEgg(void)
{
if (CreateShinyEggFromList())
gSpecialVar_Result = TRUE;
else
gSpecialVar_Result = FALSE;
}
Add at end of file
def_special GiveRandomShinyEgg
add into your chosen map script (or where you store your custom scripts)
ShinyRandomEgg_EventScript_ShinyEggNPC::
lock
faceplayer
goto_if_set FLAG_RECEIVED_SHINY_RANDOM_EGG, ShinyRandomEgg_EventScript_AlreadyReceived
msgbox ShinyRandomEgg_Text_ShinyEggIntro, MSGBOX_DEFAULT
waitmessage
waitbuttonpress
special GiveRandomShinyEgg
compare VAR_RESULT, TRUE
goto_if_eq ShinyRandomEgg_EventScript_ReceiveShinyEgg
message ShinyRandomEgg_Text_NoRoomForEgg
waitmessage
waitbuttonpress
release
end
ShinyRandomEgg_EventScript_ReceiveShinyEgg:
setflag FLAG_RECEIVED_SHINY_RANDOM_EGG
playfanfare MUS_OBTAIN_ITEM
msgbox ShinyRandomEgg_Text_ReceivedShinyEgg, MSGBOX_DEFAULT
waitmessage
waitfanfare
waitbuttonpress
release
end
ShinyRandomEgg_EventScript_AlreadyReceived:
msgbox ShinyRandomEgg_Text_AlreadyReceived, MSGBOX_DEFAULT
release
end
ShinyRandomEgg_Text_ShinyEggIntro:
.string "I have a Pokémon Egg for you!\p"
.string "Take good care of it.$"
ShinyRandomEgg_Text_ReceivedShinyEgg:
.string "You received a mysterious Egg!$"
ShinyRandomEgg_Text_NoRoomForEgg:
.string "Your party is full.$"
ShinyRandomEgg_Text_AlreadyReceived:
.string "I already gave you an Egg.$"
add an overworld NPC, set the script as ShinyRandomEgg_EventScript_ShinyEggNPC
end of guide