diff options
-rw-r--r-- | src/com/dabomstew/pkrandom/constants/Gen6Constants.java | 6 | ||||
-rw-r--r-- | src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java | 57 |
2 files changed, 32 insertions, 31 deletions
diff --git a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java index bc252c2..a679d0a 100644 --- a/src/com/dabomstew/pkrandom/constants/Gen6Constants.java +++ b/src/com/dabomstew/pkrandom/constants/Gen6Constants.java @@ -355,7 +355,11 @@ public class Gen6Constants { xyRoamerLevelPrefix = "B020DDE13F3BC1E3"; public static final String xyTrashEncountersTablePrefix = "4028100000"; - public static final int xyTrashEncounterDataLength = 16, xyTrashCanEncounterCount = 24; + public static final int xyTrashEncounterDataLength = 16, xyTrashCanEncounterCount = 24, + pokemonVillageGarbadorOffset = 0, pokemonVillageGarbadorCount = 6, pokemonVillageBanetteOffset = 6, + pokemonVillageBanetteCount = 6, lostHotelGarbadorOffset = 12, lostHotelGarbadorCount = 3, + lostHotelTrubbishOffset = 15, lostHotelTrubbishCount = 3, lostHotelRotomOffset = 18, lostHotelRotomCount = 6; + public static List<Integer> xyHardcodedTradeOffsets = Arrays.asList(1, 8); public static List<Integer> xyHardcodedTradeTexts = Arrays.asList(129, 349); diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java index b405de2..5fa2140 100644 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen6RomHandler.java @@ -2154,36 +2154,14 @@ public class Gen6RomHandler extends Abstract3DSRomHandler { // X/Y Trash Can Pokemon if (romEntry.romType == Gen6Constants.Type_XY) { - offset = find(code, Gen6Constants.xyTrashEncountersTablePrefix); - if (offset > 0) { - offset += Gen6Constants.xyTrashEncountersTablePrefix.length() / 2; // because it was a prefix - // Pokemon Village Encounters - Map<Pokemon, StaticEncounter> pokemonVillagePokemon = new HashMap<>(); - for (int i = 0; i < Gen6Constants.xyTrashCanEncounterCount / 2; i++) { - StaticEncounter se = readTrashCanEncounter(offset); - if (pokemonVillagePokemon.containsKey(se.pkmn)) { - StaticEncounter mainEncounter = pokemonVillagePokemon.get(se.pkmn); - mainEncounter.linkedEncounters.add(se); - } else { - statics.add(se); - pokemonVillagePokemon.put(se.pkmn, se); - } - offset += Gen6Constants.xyTrashEncounterDataLength; - } - - // Lost Hotel Encounters - Map<Pokemon, StaticEncounter> lostHotelPokemon = new HashMap<>(); - for (int i = Gen6Constants.xyTrashCanEncounterCount / 2; i < Gen6Constants.xyTrashCanEncounterCount; i++) { - StaticEncounter se = readTrashCanEncounter(offset); - if (lostHotelPokemon.containsKey(se.pkmn)) { - StaticEncounter mainEncounter = lostHotelPokemon.get(se.pkmn); - mainEncounter.linkedEncounters.add(se); - } else { - statics.add(se); - lostHotelPokemon.put(se.pkmn, se); - } - offset += Gen6Constants.xyTrashEncounterDataLength; - } + int tableBaseOffset = find(code, Gen6Constants.xyTrashEncountersTablePrefix); + if (tableBaseOffset > 0) { + tableBaseOffset += Gen6Constants.xyTrashEncountersTablePrefix.length() / 2; // because it was a prefix + statics.addAll(readTrashCanEncounterSet(tableBaseOffset, Gen6Constants.pokemonVillageGarbadorOffset, Gen6Constants.pokemonVillageGarbadorCount, true)); + statics.addAll(readTrashCanEncounterSet(tableBaseOffset, Gen6Constants.pokemonVillageBanetteOffset, Gen6Constants.pokemonVillageBanetteCount, true)); + statics.addAll(readTrashCanEncounterSet(tableBaseOffset, Gen6Constants.lostHotelGarbadorOffset, Gen6Constants.lostHotelGarbadorCount, true)); + statics.addAll(readTrashCanEncounterSet(tableBaseOffset, Gen6Constants.lostHotelTrubbishOffset, Gen6Constants.lostHotelTrubbishCount, true)); + statics.addAll(readTrashCanEncounterSet(tableBaseOffset, Gen6Constants.lostHotelRotomOffset, Gen6Constants.lostHotelRotomCount, false)); } } } catch (IOException e) { @@ -2207,6 +2185,25 @@ public class Gen6RomHandler extends Abstract3DSRomHandler { } } + private List<StaticEncounter> readTrashCanEncounterSet(int tableBaseOffset, int offsetWithinTable, int count, + boolean consolidateSameSpeciesEncounters) { + List<StaticEncounter> statics = new ArrayList<>(); + Map<Pokemon, StaticEncounter> encounterSet = new HashMap<>(); + int offset = tableBaseOffset + (offsetWithinTable * Gen6Constants.xyTrashEncounterDataLength); + for (int i = offsetWithinTable; i < offsetWithinTable + count; i++) { + StaticEncounter se = readTrashCanEncounter(offset); + if (consolidateSameSpeciesEncounters && encounterSet.containsKey(se.pkmn)) { + StaticEncounter mainEncounter = encounterSet.get(se.pkmn); + mainEncounter.linkedEncounters.add(se); + } else { + statics.add(se); + encounterSet.put(se.pkmn, se); + } + offset += Gen6Constants.xyTrashEncounterDataLength; + } + return statics; + } + private StaticEncounter readTrashCanEncounter(int offset) { int species = FileFunctions.readFullInt(code, offset); int forme = FileFunctions.readFullInt(code, offset + 4); |