summaryrefslogtreecommitdiff
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
parentf5fbbda90bf7733e0a2500e5a1707470bcd1c865 (diff)
Gen 6: Add support for Guaranteed Pokemon Catching
-rw-r--r--src/com/sneed/pkrandom/config/gen6_offsets.ini1
-rw-r--r--src/com/sneed/pkrandom/constants/Gen6Constants.java2
-rw-r--r--src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java28
3 files changed, 31 insertions, 0 deletions
diff --git a/src/com/sneed/pkrandom/config/gen6_offsets.ini b/src/com/sneed/pkrandom/config/gen6_offsets.ini
index 3b96a9e..b97ebbe 100644
--- a/src/com/sneed/pkrandom/config/gen6_offsets.ini
+++ b/src/com/sneed/pkrandom/config/gen6_offsets.ini
@@ -33,6 +33,7 @@ File<MegaEvolutions>=<a/2/1/6, [FE88377C, FE88377C]>
File<PokemonStats>=<a/2/1/8, [7834E6AE, 7834E6AE]>
File<BabyPokemon>=<a/2/1/9, [8219BA02, 8219BA02]>
File<ItemData>=<a/2/2/0, [C013D028, C013D028]>
+File<Battle>=<DllBattle.cro, [E0AAA768, 721F8FAC]>
File<Field>=<DllField.cro, [9ECEE09B, 555BBB72]>
File<StaticPokemon>=<DllField.cro, [9ECEE09B, 555BBB72]>
File<Intro>=<DllIntro.cro, [6C0EE4DD, 21DBFF0B]>
diff --git a/src/com/sneed/pkrandom/constants/Gen6Constants.java b/src/com/sneed/pkrandom/constants/Gen6Constants.java
index 4b2f2d6..6e4aa3b 100644
--- a/src/com/sneed/pkrandom/constants/Gen6Constants.java
+++ b/src/com/sneed/pkrandom/constants/Gen6Constants.java
@@ -249,6 +249,8 @@ public class Gen6Constants {
public static final String friendshipValueForEvoLocator = "DC0050E3BC00002A";
+ public static final String perfectOddsBranchLocator = "050000BA000050E3";
+
public static final String[] fastestTextPrefixes = new String[]{"1080BDE80000A0E31080BDE8F0412DE9", "485080E59C4040E24C50C0E5EC009FE5"};
private static final List<Integer> mainGameShopsXY = Arrays.asList(
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;
}
}