diff options
Diffstat (limited to 'src/com/sneed/pkrandom')
6 files changed, 35 insertions, 10 deletions
diff --git a/src/com/sneed/pkrandom/constants/Gen3Constants.java b/src/com/sneed/pkrandom/constants/Gen3Constants.java index 892c1a4..7f440a0 100644 --- a/src/com/sneed/pkrandom/constants/Gen3Constants.java +++ b/src/com/sneed/pkrandom/constants/Gen3Constants.java @@ -164,7 +164,7 @@ public class Gen3Constants { public static final String friendshipValueForEvoLocator = "DB2900D8"; - public static final String catchFailBranchLocator = "FE2E2FD90020"; + public static final String perfectOddsBranchLocator = "FE2E2FD90020"; public static final int unhackedMaxPokedex = 411, unhackedRealPokedex = 386, hoennPokesStart = 252; diff --git a/src/com/sneed/pkrandom/constants/Gen4Constants.java b/src/com/sneed/pkrandom/constants/Gen4Constants.java index 1309073..b314489 100644 --- a/src/com/sneed/pkrandom/constants/Gen4Constants.java +++ b/src/com/sneed/pkrandom/constants/Gen4Constants.java @@ -770,7 +770,7 @@ public class Gen4Constants { public static final String friendshipValueForEvoLocator = "DC286AD3"; - public static final String catchFailBranchLocator = "FF2901D30425"; + public static final String perfectOddsBranchLocator = "FF2901D30425"; public static final int[] dpptOverworldDexMaps = new int[] { 1, 2, 3, 4, 5, -1, -1, 6, -1, 7, // 0-9 (cities, pkmn league, wind/ironworks) diff --git a/src/com/sneed/pkrandom/constants/Gen7Constants.java b/src/com/sneed/pkrandom/constants/Gen7Constants.java index cd78fd3..6dca571 100644 --- a/src/com/sneed/pkrandom/constants/Gen7Constants.java +++ b/src/com/sneed/pkrandom/constants/Gen7Constants.java @@ -319,6 +319,8 @@ public class Gen7Constants { public static final String friendshipValueForEvoLocator = "DC0050E3F700002A"; + public static final String perfectOddsBranchLocator = "050000BA000050E3"; + public static int getPokemonCount(int romType) { if (romType == Type_SM) { return pokemonCountSM; 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); |