diff options
9 files changed, 389 insertions, 63 deletions
diff --git a/src/com/dabomstew/pkrandom/Randomizer.java b/src/com/dabomstew/pkrandom/Randomizer.java index b7368d3..28d741f 100644 --- a/src/com/dabomstew/pkrandom/Randomizer.java +++ b/src/com/dabomstew/pkrandom/Randomizer.java @@ -643,6 +643,13 @@ public class Randomizer { logShops(log);
}
+ // Pickup Items
+ if (settings.getPickupItemsMod() == Settings.PickupItemsMod.RANDOM) {
+ List<Integer> oldPickupItems = romHandler.getPickupItems();
+ romHandler.randomizePickupItems(settings);
+ logPickupItems(log, oldPickupItems);
+ }
+
// Test output for placement history
// romHandler.renderPlacementHistory();
@@ -1218,6 +1225,19 @@ public class Randomizer { log.println();
}
+ private void logPickupItems(final PrintStream log, List<Integer> oldPickupItems) {
+ List<Integer> pickupItems = romHandler.getPickupItems();
+ String[] itemNames = romHandler.getItemNames();
+ log.println("--Pickup Items--");
+ for (int i = 0; i < oldPickupItems.size(); i++) {
+ int item = pickupItems.get(i);
+ int oldItem = oldPickupItems.get(i);
+ log.printf("%s => %s", itemNames[oldItem], itemNames[item]);
+ log.println();
+ }
+ log.println();
+ }
+
private List<String> getTrainerNames() {
List<String> trainerNames = new ArrayList<>();
trainerNames.add(""); // for index 0
diff --git a/src/com/dabomstew/pkrandom/Settings.java b/src/com/dabomstew/pkrandom/Settings.java index ec4464b..f32ab97 100644 --- a/src/com/dabomstew/pkrandom/Settings.java +++ b/src/com/dabomstew/pkrandom/Settings.java @@ -49,7 +49,7 @@ public class Settings { public static final int VERSION = Version.VERSION;
- public static final int LENGTH_OF_SETTINGS_DATA = 49;
+ public static final int LENGTH_OF_SETTINGS_DATA = 50;
private CustomNamesSet customNames;
@@ -304,6 +304,13 @@ public class Settings { private boolean guaranteeEvolutionItems;
private boolean guaranteeXItems;
+ public enum PickupItemsMod {
+ UNCHANGED, RANDOM
+ }
+
+ private PickupItemsMod pickupItemsMod = PickupItemsMod.UNCHANGED;
+ private boolean banBadRandomPickupItems;
+
// to and from strings etc
public void write(FileOutputStream out) throws IOException {
byte[] settings = toString().getBytes("UTF-8");
@@ -366,7 +373,6 @@ public class Settings { limitPokemon, typesFollowMegaEvolutions));
// 3: v171: changed to the abilities byte
-
out.write(makeByteSelected(abilitiesMod == AbilitiesMod.UNCHANGED, abilitiesMod == AbilitiesMod.RANDOMIZE,
allowWonderGuard, abilitiesFollowEvolutions, banTrappingAbilities, banNegativeAbilities, banBadAbilities,
abilitiesFollowMegaEvolutions));
@@ -376,7 +382,7 @@ public class Settings { startersMod == StartersMod.UNCHANGED, startersMod == StartersMod.RANDOM_WITH_TWO_EVOLUTIONS,
randomizeStartersHeldItems, banBadRandomStarterHeldItems, allowStarterAltFormes));
- // @5 dropdowns
+ // 5 - 10: dropdowns
write2ByteInt(out, customStarters[0] - 1);
write2ByteInt(out, customStarters[1] - 1);
write2ByteInt(out, customStarters[2] - 1);
@@ -391,7 +397,6 @@ public class Settings { out.write((movesetsForceGoodDamaging ? 0x80 : 0) | movesetsGoodDamagingPercent);
// 13 trainer pokemon
- // changed 160
out.write(makeByteSelected(trainersMod == TrainersMod.UNCHANGED,
trainersMod == TrainersMod.RANDOM,
trainersMod == TrainersMod.DISTRIBUTED,
@@ -410,7 +415,6 @@ public class Settings { wildPokemonMod == WildPokemonMod.UNCHANGED, useTimeBasedEncounters));
// 16 wild pokemon 2
- // bugfix 161
out.write(makeByteSelected(useMinimumCatchRate, blockWildLegendaries,
wildPokemonRestrictionMod == WildPokemonRestrictionMod.SIMILAR_STRENGTH, randomizeWildPokemonHeldItems,
banBadRandomWildPokemonHeldItems, false, false, balanceShakingGrass)
@@ -424,7 +428,6 @@ public class Settings { limitMainGameLegendaries, limit600, allowStaticAltFormes, swapStaticMegaEvos));
// 18 tm randomization
- // new stuff 162
out.write(makeByteSelected(tmsHmsCompatibilityMod == TMsHMsCompatibilityMod.COMPLETELY_RANDOM,
tmsHmsCompatibilityMod == TMsHMsCompatibilityMod.RANDOM_PREFER_TYPE,
tmsHmsCompatibilityMod == TMsHMsCompatibilityMod.UNCHANGED, tmsMod == TMsMod.RANDOM,
@@ -432,7 +435,6 @@ public class Settings { tmsHmsCompatibilityMod == TMsHMsCompatibilityMod.FULL));
// 19 tms part 2
- // new in 170
out.write(makeByteSelected(fullHMCompat, tmsFollowEvolutions, tutorFollowEvolutions));
// 20 tms good damaging
@@ -449,7 +451,6 @@ public class Settings { // 22 tutors good damaging
out.write((tutorsForceGoodDamaging ? 0x80 : 0) | tutorsGoodDamagingPercent);
- // new 150
// 23 in game trades
out.write(makeByteSelected(inGameTradesMod == InGameTradesMod.RANDOMIZE_GIVEN_AND_REQUESTED,
inGameTradesMod == InGameTradesMod.RANDOMIZE_GIVEN, randomizeInGameTradesItems,
@@ -460,7 +461,6 @@ public class Settings { out.write(makeByteSelected(fieldItemsMod == FieldItemsMod.RANDOM, fieldItemsMod == FieldItemsMod.SHUFFLE,
fieldItemsMod == FieldItemsMod.UNCHANGED, banBadRandomFieldItems, fieldItemsMod == FieldItemsMod.RANDOM_EVEN));
- // new 170
// 25 move randomizers
// + static music
out.write(makeByteSelected(randomizeMovePowers, randomizeMoveAccuracies, randomizeMovePPs, randomizeMoveTypes,
@@ -479,7 +479,7 @@ public class Settings { swapTrainerMegaEvos,
shinyChance));
- // @ 28 pokemon restrictions
+ // 28 - 31: pokemon restrictions
try {
if (currentRestrictions != null) {
writeFullInt(out, currentRestrictions.toInt());
@@ -490,21 +490,25 @@ public class Settings { e.printStackTrace(); // better than nothing
}
- // @ 32 misc tweaks
+ // 32 - 35: misc tweaks
try {
writeFullInt(out, currentMiscTweaks);
} catch (IOException e) {
e.printStackTrace(); // better than nothing
}
- // @ 36 trainer pokemon level modifier
+ // 36 trainer pokemon level modifier
out.write((trainersLevelModified ? 0x80 : 0) | (trainersLevelModifier+50));
+ // 37 shop items
out.write(makeByteSelected(shopItemsMod == ShopItemsMod.RANDOM, shopItemsMod == ShopItemsMod.SHUFFLE,
- shopItemsMod == ShopItemsMod.UNCHANGED, banBadRandomShopItems, banRegularShopItems, banOPShopItems, balanceShopPrices, guaranteeEvolutionItems));
+ shopItemsMod == ShopItemsMod.UNCHANGED, banBadRandomShopItems, banRegularShopItems, banOPShopItems,
+ balanceShopPrices, guaranteeEvolutionItems));
+ // 38 wild level modifier
out.write((wildLevelsModified ? 0x80 : 0) | (wildLevelModifier+50));
+ // 39 EXP curve mod, block broken moves, alt forme stuff
out.write(makeByteSelected(
expCurveMod == ExpCurveMod.LEGENDARIES,
expCurveMod == ExpCurveMod.STRONG_LEGENDARIES,
@@ -515,12 +519,13 @@ public class Settings { allowTrainerAlternateFormes,
allowWildAltFormes));
- // 40
+ // 40 Double Battle Mode, Additional Boss/Important Trainer Pokemon, Weigh Duplicate Abilities
out.write((doubleBattleMode ? 0x1 : 0) |
(additionalBossTrainerPokemon << 1) |
(additionalImportantTrainerPokemon << 4) |
(weighDuplicateAbilitiesTogether ? 0x80 : 0));
+ // 41 Additional Regular Trainer Pokemon, Aura modification, evolution moves, guarantee X items
out.write(additionalRegularTrainerPokemon |
((auraMod == AuraMod.UNCHANGED) ? 0x8 : 0) |
((auraMod == AuraMod.RANDOM) ? 0x10 : 0) |
@@ -528,6 +533,7 @@ public class Settings { (evolutionMovesForAll ? 0x40 : 0) |
(guaranteeXItems ? 0x80 : 0));
+ // 42 Totem Pokemon settings
out.write(makeByteSelected(
totemPokemonMod == TotemPokemonMod.UNCHANGED,
totemPokemonMod == TotemPokemonMod.RANDOM,
@@ -536,18 +542,19 @@ public class Settings { allyPokemonMod == AllyPokemonMod.RANDOM,
allyPokemonMod == AllyPokemonMod.SIMILAR_STRENGTH,
randomizeTotemHeldItems,
- allowTotemAltFormes
- ));
+ allowTotemAltFormes));
+ // 43 Totem level modifier
out.write((totemLevelsModified ? 0x80 : 0) | (totemLevelModifier+50));
- // These two get a byte each for future proofing
+ // 44 - 45: These two get a byte each for future proofing
out.write(updateBaseStatsToGeneration);
-
out.write(updateMovesToGeneration);
+ // 46 Selected EXP curve
out.write(selectedEXPCurve.toByte());
+ // 47 Static level modifier
out.write((staticLevelModified ? 0x80 : 0) | (staticLevelModifier+50));
// 48 trainer pokemon held items.
@@ -558,6 +565,10 @@ public class Settings { sensibleItemsOnlyForTrainerPokemon,
highestLevelOnlyGetsItemsForTrainerPokemon));
+ // 49 pickup item randomization
+ out.write(makeByteSelected(pickupItemsMod == PickupItemsMod.UNCHANGED,
+ pickupItemsMod == PickupItemsMod.RANDOM, banBadRandomPickupItems));
+
try {
byte[] romName = this.romName.getBytes("US-ASCII");
out.write(romName.length);
@@ -835,6 +846,11 @@ public class Settings { settings.setSensibleItemsOnlyForTrainers(restoreState(data[48], 4));
settings.setHighestLevelGetsItemsForTrainers(restoreState(data[48], 5));
+ settings.setPickupItemsMod(restoreEnum(PickupItemsMod.class, data[49],
+ 1, // UNCHANGED
+ 0)); // RANDOMIZE
+ settings.setBanBadRandomPickupItems(restoreState(data[49], 2));
+
int romNameLength = data[LENGTH_OF_SETTINGS_DATA] & 0xFF;
String romName = new String(data, LENGTH_OF_SETTINGS_DATA + 1, romNameLength, "US-ASCII");
settings.setRomName(romName);
@@ -2195,6 +2211,26 @@ public class Settings { this.guaranteeXItems = guaranteeXItems;
}
+ public PickupItemsMod getPickupItemsMod() {
+ return pickupItemsMod;
+ }
+
+ public void setPickupItemsMod(boolean... bools) {
+ setPickupItemsMod(getEnum(PickupItemsMod.class, bools));
+ }
+
+ private void setPickupItemsMod(PickupItemsMod pickupItemsMod) {
+ this.pickupItemsMod = pickupItemsMod;
+ }
+
+ public boolean isBanBadRandomPickupItems() {
+ return banBadRandomPickupItems;
+ }
+
+ public void setBanBadRandomPickupItems(boolean banBadRandomPickupItems) {
+ this.banBadRandomPickupItems = banBadRandomPickupItems;
+ }
+
private static int makeByteSelected(boolean... bools) {
if (bools.length > 8) {
throw new IllegalArgumentException("Can't set more than 8 bits in a byte!");
diff --git a/src/com/dabomstew/pkrandom/config/gen3_offsets.ini b/src/com/dabomstew/pkrandom/config/gen3_offsets.ini index 04e988d..7e1710b 100755 --- a/src/com/dabomstew/pkrandom/config/gen3_offsets.ini +++ b/src/com/dabomstew/pkrandom/config/gen3_offsets.ini @@ -45,6 +45,8 @@ RunIndoorsTweakOffset=0xE5E00 CatchingTutorialOpponentMonOffset=0x81B00 CatchingTutorialPlayerMonOffset=0x10F62E PCPotionOffset=0x4062F0 +PickupTableStartLocator=16001E00170028000200320044003C +PickupItemCount=10 InstantTextTweak=instant_text/ruby_10_instant_text TypeEffectivenessOffset=0x1F9720 StaticPokemonSupport=1 @@ -308,6 +310,8 @@ InstantTextTweak=instant_text/em_instant_text CatchingTutorialOpponentMonOffset=0xB0870 CatchingTutorialPlayerMonOffset=0x139472 PCPotionOffset=0x5DFEFC +PickupTableStartLocator=0D000E0016000300560055 +PickupItemCount=29 TypeEffectivenessOffset=0x31ACE8 StaticPokemonSupport=1 StaticPokemon{}={Species=[0x211A1C, 0x211A41, 0x211A44, 0x211AC6, 0x211AD4], Level=[0x211A46]} // Lileep @@ -429,6 +433,8 @@ RunIndoorsTweakOffset=0xBD494 InstantTextTweak=instant_text/fr_10_instant_text CatchingTutorialOpponentMonOffset=0x7F88C PCPotionOffset=0x402220 +PickupTableStartLocator=8B000F00850019008600230087002D +PickupItemCount=16 TypeEffectivenessOffset=0x24F050 StaticPokemonSupport=1 StaticPokemon{}={Species=[0x16C472, 0x16C475, 0x16C4B5, 0x16C4E9], Level=[0x16C477]} // Eevee in Celadon Condominiums diff --git a/src/com/dabomstew/pkrandom/newgui/Bundle.properties b/src/com/dabomstew/pkrandom/newgui/Bundle.properties index 0937d4a..fb56e57 100644 --- a/src/com/dabomstew/pkrandom/newgui/Bundle.properties +++ b/src/com/dabomstew/pkrandom/newgui/Bundle.properties @@ -309,6 +309,13 @@ GUI.shGuaranteeEvolutionItemsCheckBox.toolTipText=<html>Checking this will ensur GUI.shGuaranteeEvolutionItemsCheckBox.text=Guarantee Evolution Items GUI.shGuaranteeXItemsCheckbox.tooltipText=<html>Checking this will ensure all X items (including Guard Spec. and Dire Hit) appear in shops. GUI.shGuaranteeXItemsCheckbox.text=Guarantee X Items +GUI.puPanel.title=Pickup Items +GUI.puUnchangedRadioButton.toolTipText=Items obtained via the Pickup ability remain the same. +GUI.puUnchangedRadioButton.text=Unchanged +GUI.puRandomRadioButton.toolTipText=Items obtained via the Pickup ability are randomized. +GUI.puRandomRadioButton.text=Random +GUI.puBanBadItemsCheckBox.toolTipText=<html>Checking this will remove "bad" items that don't do much from the set of possible random items for the Pickup item table, such as berries and mail. +GUI.puBanBadItemsCheckBox.text=Ban Bad Items GUI.miscTweaksPanel.title=Misc. Tweaks GUI.miscPanel.title=Misc. Tweaks GUI.miscNoneAvailableLabel.text=There are no tweaks available for the currently loaded game. diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form index 504c052..8bf9b92 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.form @@ -3054,7 +3054,7 @@ </hspacer> <vspacer id="e7c77"> <constraints> - <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <gridbag weightx="0.0" weighty="0.1"/> </constraints> </vspacer> @@ -3206,6 +3206,75 @@ </component> </children> </grid> + <grid id="30a3f" binding="pickupItemsPanel" layout-manager="GridBagLayout"> + <constraints> + <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + <properties/> + <border type="none" title-resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" title-key="GUI.puPanel.title"> + <font style="1"/> + </border> + <children> + <component id="62bb6" class="javax.swing.JRadioButton" binding="puUnchangedRadioButton"> + <constraints> + <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <gridbag top="0" left="0" bottom="0" right="140" weightx="0.0" weighty="0.0"/> + </constraints> + <properties> + <enabled value="false"/> + <text resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="GUI.puUnchangedRadioButton.text"/> + <toolTipText resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="GUI.puUnchangedRadioButton.toolTipText"/> + </properties> + </component> + <hspacer id="5bf93"> + <constraints> + <grid row="1" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.1" weighty="0.0"/> + </constraints> + </hspacer> + <vspacer id="5fa25"> + <constraints> + <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + </vspacer> + <hspacer id="3b455"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + </hspacer> + <vspacer id="ff3b7"> + <constraints> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + <gridbag weightx="0.0" weighty="0.0"/> + </constraints> + </vspacer> + <component id="478a" class="javax.swing.JRadioButton" binding="puRandomRadioButton"> + <constraints> + <grid row="2" column="1" 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="GUI.puRandomRadioButton.text"/> + <toolTipText resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="GUI.puRandomRadioButton.toolTipText"/> + </properties> + </component> + <component id="45bbb" class="javax.swing.JCheckBox" binding="puBanBadItemsCheckBox"> + <constraints> + <grid row="1" column="2" 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="GUI.puBanBadItemsCheckBox.text"/> + <toolTipText resource-bundle="com/dabomstew/pkrandom/newgui/Bundle" key="GUI.puBanBadItemsCheckBox.toolTipText"/> + </properties> + </component> + </children> + </grid> </children> </grid> <grid id="e8bbb" binding="baseTweaksPanel" layout-manager="GridBagLayout"> @@ -3754,6 +3823,10 @@ <member id="b512"/> <member id="d3f0a"/> </group> + <group name="pickupItemButtonGroup"> + <member id="62bb6"/> + <member id="478a"/> + </group> </buttonGroups> <inspectionSuppressions> <suppress inspection="MissingMnemonic"/> diff --git a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java index 2f9cc04..d1ea234 100644 --- a/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java +++ b/src/com/dabomstew/pkrandom/newgui/NewRandomizerGUI.java @@ -287,6 +287,10 @@ public class NewRandomizerGUI { private JCheckBox tpConsumableItemsOnlyCheckBox; private JCheckBox tpSensibleItemsCheckBox; private JCheckBox tpHighestLevelGetsItemCheckBox; + private JPanel pickupItemsPanel; + private JRadioButton puUnchangedRadioButton; + private JRadioButton puRandomRadioButton; + private JCheckBox puBanBadItemsCheckBox; private static JFrame frame; @@ -449,6 +453,8 @@ public class NewRandomizerGUI { shUnchangedRadioButton.addActionListener(e -> enableOrDisableSubControls()); shShuffleRadioButton.addActionListener(e -> enableOrDisableSubControls()); shRandomRadioButton.addActionListener(e -> enableOrDisableSubControls()); + puUnchangedRadioButton.addActionListener(e -> enableOrDisableSubControls()); + puRandomRadioButton.addActionListener(e -> enableOrDisableSubControls()); websiteLinkLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -1497,6 +1503,9 @@ public class NewRandomizerGUI { shGuaranteeEvolutionItemsCheckBox.setSelected(settings.isGuaranteeEvolutionItems()); shGuaranteeXItemsCheckBox.setSelected(settings.isGuaranteeXItems()); + puUnchangedRadioButton.setSelected(settings.getPickupItemsMod() == Settings.PickupItemsMod.UNCHANGED); + puRandomRadioButton.setSelected(settings.getPickupItemsMod() == Settings.PickupItemsMod.RANDOM); + puBanBadItemsCheckBox.setSelected(settings.isBanBadRandomPickupItems()); int mtsSelected = settings.getCurrentMiscTweaks(); int mtCount = MiscTweak.allTweaks.size(); @@ -1676,7 +1685,6 @@ public class NewRandomizerGUI { settings.setBanBadRandomFieldItems(fiBanBadItemsCheckBox.isSelected()); settings.setShopItemsMod(shUnchangedRadioButton.isSelected(), shShuffleRadioButton.isSelected(), shRandomRadioButton.isSelected()); - settings.setBanBadRandomShopItems(shBanBadItemsCheckBox.isSelected()); settings.setBanRegularShopItems(shBanRegularShopItemsCheckBox.isSelected()); settings.setBanOPShopItems(shBanOverpoweredShopItemsCheckBox.isSelected()); @@ -1684,6 +1692,8 @@ public class NewRandomizerGUI { settings.setGuaranteeEvolutionItems(shGuaranteeEvolutionItemsCheckBox.isSelected()); settings.setGuaranteeXItems(shGuaranteeXItemsCheckBox.isSelected()); + settings.setPickupItemsMod(puUnchangedRadioButton.isSelected(), puRandomRadioButton.isSelected()); + settings.setBanBadRandomPickupItems(puBanBadItemsCheckBox.isSelected()); int currentMiscTweaks = 0; int mtCount = MiscTweak.allTweaks.size(); @@ -2383,6 +2393,15 @@ public class NewRandomizerGUI { shGuaranteeXItemsCheckBox.setVisible(true); shGuaranteeXItemsCheckBox.setEnabled(false); shGuaranteeXItemsCheckBox.setSelected(false); + puUnchangedRadioButton.setVisible(true); + puUnchangedRadioButton.setEnabled(false); + puUnchangedRadioButton.setSelected(false); + puRandomRadioButton.setVisible(true); + puRandomRadioButton.setEnabled(false); + puRandomRadioButton.setSelected(false); + puBanBadItemsCheckBox.setVisible(true); + puBanBadItemsCheckBox.setEnabled(false); + puBanBadItemsCheckBox.setSelected(false); miscBWExpPatchCheckBox.setVisible(true); miscBWExpPatchCheckBox.setEnabled(false); miscBWExpPatchCheckBox.setSelected(false); @@ -2732,6 +2751,11 @@ public class NewRandomizerGUI { shShuffleRadioButton.setEnabled(true); shRandomRadioButton.setEnabled(true); + pickupItemsPanel.setVisible(romHandler.generationOfPokemon() == 3); + puUnchangedRadioButton.setEnabled(true); + puUnchangedRadioButton.setSelected(true); + puRandomRadioButton.setEnabled(true); + int mtsAvailable = romHandler.miscTweaksAvailable(); int mtCount = MiscTweak.allTweaks.size(); List<JCheckBox> usableCheckBoxes = new ArrayList<>(); @@ -3333,6 +3357,13 @@ public class NewRandomizerGUI { shGuaranteeXItemsCheckBox.setEnabled(false); shGuaranteeXItemsCheckBox.setSelected(false); } + + if (puRandomRadioButton.isSelected() && puRandomRadioButton.isVisible() && puRandomRadioButton.isEnabled()) { + puBanBadItemsCheckBox.setEnabled(true); + } else { + puBanBadItemsCheckBox.setEnabled(false); + puBanBadItemsCheckBox.setSelected(false); + } } private void initTweaksPanel() { diff --git a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java index 9f01a32..e5884da 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java @@ -4943,6 +4943,21 @@ public abstract class AbstractRomHandler implements RomHandler { }
@Override
+ public void randomizePickupItems(Settings settings) {
+ boolean banBadItems = settings.isBanBadRandomPickupItems();
+
+ ItemList possibleItems = banBadItems ? this.getNonBadItems() : this.getAllowedItems();
+ List<Integer> currentItems = this.getPickupItems();
+ List<Integer> newItems = new ArrayList<>();
+ for (int i = 0; i < currentItems.size(); i++) {
+ // TODO: Should we allow TMs in Gen 3/4?
+ newItems.add(possibleItems.randomNonTM(this.random));
+ }
+
+ this.setPickupItems(newItems);
+ }
+
+ @Override
public void minimumCatchRate(int rateNonLegendary, int rateLegendary) {
List<Pokemon> pokes = getPokemonInclFormes();
for (Pokemon pkmn : pokes) {
@@ -6334,4 +6349,14 @@ public abstract class AbstractRomHandler implements RomHandler { public List<Pokemon> getBannedFormesForTrainerPokemon() {
return new ArrayList<>();
}
+
+ @Override
+ public List<Integer> getPickupItems() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public void setPickupItems(List<Integer> pickupItems) {
+ // do nothing
+ }
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java index 3f5c4e5..4a14722 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen3RomHandler.java @@ -76,6 +76,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler { private boolean copyStaticPokemon;
private Map<String, Integer> entries = new HashMap<>();
private Map<String, int[]> arrayEntries = new HashMap<>();
+ private Map<String, String> strings = new HashMap<>();
private List<StaticPokemon> staticPokemon = new ArrayList<>();
private List<StaticPokemon> roamingPokemon = new ArrayList<>();
private List<TMOrMTTextEntry> tmmtTexts = new ArrayList<>();
@@ -94,6 +95,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler { this.copyStaticPokemon = toCopy.copyStaticPokemon;
this.entries.putAll(toCopy.entries);
this.arrayEntries.putAll(toCopy.arrayEntries);
+ this.strings.putAll(toCopy.strings);
this.staticPokemon.addAll(toCopy.staticPokemon);
this.roamingPokemon.addAll(toCopy.roamingPokemon);
this.tmmtTexts.addAll(toCopy.tmmtTexts);
@@ -106,6 +108,13 @@ public class Gen3RomHandler extends AbstractGBRomHandler { }
return entries.get(key);
}
+
+ private String getString(String key) {
+ if (!strings.containsKey(key)) {
+ strings.put(key, "");
+ }
+ return strings.get(key);
+ }
}
private static class TMOrMTTextEntry {
@@ -210,6 +219,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler { // copy from here
current.arrayEntries.putAll(otherEntry.arrayEntries);
current.entries.putAll(otherEntry.entries);
+ current.strings.putAll(otherEntry.strings);
boolean cTT = (current.getValue("CopyTMText") == 1);
if (current.copyStaticPokemon) {
current.staticPokemon.addAll(otherEntry.staticPokemon);
@@ -224,6 +234,8 @@ public class Gen3RomHandler extends AbstractGBRomHandler { current.tableFile = otherEntry.tableFile;
}
}
+ } else if (r[0].endsWith("Locator")) {
+ current.strings.put(r[0], r[1]);
} else {
if (r[1].startsWith("[") && r[1].endsWith("]")) {
String[] offsets = r[1].substring(1, r[1].length() - 1).split(",");
@@ -332,6 +344,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler { private int pokedexCount;
private String[] pokeNames;
private ItemList allowedItems, nonBadItems;
+ private int pickupItemsTableOffset;
@Override
public boolean detectRom(byte[] rom) {
@@ -2757,6 +2770,41 @@ public class Gen3RomHandler extends AbstractGBRomHandler { }
@Override
+ public List<Integer> getPickupItems() {
+ List<Integer> pickupItems = new ArrayList<>();
+ int pickupItemCount = romEntry.getValue("PickupItemCount");
+ int sizeOfPickupEntry = romEntry.romType == Gen3Constants.RomType_Em ? 2 : 4;
+
+ if (pickupItemsTableOffset == 0) {
+ String pickupTableStartLocator = romEntry.getString("PickupTableStartLocator");
+ int offset = find(pickupTableStartLocator);
+ if (offset > 0) {
+ pickupItemsTableOffset = offset;
+ }
+ }
+
+ if (pickupItemsTableOffset > 0) {
+ for (int i = 0; i < pickupItemCount; i++) {
+ int itemOffset = pickupItemsTableOffset + (sizeOfPickupEntry * i);
+ int item = FileFunctions.read2ByteInt(rom, itemOffset);
+ pickupItems.add(item);
+ }
+ }
+ return pickupItems;
+ }
+
+ @Override
+ public void setPickupItems(List<Integer> pickupItems) {
+ int sizeOfPickupEntry = romEntry.romType == Gen3Constants.RomType_Em ? 2 : 4;
+ if (pickupItemsTableOffset > 0) {
+ for (int i = 0; i < pickupItems.size(); i++) {
+ int itemOffset = pickupItemsTableOffset + (sizeOfPickupEntry * i);
+ FileFunctions.write2ByteInt(rom, itemOffset, pickupItems.get(i));
+ }
+ }
+ }
+
+ @Override
public boolean canChangeTrainerText() {
return true;
}
diff --git a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java index 043ecdb..f4aa9ba 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/RomHandler.java @@ -48,7 +48,9 @@ public interface RomHandler { public abstract boolean isLoadable(String filename);
}
- // Basic load/save to filenames
+ // =======================
+ // Basic load/save methods
+ // =======================
boolean loadRom(String filename);
@@ -58,7 +60,9 @@ public interface RomHandler { String loadedFilename();
+ // =============================================================
// Methods relating to game updates for the 3DS and Switch games
+ // =============================================================
boolean hasGameUpdateLoaded();
@@ -68,14 +72,20 @@ public interface RomHandler { String getGameUpdateVersion();
- // Log stuff
+ // ===========
+ // Log methods
+ // ===========
void setLog(PrintStream logStream);
void printRomDiagnostics(PrintStream logStream);
- // Get a List of Pokemon objects in this game.
- // 0 = null 1-whatever = the Pokemon.
+ // ======================================================
+ // Methods for retrieving a list of Pokemon objects.
+ // Note that for many of these lists, index 0 is null.
+ // Instead, you use index on the species' National Dex ID
+ // ======================================================
+
List<Pokemon> getPokemon();
List<Pokemon> getPokemonInclFormes();
@@ -86,14 +96,18 @@ public interface RomHandler { Pokemon getAltFormeOfPokemon(Pokemon pk, int forme);
- boolean hasFunctionalFormes();
+ // ==================================
+ // Methods to set up Gen Restrictions
+ // ==================================
- // Setup Gen Restrictions.
void setPokemonPool(Settings settings);
void removeEvosForPokemonPool();
- // Randomizer: Starters
+ // ===============
+ // Starter Pokemon
+ // ===============
+
List<Pokemon> getStarters();
boolean setStarters(List<Pokemon> newStarters);
@@ -110,7 +124,15 @@ public interface RomHandler { List<Pokemon> getPickedStarters();
- // Randomizer: Pokemon stats
+ List<Integer> getStarterHeldItems();
+
+ void setStarterHeldItems(List<Integer> items);
+
+ void randomizeStarterHeldItems(Settings settings);
+
+ // =======================
+ // Pokemon Base Statistics
+ // =======================
// Run the stats shuffler on each Pokemon.
void shufflePokemonStats(Settings settings);
@@ -124,6 +146,12 @@ public interface RomHandler { Map<Integer,StatChange> getUpdatedPokemonStats(int generation);
+ void standardizeEXPCurves(Settings settings);
+
+ // ====================================
+ // Methods for selecting random Pokemon
+ // ====================================
+
// Give a random Pokemon who's in this game
Pokemon randomPokemon();
@@ -141,7 +169,9 @@ public interface RomHandler { // Should make a good starter Pokemon
Pokemon random2EvosPokemon(boolean allowAltFormes);
- // Randomizer: types
+ // =============
+ // Pokemon Types
+ // =============
// return a random type valid in this game.
Type randomType();
@@ -153,7 +183,10 @@ public interface RomHandler { // some evolutions dont anyway, e.g. Eeveelutions, Hitmons
void randomizePokemonTypes(Settings settings);
- // Randomizer: pokemon abilities
+ // =================
+ // Pokemon Abilities
+ // =================
+
int abilitiesPerPokemon();
int highestAbilityIndex();
@@ -170,7 +203,10 @@ public interface RomHandler { boolean hasMegaEvolutions();
- // Randomizer: wild pokemon
+ // ============
+ // Wild Pokemon
+ // ============
+
List<EncounterSet> getEncounters(boolean useTimeOfDay);
void setEncounters(boolean useTimeOfDay, List<EncounterSet> encounters);
@@ -189,12 +225,19 @@ public interface RomHandler { List<Pokemon> bannedForWildEncounters();
- // Randomizer: trainer pokemon
+ void randomizeWildHeldItems(Settings settings);
+
+ void changeCatchRates(Settings settings);
+
+ void minimumCatchRate(int rateNonLegendary, int rateLegendary);
+
+ // ===============
+ // Trainer Pokemon
+ // ===============
+
List<Trainer> getTrainers();
List<Integer> getMainPlaythroughTrainers();
-
- List<Integer> getEvolutionItems();
void setTrainers(List<Trainer> trainerData, boolean doubleBattleMode);
@@ -220,7 +263,10 @@ public interface RomHandler { void doubleBattleMode();
- // Randomizer: moves
+ // =========
+ // Move Data
+ // =========
+
void randomizeMovePowers();
void randomizeMovePPs();
@@ -243,6 +289,10 @@ public interface RomHandler { // return all the moves valid in this game.
List<Move> getMoves();
+ // ================
+ // Pokemon Movesets
+ // ================
+
Map<Integer, List<MoveLearnt>> getMovesLearnt();
void setMovesLearnt(Map<Integer, List<MoveLearnt>> movesets);
@@ -257,7 +307,9 @@ public interface RomHandler { boolean supportsFourStartingMoves();
- // Randomizer: static pokemon (except starters)
+ // ==============
+ // Static Pokemon
+ // ==============
List<StaticEncounter> getStaticPokemon();
@@ -285,7 +337,9 @@ public interface RomHandler { boolean hasStaticMusicFix();
- // Randomizer: Totem Pokemon
+ // =============
+ // Totem Pokemon
+ // =============
List<TotemPokemon> getTotemPokemon();
@@ -293,7 +347,9 @@ public interface RomHandler { void randomizeTotemPokemon(Settings settings);
- // Randomizer: TMs/HMs
+ // =========
+ // TMs & HMs
+ // =========
List<Integer> getTMMoves();
@@ -331,7 +387,9 @@ public interface RomHandler { void fullHMCompatibility();
- // Randomizer: move tutors
+ // ===========
+ // Move Tutors
+ // ===========
void copyTMCompatibilityToCosmeticFormes();
@@ -355,7 +413,9 @@ public interface RomHandler { void ensureMoveTutorEvolutionSanity();
- // Randomizer: trainer names
+ // =============
+ // Trainer Names
+ // =============
void copyMoveTutorCompatibilityToCosmeticFormes();
@@ -383,7 +443,9 @@ public interface RomHandler { void randomizeTrainerNames(Settings settings);
- // Randomizer: trainer class names
+ // ===============
+ // Trainer Classes
+ // ===============
List<String> getTrainerClassNames();
@@ -397,31 +459,27 @@ public interface RomHandler { List<Integer> getDoublesTrainerClasses();
- // Randomizer: Items
+ // =====
+ // Items
+ // =====
ItemList getAllowedItems();
ItemList getNonBadItems();
+ List<Integer> getEvolutionItems();
+
List<Integer> getUniqueNoSellItems();
List<Integer> getRegularShopItems();
List<Integer> getOPShopItems();
- void randomizeWildHeldItems(Settings settings);
-
String[] getItemNames();
-
- String[] getShopNames();
-
- List<Integer> getStarterHeldItems();
-
- void setStarterHeldItems(List<Integer> items);
-
- void randomizeStarterHeldItems(Settings settings);
+ // ===========
// Field Items
+ // ===========
// TMs on the field
@@ -443,7 +501,11 @@ public interface RomHandler { void randomizeFieldItems(Settings settings);
- // Shop methods
+ // ============
+ // Special Shops
+ // =============
+
+ String[] getShopNames();
boolean hasShopRandomization();
@@ -459,7 +521,19 @@ public interface RomHandler { List<Integer> getMainGameShops();
- // Randomizer: Trades
+ // ============
+ // Pickup Items
+ // ============
+
+ List<Integer> getPickupItems();
+
+ void setPickupItems(List<Integer> pickupItems);
+
+ void randomizePickupItems(Settings settings);
+
+ // ==============
+ // In-Game Trades
+ // ==============
List<IngameTrade> getIngameTrades();
@@ -473,7 +547,9 @@ public interface RomHandler { int maxTradeOTNameLength();
- // Randomizer: Evos
+ // ==================
+ // Pokemon Evolutions
+ // ==================
void removeImpossibleEvolutions(Settings settings);
@@ -491,14 +567,9 @@ public interface RomHandler { void randomizeEvolutions(Settings settings);
- void changeCatchRates(Settings settings);
-
- // stats stuff
- void minimumCatchRate(int rateNonLegendary, int rateLegendary);
-
- void standardizeEXPCurves(Settings settings);
-
+ // ==================================
// (Mostly) unchanging lists of moves
+ // ==================================
List<Integer> getGameBreakingMoves();
@@ -510,7 +581,10 @@ public interface RomHandler { // (excluding Gameshark codes or early drink in RBY)
List<Integer> getEarlyRequiredHMMoves();
+
+ // ====
// Misc
+ // ====
boolean isYellow();
@@ -534,7 +608,9 @@ public interface RomHandler { void writeCheckValueToROM(int value);
+ // ===========
// code tweaks
+ // ===========
int miscTweaksAvailable();
@@ -544,7 +620,11 @@ public interface RomHandler { void renderPlacementHistory();
- // Forme stuff
+ // ==========================
+ // Misc forme-related methods
+ // ==========================
+
+ boolean hasFunctionalFormes();
List<Pokemon> getAbilityDependentFormes();
|