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

Fix daycare move transferring between evolved mons and allow sharing moves between different forms of the same species #4479

Merged
merged 9 commits into from
Jun 7, 2024
2 changes: 1 addition & 1 deletion include/daycare.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void SetDaycareCompatibilityString(void);
bool8 NameHasGenderSymbol(const u8 *name, u8 genderRatio);
void ShowDaycareLevelMenu(void);
void ChooseSendDaycareMon(void);
u8 GetEggMovesSpecies(u16 species, u16 *eggMoves);
u8 GetEggMovesBySpecies(u16 species, u16 *eggMoves);
bool8 SpeciesCanLearnEggMove(u16 species, u16 move);

#endif // GUARD_DAYCARE_H
71 changes: 42 additions & 29 deletions src/daycare.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *
static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y);
static u8 ModifyBreedingScoreForOvalCharm(u8 score);
static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves);
static u16 GetEggSpecies(u16 species);

// RAM buffers used to assist with BuildEggMoveset()
EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0};
Expand Down Expand Up @@ -86,6 +87,24 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate =
.cursorKind = CURSOR_BLACK_ARROW
};

static const struct {
u16 currSpecies;
u16 item;
u16 babySpecies;
} sIncenseBabyTable[] =
{
// Regular offspring, Item, Incense Offspring
{ SPECIES_WOBBUFFET, ITEM_LAX_INCENSE, SPECIES_WYNAUT },
{ SPECIES_MARILL, ITEM_SEA_INCENSE, SPECIES_AZURILL },
{ SPECIES_SNORLAX, ITEM_FULL_INCENSE, SPECIES_MUNCHLAX },
{ SPECIES_CHANSEY, ITEM_LUCK_INCENSE, SPECIES_HAPPINY },
{ SPECIES_MR_MIME, ITEM_ODD_INCENSE, SPECIES_MIME_JR },
{ SPECIES_CHIMECHO, ITEM_PURE_INCENSE, SPECIES_CHINGLING },
{ SPECIES_SUDOWOODO, ITEM_ROCK_INCENSE, SPECIES_BONSLY },
{ SPECIES_ROSELIA, ITEM_ROSE_INCENSE, SPECIES_BUDEW },
{ SPECIES_MANTINE, ITEM_WAVE_INCENSE, SPECIES_MANTYKE },
};

static const u8 *const sCompatibilityMessages[] =
{
gDaycareText_GetAlongVeryWell,
Expand Down Expand Up @@ -174,26 +193,42 @@ static void TransferEggMoves(void)
{
u32 i, j, k, l;
u16 numEggMoves;
struct Pokemon mon;

for (i = 0; i < DAYCARE_MON_COUNT; i++)
{
u16 moveLearnerSpecies = GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SPECIES);
u16 eggSpecies = GetEggSpecies(moveLearnerSpecies);

if (!GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SANITY_HAS_SPECIES))
continue;

BoxMonToMon(&gSaveBlock1Ptr->daycare.mons[i].mon, &mon);
// Prevent non-baby species from learning incense baby egg moves
if (P_INCENSE_BREEDING < GEN_9 && eggSpecies != moveLearnerSpecies)
{
for (j = 0; j < ARRAY_COUNT(sIncenseBabyTable); j++)
{
if (sIncenseBabyTable[j].babySpecies == eggSpecies)
{
eggSpecies = sIncenseBabyTable[j].currSpecies;
break;
}
}
}

ClearHatchedEggMoves();
numEggMoves = GetEggMoves(&mon, sHatchedEggEggMoves);
numEggMoves = GetEggMovesBySpecies(eggSpecies, sHatchedEggEggMoves);
for (j = 0; j < numEggMoves; j++)
{
// Go through other Daycare mons
for (k = 0; k < DAYCARE_MON_COUNT; k++)
{
u16 moveTeacherSpecies = GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_SPECIES);

if (k == i || !GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_SANITY_HAS_SPECIES))
continue;

// Check if you can inherit from them
if (GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_SPECIES) != GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SPECIES)
if (GET_BASE_SPECIES_ID(moveTeacherSpecies) != GET_BASE_SPECIES_ID(moveLearnerSpecies)
&& (P_EGG_MOVE_TRANSFER < GEN_9 || GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_HELD_ITEM) != ITEM_MIRROR_HERB)
)
continue;
Expand Down Expand Up @@ -770,7 +805,7 @@ static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves)
return numEggMoves;
}

u8 GetEggMovesSpecies(u16 species, u16 *eggMoves)
u8 GetEggMovesBySpecies(u16 species, u16 *eggMoves)
{
u16 eggMoveIdx;
u16 numEggMoves;
Expand Down Expand Up @@ -954,26 +989,6 @@ void RejectEggFromDayCare(void)
RemoveEggFromDayCare(&gSaveBlock1Ptr->daycare);
}


static const struct {
u16 currSpecies;
u16 item;
u16 babySpecies;
} sIncenseBabyTable[] =
{
// Regular offspring, Item, Incense Offspring
{ SPECIES_WOBBUFFET, ITEM_LAX_INCENSE, SPECIES_WYNAUT },
{ SPECIES_MARILL, ITEM_SEA_INCENSE, SPECIES_AZURILL },
{ SPECIES_SNORLAX, ITEM_FULL_INCENSE, SPECIES_MUNCHLAX },
{ SPECIES_CHANSEY, ITEM_LUCK_INCENSE, SPECIES_HAPPINY },
{ SPECIES_MR_MIME, ITEM_ODD_INCENSE, SPECIES_MIME_JR },
{ SPECIES_CHIMECHO, ITEM_PURE_INCENSE, SPECIES_CHINGLING },
{ SPECIES_SUDOWOODO, ITEM_ROCK_INCENSE, SPECIES_BONSLY },
{ SPECIES_ROSELIA, ITEM_ROSE_INCENSE, SPECIES_BUDEW },
{ SPECIES_MANTINE, ITEM_WAVE_INCENSE, SPECIES_MANTYKE },
};

#if P_INCENSE_BREEDING < GEN_9
static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare)
{
u32 i;
Expand All @@ -990,7 +1005,6 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare
}
}
}
#endif

static const struct {
u16 offspring;
Expand Down Expand Up @@ -1083,9 +1097,8 @@ static void _GiveEggFromDaycare(struct DayCare *daycare)
bool8 isEgg;

species = DetermineEggSpeciesAndParentSlots(daycare, parentSlots);
#if P_INCENSE_BREEDING < GEN_9
AlterEggSpeciesWithIncenseItem(&species, daycare);
#endif
if (P_INCENSE_BREEDING < GEN_9)
AlterEggSpeciesWithIncenseItem(&species, daycare);
SetInitialEggData(&egg, species, daycare);
InheritIVs(&egg, daycare);
InheritPokeball(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon);
Expand Down
2 changes: 1 addition & 1 deletion src/pokedex_plus_hgss.c
Original file line number Diff line number Diff line change
Expand Up @@ -5128,7 +5128,7 @@ static bool8 CalculateMoves(void)
species = GetFormSpeciesId(species, 0);

//Calculate amount of Egg and LevelUp moves
numEggMoves = GetEggMovesSpecies(species, statsMovesEgg);
numEggMoves = GetEggMovesBySpecies(species, statsMovesEgg);
numLevelUpMoves = GetLevelUpMovesBySpecies(species, statsMovesLevelUp);

//Egg moves
Expand Down
Loading