diff --git a/include/constants/daycare.h b/include/constants/daycare.h index ac48e4f716..782bbe9546 100644 --- a/include/constants/daycare.h +++ b/include/constants/daycare.h @@ -13,7 +13,6 @@ #define DAYCARE_ONE_MON 2 #define DAYCARE_TWO_MONS 3 -#define INHERITED_IV_COUNT 3 #if P_EGG_HATCH_LEVEL >= GEN_4 #define EGG_HATCH_LEVEL 1 #else diff --git a/src/daycare.c b/src/daycare.c index 2a96ca7a91..cabecc8ea5 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -539,11 +539,17 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv) static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) { + u16 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); + u16 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); u8 i; - u8 selectedIvs[INHERITED_IV_COUNT]; + u8 selectedIvs[5]; u8 availableIVs[NUM_STATS]; - u8 whichParents[INHERITED_IV_COUNT]; + u8 whichParents[5]; u8 iv; + u8 howManyIVs = 3; + + if (motherItem == ITEM_DESTINY_KNOT || fatherItem == ITEM_DESTINY_KNOT) + howManyIVs = 5; // Initialize a list of IV indices. for (i = 0; i < NUM_STATS; i++) @@ -551,8 +557,8 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) availableIVs[i] = i; } - // Select the 3 IVs that will be inherited. - for (i = 0; i < INHERITED_IV_COUNT; i++) + // Select which IVs that will be inherited. + for (i = 0; i < howManyIVs; i++) { // Randomly pick an IV from the available list and stop from being chosen again. // BUG: Instead of removing the IV that was just picked, this @@ -571,13 +577,13 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) } // Determine which parent each of the selected IVs should inherit from. - for (i = 0; i < INHERITED_IV_COUNT; i++) + for (i = 0; i < howManyIVs; i++) { whichParents[i] = Random() % DAYCARE_MON_COUNT; } // Set each of inherited IVs on the egg mon. - for (i = 0; i < INHERITED_IV_COUNT; i++) + for (i = 0; i < howManyIVs; i++) { switch (selectedIvs[i]) {