Surviving Mars

Surviving Mars

Not enough ratings
Extract HPK files
By ChoGGi
How to extract files from HPK files
   
Award
Favorite
Favorited
Unfavorite
How to
Get a copy of hpk.exe from https://github.com/nickelc/hpk/releases
(if you're uncertain of which file: x86_64-pc-windows-msvc.zip)

Put this in a batch file (make a new .txt file and rename it to extract.bat)
for %%g in (*.hpk) do mkdir "%%~ng" for %%g in (*.hpk) do hpk.exe extract "%%g" "%%~ng" @echo All Done! pause


Copy hpk.exe, somefile.hpk, and extract.bat to the same location.


Run extract.bat.


Google what you don't know.
https://www.makeuseof.com/tag/write-simple-batch-bat-file/

To create hpk archives use: hpk.exe create FolderContainingFiles ModContent.hpk
Misc
If you're wondering why your image editor/exporter doesn't work with DDS files from Armstrong update (quote from dev):
For the UI images shipped with the game we switched to BC7 compression format, which we store in DDS files. We use Intel's ispc_texcomp conversion library (on GitHub).
Because BC7 works on 4x4 blocks of pixels, and thus requires image dimensions to be multiples of 4; we internally pad the images to 4x4, but still store the "real" dimensions in the header, because we need the exact original size to do UI layout. This probably makes them look corrupted to some tools.

You can directly edit them in Paint*NET[getpaint.net]

Use Texconv[github.com] to convert them:
texconv.exe *.dds -ft tga
(or png)
To convert images to the dds format used by the game:
texconv.exe *.tga -ft dds -f BC7_UNORM

To get a copy of texconv.exe: look for releases with 5 assets
https://github.com/microsoft/DirectXTex/releases

Chef Niko:
Script to convert dds to png using texconv. Place texconv in c:\ and run the script from the root of the directories with dds files in them.
forfiles /s /m *.dds /C "CMD /c c:\texconv.exe @path -ft png"


You can use my ECM mod to extract mods (Menu>Help>Extract Mods).


If you're extracting lua files to decompile them; then add --fix-lua-files to help out unluac (more help[github.com]).
55 Comments
ChoGGi  [author] Oct 8, 2023 @ 8:06pm 
I really should get around to playing it...

and maybe some modding ;)
Sig Oct 8, 2023 @ 7:28pm 
My thanks from another jagged alliance 3 wannabe modder, cheers for this guide
ChoGGi  [author] Sep 26, 2023 @ 4:16pm 
I just threw a guide together, nickelc is the one doing the heavy lifting by making hpk archiver.

but thanks :)
SupremeMaster Sep 26, 2023 @ 12:23pm 
Thanks, I did this for jagged alliance 3. You deserve commendation! along with Igor!
ChoGGi  [author] Jul 15, 2023 @ 9:10am 
If you're replacing the games hpk files then yes, use dont compress, but for mods it doesn't matter.

I haven't touched JA3 or SAD, maybe someday...
Vendaar Jul 15, 2023 @ 8:57am 
sorry i thought this was JA3 and not SM. someone told me to use dont-compress. is there a way to do it without replaying the hpks?
ChoGGi  [author] Jul 15, 2023 @ 8:30am 
btw why do you use dont-compress-files? You only need that when replacing the game hpk files.
ChoGGi  [author] Jul 15, 2023 @ 8:22am 
getpaint.net (you're linking to a link farm)

Thanks!
Vendaar Jul 15, 2023 @ 8:11am 
you can use paint.net to edit DDS without converting anything.

to convert folders to hpk agaiin use:
hpk.exe create --dont-compress-files foldername hpkname.hpk"
@echo All Done!
ChoGGi  [author] Mar 5, 2023 @ 9:20am 
Yeah it works fine for that as well.