Basic asset editing

Introduction
In this tutorial, we're going to see how to edit an asset from a level's HIP or HOP file from the unpacked archive. As an example, we'll be editing one or more textures from Bikini Bottom (hub) and moving a few objects around in the level.

What you'll need

 * The game's unpacked ISO and a way to run it
 * HipHopTool
 * Magic.TXD
 * Optional: Bulk Rename Utility for renaming a large amount of files at once
 * Optional: A hex editor and a little bit of knowledge on how to use it

Step 1: Unpacking the archive with HipHopTool
If you open HipHopTool directly, you'll be prompted with three options: extract a HIP/HOP, create a HIP/HOP, or close. If you choose to extract, you can select a file to do so and all assets will be unpacked to a folder in the same directory of the archive.

You can do it that way if you want, and that should be the end of this step for you. But I'm gonna show you how to create a batch file to be able to do it faster and have more control over where the files will land.

1. Create a new text file in the same directory of HipHopTool and name it unpack.bat (make sure the extension is .bat and not .txt)

2. Open the file in notepad or any text editor. Enter the following, then save:

HipHopTool.exe -extract "C:\spongebob\game\files\hb\hb01.HOP" -dest "C:\spongebob\unpack\hb01_hop_unpacked"

Obviously, you should replace the file paths with the path to the HOP you want to extract and the folder you want the files to be extracted to (name the folder something you'll remember, like hb01_hop_unpacked). The "hb01.HOP" file in the hb folder is the HOP file of the main section of Bikini Bottom (you can view a full list of files here.

3. Double-click unpack.bat to run it. All assets from hb01.HOP should be extracted to the folder you specified.

Step 2: Editing the texture with Magic.TXD
Important note: all asset files start with the asset ID, a hex identifier which looks like [1234ABCD] before the asset name. Do not change or remove this number, otherwise you won't be able to recreate the archive later. Feel free to change the rest of the filename if you want to, though.

1. Go to the folder you unpacked the HOP in. It should contain many folders with different asset types. Open the RWTX folder. It should have a large amount of files.

2. Find the texture you want to edit. The texture's name is usually a good description, but you might need to open the texture in Magic.TXD to view it.

3. Magic.TXD can only open files with the .txd extension. None of the textures have that extension, so if you want to add it to all of them, you can use Bulk Rename Utility at this point, as it has a feature to add the .txd extension to all files at once. Otherwise, you can add .txd to the filenames manually. There's no need to remove it afterwards.

4. With the texture open in Magic.TXD, use Edit -> Replace or the shortcut Ctrl + R to replace the texture with a new one.

5. In the import texture dialog, set the Raster Format to Compressed > DXT1. This will compress your textures so the file size is smaller. Don't do this for textures with alpha transparency!

6. After replacing the texture, save.

Step 3: Repacking the archive
Just like in step 1, you can do this by opening HipHopTool directly. But I'm gonna show you how to do this with a batch file!

1. Create a new text file in the same directory of HipHopTool and name it create.bat (make sure the extension is .bat and not .txt)

2. Open the file in notepad or any text editor. Enter the following, then save:

HipHopTool.exe -create "C:\spongebob\unpack\hb01_hop_unpacked\Settings.ini" -dest "C:\spongebob\game\files\hb\hb01.HOP"

Obviously, replace the file paths with the path to the INI of the HOP you want to create and the destination where you want the new HOP file. In this case, we're replacing the file in the unpacked game directly - it only takes one click to place our modified files ingame!

3. Double-click create.bat to run it. A new hb01.HOP should be created in the path you specified (possibly replacing an existing one).

Run the game now and your replaced textures should show up.

Editing other assets
Currently, textures are the only asset with an editor specifically for them. However, you can use a hex editor to play a bit with other types of assets. You can visit each asset's individual page for a description of the asset's format. Just to know what we can do with a hex editor, let's make some changes to item placement in the level.

1. Follow step 1 again, but this time, extract the HIP of Bikini Bottom (hb01.HIP) to a folder with a name like hb01_hip_unpacked.

2. Open your hex editor. Make sure it's set to big endian.

3. In your extracted files, go to the PKUP folder. Open the GOLDENSPATULA_PICKUP_1 and GOLDENUNDERWEAR_PICKUP_01 files in your hex editor.

4. Now go to the VIL folder. Open MRKRABS_NPC_01 in the hex editor.

5. At offset 0x20 in each of these files, there should be three 4-byte floating point values one after the other. These are the object's XYZ positions.

6. Copy these values from all three files and paste them somewhere else.

7. Now paste the values back into the files you have opened. But paste them in a different file than they were before! This will switch up the three object's positions.

8. Save all three files.

9. Follow step 3 again, but this time, create the new HIP file in place of the old HIP.

10. Test ingame. The objects should have their positions switched around. Note that you can do this to any PKUP or VIL object.

Example of level with edited textures (on HOP) and switched object positions (on HIP):