diff options
author | spaceonaut <82479892+spaceonaut@users.noreply.github.com> | 2021-04-18 20:38:22 -0400 |
---|---|---|
committer | spaceonaut <82479892+spaceonaut@users.noreply.github.com> | 2021-04-19 18:01:30 -0400 |
commit | e20756f85d493ae6bb11b2b6a6f8ded53f9c44eb (patch) | |
tree | a45ab6aca2bbc3cf7a5dd651d82a9d444caa97b0 /src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java | |
parent | 539536dbf112c895a9050f93eff0c769e1267034 (diff) |
Add support to Gen 3+ to randomize held items for trainer's pokes
This adds two list of items per Gen, one for all [1] consumable held items and one for all [1] held items. This adds the options to add items from either of these lists to boss trainers, important trainers, and/or regular trainers. There is a disabled UI element for future work on "sensible" items, which would use a smaller pool of items (e.g. include the Yache berry in the pool only if the Pokemon is weak to ice).
There had been a smaller list of items used for the Totem pokemon in Gen 7; this has been combined with this new code.
[1] We exclude held items that affect only things for the player (e.g. amulet coin, macho brace ), affect only one species of Pokemon (e.g. light ball, lucky punch), or affect only one move (e.g. douse drive, flying memory).
Diffstat (limited to 'src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java')
-rwxr-xr-x | src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java index 88488be..ca39813 100755 --- a/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java +++ b/src/com/dabomstew/pkrandom/romhandlers/Gen4RomHandler.java @@ -2104,11 +2104,11 @@ public class Gen4RomHandler extends AbstractDSRomHandler { tpk.formeSuffix = Gen4Constants.getFormeSuffixByBaseForme(species,formnum);
tpk.absolutePokeNumber = Gen4Constants.getAbsolutePokeNumByBaseForme(species,formnum);
pokeOffs += 6;
- if ((tr.poketype & 2) == 2) {
+ if (tr.pokemonHaveItems()) {
tpk.heldItem = readWord(trpoke, pokeOffs);
pokeOffs += 2;
}
- if ((tr.poketype & 1) == 1) {
+ if (tr.pokemonHaveCustomMoves()) {
int attack1 = readWord(trpoke, pokeOffs);
int attack2 = readWord(trpoke, pokeOffs + 2);
int attack3 = readWord(trpoke, pokeOffs + 4);
@@ -2194,10 +2194,10 @@ public class Gen4RomHandler extends AbstractDSRomHandler { if (romEntry.romType != Gen4Constants.Type_DP) {
bytesNeeded += 2 * numPokes;
}
- if ((tr.poketype & 1) == 1) {
- bytesNeeded += 8 * numPokes;
+ if (tr.pokemonHaveCustomMoves()) {
+ bytesNeeded += 8 * numPokes; // 2 bytes * 4 moves
}
- if ((tr.poketype & 2) == 2) {
+ if (tr.pokemonHaveItems()) {
bytesNeeded += 2 * numPokes;
}
byte[] trpoke = new byte[bytesNeeded];
@@ -2210,11 +2210,11 @@ public class Gen4RomHandler extends AbstractDSRomHandler { writeWord(trpoke, pokeOffs + 4, tp.pokemon.number);
trpoke[pokeOffs + 5] |= (tp.forme << 2);
pokeOffs += 6;
- if ((tr.poketype & 2) == 2) {
+ if (tr.pokemonHaveItems()) {
writeWord(trpoke, pokeOffs, tp.heldItem);
pokeOffs += 2;
}
- if ((tr.poketype & 1) == 1) {
+ if (tr.pokemonHaveCustomMoves()) {
if (tp.resetMoves) {
int[] pokeMoves = RomFunctions.getMovesAtLevel(tp.absolutePokeNumber, movesets, tp.level);
for (int m = 0; m < 4; m++) {
@@ -3402,11 +3402,6 @@ public class Gen4RomHandler extends AbstractDSRomHandler { }
@Override
- public int randomHeldItem() {
- return 0;
- }
-
- @Override
public boolean canChangeTrainerText() {
return true;
}
@@ -4243,4 +4238,14 @@ public class Gen4RomHandler extends AbstractDSRomHandler { throw new RandomizerIOException(e);
}
}
+
+ @Override
+ public List<Integer> getAllConsumableHeldItems() {
+ return Gen4Constants.consumableHeldItems;
+ }
+
+ @Override
+ public List<Integer> getAllHeldItems() {
+ return Gen4Constants.allHeldItems;
+ }
}
|