• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Tutorial] Create a basic BDSP mod (altering item prices)

1
Posts
2
Years
    • Seen May 16, 2022
    In this tutorial, you will learn the very basics of modding BDSP: extracting NCA files from original NSP files (base game AND title update), extract romfs and exefs folders from the NCAs, disassemble those folders in a readable JSON format, edit the disassembled JSON file to modify the price of an item, reassemble the file, package the mod and test it live in an emulator.

    Huge shoutout to Team Luminescent, without them this wouldn't be possible. Check out their Discord for more resources!

    Prerequisites:
    - A legal copy of Brilliant Diamond or Shining Pearl in NSP format
    - A Nintendo Switch for production keys
    - Hactool
    - BDSP Repacker by Ai0796 / Smackteo
    - A hex editor such as HxD
    - A text editor such as Notepad++

    The first two items are outside the scope of this tutorial, but you can use either SwitchSDTool (digital purchases) or Nxdumptool (physical purchases) to dump your game to the NSP format. For the keys, you can use Lockpick_RCM to generate prod.keys. Alternatively, if you own the game and device legally, you can attempt to digitally source the NSPs and the keys. This forum can't assist further with that.

    1. From NSP to romfs / exefs
    We need the following four files in the same folder: The base game NSP, the latest title update NSP, hactool.exe and keys.prod. The first step is to generate two NCA files, for the base game and the update. Navigate to the folder in CMD and run the following two commands:
    Code:
    hactool.exe -t pfs0 --pfs0dir="basegame" basegame.nsp
    Code:
    hactool.exe -t pfs0 --pfs0dir="update" update.nsp

    This will populate two folders with several files. For both the basegame and the update, copy the largest NCA file from each folder (should be similar to the NSP file size), paste them in the above hactool folder and rename them (for easier commands).

    In order to generate the required romfs / exefs folders though, we need a title key from the game update in the command. We can retrieve this by opening the Hex Editor, HxD, and open the .TIK file generated by hactool in the "update" folder. Then, look at line 00000180 and copy the 32 characters (columns 00 to 0F):
    igQ4kFg.png


    We then replace the "32 bit" value in below command with the extracted key, and run the command:
    Code:
    hactool.exe -k prod.keys --basenca="basegame.nca" --titlekey="YOUR32BITKEY" --romfsdir="romfs" --exefsdir="exefs" "update.nca"

    2. Disassemble, modify and reassemble
    The extracted files are unfortunately not in a readable format. Luckily, Team Luminescent has created tools that convert them into a readable JSON file, and convert it back! There are multiple repackers, I use this variant. Create a new folder for this Repacker, and run Unpack.exe once. This will create a folder called "AssetFolder".

    We now need to decide which file to alter. This is the most ambiguous part as the current file structure is being discovered and documented as we speak. The primary source for this, is Team Luminescent's BDSP Development Resource file.

    For the sake of this tutorial, I want to price a Potion at 1 dollar. In the above file, I see a tab called "Items IDs" which lists a Potion. Great! But how to know which file to edit for altering the price in a Mart? That is where the "Personal & Waza table file structure" tab comes into play, as this attempts to list file structures.

    There's many entries, but one name often appears: Pml/personal_masterdatas/*. So let's search in our romfs folder for "personal_masterdatas" and copy the file to "AssetFolder". Then press enter in unpack.exe / open unpack.exe again and this will create a personal_masterdatas_Export folder with inside numerous JSON files, including something called.. ItemTable.JSON! There are also other self explanatory names that aren't necessarily listed in the resource file (yet) so you might have to explore yourself.

    55ASqlt.png


    The table itself starts at line 11, and each item is an object called.. "Item". The number mentioned in the first attribute, "no: 0", is the Item ID from the Items ID tab in the resource file. When we look up Potion, it is item ID ("Dec ID") 17. So in ItemTable.JSON we scroll to "No: 17", line 677. We can change many attributes, in this case we want "Price" though. We replace the existing 300 value with 1, and save the JSON file.

    Finally, we need to repack this file to the original format. Simply run repack.exe, your reconverted file will appear in a newly created folder called EditedAssets.

    3. Create and test your mod
    The last part should be fairly easy, especially if you have installed mods before. Create a new folder with the name of your mod, whichever you chose. Then within that folder, you need to place the modified files within the original folder structure. So for example, I named my mod "Cheap Potion" and this is the file structure:
    Cheap Potion\romfs\Data\StreamingAssets\AssetAssistant\Pml\personal_masterdatas

    Keep in mind you only need to place files (and its original folder structure) here that you altered, nothing else. We then paste the top folder ("Cheap Potion") in the relevant game mod folder, as if we've downloaded a ZIP containing this mod. To find this mod folder:
    - In Ryujinx click right on the game and then Open Mods Directory
    - In Yuzu click right on the game and then Open Mod Data Location

    Then simply run the game, go to a Poke Mart and.. ta-da! You just created your first mod.
    XtfS4jP.png
     
    Back
    Top