diff options
Diffstat (limited to 'src/com/sneed/pkrandom/romhandlers')
-rwxr-xr-x | src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java | 2 | ||||
-rwxr-xr-x | src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java | 2 | ||||
-rw-r--r-- | src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java | 35 |
3 files changed, 31 insertions, 8 deletions
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java index 36c92a7..2000f7c 100755 --- a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java @@ -4333,7 +4333,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler { } private void enableGuaranteedPokemonCatching() { - int offset = find(rom, Gen3Constants.catchFailBranchLocator); + int offset = find(rom, Gen3Constants.perfectOddsBranchLocator); if (offset > 0) { // In Cmd_handleballthrow, the middle of the function checks if the odds of catching a Pokemon // is greater than 254; if it is, then the Pokemon is automatically caught. In ASM, this is diff --git a/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java index cc98c3b..a529d95 100755 --- a/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java @@ -5536,7 +5536,7 @@ public class Gen4RomHandler extends AbstractDSRomHandler { private void enableGuaranteedPokemonCatching() {
try {
byte[] battleOverlay = readOverlay(romEntry.getInt("BattleOvlNumber"));
- int offset = find(battleOverlay, Gen4Constants.catchFailBranchLocator);
+ int offset = find(battleOverlay, Gen4Constants.perfectOddsBranchLocator);
if (offset > 0) {
// In Cmd_handleballthrow (name taken from pokeemerald decomp), the middle of the function checks
// if the odds of catching a Pokemon is greater than 254; if it is, then the Pokemon is automatically
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java index 11e0dc0..6ed238c 100644 --- a/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java @@ -2397,6 +2397,7 @@ public class Gen7RomHandler extends Abstract3DSRomHandler { available |= MiscTweak.BAN_LUCKY_EGG.getValue(); available |= MiscTweak.SOS_BATTLES_FOR_ALL.getValue(); available |= MiscTweak.RETAIN_ALT_FORMES.getValue(); + available |= MiscTweak.GUARANTEED_POKEMON_CATCHING.getValue(); return available; } @@ -2404,20 +2405,19 @@ public class Gen7RomHandler extends Abstract3DSRomHandler { public void applyMiscTweak(MiscTweak tweak) { if (tweak == MiscTweak.FASTEST_TEXT) { applyFastestText(); - } - if (tweak == MiscTweak.BAN_LUCKY_EGG) { + } else if (tweak == MiscTweak.BAN_LUCKY_EGG) { allowedItems.banSingles(Items.luckyEgg); nonBadItems.banSingles(Items.luckyEgg); - } - if (tweak == MiscTweak.SOS_BATTLES_FOR_ALL) { + } else if (tweak == MiscTweak.SOS_BATTLES_FOR_ALL) { positiveCallRates(); - } - if (tweak == MiscTweak.RETAIN_ALT_FORMES) { + } else if (tweak == MiscTweak.RETAIN_ALT_FORMES) { try { patchFormeReversion(); } catch (IOException e) { e.printStackTrace(); } + } else if (tweak == MiscTweak.GUARANTEED_POKEMON_CATCHING) { + enableGuaranteedPokemonCatching(); } } @@ -2454,6 +2454,29 @@ public class Gen7RomHandler extends Abstract3DSRomHandler { } } + private void enableGuaranteedPokemonCatching() { + try { + byte[] battleCRO = readFile(romEntry.getFile("Battle")); + int offset = find(battleCRO, Gen7Constants.perfectOddsBranchLocator); + if (offset > 0) { + // The game checks to see if your odds are greater then or equal to 255 using the following + // code. Note that they compare to 0xFF000 instead of 0xFF; it looks like all catching code + // probabilities are shifted like this? + // cmp r7, #0xFF000 + // blt oddsLessThanOrEqualTo254 + // The below code just nops the branch out so it always acts like our odds are 255, and + // Pokemon are automatically caught no matter what. + battleCRO[offset] = 0x00; + battleCRO[offset + 1] = 0x00; + battleCRO[offset + 2] = 0x00; + battleCRO[offset + 3] = 0x00; + writeFile(romEntry.getFile("Battle"), battleCRO); + } + } catch (IOException e) { + throw new RandomizerIOException(e); + } + } + @Override public List<Integer> getTMMoves() { String tmDataPrefix = Gen7Constants.getTmDataPrefix(romEntry.romType); |