diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_ai_script_commands.c | 9 | ||||
-rw-r--r-- | src/battle_tower.c | 22 | ||||
-rw-r--r-- | src/daycare.c | 7 | ||||
-rw-r--r-- | src/pokemon_storage_system.c | 14 |
4 files changed, 33 insertions, 19 deletions
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 4185f8017..2423cfe37 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -450,7 +450,16 @@ static u8 ChooseMoveOrAction_Doubles(void) { s32 i; s32 j; +#ifndef BUGFIX s32 scriptsToRun; +#else + // the value assigned to this is a u32 (aiFlags) + // this becomes relevant because aiFlags can have bit 31 set + // and scriptsToRun is shifted + // this never happens in the vanilla game because bit 31 is + // only set when it's the first battle + u32 scriptsToRun; +#endif s16 bestMovePointsForTarget[MAX_BATTLERS_COUNT]; s8 mostViableTargetsArray[MAX_BATTLERS_COUNT]; u8 actionOrMoveIndex[MAX_BATTLERS_COUNT]; diff --git a/src/battle_tower.c b/src/battle_tower.c index b7d03a5bc..6fc0cd5be 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -999,7 +999,7 @@ static bool8 ChooseSpecialBattleTowerTrainer(void) return FALSE; winStreak = GetCurrentBattleTowerWinStreak(lvlMode, battleMode); - for (i = 0; i < 5; i++) + for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++) { u32 *record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]); u32 recordHasData = 0; @@ -1010,7 +1010,7 @@ static bool8 ChooseSpecialBattleTowerTrainer(void) checksum += record[j]; } validMons = 0; - for (j = 0; j < 4; j++) + for (j = 0; j < MAX_FRONTIER_PARTY_SIZE; j++) { if (gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species != 0 && gSaveBlock2Ptr->frontier.towerRecords[i].party[j].level <= GetFrontierEnemyMonLevel(lvlMode)) @@ -1324,7 +1324,7 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm) struct EmeraldBattleTowerRecord *newRecord = newRecordEm; // Needed to match. // Find a record slot of the same player and replace it. - for (i = 0; i < 5; i++) + for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++) { k = 0; for (j = 0; j < TRAINER_ID_LENGTH; j++) @@ -1350,19 +1350,19 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm) if (k == PLAYER_NAME_LENGTH) break; } - if (i < 5) + if (i < BATTLE_TOWER_RECORD_COUNT) { gSaveBlock2Ptr->frontier.towerRecords[i] = *newRecord; return; } // Find an empty record slot. - for (i = 0; i < 5; i++) + for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++) { if (gSaveBlock2Ptr->frontier.towerRecords[i].winStreak == 0) break; } - if (i < 5) + if (i < BATTLE_TOWER_RECORD_COUNT) { gSaveBlock2Ptr->frontier.towerRecords[i] = *newRecord; return; @@ -1373,7 +1373,7 @@ void PutNewBattleTowerRecord(struct EmeraldBattleTowerRecord *newRecordEm) slotIds[0] = 0; slotsCount++; - for (i = 1; i < 5; i++) + for (i = 1; i < BATTLE_TOWER_RECORD_COUNT; i++) { for (j = 0; j < slotsCount; j++) { @@ -2240,7 +2240,7 @@ static void GetRecordMixFriendMultiPartnerParty(u16 trainerId) u16 species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); count = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_FRONTIER_PARTY_SIZE; i++) { if (gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[i].species != species1 && gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].party[i].species != species2 @@ -2362,7 +2362,7 @@ static void LoadMultiPartnerCandidatesData(void) } r10 = 0; - for (i = 0; i < 5; i++) + for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++) { u32 *record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]); u32 recordHasData = 0; @@ -2379,7 +2379,7 @@ static void LoadMultiPartnerCandidatesData(void) && gSaveBlock2Ptr->frontier.towerRecords[i].checksum == checksum) { k = 0; - for (j = 0; j < 4; j++) + for (j = 0; j < MAX_FRONTIER_PARTY_SIZE; j++) { if (species1 != gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species && species2 != gSaveBlock2Ptr->frontier.towerRecords[i].party[j].species @@ -2682,7 +2682,7 @@ static void ValidateBattleTowerRecordChecksums(void) if (gSaveBlock2Ptr->frontier.towerPlayer.checksum != checksum) ClearBattleTowerRecord(&gSaveBlock2Ptr->frontier.towerPlayer); - for (i = 0; i < 5; i++) + for (i = 0; i < BATTLE_TOWER_RECORD_COUNT; i++) { record = (u32*)(&gSaveBlock2Ptr->frontier.towerRecords[i]); checksum = 0; diff --git a/src/daycare.c b/src/daycare.c index a438c8e85..fd6ed3a50 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -548,7 +548,12 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) { // Randomly pick an IV from the available list and stop from being chosen again. selectedIvs[i] = availableIVs[Random() % (NUM_STATS - i)]; - RemoveIVIndexFromList(availableIVs, i); + // BUG: Instead of removing the IV that was just picked (like in RS and FRLG), 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. Uncomment the inline comment and remove the existing expression to get the + // intended behavior and to match the other Gen 3 games. + RemoveIVIndexFromList(availableIVs, i /*selectedIvs[i]*/); } // Determine which parent each of the selected IVs should inherit from. diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 6efca2562..eb288c978 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -6777,11 +6777,11 @@ static void SetCursorMonData(void *pokemon, u8 mode) { u8 *txtPtr; u16 gender; - bool8 sanityIsBagEgg; + bool8 sanityIsBadEgg; sPSSData->cursorMonItem = 0; gender = MON_MALE; - sanityIsBagEgg = FALSE; + sanityIsBadEgg = FALSE; if (mode == MODE_PARTY) { struct Pokemon *mon = (struct Pokemon *)pokemon; @@ -6789,8 +6789,8 @@ static void SetCursorMonData(void *pokemon, u8 mode) sPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); if (sPSSData->cursorMonSpecies != SPECIES_NONE) { - sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); - if (sanityIsBagEgg) + sanityIsBadEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBadEgg) sPSSData->cursorMonIsEgg = TRUE; else sPSSData->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); @@ -6813,8 +6813,8 @@ static void SetCursorMonData(void *pokemon, u8 mode) if (sPSSData->cursorMonSpecies != SPECIES_NONE) { u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); - sanityIsBagEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); - if (sanityIsBagEgg) + sanityIsBadEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBadEgg) sPSSData->cursorMonIsEgg = TRUE; else sPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); @@ -6846,7 +6846,7 @@ static void SetCursorMonData(void *pokemon, u8 mode) } else if (sPSSData->cursorMonIsEgg) { - if (sanityIsBagEgg) + if (sanityIsBadEgg) StringCopyPadded(sPSSData->cursorMonNickText, sPSSData->cursorMonNick, CHAR_SPACE, 5); else StringCopyPadded(sPSSData->cursorMonNickText, gText_EggNickname, CHAR_SPACE, 8); |