Using Bspzip to Put Map Materials in Your BSP


dackz
11-01-2005, 04:32 AM
If you run a game server like myself, you probably get annoyed when custom maps come with more than just a BSP file. You have to merge the BSP's custom materials with the mod's, which makes it tedious to remove in the future. It also makes distributing the files to clients harder if you're using HTTP downloading, as you have to either copy all of those materials to your web directory, or set up a myriad of symbolic links and do dumb things to your server directory's file permissions. You also sometimes have to make or correct a RES file, as many mappers don't even include that. There's something even better and more convenient than creating RES files though, and that's bspzip.

Bspzip allows you to embed your custom map-related files directly into your BSP. Materials, models, resources, scripts, sounds, even AIN files and map description text files should work. You can pretty much put everything in your BSP file, which would leave you with only a BSP to distribute, which is the correct way to release a map.

Of course the tool Valve has provided isn't exactly easy to use. You can find it in your Steam directory under SteamApps\<account>\sourcesdk\bspzip.exe. It's a command line program, so you'll probably want a command prompt when using it. Running "cmd" from the run dialog in the start menu should suffice, at least for Windows 2000 and XP. Once you have a command prompt, run "X:" where X: is the drive that Steam is on, then run "cd X:\path\to\Steam\SteamApps\<account>\sourcesdk". Now when you run "bspzip.exe" you'll see the following output:
usage:
bspzip -extract bspfile blah.zip
bspzip -dir bspfile
bspzip -addfile bspfile relativepathname fullpathname newbspfile
bspzip -addlist bspfile listfile newbspfile
As you can see it isn't very helpful. First of all you're generally going to want to run this in the mod directory of your map, as it'll whine if it doesn't find a valid gameinfo.txt. So for DOD:S you'll want to run "cd X:\path\to\Steam\SteamApps\<account>\day of defeat source\dod". Now you'll probably want to use the full path of bspzip.exe in order to run it.

At this point you can try to add each file manually with "bspzip.exe -addfile maps/yourmap.bsp materials\somematerial.xxx X:\path\to\Steam\SteamApps\<account>\day of defeat source\dod\materials\somematerial.xxx maps/yournewbsp.bsp" but that's pretty impractical for maps that have many custom materials. Instead you should do the following:
Load up your mod and run the map once. This will generate an AIN file in maps\graphs. You'll want to pack this into your BSP.
Make a text file with a list of all of your files in this format (relative to the mod directory):
directory/file1
X:/path/to/Steam/SteamApps/<account>/mod directory/mod/directory/file1
directory/file2
X:/path/to/Steam/SteamApps/<account>/mod directory/mod/directory/file2
Save the text file in the same directory as gameinfo.txt.
Rename your BSP file to yourmap-old.bsp
Run "bspzip.exe maps\yourmap-old.bsp yourfilelist.txt maps\yourmap.bsp"
You probably won't want to do number two manually though, as that would be incredibly time-consuming. I have my own script that creates a list of files for me, and I weed out what I don't need, but it's a Python script. You'll probably find it easier to something like WinBSPZip (http://www.chaosincarnate.net/cannonfodder/winbspzip.php). You can add files to this with file dialogs and it'll do the rest for you.

I recommend adding EVERYTHING into the BSP, including your map description file and AIN file. Ideally you should end up with just a BSP file. You should test things to make sure it all worked though. Remove all the custom materials from the mod directory and run the new bspzipped BSP in the mod. Make sure your map description is shown and you aren't missing any sounds or textures or anything of the like. Once you've made sure of that, you should test sending out the BSP on a dedicated server. I'm not going to get into this, but if you run into issues with the BSP file being bigger than what the server will send out, look into changing the net_maxfilesize convar.

Hopefully this guide has been clear enough. WinBSPZip does make a lot of the guide irrelevant, but it's good to know how it works regardless. If you're still confused, feel free to ask questions. Oh and when you're distributing your map file, please don't put them in an EXE file or anything weird like that. A lot of server admins don't run Windows, so you're making it harder on them to get it installed, which can hurt your map's exposure. ZIP and RAR files are much nicer, but if you're concerned about people who don't have ZIP/RAR programs, make it a self-extracting RAR file (WinRAR can make these for you).

And here are some other bspzip-related tutorials: http://developer.valvesoftware.com/wiki/Using_Bspzip_to_Embed_Custom_Content Official SDK documentation.
http://forums.fortress-forever.com/viewtopic.php?t=2947 Tutorial from Fortress Forever mod team.

ultranew_b
11-01-2005, 07:40 AM
Pakrat is quite popular and very easy to use. It's made by the same dude who made Vmex I think.

Pakrat is a graphical replacement for the BSPZIP program, that allows you to embed external files, such as textures (vtf), material (vmt) and model (mdl) files into a HL2 bsp file.

http://www.geocities.com/cofrdrbob/pakrat.html

:)

[oap]Agent_S
11-01-2005, 08:02 AM
Originally posted by ultranew_b
Pakrat is quite popular and very easy to use. It's made by the same dude who made Vmex I think.

Pakrat is a graphical replacement for the BSPZIP program, that allows you to embed external files, such as textures (vtf), material (vmt) and model (mdl) files into a HL2 bsp file.

http://www.geocities.com/cofrdrbob/pakrat.html

:)

I used to use winbspzip but im now going to use Pakrat :D much easier to use thx for the link

meelo
11-01-2005, 02:22 PM
I used to use bspzip until one of the valve patches changed the map version and bspzip stopped working.

Then my buddy tells me about pakrat which was sooooo insanely easy to use I don't know why I didn't find out about it sooner. The only problem I've got with it is that it doesn't seem to want to add text files (like the map goals in counterstrike) from the maps folder :/ maybe that was just some weird bug I had once.

Anyway, pakrat is the way to go.

[SAS]==Colster==
11-01-2005, 04:58 PM
Is there a tool for source that can query the map and tell you what files it needs?

In 1.3 resgen could query the bsp and tell you what dependancies the map had, then made a res file to suit.

I use a util to make res files for source maps but you have to have everything arranged in the right folders for it, it cant tell you what it needs :(

Day of Defeat Forum Archive created by Neil Jedrzejewski.

This in an partial archive of the old Day of Defeat forums orignally hosted by Valve Software LLC.
Material has been archived for the purpose of creating a knowledge base from messages posted between 2003 and 2008.