Fix give daycare egg option giving buggy eggs (#3335)

This commit is contained in:
DizzyEggg 2023-09-22 17:20:00 +02:00 committed by GitHub
parent f564d4492b
commit 662dd7d2c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 26 deletions

View File

@ -142,5 +142,29 @@ DebugScript_HatchAnEgg_Text_EmptyParty::
DebugScript_HatchAnEgg_Text_NotAnEgg::
.string "That's not a Pokémon Egg.$"
DebugScript_ZeroDaycareMons::
msgbox DebugText_DaycareNoPokemon, MSGBOX_DEFAULT
releaseall
end
DebugScript_OneDaycareMons::
msgbox DebugText_DaycareOnePokemon, MSGBOX_DEFAULT
releaseall
end
DebugScript_DaycareMonsNotCompatible::
msgbox DebugText_DaycarePokemonNotCompatible, MSGBOX_DEFAULT
releaseall
end
DebugText_DaycareNoPokemon:
.string "You have no Pokémon at Daycare.$"
DebugText_DaycareOnePokemon:
.string "You have only one Pokémon at Daycare.$"
DebugText_DaycarePokemonNotCompatible:
.string "Your Pokémon at Daycare can't\nhave babies together!$"
.endif

View File

@ -14,6 +14,7 @@ u8 *GetMonNickname2(struct Pokemon *mon, u8 *dest);
u8 *GetBoxMonNickname(struct BoxPokemon *mon, u8 *dest);
u8 CountPokemonInDaycare(struct DayCare *daycare);
void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDaycareMail *mixMail);
s8 Daycare_FindEmptySpot(struct DayCare *daycare);
void StoreSelectedPokemonInDaycare(void);
u16 TakePokemonFromDaycare(void);
void GetDaycareCost(void);
@ -26,6 +27,7 @@ bool8 ShouldEggHatch(void);
u16 GetSelectedMonNicknameAndSpecies(void);
void GetDaycareMonNicknames(void);
u8 GetDaycareState(void);
u8 GetDaycareCompatibilityScore(struct DayCare *daycare);
void SetDaycareCompatibilityString(void);
bool8 NameHasGenderSymbol(const u8 *name, u8 genderRatio);
void ShowDaycareLevelMenu(void);

View File

@ -32,7 +32,6 @@ extern const struct Evolution gEvolutionTable[][EVOS_PER_MON];
static void ClearDaycareMonMail(struct DaycareMail *mail);
static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare);
static u8 GetDaycareCompatibilityScore(struct DayCare *daycare);
static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y);
static u8 ModifyBreedingScoreForOvalCharm(u8 score);
static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves);
@ -151,7 +150,7 @@ void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDay
mixMail->numDaycareMons = numDaycareMons;
}
static s8 Daycare_FindEmptySpot(struct DayCare *daycare)
s8 Daycare_FindEmptySpot(struct DayCare *daycare)
{
u8 i;
@ -193,7 +192,7 @@ static void TransferEggMoves(void)
{
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 P_EGG_MOVE_TRANSFER >= GEN_9
@ -493,7 +492,7 @@ static s32 GetParentToInheritNature(struct DayCare *daycare)
if (ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE
#if P_NATURE_INHERITANCE == GEN_3
&& (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE || IS_DITTO(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES)))
#endif
#endif
) {
slot = i;
numWithEverstone++;
@ -603,7 +602,7 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
}
start = 0;
if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM &&
if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM &&
ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM)
{
whichParents[0] = Random() % DAYCARE_MON_COUNT;
@ -612,14 +611,14 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
RemoveIVIndexFromList(availableIVs, selectedIvs[0]);
start++;
}
else if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM)
else if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM)
{
whichParents[0] = 0;
selectedIvs[0] = ItemId_GetSecondaryId(motherItem);
RemoveIVIndexFromList(availableIVs, selectedIvs[0]);
start++;
}
else if (ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM)
else if (ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM)
{
whichParents[0] = 1;
selectedIvs[0] = ItemId_GetSecondaryId(fatherItem);
@ -1230,7 +1229,7 @@ static bool8 EggGroupsOverlap(u16 *eggGroups1, u16 *eggGroups2)
return FALSE;
}
static u8 GetDaycareCompatibilityScore(struct DayCare *daycare)
u8 GetDaycareCompatibilityScore(struct DayCare *daycare)
{
u32 i;
u16 eggGroups[DAYCARE_MON_COUNT][EGG_GROUPS_PER_MON];

View File

@ -372,24 +372,27 @@ static void DebugAction_Sound_MUS(u8 taskId);
static void DebugAction_Sound_MUS_SelectId(u8 taskId);
extern u8 Debug_FlagsNotSetOverworldConfigMessage[];
extern u8 Debug_FlagsNotSetBattleConfigMessage[];
extern u8 Debug_Script_1[];
extern u8 Debug_Script_2[];
extern u8 Debug_Script_3[];
extern u8 Debug_Script_4[];
extern u8 Debug_Script_5[];
extern u8 Debug_Script_6[];
extern u8 Debug_Script_7[];
extern u8 Debug_Script_8[];
extern const u8 Debug_FlagsNotSetOverworldConfigMessage[];
extern const u8 Debug_FlagsNotSetBattleConfigMessage[];
extern const u8 Debug_Script_1[];
extern const u8 Debug_Script_2[];
extern const u8 Debug_Script_3[];
extern const u8 Debug_Script_4[];
extern const u8 Debug_Script_5[];
extern const u8 Debug_Script_6[];
extern const u8 Debug_Script_7[];
extern const u8 Debug_Script_8[];
extern const u8 DebugScript_DaycareMonsNotCompatible[];
extern const u8 DebugScript_OneDaycareMons[];
extern const u8 DebugScript_ZeroDaycareMons[];
extern u8 Debug_ShowFieldMessageStringVar4[];
extern u8 Debug_CheatStart[];
extern u8 Debug_HatchAnEgg[];
extern u8 PlayersHouse_2F_EventScript_SetWallClock[];
extern u8 PlayersHouse_2F_EventScript_CheckWallClock[];
extern u8 Debug_CheckSaveBlock[];
extern u8 Debug_BoxFilledMessage[];
extern const u8 Debug_ShowFieldMessageStringVar4[];
extern const u8 Debug_CheatStart[];
extern const u8 Debug_HatchAnEgg[];
extern const u8 PlayersHouse_2F_EventScript_SetWallClock[];
extern const u8 PlayersHouse_2F_EventScript_CheckWallClock[];
extern const u8 Debug_CheckSaveBlock[];
extern const u8 Debug_BoxFilledMessage[];
#include "data/map_group_count.h"
@ -3467,7 +3470,15 @@ static void DebugAction_Give_MaxBattlePoints(u8 taskId)
static void DebugAction_Give_DayCareEgg(u8 taskId)
{
TriggerPendingDaycareEgg();
s32 emptySlot = Daycare_FindEmptySpot(&gSaveBlock1Ptr->daycare);
if (emptySlot == 0) // no daycare mons
Debug_DestroyMenu_Full_Script(taskId, DebugScript_ZeroDaycareMons);
else if (emptySlot == 1) // 1 daycare mon
Debug_DestroyMenu_Full_Script(taskId, DebugScript_OneDaycareMons);
else if (GetDaycareCompatibilityScore(&gSaveBlock1Ptr->daycare) == PARENTS_INCOMPATIBLE) // not compatible parents
Debug_DestroyMenu_Full_Script(taskId, DebugScript_DaycareMonsNotCompatible);
else // 2 pokemon which can have a pokemon baby together
TriggerPendingDaycareEgg();
}
// *******************************