Merge pull request #2616 from Jaizu/patch-3

Implement Destiny Knot
This commit is contained in:
Eduardo Quezada D'Ottone 2023-01-31 07:43:03 -03:00 committed by GitHub
commit a56cc4b6c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

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

View File

@ -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])
{