diff options
author | tom-overton <tom.overton@outlook.com> | 2022-05-27 23:06:29 -0700 |
---|---|---|
committer | rafa_99 <raroma09@gmail.com> | 2022-05-29 22:01:37 +0100 |
commit | e3b45c8a01a3c09a5c2dd5c0e08d7065512a0510 (patch) | |
tree | e829fde17ec75bfa58dc4153a5f5ca3fe1c65fb8 /src/com/sneed | |
parent | 339d465120f59de9180243e94a4a4811bf425736 (diff) |
Gen 3: Read/write Deoxys stats from the right places in FRLG/Em
Diffstat (limited to 'src/com/sneed')
-rwxr-xr-x | src/com/sneed/pkrandom/config/gen3_offsets.ini | 4 | ||||
-rwxr-xr-x | src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java | 38 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/com/sneed/pkrandom/config/gen3_offsets.ini b/src/com/sneed/pkrandom/config/gen3_offsets.ini index a02efda..b2d5107 100755 --- a/src/com/sneed/pkrandom/config/gen3_offsets.ini +++ b/src/com/sneed/pkrandom/config/gen3_offsets.ini @@ -332,6 +332,7 @@ PCPotionOffset=0x5DFEFC PickupTableStartLocator=0D000E0016000300560055 PickupItemCount=29 TypeEffectivenessOffset=0x31ACE8 +DeoxysStatPrefix=190A1E0A230A280A StaticPokemonSupport=1 StaticPokemon{}={Species=[0x211A1C, 0x211A41, 0x211A44, 0x211AC6, 0x211AD4], Level=[0x211A46]} // Lileep StaticPokemon{}={Species=[0x211A2E, 0x211AE4, 0x211AE7, 0x211B69, 0x211B77], Level=[0x211AE9]} // Anorith @@ -461,6 +462,7 @@ PCPotionOffset=0x402220 PickupTableStartLocator=8B000F00850019008600230087002D PickupItemCount=16 TypeEffectivenessOffset=0x24F050 +DeoxysStatPrefix=7F002301FFFF StaticPokemonSupport=1 StaticPokemon{}={Species=[0x16C472, 0x16C475, 0x16C4B5, 0x16C4E9], Level=[0x16C477]} // Eevee in Celadon Condominiums StaticPokemon{}={Species=[0x16EC0C, 0x16EC13], Level=[0x16EC86]} // Hitmonlee in Fighting Dojo @@ -2119,6 +2121,7 @@ PCPotionOffset=0x5C0BE0 PickupTableStartLocator=0D000E0016000300560055 PickupItemCount=29 TypeEffectivenessOffset=0x2EBB38 +DeoxysStatPrefix=8AAE6C78FF00 StaticPokemonSupport=1 StaticPokemon{}={Species=[0x2015EE, 0x201613, 0x201616, 0x201698, 0x2016A6], Level=[0x201618]} // Lileep StaticPokemon{}={Species=[0x201600, 0x2016B6, 0x2016B9, 0x20173B, 0x201749], Level=[0x2016BB]} // Anorith @@ -2209,6 +2212,7 @@ PCPotionOffset=0x3C83F8 PickupTableStartLocator=8B000F00850019008600230087002D PickupItemCount=16 TypeEffectivenessOffset=0x20BF24 +DeoxysStatPrefix=7F002301FFFF StaticPokemonSupport=1 StaticPokemon{}={Species=[0x184BB8, 0x184BBB, 0x184BFB, 0x184C2F], Level=[0x184BBD]} // Eevee in Celadon Condominiums StaticPokemon{}={Species=[0x18A2E0, 0x18A2E7], Level=[0x18A35A]} // Hitmonlee in Fighting Dojo diff --git a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java index 3997f63..5f6b3ff 100755 --- a/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java +++ b/src/com/sneed/pkrandom/romhandlers/Gen3RomHandler.java @@ -237,7 +237,7 @@ public class Gen3RomHandler extends AbstractGBRomHandler { current.tableFile = otherEntry.tableFile; } } - } else if (r[0].endsWith("Locator")) { + } else if (r[0].endsWith("Locator") || r[0].endsWith("Prefix")) { current.strings.put(r[0], r[1]); } else { if (r[1].startsWith("[") && r[1].endsWith("]")) { @@ -791,6 +791,24 @@ public class Gen3RomHandler extends AbstractGBRomHandler { int pkoffs = offs + i * Gen3Constants.baseStatsEntrySize; loadBasicPokeStats(pk, pkoffs); } + + // In these games, the alternate formes of Deoxys have hardcoded stats that are used 99% of the time; + // the only times these hardcoded stats are ignored are during Link Battles. Since not many people + // are using the randomizer to battle against others, let's just always use these stats. + if (romEntry.romType == Gen3Constants.RomType_FRLG || romEntry.romType == Gen3Constants.RomType_Em) { + String deoxysStatPrefix = romEntry.strings.get("DeoxysStatPrefix"); + int offset = find(deoxysStatPrefix); + if (offset > 0) { + offset += deoxysStatPrefix.length() / 2; // because it was a prefix + Pokemon deoxys = pokes[Species.deoxys]; + deoxys.hp = readWord(offset); + deoxys.attack = readWord(offset + 2); + deoxys.defense = readWord(offset + 4); + deoxys.speed = readWord(offset + 6); + deoxys.spatk = readWord(offset + 8); + deoxys.spdef = readWord(offset + 10); + } + } } private void savePokemonStats() { @@ -805,6 +823,24 @@ public class Gen3RomHandler extends AbstractGBRomHandler { writeFixedLengthString(pk.name, stringOffset, nameLen); saveBasicPokeStats(pk, offs2 + i * Gen3Constants.baseStatsEntrySize); } + + // Make sure to write to the hardcoded Deoxys stat location, since otherwise it will just have vanilla + // stats no matter what settings the user selected. + if (romEntry.romType == Gen3Constants.RomType_FRLG || romEntry.romType == Gen3Constants.RomType_Em) { + String deoxysStatPrefix = romEntry.strings.get("DeoxysStatPrefix"); + int offset = find(deoxysStatPrefix); + if (offset > 0) { + offset += deoxysStatPrefix.length() / 2; // because it was a prefix + Pokemon deoxys = pokes[Species.deoxys]; + writeWord(offset, deoxys.hp); + writeWord(offset + 2, deoxys.attack); + writeWord(offset + 4, deoxys.defense); + writeWord(offset + 6, deoxys.speed); + writeWord(offset + 8, deoxys.spatk); + writeWord(offset + 10, deoxys.spdef); + } + } + writeEvolutions(); } |