kwsch / PKHeX

Pokémon Save File Editor
https://projectpokemon.org/pkhex/
Other
3.68k stars 689 forks source link

In-Game Trade Documentation [OT, TID, SID, PID] #1249

Closed sora10pls closed 6 years ago

sora10pls commented 7 years ago

As the issue title says. This should work like the Gen 1 in-game trade OT checks function, and can use the exact same legality strings (V10 = invalid, V11 = valid). Can't say the same for any other in-game trades for other games, since I'm currently only running LeafGreen for testing.

image

kwsch commented 7 years ago

PID/OT details aren't readily available on the internet, and would require a bit of work to get documented.

Applies to gens 3-5; gen3/4 have fixed PIDs which may differ between languages.

ReignOfComputer commented 7 years ago

https://github.com/ReignOfComputer/RoCs-PC/tree/master/06%20-%20Gen%20III%20-%20FRLG%20Collection/Pokemon%20Fire%20Red/In-game%20Trades

If this helps :P

sora10pls commented 7 years ago

Edit: I guess I'll maintain a few Pastebins for info dumps. I can also confirm that PIDs are static across all different languages. Will work more on this after I get some sleep.

Static Info (All Languages): https://pastebin.com/WbDykr2m Japanese: https://pastebin.com/bXnRiuXz English: https://pastebin.com/ELFDgXhZ French: https://pastebin.com/TYKbJm1x Italian: https://pastebin.com/Hb3B2An4 German: https://pastebin.com/TmLD056F Spanish: https://pastebin.com/GX09eKFQ Korean: see my following comment

javierhimura commented 7 years ago

I look how to extract this data directly from the rom files, to avoid having to play all games in all languages to gather the information. I found code in the program Universal Pokemon Randomizer prepared just for that, extract the names of traded pokemon, Is in Java, i started to adapt the code from the getIngameTrades functions to .NET to extract the data, but i do not have much time lately to complet it https://github.com/Dabomstew/universal-pokemon-randomizer

sora10pls commented 7 years ago

Static Info Pastebin updated to list all TIDs/SIDs/PIDs; will work on getting language-specific OT Names and Nicknames.

Edit 1: Now all we're missing is Korean! @kwsch

Edit 2: Actually, it turns out FR/LG went unreleased in South Korea? I'm taking this from Bulbapedia so don't quote me on it... that, and every version of FR/LG I've found in Korean is a fan-translated Japanese version (PKHeX automatically detects it as a Japanese save file, and all Pokemon caught/obtained in it are viewed as Japanese over Korean).

sora10pls commented 7 years ago

Turns out there's another bug with the in-game trade Lickitung. PKHeX deems the English in-game trade legal, however in all other languages, it tries to match the Lickitung up with an Event rather than the in-game trade.

English: image Other languages: image

Edit: PKHeX should also check for minimum Levels for in-game trades. For example. a player could breed for a Spearow and it would hatch at Lv. 5, but PKHeX immediately assumes that the encounter is from an Egg rather than it being the in-game trade Farfetch'd. image

kwsch commented 7 years ago

@sora10pls That's how the encounter generator works, it will stop generating encounters once a valid-enough match is found. In this case it stops at the Wish Lickitung Egg. The encountermatch determination only checks Moves/Relearn/PIDIV/Evolution; once matched, the secondary checks are then performed.

https://github.com/kwsch/PKHeX/blob/b4222c756a278d3ddcb568cca5c7283045a47971/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs#L259-L285

Gifts -> Static -> FriendSafari(will remove) -> Wild -> Trade

Trades from Gen3/4 are difficult to match; when OT/ID/PID/IV info is added it will be possible to get a precise match, and we can prioritize generating ingame trades above gifts. Might be a new method that uses one of the unique values (PID) with a dict for the origin game to grab the encounter; would be faster than checking the species & dexlevel for everything.

kwsch commented 7 years ago

With the Persian/Meowth example from yesterday, I think this ability portion is fixed.

So it just remains that the OT/PID isn't checked; will probably need a dictionary for all associated games (gen3/4), gen5 can be decided later.

FlapjacksNsyrup commented 7 years ago

https://bulbapedia.bulbagarden.net/wiki/In-game_trade#FireRed_and_LeafGreen

I'd assume the information on here should be accurate, no? It would save time having to play the games just to get the trades. Is there information you need that isn't present on that page?

sora10pls commented 7 years ago

Check my Pastebins above. That information only lists English/Japanese, and also doesn't display PID or SID. I've already gathered the information needed for FR/LG.

sora10pls commented 6 years ago

Gonna bump this since to this day I've only done FR/LG. What all else needs to be obtained for this to be resolved? I'm gonna assume it's:

If it's anything like FR/LG, the only differing thing would be OT (rest are static).

sora10pls commented 6 years ago

In any case... onto Gen 4!

Static Info (All Languages): https://pastebin.com/Vfym14j5 OTs will be posted periodically as I get the chance to.

Compared to Gen 3, this will take time since some are time-based (ie, having required Gym Leader rematches and the NDS punishing you for changing internal clock -> 24hr time freeze).

kwsch commented 6 years ago

not using DeSmuME and using the record movie function to provide a startup date

sora10pls commented 6 years ago

I didn't know you could do that! But in the end it doesn't even matter, since I forgot that changing the NDS clock only affects getting Blue's number, which isn't needed for HGSS in-game trades. All it really comes down to is when I have the time and motivation to grind out these trades in several languages other than English.

kwsch commented 6 years ago

not looking up a static PIDs in the ROM to find the ingame trade data

sora10pls commented 6 years ago

leave me alone lmao

I'll get to it some time tomorrow after work.

kwsch commented 6 years ago

Magneton: 0000D136 Pikachu: 00485876 Rhyhorn: 0012971C Steelix: 00101596

ps: RoC's PC has a lot of ingame trades, and having a huge bank of savefiles makes searching for TID/SID pairs easy ;)

sora10pls commented 6 years ago

Updated the Pastebin with those PIDs. And yeah that's how I've been managing it, even with FR/LG (which is done).

A base save file with all the PKMs needed for the trade, copied around to match the different game language (ROMs for FRE, GER, ITA, etc.), then from there it's just grabbing the OTs. English/Japanese OTs are on Bulbapedia, the only real task is getting the rest of the languages.

Out of curiosity, how would I go about searching for the data in the ROM using the PIDs?

kwsch commented 6 years ago

convert 32bit val back to bytes (or just look at the pkm data); then find which narc has those bytes.

NDS narcs are essentially equivalent to 3DS's garcs

there's also: http://hackromtools.altervista.org/ds-trade-editor/

not sure if the PID is stored but I'd bet it is.

see also: https://bulbapedia.bulbagarden.net/wiki/User:SnorlaxMonster/In-game_trades_in_other_languages

sora10pls commented 6 years ago

That last Bulbapedia article you linked is exactly what I needed.

Here's a 100% complete Pastebin with TIDs and PIDs: https://pastebin.com/Dk2HrxTZ

Click here for Nicknames in all languages. Click here for Original Trainer names in all languages.

Edit: if there's anything else you need aside from OT, TID, SID, and PID, let me know. That should be everything needed, since source code already has their Natures, IVs, etc...