summaryrefslogtreecommitdiff
path: root/src/com/sneed/pkrandom
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
parent9c4a20b628b4e9a407a13e9ce9a2973b05db62bc (diff)
Gen 3: Add support for Guaranteed Pokemon Catching
Diffstat (limited to 'src/com/sneed/pkrandom')
-rwxr-xr-xsrc/com/sneed/pkrandom/MiscTweak.java1
-rw-r--r--src/com/sneed/pkrandom/Version.java5
-rw-r--r--src/com/sneed/pkrandom/constants/Gen3Constants.java2
-rw-r--r--src/com/sneed/pkrandom/newgui/Bundle.properties2
-rw-r--r--src/com/sneed/pkrandom/newgui/NewRandomizerGUI.form11
-rw-r--r--src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java1
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java20
7 files changed, 40 insertions, 2 deletions
diff --git a/src/com/sneed/pkrandom/MiscTweak.java b/src/com/sneed/pkrandom/MiscTweak.java
index 5cbdda1..7391c30 100755
--- a/src/com/sneed/pkrandom/MiscTweak.java
+++ b/src/com/sneed/pkrandom/MiscTweak.java
@@ -61,6 +61,7 @@ public class MiscTweak implements Comparable<MiscTweak> {
public static final MiscTweak FASTER_HP_AND_EXP_BARS = new MiscTweak(1 << 19, "fasterHpAndExpBars", 0);
public static final MiscTweak FAST_DISTORTION_WORLD = new MiscTweak(1 << 20, "fastDistortionWorld", 0);
public static final MiscTweak UPDATE_ROTOM_FORME_TYPING = new MiscTweak(1 << 21, "updateRotomFormeTyping", 0);
+ public static final MiscTweak GUARANTEED_POKEMON_CATCHING = new MiscTweak(1 << 22, "guaranteedPokemonCatching", 0);
/* @formatter:on */
private final int value;
diff --git a/src/com/sneed/pkrandom/Version.java b/src/com/sneed/pkrandom/Version.java
index 9a1d00a..c05394e 100644
--- a/src/com/sneed/pkrandom/Version.java
+++ b/src/com/sneed/pkrandom/Version.java
@@ -28,8 +28,8 @@ import java.util.HashMap;
import java.util.Map;
public class Version {
- public static final int VERSION = 320; // Increment by 1 for new version. Updated for 4.5.1-dev.
- public static final String VERSION_STRING = "4.5.1-dev";
+ public static final int VERSION = 321; // Increment by 1 for new version. Updated for 4.5.2-dev.
+ public static final String VERSION_STRING = "4.5.2-dev";
public static final Map<Integer,String> oldVersions = setupVersionsMap();
@@ -60,6 +60,7 @@ public class Version {
map.put(317, "4.3.0");
map.put(318, "4.4.0");
map.put(319, "4.5.0");
+ map.put(320, "4.5.1");
// Latest version - when version is updated, add the old version as an explicit put
map.put(VERSION, VERSION_STRING);
diff --git a/src/com/sneed/pkrandom/constants/Gen3Constants.java b/src/com/sneed/pkrandom/constants/Gen3Constants.java
index 98815e6..892c1a4 100644
--- a/src/com/sneed/pkrandom/constants/Gen3Constants.java
+++ b/src/com/sneed/pkrandom/constants/Gen3Constants.java
@@ -164,6 +164,8 @@ public class Gen3Constants {
public static final String friendshipValueForEvoLocator = "DB2900D8";
+ public static final String catchFailBranchLocator = "FE2E2FD90020";
+
public static final int unhackedMaxPokedex = 411, unhackedRealPokedex = 386, hoennPokesStart = 252;
public static final int evolutionMethodCount = 15;
diff --git a/src/com/sneed/pkrandom/newgui/Bundle.properties b/src/com/sneed/pkrandom/newgui/Bundle.properties
index 6b5ec6b..e297729 100644
--- a/src/com/sneed/pkrandom/newgui/Bundle.properties
+++ b/src/com/sneed/pkrandom/newgui/Bundle.properties
@@ -519,6 +519,8 @@ CodeTweaks.fastDistortionWorld.name=Fast Distortion World
CodeTweaks.fastDistortionWorld.toolTipText=<html>Cuts out most of the Distortion World by instantly warping you to the Cyrus fight when you enter it.
CodeTweaks.updateRotomFormeTyping.name=Update Rotom Appliance Typings
CodeTweaks.updateRotomFormeTyping.toolTipText=<html>Updates the typings of Rotom's alternate formes (i.e., the appliances) to match the typings they have in Gen 5 and onwards.<br />For example, Wash Rotom will change from Electric/Ghost to Electric/Water.
+CodeTweaks.guaranteedPokemonCatching.name=Guaranteed Pokemon Catching
+CodeTweaks.guaranteedPokemonCatching.toolTipText=<html>Makes it so that any Poke Ball thrown at a wild Pokemon will be guaranteed to catch them, so long as the Pokemon is catchable in the first place.
CustomNamesEditorDialog.trainerNamesSP.TabConstraints.tabTitle=Trainer Names
CustomNamesEditorDialog.title=Custom Names Editor
CustomNamesEditorDialog.closeBtn.text=Close
diff --git a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.form b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.form
index 4b1ff5d..838994c 100644
--- a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.form
+++ b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.form
@@ -3609,6 +3609,17 @@
<toolTipText resource-bundle="com/sneed/pkrandom/newgui/Bundle" key="CodeTweaks.updateRotomFormeTyping.toolTipText"/>
</properties>
</component>
+ <component id="c40e" class="javax.swing.JCheckBox" binding="miscGuaranteedPokemonCatchingCheckBox">
+ <constraints>
+ <grid row="6" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <gridbag weightx="0.0" weighty="0.0"/>
+ </constraints>
+ <properties>
+ <enabled value="false"/>
+ <text resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="CodeTweaks.guaranteedPokemonCatching.name"/>
+ <toolTipText resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="CodeTweaks.guaranteedPokemonCatching.toolTipText"/>
+ </properties>
+ </component>
</children>
</grid>
<hspacer id="c4e06">
diff --git a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
index 5eecbe7..a625e8c 100644
--- a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
+++ b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
@@ -297,6 +297,7 @@ public class NewRandomizerGUI {
private JCheckBox tpBetterMovesetsCheckBox;
private JCheckBox paEnsureTwoAbilitiesCheckbox;
private JCheckBox miscUpdateRotomFormeTypingCheckBox;
+ private JCheckBox miscGuaranteedPokemonCatchingCheckBox;
private static JFrame frame;
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;