Restore bugfix

Ooopsie!
This commit is contained in:
Jaizu 2023-01-30 13:57:59 +01:00 committed by GitHub
parent 267cf1e6f0
commit 68ee9e5739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -558,8 +558,20 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare, struct BoxP
// 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
// removes position 0 (HP) then position 1 (DEF), then position 2. This is why HP and DEF
// have a lower chance to be inherited in Emerald and why the IV picked for inheritance can
// be repeated. Amusingly, FRLG and RS also got this wrong. They remove selectedIvs[i], which
// is not an index! This means that it can sometimes remove the wrong stat.
#ifndef BUGFIX
selectedIvs[i] = availableIVs[Random() % (NUM_STATS - i)];
RemoveIVIndexFromList(availableIVs, i);
#else
u8 index = Random() % (NUM_STATS - i);
selectedIvs[i] = availableIVs[index];
RemoveIVIndexFromList(availableIVs, index);
#endif
}
// Determine which parent each of the selected IVs should inherit from.