summaryrefslogtreecommitdiff
path: root/src/com/sneed
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-09-22 23:57:01 -0700
committerrafa_99 <raroma09@gmail.com>2022-09-24 01:02:39 +0100
commit4226887959f7e48d2fa1b24943384abe2b16447a (patch)
tree1957d573b565d257afbe82ae1988b32dbd4891ad /src/com/sneed
parent88f5b7bc0fc6ac127cbc662448bdd592827ea02a (diff)
Add support for randomizing starter held items in DPPt
Diffstat (limited to 'src/com/sneed')
-rwxr-xr-xsrc/com/sneed/pkrandom/config/gen4_offsets.ini4
-rw-r--r--src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java8
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java6
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java5
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java5
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java17
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java5
-rw-r--r--src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java5
-rw-r--r--src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java5
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/RomHandler.java2
10 files changed, 55 insertions, 7 deletions
diff --git a/src/com/sneed/pkrandom/config/gen4_offsets.ini b/src/com/sneed/pkrandom/config/gen4_offsets.ini
index f225d43..9aab5dd 100755
--- a/src/com/sneed/pkrandom/config/gen4_offsets.ini
+++ b/src/com/sneed/pkrandom/config/gen4_offsets.ini
@@ -30,6 +30,8 @@ NationalDexAtStartTweak=national_dex/dp_national_dex
StarterPokemonOffset=0x1B88
StarterPokemonGraphicsPrefix=000222402104120C
StarterPokemonGraphicsPrefixInner=0290039002200002
+StarterPokemonScriptOffset=342
+StarterPokemonHeldItemOffset=0x2B4
HasExtraPokemonNames=Yes
PokemonNamesTextOffset=362
TrainerNamesTextOffset=559
@@ -166,6 +168,8 @@ NationalDexAtStartTweak=national_dex/plat_national_dex
StarterPokemonOffset=0x1BC0
StarterPokemonGraphicsPrefix=000222402104120C
StarterPokemonGraphicsPrefixInner=0290039002200002
+StarterPokemonScriptOffset=427
+StarterPokemonHeldItemOffset=0x460
MoveTutorMovesOffset=0x2FF64
MoveTutorCount=38
MoveTutorBytesCount=12
diff --git a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
index 0a45b80..03e9d00 100644
--- a/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
+++ b/src/com/sneed/pkrandom/newgui/NewRandomizerGUI.java
@@ -2669,11 +2669,11 @@ public class NewRandomizerGUI {
}
populateDropdowns();
- boolean hasStarterHeldItems = (pokemonGeneration != 1 && pokemonGeneration != 4 && pokemonGeneration != 5);
- spRandomizeStarterHeldItemsCheckBox.setEnabled(hasStarterHeldItems);
- spRandomizeStarterHeldItemsCheckBox.setVisible(hasStarterHeldItems);
+ boolean supportsStarterHeldItems = romHandler.supportsStarterHeldItems();
+ spRandomizeStarterHeldItemsCheckBox.setEnabled(supportsStarterHeldItems);
+ spRandomizeStarterHeldItemsCheckBox.setVisible(supportsStarterHeldItems);
spBanBadItemsCheckBox.setEnabled(false);
- spBanBadItemsCheckBox.setVisible(hasStarterHeldItems);
+ spBanBadItemsCheckBox.setVisible(supportsStarterHeldItems);
stpUnchangedRadioButton.setEnabled(true);
stpUnchangedRadioButton.setSelected(true);
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java
index 3ba0183..470d7c7 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen1RomHandler.java
@@ -991,6 +991,12 @@ public class Gen1RomHandler extends AbstractGBCRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ // No held items in Gen 1
+ return false;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
// do nothing
return new ArrayList<>();
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java
index 388bdbc..ef2c6ac 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen2RomHandler.java
@@ -835,6 +835,11 @@ public class Gen2RomHandler extends AbstractGBCRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ return true;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
List<Integer> sHeldItems = new ArrayList<>();
int[] shiOffsets = romEntry.arrayEntries.get("StarterHeldItems");
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
index 14a0987..a9dff29 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java
@@ -1576,6 +1576,11 @@ public class Gen3RomHandler extends AbstractGBRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ return true;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
List<Integer> sHeldItems = new ArrayList<>();
if (romEntry.romType == Gen3Constants.RomType_FRLG) {
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java
index 76e867a..19dcf80 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen4RomHandler.java
@@ -1567,14 +1567,25 @@ public class Gen4RomHandler extends AbstractDSRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ return romEntry.romType == Gen4Constants.Type_DP || romEntry.romType == Gen4Constants.Type_Plat;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
- // do nothing
- return new ArrayList<>();
+ int starterScriptNumber = romEntry.getInt("StarterPokemonScriptOffset");
+ int starterHeldItemOffset = romEntry.getInt("StarterPokemonHeldItemOffset");
+ byte[] file = scriptNarc.files.get(starterScriptNumber);
+ int item = FileFunctions.read2ByteInt(file, starterHeldItemOffset);
+ return Arrays.asList(item);
}
@Override
public void setStarterHeldItems(List<Integer> items) {
- // do nothing
+ int starterScriptNumber = romEntry.getInt("StarterPokemonScriptOffset");
+ int starterHeldItemOffset = romEntry.getInt("StarterPokemonHeldItemOffset");
+ byte[] file = scriptNarc.files.get(starterScriptNumber);
+ FileFunctions.write2ByteInt(file, starterHeldItemOffset, items.get(0));
}
@Override
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java
index 0243132..538c8da 100755
--- a/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java
@@ -1006,6 +1006,11 @@ public class Gen5RomHandler extends AbstractDSRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ return false;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
// do nothing
return new ArrayList<>();
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
index 03ab7cc..86bfec7 100644
--- a/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen6RomHandler.java
@@ -1160,6 +1160,11 @@ public class Gen6RomHandler extends Abstract3DSRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ return true;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
List<Integer> starterHeldItems = new ArrayList<>();
try {
diff --git a/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java
index 737eedc..07296f7 100644
--- a/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/Gen7RomHandler.java
@@ -1262,6 +1262,11 @@ public class Gen7RomHandler extends Abstract3DSRomHandler {
}
@Override
+ public boolean supportsStarterHeldItems() {
+ return true;
+ }
+
+ @Override
public List<Integer> getStarterHeldItems() {
List<Integer> starterHeldItems = new ArrayList<>();
try {
diff --git a/src/com/sneed/pkrandom/romhandlers/RomHandler.java b/src/com/sneed/pkrandom/romhandlers/RomHandler.java
index aa067e7..4078ead 100755
--- a/src/com/sneed/pkrandom/romhandlers/RomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/RomHandler.java
@@ -128,6 +128,8 @@ public interface RomHandler {
List<Pokemon> getPickedStarters();
+ boolean supportsStarterHeldItems();
+
List<Integer> getStarterHeldItems();
void setStarterHeldItems(List<Integer> items);