diff options
author | GriffinR <griffin.richards@comcast.net> | 2019-09-25 14:48:22 -0400 |
---|---|---|
committer | huderlem <huderlem@gmail.com> | 2019-09-25 18:46:25 -0500 |
commit | 801ca37f0402083d7c0749cbf2ea473bf9dc4894 (patch) | |
tree | cb7d48fc0191f425190342e5207cc05edb1f1ba5 /src | |
parent | 1ae352bcb6307ae5aa6f64085dea217c0ca23eac (diff) |
Document day_care.inc and related
Diffstat (limited to 'src')
-rw-r--r-- | src/daycare.c | 285 | ||||
-rw-r--r-- | src/egg_hatch.c | 14 |
2 files changed, 146 insertions, 153 deletions
diff --git a/src/daycare.c b/src/daycare.c index dc44b4887..bd705e73f 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -3,14 +3,11 @@ #include "battle.h" #include "daycare.h" #include "string_util.h" -#include "constants/species.h" -#include "constants/items.h" #include "mail.h" #include "pokemon_storage_system.h" #include "event_data.h" #include "random.h" #include "main.h" -#include "constants/moves.h" #include "egg_hatch.h" #include "text.h" #include "menu.h" @@ -22,9 +19,10 @@ #include "party_menu.h" #include "list_menu.h" #include "overworld.h" - -#define EGG_MOVES_ARRAY_COUNT 10 -#define EGG_LVL_UP_MOVES_ARRAY_COUNT 50 +#include "constants/items.h" +#include "constants/moves.h" +#include "constants/region_map_sections.h" +#include "constants/species.h" // this file's functions static void ClearDaycareMonMail(struct DayCareMail *mail); @@ -52,11 +50,13 @@ static const struct WindowTemplate sDaycareLevelMenuWindowTemplate = .baseBlock = 8 }; +// Indices here are assigned by Task_HandleDaycareLevelMenuInput to VAR_RESULT, +// which is copied to VAR_0x8004 and used as an index for GetDaycareCost static const struct ListMenuItem sLevelMenuItems[] = { - {gExpandedPlaceholder_Empty, 0}, - {gExpandedPlaceholder_Empty, 1}, - {gText_Exit, 5} + {gExpandedPlaceholder_Empty, EGG_MOTHER}, + {gExpandedPlaceholder_Empty, EGG_FATHER}, + {gText_Exit, DAYCARE_LEVEL_MENU_EXIT} }; static const struct ListMenuTemplate sDaycareListMenuLevelTemplate = @@ -202,16 +202,16 @@ void StoreSelectedPokemonInDaycare(void) static void ShiftDaycareSlots(struct DayCare *daycare) { // This condition is only satisfied when the player takes out the first pokemon from the daycare. - if (GetBoxMonData(&daycare->mons[1].mon, MON_DATA_SPECIES) != 0 - && GetBoxMonData(&daycare->mons[0].mon, MON_DATA_SPECIES) == 0) + if (GetBoxMonData(&daycare->mons[EGG_FATHER].mon, MON_DATA_SPECIES) != SPECIES_NONE + && GetBoxMonData(&daycare->mons[EGG_MOTHER].mon, MON_DATA_SPECIES) == SPECIES_NONE) { - daycare->mons[0].mon = daycare->mons[1].mon; - ZeroBoxMonData(&daycare->mons[1].mon); + daycare->mons[EGG_MOTHER].mon = daycare->mons[EGG_FATHER].mon; + ZeroBoxMonData(&daycare->mons[EGG_FATHER].mon); - daycare->mons[0].mail = daycare->mons[1].mail; - daycare->mons[0].steps = daycare->mons[1].steps; - daycare->mons[1].steps = 0; - ClearDaycareMonMail(&daycare->mons[1].mail); + daycare->mons[EGG_MOTHER].mail = daycare->mons[EGG_FATHER].mail; + daycare->mons[EGG_MOTHER].steps = daycare->mons[EGG_FATHER].steps; + daycare->mons[EGG_FATHER].steps = 0; + ClearDaycareMonMail(&daycare->mons[EGG_FATHER].mail); } } @@ -341,8 +341,8 @@ void GetDaycareCost(void) static void Debug_AddDaycareSteps(u16 numSteps) { - gSaveBlock1Ptr->daycare.mons[0].steps += numSteps; - gSaveBlock1Ptr->daycare.mons[1].steps += numSteps; + gSaveBlock1Ptr->daycare.mons[EGG_MOTHER].steps += numSteps; + gSaveBlock1Ptr->daycare.mons[EGG_FATHER].steps += numSteps; } u8 GetNumLevelsGainedFromDaycare(void) @@ -419,18 +419,18 @@ static u16 GetEggSpecies(u16 species) return species; } -static s32 GetSlotToInheritNature(struct DayCare *daycare) +static s32 GetParentToInheritNature(struct DayCare *daycare) { u32 species[DAYCARE_MON_COUNT]; s32 i; s32 dittoCount; - s32 slot = -1; + s32 parent = NEITHER_PARENT; // search for female gender for (i = 0; i < DAYCARE_MON_COUNT; i++) { if (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE) - slot = i; + parent = i; } // search for ditto @@ -438,50 +438,52 @@ static s32 GetSlotToInheritNature(struct DayCare *daycare) { species[i] = GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES); if (species[i] == SPECIES_DITTO) - dittoCount++, slot = i; + dittoCount++, parent = i; } // coin flip on ...two Dittos - if (dittoCount == 2) + if (dittoCount == DAYCARE_MON_COUNT) { if (Random() >= USHRT_MAX / 2) - slot = 0; + parent = EGG_MOTHER; else - slot = 1; + parent = EGG_FATHER; } - // nature inheritance only if holds everstone - if (GetBoxMonData(&daycare->mons[slot].mon, MON_DATA_HELD_ITEM) != ITEM_EVERSTONE + // Don't inherit nature if not holding Everstone + if (GetBoxMonData(&daycare->mons[parent].mon, MON_DATA_HELD_ITEM) != ITEM_EVERSTONE || Random() >= USHRT_MAX / 2) { - return -1; + return NEITHER_PARENT; } - return slot; + return parent; } static void _TriggerPendingDaycareEgg(struct DayCare *daycare) { - s32 natureSlot; + s32 parent; s32 natureTries = 0; SeedRng2(gMain.vblankCounter2); - natureSlot = GetSlotToInheritNature(daycare); + parent = GetParentToInheritNature(daycare); - if (natureSlot < 0) + // don't inherit nature + if (parent < 0) { - daycare->offspringPersonality = (Random2() << 0x10) | ((Random() % 0xfffe) + 1); + daycare->offspringPersonality = (Random2() << 16) | ((Random() % 0xfffe) + 1); } + // inherit nature else { - u8 wantedNature = GetNatureFromPersonality(GetBoxMonData(&daycare->mons[natureSlot].mon, MON_DATA_PERSONALITY, NULL)); + u8 wantedNature = GetNatureFromPersonality(GetBoxMonData(&daycare->mons[parent].mon, MON_DATA_PERSONALITY, NULL)); u32 personality; do { - personality = (Random2() << 0x10) | (Random()); + personality = (Random2() << 16) | (Random()); if (wantedNature == GetNatureFromPersonality(personality) && personality != 0) - break; // we found a personality with the same nature + break; // found a personality with the same nature natureTries++; } while (natureTries <= 2400); @@ -492,9 +494,10 @@ static void _TriggerPendingDaycareEgg(struct DayCare *daycare) FlagSet(FLAG_PENDING_DAYCARE_EGG); } +// Functionally unused static void _TriggerPendingDaycareMaleEgg(struct DayCare *daycare) { - daycare->offspringPersonality = (Random()) | (0x8000); + daycare->offspringPersonality = (Random()) | (EGG_GENDER_MALE); FlagSet(FLAG_PENDING_DAYCARE_EGG); } @@ -503,6 +506,7 @@ void TriggerPendingDaycareEgg(void) _TriggerPendingDaycareEgg(&gSaveBlock1Ptr->daycare); } +// Unused static void TriggerPendingDaycareMaleEgg(void) { _TriggerPendingDaycareMaleEgg(&gSaveBlock1Ptr->daycare); @@ -532,9 +536,9 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv) static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) { u8 i; - u8 selectedIvs[3]; + u8 selectedIvs[INHERITED_IV_COUNT]; u8 availableIVs[NUM_STATS]; - u8 whichParent[ARRAY_COUNT(selectedIvs)]; + u8 whichParent[INHERITED_IV_COUNT]; u8 iv; // Initialize a list of IV indices. @@ -544,23 +548,21 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) } // Select the 3 IVs that will be inherited. - for (i = 0; i < ARRAY_COUNT(selectedIvs); i++) + for (i = 0; i < INHERITED_IV_COUNT; i++) { - // Randomly pick an IV from the available list. + // Randomly pick an IV from the available list and stop from being chosen again. selectedIvs[i] = availableIVs[Random() % (NUM_STATS - i)]; - - // Remove the selected IV index from the available IV indices. RemoveIVIndexFromList(availableIVs, i); } // Determine which parent each of the selected IVs should inherit from. - for (i = 0; i < ARRAY_COUNT(selectedIvs); i++) + for (i = 0; i < INHERITED_IV_COUNT; i++) { - whichParent[i] = Random() % 2; + whichParent[i] = Random() % DAYCARE_MON_COUNT; } // Set each of inherited IVs on the egg mon. - for (i = 0; i < ARRAY_COUNT(selectedIvs); i++) + for (i = 0; i < INHERITED_IV_COUNT; i++) { switch (selectedIvs[i]) { @@ -638,14 +640,14 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru numSharedParentMoves = 0; for (i = 0; i < MAX_MON_MOVES; i++) { - sHatchedEggMotherMoves[i] = 0; - sHatchedEggFatherMoves[i] = 0; - sHatchedEggFinalMoves[i] = 0; + sHatchedEggMotherMoves[i] = MOVE_NONE; + sHatchedEggFatherMoves[i] = MOVE_NONE; + sHatchedEggFinalMoves[i] = MOVE_NONE; } for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++) - sHatchedEggEggMoves[i] = 0; + sHatchedEggEggMoves[i] = MOVE_NONE; for (i = 0; i < EGG_LVL_UP_MOVES_ARRAY_COUNT; i++) - sHatchedEggLevelUpMoves[i] = 0; + sHatchedEggLevelUpMoves[i] = MOVE_NONE; numLevelUpMoves = GetLevelUpMovesBySpecies(GetMonData(egg, MON_DATA_SPECIES), sHatchedEggLevelUpMoves); for (i = 0; i < MAX_MON_MOVES; i++) @@ -732,8 +734,8 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare u16 motherItem, fatherItem; if (*species == SPECIES_WYNAUT || *species == SPECIES_AZURILL) { - motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); - fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); + motherItem = GetBoxMonData(&daycare->mons[EGG_MOTHER].mon, MON_DATA_HELD_ITEM); + fatherItem = GetBoxMonData(&daycare->mons[EGG_FATHER].mon, MON_DATA_HELD_ITEM); if (*species == SPECIES_WYNAUT && motherItem != ITEM_LAX_INCENSE && fatherItem != ITEM_LAX_INCENSE) { *species = SPECIES_WOBBUFFET; @@ -748,8 +750,8 @@ static void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *daycare) { - u32 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); - u32 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); + u32 motherItem = GetBoxMonData(&daycare->mons[EGG_MOTHER].mon, MON_DATA_HELD_ITEM); + u32 fatherItem = GetBoxMonData(&daycare->mons[EGG_FATHER].mon, MON_DATA_HELD_ITEM); if (motherItem == ITEM_LIGHT_BALL || fatherItem == ITEM_LIGHT_BALL) { @@ -761,60 +763,57 @@ static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *dayca static u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parentSlots) { u16 i; - u16 species[2]; + u16 species[DAYCARE_MON_COUNT]; u16 eggSpecies; - // Determine which of the daycare mons is the mother and father of the egg. - // The 0th index of the parentSlots array is considered the mother slot, and the - // 1st index is the father slot. - for (i = 0; i < 2; i++) + for (i = 0; i < DAYCARE_MON_COUNT; i++) { species[i] = GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES); if (species[i] == SPECIES_DITTO) { - parentSlots[0] = i ^ 1; - parentSlots[1] = i; + parentSlots[EGG_MOTHER] = i ^ 1; + parentSlots[EGG_FATHER] = i; } else if (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE) { - parentSlots[0] = i; - parentSlots[1] = i ^ 1; + parentSlots[EGG_MOTHER] = i; + parentSlots[EGG_FATHER] = i ^ 1; } } - eggSpecies = GetEggSpecies(species[parentSlots[0]]); - if (eggSpecies == SPECIES_NIDORAN_F && daycare->offspringPersonality & 0x8000) + eggSpecies = GetEggSpecies(species[parentSlots[EGG_MOTHER]]); + if (eggSpecies == SPECIES_NIDORAN_F && daycare->offspringPersonality & EGG_GENDER_MALE) { eggSpecies = SPECIES_NIDORAN_M; } - if (eggSpecies == SPECIES_ILLUMISE && daycare->offspringPersonality & 0x8000) + if (eggSpecies == SPECIES_ILLUMISE && daycare->offspringPersonality & EGG_GENDER_MALE) { eggSpecies = SPECIES_VOLBEAT; } // Make Ditto the "mother" slot if the other daycare mon is male. - if (species[parentSlots[1]] == SPECIES_DITTO && GetBoxMonGender(&daycare->mons[parentSlots[0]].mon) != MON_FEMALE) + if (species[parentSlots[EGG_FATHER]] == SPECIES_DITTO && GetBoxMonGender(&daycare->mons[parentSlots[EGG_MOTHER]].mon) != MON_FEMALE) { - u8 temp = parentSlots[1]; - parentSlots[1] = parentSlots[0]; - parentSlots[0] = temp; + u8 ditto = parentSlots[EGG_FATHER]; + parentSlots[EGG_FATHER] = parentSlots[EGG_MOTHER]; + parentSlots[EGG_MOTHER] = ditto; } return eggSpecies; } -static void _GiveEggFromDaycare(struct DayCare *daycare) // give_egg +static void _GiveEggFromDaycare(struct DayCare *daycare) { struct Pokemon egg; u16 species; - u8 parentSlots[2]; // 0th index is "mother" daycare slot, 1st is "father" + u8 parentSlots[DAYCARE_MON_COUNT]; bool8 isEgg; species = DetermineEggSpeciesAndParentSlots(daycare, parentSlots); AlterEggSpeciesWithIncenseItem(&species, daycare); SetInitialEggData(&egg, species, daycare); InheritIVs(&egg, daycare); - BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); + BuildEggMoveset(&egg, &daycare->mons[parentSlots[EGG_FATHER]].mon, &daycare->mons[parentSlots[EGG_MOTHER]].mon); if (species == SPECIES_PICHU) GiveVoltTackleIfLightBall(&egg, daycare); @@ -835,7 +834,7 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) u8 metLocation; u8 isEgg; - CreateMon(mon, species, EGG_HATCH_LEVEL, 0x20, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateMon(mon, species, EGG_HATCH_LEVEL, 32, FALSE, 0, OT_ID_PLAYER_ID, 0); metLevel = 0; ball = ITEM_POKE_BALL; language = LANGUAGE_JAPANESE; @@ -846,7 +845,7 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) SetMonData(mon, MON_DATA_LANGUAGE, &language); if (setHotSpringsLocation) { - metLocation = 253; // hot springs; see PokemonSummaryScreen_PrintEggTrainerMemo + metLocation = METLOC_SPECIAL_EGG; SetMonData(mon, MON_DATA_MET_LOCATION, &metLocation); } @@ -862,7 +861,7 @@ static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare * u8 language; personality = daycare->offspringPersonality; - CreateMon(mon, species, EGG_HATCH_LEVEL, 0x20, TRUE, personality, OT_ID_PLAYER_ID, 0); + CreateMon(mon, species, EGG_HATCH_LEVEL, 32, TRUE, personality, OT_ID_PLAYER_ID, 0); metLevel = 0; ball = ITEM_POKE_BALL; language = LANGUAGE_JAPANESE; @@ -889,7 +888,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare) } // try to trigger poke sex - if (daycare->offspringPersonality == 0 && validEggs == 2 && (daycare->mons[1].steps & 0xFF) == 0xFF) + if (daycare->offspringPersonality == 0 && validEggs == DAYCARE_MON_COUNT && (daycare->mons[EGG_FATHER].steps & 0xFF) == 0xFF) { u8 loveScore = GetDaycareCompatibilityScore(daycare); if (loveScore > (Random() * 100u) / USHRT_MAX) @@ -945,16 +944,16 @@ static bool8 IsEggPending(struct DayCare *daycare) static void _GetDaycareMonNicknames(struct DayCare *daycare) { u8 text[12]; - if (GetBoxMonData(&daycare->mons[0].mon, MON_DATA_SPECIES) != 0) + if (GetBoxMonData(&daycare->mons[EGG_MOTHER].mon, MON_DATA_SPECIES) != 0) { - GetBoxMonNick(&daycare->mons[0].mon, gStringVar1); - GetBoxMonData(&daycare->mons[0].mon, MON_DATA_OT_NAME, text); + GetBoxMonNick(&daycare->mons[EGG_MOTHER].mon, gStringVar1); + GetBoxMonData(&daycare->mons[EGG_MOTHER].mon, MON_DATA_OT_NAME, text); StringCopy(gStringVar3, text); } - if (GetBoxMonData(&daycare->mons[1].mon, MON_DATA_SPECIES) != 0) + if (GetBoxMonData(&daycare->mons[EGG_FATHER].mon, MON_DATA_SPECIES) != 0) { - GetBoxMonNick(&daycare->mons[1].mon, gStringVar2); + GetBoxMonNick(&daycare->mons[EGG_FATHER].mon, gStringVar2); } } @@ -971,26 +970,19 @@ void GetDaycareMonNicknames(void) u8 GetDaycareState(void) { - // The daycare can be in 4 possible states: - // 0: default state--no deposited mons, no egg - // 1: there is an egg waiting for the player to pick it up - // 2: there is a single pokemon in the daycare - // 3: there are two pokemon in the daycare, no egg - u8 numMons; if (IsEggPending(&gSaveBlock1Ptr->daycare)) { - // There is an Egg waiting for the player. - return 1; + return DAYCARE_EGG_WAITING; } numMons = CountPokemonInDaycare(&gSaveBlock1Ptr->daycare); if (numMons != 0) { - return numMons + 1; + return numMons + 1; // DAYCARE_ONE_MON or DAYCARE_TWO_MONS } - return 0; + return DAYCARE_NO_MONS; } static u8 GetDaycarePokemonCount(void) @@ -1002,15 +994,15 @@ static u8 GetDaycarePokemonCount(void) return 0; } +// Determine if the two given egg group lists contain any of the +// same egg groups. static bool8 EggGroupsOverlap(u16 *eggGroups1, u16 *eggGroups2) { - // Determine if the two given egg group lists contain any of the - // same egg groups. s32 i, j; - for (i = 0; i < 2; i++) + for (i = 0; i < EGG_GROUPS_PER_MON; i++) { - for (j = 0; j < 2; j++) + for (j = 0; j < EGG_GROUPS_PER_MON; j++) { if (eggGroups1[i] == eggGroups2[j]) return TRUE; @@ -1023,12 +1015,12 @@ static bool8 EggGroupsOverlap(u16 *eggGroups1, u16 *eggGroups2) static u8 GetDaycareCompatibilityScore(struct DayCare *daycare) { u32 i; - u16 eggGroups[2][2]; - u16 species[2]; - u32 trainerIds[2]; - u32 genders[2]; + u16 eggGroups[DAYCARE_MON_COUNT][EGG_GROUPS_PER_MON]; + u16 species[DAYCARE_MON_COUNT]; + u32 trainerIds[DAYCARE_MON_COUNT]; + u32 genders[DAYCARE_MON_COUNT]; - for (i = 0; i < 2; i++) + for (i = 0; i < DAYCARE_MON_COUNT; i++) { u32 personality; @@ -1041,42 +1033,43 @@ static u8 GetDaycareCompatibilityScore(struct DayCare *daycare) } // check unbreedable egg group - if (eggGroups[0][0] == EGG_GROUP_UNDISCOVERED || eggGroups[1][0] == EGG_GROUP_UNDISCOVERED) - return 0; + if (eggGroups[EGG_MOTHER][0] == EGG_GROUP_UNDISCOVERED || eggGroups[EGG_FATHER][0] == EGG_GROUP_UNDISCOVERED) + return PARENTS_INCOMPATIBLE; // two Ditto can't breed - if (eggGroups[0][0] == EGG_GROUP_DITTO && eggGroups[1][0] == EGG_GROUP_DITTO) - return 0; + if (eggGroups[EGG_MOTHER][0] == EGG_GROUP_DITTO && eggGroups[EGG_FATHER][0] == EGG_GROUP_DITTO) + return PARENTS_INCOMPATIBLE; - // now that we checked, one ditto can breed with any other mon - if (eggGroups[0][0] == EGG_GROUP_DITTO || eggGroups[1][0] == EGG_GROUP_DITTO) + // one parent is Ditto + if (eggGroups[EGG_MOTHER][0] == EGG_GROUP_DITTO || eggGroups[EGG_FATHER][0] == EGG_GROUP_DITTO) { - if (trainerIds[0] == trainerIds[1]) // same trainer - return 20; + if (trainerIds[EGG_MOTHER] == trainerIds[EGG_FATHER]) + return PARENTS_LOW_COMPATIBILITY; - return 50; // different trainers, more chance of poke sex + return PARENTS_MED_COMPATABILITY; } + // neither parent is Ditto else { - if (genders[0] == genders[1]) // no homo - return 0; - if (genders[0] == MON_GENDERLESS || genders[1] == MON_GENDERLESS) - return 0; - if (!EggGroupsOverlap(eggGroups[0], eggGroups[1])) // not compatible with each other - return 0; - - if (species[0] == species[1]) // same species + if (genders[EGG_MOTHER] == genders[EGG_FATHER]) + return PARENTS_INCOMPATIBLE; + if (genders[EGG_MOTHER] == MON_GENDERLESS || genders[EGG_FATHER] == MON_GENDERLESS) + return PARENTS_INCOMPATIBLE; + if (!EggGroupsOverlap(eggGroups[EGG_MOTHER], eggGroups[EGG_FATHER])) + return PARENTS_INCOMPATIBLE; + + if (species[EGG_MOTHER] == species[EGG_FATHER]) { - if (trainerIds[0] == trainerIds[1]) // same species and trainer - return 50; + if (trainerIds[EGG_MOTHER] == trainerIds[EGG_FATHER]) + return PARENTS_MED_COMPATABILITY; // same species, same trainer - return 70; // different trainers, same species + return PARENTS_MAX_COMPATABILITY; // same species, different trainers } else { - if (trainerIds[0] != trainerIds[1]) // different trainers, different species - return 50; + if (trainerIds[EGG_MOTHER] != trainerIds[EGG_FATHER]) + return PARENTS_MED_COMPATABILITY; // different species, different trainers - return 20; // different species, same trainer + return PARENTS_LOW_COMPATIBILITY; // different species, same trainer } } } @@ -1093,13 +1086,13 @@ void SetDaycareCompatibilityString(void) relationshipScore = GetDaycareCompatibilityScoreFromSave(); whichString = 0; - if (relationshipScore == 0) + if (relationshipScore == PARENTS_INCOMPATIBLE) whichString = 3; - if (relationshipScore == 20) + if (relationshipScore == PARENTS_LOW_COMPATIBILITY) whichString = 2; - if (relationshipScore == 50) + if (relationshipScore == PARENTS_MED_COMPATABILITY) whichString = 1; - if (relationshipScore == 70) + if (relationshipScore == PARENTS_MAX_COMPATABILITY) whichString = 0; StringCopy(gStringVar4, sCompatibilityMessages[whichString]); @@ -1108,20 +1101,20 @@ void SetDaycareCompatibilityString(void) bool8 NameHasGenderSymbol(const u8 *name, u8 genderRatio) { u8 i; - u8 symbolsCount[2]; // male, female - symbolsCount[0] = symbolsCount[1] = 0; + u8 symbolsCount[GENDER_COUNT]; + symbolsCount[MALE] = symbolsCount[FEMALE] = 0; for (i = 0; name[i] != EOS; i++) { if (name[i] == CHAR_MALE) - symbolsCount[0]++; + symbolsCount[MALE]++; if (name[i] == CHAR_FEMALE) - symbolsCount[1]++; + symbolsCount[FEMALE]++; } - if (genderRatio == MON_MALE && symbolsCount[0] != 0 && symbolsCount[1] == 0) + if (genderRatio == MON_MALE && symbolsCount[MALE] != 0 && symbolsCount[FEMALE] == 0) return TRUE; - if (genderRatio == MON_FEMALE && symbolsCount[1] != 0 && symbolsCount[0] == 0) + if (genderRatio == MON_FEMALE && symbolsCount[FEMALE] != 0 && symbolsCount[MALE] == 0) return TRUE; return FALSE; @@ -1150,19 +1143,19 @@ static u8 *AppendMonGenderSymbol(u8 *name, struct BoxPokemon *boxMon) static void GetDaycareLevelMenuText(struct DayCare *daycare, u8 *dest) { - u8 monNames[2][20]; + u8 monNames[DAYCARE_MON_COUNT][20]; u8 i; *dest = EOS; - for (i = 0; i < 2; i++) + for (i = 0; i < DAYCARE_MON_COUNT; i++) { GetBoxMonNick(&daycare->mons[i].mon, monNames[i]); AppendMonGenderSymbol(monNames[i], &daycare->mons[i].mon); } - StringCopy(dest, monNames[0]); + StringCopy(dest, monNames[EGG_MOTHER]); StringAppend(dest, gText_NewLine2); - StringAppend(dest, monNames[1]); + StringAppend(dest, monNames[EGG_FATHER]); StringAppend(dest, gText_NewLine2); StringAppend(dest, gText_Exit4); } @@ -1174,7 +1167,7 @@ static void GetDaycareLevelMenuLevelText(struct DayCare *daycare, u8 *dest) u8 text[20]; *dest = EOS; - for (i = 0; i < 2; i++) + for (i = 0; i < DAYCARE_MON_COUNT; i++) { StringAppend(dest, gText_Lv); level = GetLevelAfterDaycareSteps(&daycare->mons[i].mon, daycare->mons[i].steps); @@ -1250,12 +1243,12 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId) { switch (input) { - case 0: - case 1: + case EGG_MOTHER: + case EGG_FATHER: gSpecialVar_Result = input; break; - case 5: - gSpecialVar_Result = 2; + case DAYCARE_LEVEL_MENU_EXIT: + gSpecialVar_Result = DAYCARE_EXITED_LEVEL_MENU; break; } DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL); @@ -1266,7 +1259,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId) } else if (gMain.newKeys & B_BUTTON) { - gSpecialVar_Result = 2; + gSpecialVar_Result = DAYCARE_EXITED_LEVEL_MENU; DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL); ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE); RemoveWindow(gTasks[taskId].tWindowId); diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 4fba8578c..5262c4af4 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -388,13 +388,13 @@ void ScriptHatchMon(void) AddHatchedMonToParty(gSpecialVar_0x8004); } -static bool8 sub_807158C(struct DayCare *daycare, u8 daycareId) +static bool8 _CheckDaycareMonReceivedMail(struct DayCare *daycare, u8 daycareId) { - u8 nick[0x20]; + u8 nick[32]; struct DaycareMon *daycareMon = &daycare->mons[daycareId]; GetBoxMonNick(&daycareMon->mon, nick); - if (daycareMon->mail.message.itemId != 0 + if (daycareMon->mail.message.itemId != ITEM_NONE && (StringCompareWithoutExtCtrlCodes(nick, daycareMon->mail.monName) != 0 || StringCompareWithoutExtCtrlCodes(gSaveBlock2Ptr->playerName, daycareMon->mail.OT_name) != 0)) { @@ -406,9 +406,9 @@ static bool8 sub_807158C(struct DayCare *daycare, u8 daycareId) return FALSE; } -bool8 sub_8071614(void) +bool8 CheckDaycareMonReceivedMail(void) { - return sub_807158C(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004); + return _CheckDaycareMonReceivedMail(&gSaveBlock1Ptr->daycare, gSpecialVar_0x8004); } static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc) @@ -880,9 +880,9 @@ u8 GetEggStepsToSubtract(void) return 1; } -u16 sub_80722E0(void) +u16 CountPartyAliveNonEggMons(void) { u16 aliveNonEggMonsCount = CountStorageNonEggMons(); - aliveNonEggMonsCount += CountPartyAliveNonEggMonsExcept(6); + aliveNonEggMonsCount += CountPartyAliveNonEggMonsExcept(PARTY_SIZE); return aliveNonEggMonsCount; } |