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

* Fix daycare move transferring between evolved mons

Also allow sharing moves between different forms

* Make sure Snorlax gets Snorlax's egg moves instead of Munchlax's

* Use GET_BASE_SPECIES_ID

* Actually fix Snorlax/Roselia/etc behavior

* remove preproc checks

* rename ambiguous GetEggMovesSpecies function

* remove extra indentation, add incense breeding check

* update comment

* Update src/daycare.c

---------

Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
sneed 2024-06-07 22:54:58 +03:00 committed by GitHub
parent dc742b3077
commit 2cc2dc01ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 31 deletions

View file

@ -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

View file

@ -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};
@ -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,
@ -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;
@ -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;
@ -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;
@ -990,7 +1005,6 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare
}
}
}
#endif
static const struct {
u16 offspring;
@ -1095,9 +1109,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);

View file

@ -5130,7 +5130,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