Include/pack things into a bsp (my way)

Avatar
DaMaGepy
361 Posts
Posted May 22, 2011
Hi.
Since I've read on this forum that some ppl have problem merging resources (custom textures, sounds etc) into the bsp, I tell you how I do that. I made this method for portal 1 but then I modified it for portal 2.

My method requires, that you never launch the map after the compiling is done from hammer. Well, I never, I youst use a shortcut from my desktop to launch portal + my map, and then (since it runs in window) I just press "i" to reload it after every compile.

So:
1. Add a desktop shortcut
I made a shortcut on the desktop (your portal 2 exe path wil be different ofc):
"E:\JATEK\Valve\Steam\SteamApps\common\portal 2\portal2.exe" -novid -console +map sp_damagepy_02
this will launch portal without the starting vid, showing the console, and auto-loading the specified map. Portal should run in windowed mode.

2. Bind a key in portal2 to load or reload the map
In portal I made a binding in console:
bind i "map sp_damagepy_02"
portal saves this binding if u exit portal 2, so will work after next launch too, and you only need to change it (or bind another key) if you making other maps too. After I re-compiled my map, I just switch to the portal 2 windows and press "I" to reload. I shouldn't move ingame tho, because if there were some serious changes in the bsp, and portal2 tries to load something new from the bsp (and ofc it changed), sometimes just crashes portal2. If that happens, just use the desktop shortcut to load the map. I sometimes use the console command "reload" but loading the map is safer, since reload sometimes keeps your location etc and remembers things, that sometimes not there in the newly compiled bsp.

3. Adding bspzip's path in hammer
Since I failed to add a custom executable with path to hammer's F9 advanced compiling, I had to use the game_exe variable for bspzip:
Tools / Options / Build programs tab, Game executable:
$SteamUserDir\portal 2\bin\bspzip.exe
(Note: when I added the bspzip with path as a command into the expert mode, the space in the path f@cked up things, Also tried to use $gamedir but it just added it as a text, thats why Ichose to use the game_exe variable to set bspzip's path)

4. Compiling, F9 Expert mode
Now when compiling a map in expert mode, I've added a new row after the $light_exe row but before the Copy file:
command: $game_exe
Parameters: -addlist $path\$file.bsp $path\$file.txt $path\$file.bsp

and of course unchecked the last $game_exe row since it can't auto-launch the compiled map now (can be done with the desktop shortcut, or just reloading the map with the keybinding)
With this command, bspzip will look for a txt file where the .vmf is and process it

5. Making the resource-list .txt
Create a txt, its name is thesame as the map, in my example its sp_damagepy_02.txt
The txt must contain the files you want to include in the bsp. For example if you want to add two custom sound (mind the different \ and / separators in the paths!):
sound/damagepy/music1.mp3
e:\JATEK\Valve\Steam\SteamApps\common\portal 2\sdk_content\maps\music\music1.mp3
sound/damagepy/cavesound.mp3
f:\whatever\mysounds\customsound_cave.mp3

to add a file it needs 2 row (paired), so to add 3 custom thing, the txt must have 3x2=6 row:
The first row is the path inside the bsp where you want to add it
The second is the path to the file, can be anywhere, as I showed in the 2nd custom sound example
(btw sound can be mp3, must be 44100 khz 128 bit, and must be in a sound dir, since in an ambient_generic, I can only specify its location as damagepy/music1.mp3, portal automatically search it in a sound path)
Must make it for every included file.

Thats all, when you compile the map, it will automatically add the files to the bsp. Check the log after compiling for errors (if you have some blank/empty line at the end of the .txt or it can't find the files, it gives an error)
This is my method, after setup, then everything is automatic, just compile the map with F9 as normally, the only difference is that you need to launch the map in Portal 2 on your own.
IF you make a new map, the only thing you need to do is to manage it's .txt file, if you use the same resources as your other map, just copy/rename its .txt...

Advertisement
Registered users don’t see ads! Register now!
Avatar
ChickenMobile
2,460 Posts
Posted Jun 09, 2011
Replied 18 days later
Thanks for the tut man, very in depth and helpful. I tried doing this before and failed because I needed to change a '' to a '/'. -.-
The only problem I have with is this:> DaMaGeby wrote:

Since I failed to add a custom executable with path to hammer's F9 advanced compiling, I had to use the game_exe variable for bspzip:
Tools / Options / Build programs tab, Game executable:
$SteamUserDir\portal 2\bin\bspzip.exe

So will this interfere with anything other than the "Don't run the game after compiling" option? If not I will do this myself.

Also just for a heads up: :postpics:. It will help a lot. :lol:

Avatar
DaMaGepy
361 Posts
Posted Jun 09, 2011
Replied 2 hours later
Will not interfere, if you dont want hammer to start the map in Portal 2 after compiling.
But in expert mode there is no such checkbox, and the normal mode checkbox only turns the last "$game_exe -dev ..." command off (in expert mode)

I never used that feature anyway, since Portal 2 runs in the background all the time (windowed) and after each compile I just alt-tab and reload the map. Not a big loss.

Avatar
Omnicoder
299 Posts
Posted Jun 09, 2011
Replied 2 hours later
I don't see why replacing the game exe path is necessary, I've had something similar set up for a while without having to mess up any existing features.
Avatar
DaMaGepy
361 Posts
Posted Jun 10, 2011
Replied 15 hours later

Omnicoder wrote:
I don't see why replacing the game exe path is necessary, I've had something similar set up for a while without having to mess up any existing features.

well I tried to enter the bspzip into the Command: editbox using variables $ but then that appeared exactly the same way with $ in the compilation window. Same goes for parameters. Or maxbe it was good as command but when my path had a space it went wrong, and when I used " " in the command it also went wrong. And I never use that $game_exe variable to launch the map, I just use my shortcut:
"E:\JATEK\Valve\Steam\SteamApps\common\portal 2\portal2.exe" -novid -console -w 1600 -h 900 -sw +map sp_damagepy_02
(In the last 2-3 day portal 2 started to forgot its "run in windowed mode" video setting so I had to include the windowed params, also it only ran in 1280x720 or 1440x900 so I included a custom resolution 16:9 for frapsing in HD)

Avatar
briandoyle81
10 Posts
Posted Dec 05, 2011
Replied 5 months later
I've been trying to get this method to work for several hours. I've also tried creating a .vpk. Both ways, if I try to play an mp3, I get the "Can't create mixer" error. If I try to play a .wav, the sound doesn't play, but there are no errors.

Anyone have any suggestions?

Avatar
iWork925
1,080 Posts
Posted Dec 06, 2011
Replied 1 day later
EPIC THREAD RESSURECTION!!!!!

Has been burried for 6 months, but LIVES AND BREATHES AGAIN!!!!!

.... you cant play mp3's in portal 2. There is a specific method of getting wavs to work that I cant remember of the top of my.... oh wait. http://bit.ly/rCJ3aQ

Avatar
DaMaGepy
361 Posts
Posted Dec 07, 2011
Replied 22 hours later

iWork925 wrote:
EPIC THREAD RESSURECTION!!!!!
.... you cant play mp3's in portal 2. There is a specific method of getting wavs to work that I cant remember of the top of my.... oh wait. http://bit.ly/rCJ3aQ

You can, since I use MP3s all the time as a background music in my maps. :smile: They just must be 44.1khz 128 bit stereo CBR.

Avatar
iWork925
1,080 Posts
Posted Dec 07, 2011
Replied 1 hour later
oh i thought you could only play wavs. heard it from a pretty reliable source.
Avatar
sicklebrick
876 Posts
Posted Dec 08, 2011
Replied 6 hours later
Oh well, while it's being ressurected, it might be worth noting that you can add gaps in your resource list as long as you add 2 at a time E.g:

materials/models/whatever/
c:\blah\materials\models\whatever
materials/models/whatever2/
c:\blah\materials\models\whatever2


models/newmodel/
c:\blah\models\newmodel

Helps a little in spacing things out - more readable.:smile:

Avatar
josepezdj
2,386 Posts
Posted Dec 13, 2011
Replied 5 days later
OK, I have tried several times ti use Damagepy's method, but all the time without success.

I think this way would be the best one for adding custom content (instead of VPKs, still NOT working, or sdk_dlc3\ folders or else...) and I would really like this to work!

By now, I've got everything working following this guide: bspzip.exe adds my custom content, no errors, etc. But when I try to check out about if my BSP works good by removing the custom textures from portal2 folders (from materials/.../) and run the bsp, textures are not showing. So I suppose something is not working out.

What could I be doing wrong?

Avatar
KennKong
942 Posts
Posted Jan 10, 2012
Replied 28 days later
I am preparing a basic mod for playing .vpks, see here:
http://forums.thinking.withportals.com/mapping-help/mod-for-playing-vpk-file-t5388.html
In that thread, others have said you could pack your files into the .bsp, as discussed here. I have the following questions:
- If you have a multimap series (e.g. NYS-5) do you need to include the custom content in every .bsp file that uses them? And if so, does custom content add enough size doing it this way to make using a .vpk a better option?- Are there any files that would work in a .vpk that won't work in a .bsp, e.g. sp_lightboard_icons.txt?
Avatar
DaMaGepy
361 Posts
Posted Jan 10, 2012
Replied 5 hours later
  • ye, must include into all bsp, so that way vpk is better for mappacks
  • ye, it should work with bsp too. In my latest experiment map I included a custom music mp3, skybox, and a .nut file without problem. Also works with script .txt
Avatar
Skotty
671 Posts
Posted Jan 11, 2012
Replied 21 hours later

Why aren't you just using Pakrat?

https://developer.valvesoftware.com/wiki/Pakrat

It's an old but very very useful and easy to handle program.

Avatar
DaMaGepy
361 Posts
Posted Jan 12, 2012
Replied 12 hours later

Skotty wrote:
Why aren't you just using Pakrat?
https://developer.valvesoftware.com/wiki/Pakrat

It's an old but very very useful and easy to handle program.

I must pak things into the bsp manually after every compilation, or does it have a commandline auto feature? Since with bspzip, I do nothing. Every time I compile my map with F9 in hammer, it auto-includes everything, so at the end, the resulting BSP that gets copied to the maps dir is ready to go. Thats why I like my method (even if it not always works for others)

Avatar
CosmicD
125 Posts
Posted Dec 30, 2012
Replied 11 months later
I found this topic trough google.

I had the big trouble in one of my maps that wav sounds just don't play (you hear kleiner complain about fiddlesticks) Strangely enough pakrat would include the wavs in my sound/cosmicd/glados map, but not in the sound/cosmicd/music dir

I just have tried all kind of methods, also adding the $b_zip variable with addlist but hmm.. doesn't still work somehow.

bzip says -addlist unknown command

EDIT: So I read the issue you had with bsp variables and tried the game thing, but what I get then is that my game just starts up (even when I didn't tick the game start rule in the expert compile mode)

Avatar
josepezdj
2,386 Posts
Posted Dec 30, 2012
Replied 3 hours later
Always use pakrat... works great for everything. Follow this tutorial. If your .wav files are not working, maybe they're not accomplishing the requirements. Fir example, are they 44110Hz sample rate?
Avatar
CosmicD
125 Posts
Posted Dec 31, 2012
Replied 1 day later
Very strange. This is a silly engine trap once again. I just don't understand.

  1. I made all files mono 44.1k (because I thought it might be an issue to include stereo files
  2. I recompiled the map to have it without all custom stuff in it. skybox stuff
  3. I open the bsp with pakrat and if i click "auto" it only finds models/materials but doesn't want to add the sounds somehow. (as it does with the other map.

Where does pakrat look to decide with sounds to add ? I thought it was in the ambient_generics but that doesn't sem to be it because there are about 4 with custom sounds that I use in this map.

Avatar
CosmicD
125 Posts
Posted Dec 31, 2012
Replied 4 hours later
UPDATE:

Seems like it has something to do with the compiler. If I don't choose expert mode to compile (and I use the normal mode with hdr checkbox), then the information for the waves somehow get included)

Now I'm wondering, what does the compiler do in normal mode what it doesn't do in expert mode ?

Advertisement
Registered users don’t see ads! Register now!
Avatar
Gemarakup
1,183 Posts
Posted Jan 14, 2013
Replied 13 days later
What directory via pakrat do you need to write to pak instances?