diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/sneed/pkrandom/pokemon/Trainer.java | 16 | ||||
-rwxr-xr-x | src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java | 5 | ||||
-rwxr-xr-x | src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/com/sneed/pkrandom/pokemon/Trainer.java b/src/com/sneed/pkrandom/pokemon/Trainer.java index a6a6a8a..8e8a76e 100755 --- a/src/com/sneed/pkrandom/pokemon/Trainer.java +++ b/src/com/sneed/pkrandom/pokemon/Trainer.java @@ -40,6 +40,8 @@ public class Trainer implements Comparable<Trainer> { public String fullDisplayName; public MultiBattleStatus multiBattleStatus = MultiBattleStatus.NEVER; public int forceStarterPosition = -1; + // Certain trainers (e.g., trainers in the PWT in BW2) require unique held items for all of their Pokemon to prevent a game crash. + public boolean requiresUniqueHeldItems; public String toString() { StringBuilder sb = new StringBuilder("["); @@ -127,6 +129,20 @@ public class Trainer implements Comparable<Trainer> { return (this.poketype & 1) == 1; } + public boolean pokemonHaveUniqueHeldItems() { + List<Integer> heldItemsForThisTrainer = new ArrayList<>(); + for (TrainerPokemon poke : this.pokemon) { + if (poke.heldItem > 0) { + if (heldItemsForThisTrainer.contains(poke.heldItem)) { + return false; + } else { + heldItemsForThisTrainer.add(poke.heldItem); + } + } + } + return true; + } + public enum MultiBattleStatus { NEVER, POTENTIAL, ALWAYS } diff --git a/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java index 4f289e9..f3471db 100755 --- a/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/AbstractRomHandler.java @@ -1962,6 +1962,11 @@ public abstract class AbstractRomHandler implements RomHandler { } else { for (TrainerPokemon tp : t.pokemon) { randomizeHeldItem(tp, settings, moves, movesets); + if (t.requiresUniqueHeldItems) { + while (!t.pokemonHaveUniqueHeldItems()) { + randomizeHeldItem(tp, settings, moves, movesets); + } + } } } } diff --git a/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java index 2743583..26a3aee 100755 --- a/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/Gen5RomHandler.java @@ -1468,6 +1468,7 @@ public class Gen5RomHandler extends AbstractDSRomHandler { tr.poketype = 3; // have held items and custom moves
int nameAndClassIndex = Gen5Constants.bw2DriftveilTrainerOffsets.get(trno);
tr.fullDisplayName = tclasses.get(Gen5Constants.normalTrainerClassLength + nameAndClassIndex) + " " + tnames.get(Gen5Constants.normalTrainerNameLength + nameAndClassIndex);
+ tr.requiresUniqueHeldItems = true;
int pokemonNum = 6;
if (trno < 2) {
pokemonNum = 3;
|