kwsch / pkNX

Pokémon (Nintendo Switch) ROM Editor & Randomizer
https://projectpokemon.org/home/forums/topic/48647-pknx-nintendo-switch-rom-editor-randomizer/
GNU General Public License v3.0
362 stars 108 forks source link

Randomizing Field Items Pokemon Sword and Shield #383

Closed nvbeusekom closed 2 months ago

nvbeusekom commented 2 months ago

Hi all,

I am trying to randomize field items in Pokemon Sword and Shield by coding it into the Randomize() function for the Placement form. I figured out that the items you find are described with ulong values in the Flags field in:

pkNX.Structures.FlatBuffers.SWSH/Schemas/Placement/PlacementZoneFieldItemHolder.fbs

and that the amounts are described in the Items field. I have managed to change the items by copying other ulongs, that I found during debugging, into the Flags field.

However, everywhere else in the code (it seems that) items are described simply by integers, or ushorts.

I could simply gather a list of ulongs of findable items and randomize those, but I was hoping to extend the list of findable items to add, for example, Master Balls as being findable in the field, based on the Legal Item List.

So my question is: would someone have any idea how these ulong values could be computed for any item?

Many thanks in advance

sora10pls commented 2 months ago

romfs/bin/pml/item/item_hash_to_index.dat stores all of this data in an easy to interpret table. Structure detailed below.

u32 numItems

Then a table: length 0x10 * numItems u64 hash u64 item ID

In the event of an unavailable item (e.g. Ultranecrozium Z), the item ID is stubbed from the table. Full parse here: https://gist.github.com/sora10pls/655af1165dceb4fdc890d9329249471a

nvbeusekom commented 2 months ago

Thank you so much 🙏 with this I got it to work!