summaryrefslogtreecommitdiff
path: root/src/com/sneed/pkrandom/romhandlers
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-10-21 06:54:03 -0700
committerRafael Marçalo <raroma09@gmail.com>2022-10-21 22:46:42 +0100
commit74b1c45b35d6a0f093f9a1f8ddc99b01584ff71e (patch)
treed62f5f352323f71acf045ad43e40fcf6b0d95a4d /src/com/sneed/pkrandom/romhandlers
parentf5fbbda90bf7733e0a2500e5a1707470bcd1c865 (diff)
Gen 6: Add support for Guaranteed Pokemon Catching
Diffstat (limited to 'src/com/sneed/pkrandom/romhandlers')
-rw-r--r--src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
index 86bfec7..ecbbc92 100644
--- a/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
@@ -2622,6 +2622,7 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
available |= MiscTweak.BAN_LUCKY_EGG.getValue();
available |= MiscTweak.RETAIN_ALT_FORMES.getValue();
available |= MiscTweak.NATIONAL_DEX_AT_START.getValue();
+ available |= MiscTweak.GUARANTEED_POKEMON_CATCHING.getValue();
return available;
}
@@ -2640,6 +2641,8 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
}
} else if (tweak == MiscTweak.NATIONAL_DEX_AT_START) {
patchForNationalDex();
+ } else if (tweak == MiscTweak.GUARANTEED_POKEMON_CATCHING) {
+ enableGuaranteedPokemonCatching();
}
}
@@ -2731,6 +2734,30 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
}
}
+ // TODO: Battle CRO for XY
+ private void enableGuaranteedPokemonCatching() {
+ try {
+ byte[] battleCRO = readFile(romEntry.getFile("Battle"));
+ int offset = find(battleCRO, Gen6Constants.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 r6, #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 = Gen6Constants.tmDataPrefix;
@@ -4092,6 +4119,7 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
long expectedCRC32 = romEntry.files.get(fileKey).expectedCRC32s[index];
long actualCRC32 = actualFileCRC32s.get(fileKey);
if (expectedCRC32 != actualCRC32) {
+ System.out.println(actualCRC32);
return false;
}
}