L4D Custom Music Tutorial

From Valve Developer Community
Revision as of 19:05, 26 May 2011 by Phreque (talk | contribs) (_Master.Cache Method)

Jump to: navigation, search

Warning: There is atleast 5 seperate issues (talked about indepth on the official L4D Mappers Mailing List) that will give you countless headaches when trying to get custom sound scripts to work in your campaign. Until Valve fixes these issues, I HIGHLY recommend you avoid using soundscripts, and instead pakrat your custom sounds and call them directly by ambient_generics. You will lose a ton of customizability including the ability customize the Music Director, but atleast your campaign will have working custom sounds without screwing up other peoples campaign sounds and other oddities.

Bug: At the moment there is an issue where any campaign implementing custom soundscripts will play a random incorrect sound when you throw a molotov at zombies. Valve is aware of this issue and has it placed in the list of things to fix.

This tutorial will go over how to customize the Music Director for your campaign using the mymapname_level_sounds.txt file. If you are planning on creating custom soundscripts as well, you should still follow this tutorial and append those scripts to the level_sounds.txt.

There is 2 methods for adding custom music to your campaign.

Note:Your campaign maps should have a valid nav mesh for many soundscript events to work properly.

PAKRAT Method

This method is the easiest but often will lead to a much larger VPK file size due to duplicate WAV files across multiple BSPs. You will need to repackadge your sounds after every map compile. Use this method if you only have a few custom sound files or they are not used on multiple maps within your campaign.

There are 7 steps to this method of adding custom music to your campaign:

  1. Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
  2. Copy ALL the contents from my example soundscript into that file.
  3. In the missions file of your addon, find the NAME parameter, and pick a short name that has no spaces.
  4. In notepad, press CTRL + H, to find and replace XXXXX with the same name you used in missions.txt NAME field.
  5. Begin replacing any wav files you choose in the script to reference your own files. (Do not include sounds/ in the paths, it's assumed)
  6. BSPZIP or Pakrat your custom music into the map .bsp file. (The paths for each wav file within the bsp should be sounds/music/your_custom_folder)
  7. Packadge your campaign into a VPK and test it out ingame, your custom music should work!

_Master.Cache Method

This method is more size efficient since you won't be storing files within BSPs. Wwhen you recompile your maps during development, you wont need to repackage custom sounds.

Bug: this method requires that your campaign be the very first campaign played when players load Left 4 Dead as once the game engine loads a campaigns cache file, it won't bother loading any others until the game is restarted. Valve is aware of this issue, and it may be fixed with the Match Making update coming out shortly after the Crash Course DLC

Use this method if you have tons of custom sounds/music that is used across multiple maps and you want to maintain a small VPK size.

There are 9 steps to this method of adding custom music to your campaign:

  1. Create a text file called [your_exact_map_name]_level_sounds.txt in your addons maps directory.
  2. Copy ALL the contents from my example soundscript into that file.
  3. In the missions file of your addon, find the NAME parameter, and pick a short name that has no spaces.
  4. In notepad, press CTRL + H, to find and replace XXXXX with the same name you used in missions.txt NAME field.
  5. Begin replacing any wav files you choose in the script to reference your own files. (Do not include sounds/ in the paths, it's assumed)
  6. Load up Left 4 Dead and turn off all addons except the one you are working on. (Other campaigns custom sounds will screw this step up if you don't)
  7. In the console, enter snd_rebuildaudiocache and wait about 5 mins for it to finish.
  8. Copy the _master.cache file from your maps/soundcache, place it in your addons maps/soundcache directory.
  9. Packadge your campaign into a VPK and test it out ingame, your custom music should work!
Note:You will need to repeat the snd_rebuild steps whenever you add new sound files.
Tip:This method seems to have a 50/50 chance of allowing users to hear your custom sounds without rebuilding their audio cache. I am begining to wonder if it may be more beneficial to PAKRAT/BSPZIP the _master.cache file within the bsp itself, thereby hiding the file from other peoples addons which would avoid sound conflicts, as well as possibly forcing your custom soundcache to load instead of the default. This is untested, but worth a try.

Custom Music Script File

This is the example soundscript you need to copy.

It is a stripped version of the game_sounds_music.txt to only include the Events you need to edit for your campaign. It is highly commented allowing a greater insight into what each section is for when deciding on what to change.

You may also opt not to change anything in the file, which will give your campaign the default music cues associated with the Airport campaign.

http://www.evolvedant.com/soundscript/example_script.zip

Note:There was a slight typo in the previous file.. if intro music wasn't working for you, redownload this file.

Example Tips

If your campaign is called 'Awesome' and contains maps such as l4d_awesome_forest, l4d_awesome_campsite, etc... Your addons maps directory should contain l4d_awesome_forest_level_sounds.txt

L4dMapDir.jpg

The NAME parameter in your missions.txt would be 'awesome' and look like this:

L4dmissions2.jpg

A custom intro song that we will call 'thriller.wav' when using method 1, correctly pathed and added into the bsp would look like this:

L4dPakrat.jpg

Heres how your sound script would look properly edited to make use of thriller.wav

L4dsoundscript.jpg

See also