summaryrefslogtreecommitdiff
path: root/src/daycare.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daycare.c')
-rw-r--r--src/daycare.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/daycare.c b/src/daycare.c
index 5d4480403..511fa0551 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -22,7 +22,6 @@
#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);
@@ -548,8 +547,19 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
for (i = 0; i < INHERITED_IV_COUNT; 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.
@@ -615,10 +625,7 @@ static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves)
for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++)
{
if (gEggMoves[eggMoveIdx + i] > EGG_MOVES_SPECIES_OFFSET)
- {
- // TODO: the curly braces around this if statement are required for a matching build.
break;
- }
eggMoves[i] = gEggMoves[eggMoveIdx + i];
numEggMoves++;
@@ -1237,7 +1244,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
{
u32 input = ListMenu_ProcessInput(gTasks[taskId].tMenuListTaskId);
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
switch (input)
{
@@ -1255,7 +1262,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
DestroyTask(taskId);
EnableBothScriptContexts();
}
- else if (gMain.newKeys & B_BUTTON)
+ else if (JOY_NEW(B_BUTTON))
{
gSpecialVar_Result = DAYCARE_EXITED_LEVEL_MENU;
DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL);