summaryrefslogtreecommitdiff
path: root/src/com/sneed/pkrandom/romhandlers
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-10-20 00:42:59 -0700
committerRafael Marçalo <raroma09@gmail.com>2022-10-21 02:05:55 +0100
commit6965244cc012abeb9fd11987af7507b3bac05d36 (patch)
tree4c38312bdd058a0972c0479577a14de80aeec390 /src/com/sneed/pkrandom/romhandlers
parent9c4a20b628b4e9a407a13e9ce9a2973b05db62bc (diff)
Gen 3: Add support for Guaranteed Pokemon Catching
Diffstat (limited to 'src/com/sneed/pkrandom/romhandlers')
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
index a9dff29..36c92a7 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
@@ -4112,6 +4112,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
if (romEntry.romType == Gen3Constants.RomType_FRLG) {
available |= MiscTweak.BALANCE_STATIC_LEVELS.getValue();
}
+ available |= MiscTweak.GUARANTEED_POKEMON_CATCHING.getValue();
return available;
}
@@ -4141,6 +4142,8 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
}
} else if (tweak == MiscTweak.UPDATE_TYPE_EFFECTIVENESS) {
updateTypeEffectiveness();
+ } else if (tweak == MiscTweak.GUARANTEED_POKEMON_CATCHING) {
+ enableGuaranteedPokemonCatching();
}
}
@@ -4329,6 +4332,23 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
}
}
+ private void enableGuaranteedPokemonCatching() {
+ int offset = find(rom, Gen3Constants.catchFailBranchLocator);
+ 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
+ // represented by:
+ // cmp r6, #0xFE
+ // bls oddsLessThanOrEqualTo254
+ // The below code just nops these two instructions so that we *always* act like our odds are 255,
+ // and Pokemon are automatically caught no matter what.
+ rom[offset] = 0x00;
+ rom[offset + 1] = 0x00;
+ rom[offset + 2] = 0x00;
+ rom[offset + 3] = 0x00;
+ }
+ }
+
@Override
public boolean isRomValid() {
return romEntry.expectedCRC32 == actualCRC32;