Left 4 Dead 2

Left 4 Dead 2

Level Background Music Support
 This topic has been pinned, so it's probably important
ChimiChamo  [developer] 9 Apr, 2024 @ 3:10pm
How to make your custom background music.
"Aight ChimiChanga that's all great but how do I actually use this?" - You presumably

This assumes you know the basics of setting up a folder in your addons and how to turn it into a VPK.

First get the actual music files you want and put them in the "sound" folder of your addon directory. Ensure that the music files are UNDER 48000Hz, are .wav files and have loop points set up.

Then create the file with this folder path in your addon directory -> "scripts/vscripts/director_base_addon.nut"
You could call the script differently as long as it isn't mapspawn_addon but the one above will fire automatically.

Now open the file in your text editor of choice, and now to actually set up playing the music. To add a track with a "calm" and "battle" variant put this in the script:
getroottable().ChCh_AddBackgroundMusic(map,calm,angry,consistent)

The "map" bit is the filename of the map to add the music to, setting it to "all_maps" will add the music to all maps.
The "calm" and "angry" bits correspond with the filenames of the "calm" and "battle" versions of the music to play.
The "consistent" bit is a true or false on whether to have the 2 sounds be synced. If set to true, the music will blend into each other at the same position in the track. Having at as false will pause the respective tracks when the other is playing

So say for example I wanted to add 2 consistent tracks located in the directory "sound/music/ultrakill/" for map 2 of Dead Center then I would write:
getroottable().ChCh_AddBackgroundMusic("c1m2_streets","music/ultrakill/4-2 Clean.wav","music/ultrakill/4-2.wav",true)
Make sure not to include "sound" at the start of the filename or else it won't work.

You can also just have 1 track play the whole time without changing like this:
getroottable().ChCh_AddBackgroundMusicSingular(map,angry)

Again, the "map" is for the map filename and "angry" is for the sound to play at all times.

Further functions for customisability are in the "Further Utility Functions" discussion.

And there you go, build a soundcache for your sounds and your music should play in the map you chose.
Last edited by ChimiChamo; 21 Apr, 2024 @ 3:33pm
< >
Showing 1-15 of 22 comments
Jay0Jantern 9 Apr, 2024 @ 3:28pm 
yes
ึBubbyツ 11 Apr, 2024 @ 1:11pm 
ty
please add support for permanent angry music during crescendo events
ChimiChamo  [developer] 14 Apr, 2024 @ 4:47am 
Originally posted by JermaDrink:
please add support for permanent angry music during crescendo events
theres not really a way to check whether specifically a crescendo is happening, it just checks for whether at least 14 common infected are rushing the survivors + some other stuff. i could add a "force angry" or "force calm" music thing though
Originally posted by ChimiChamo:
Originally posted by JermaDrink:
please add support for permanent angry music during crescendo events
theres not really a way to check whether specifically a crescendo is happening, it just checks for whether at least 14 common infected are rushing the survivors + some other stuff. i could add a "force angry" or "force calm" music thing though
that might work, depends on the implementation and whether it functions by ignoring the drop below 14 commons or more than 14 commons rushing the player once the specified music is triggered
Last edited by emo braixen gf θΔ; 14 Apr, 2024 @ 4:51am
alternatively, being able to customize the amount of infected needed to trigger the angry music if possible would be a cool addition since it would prevent issues like what i'm experiencing testing my mod
ChimiChamo  [developer] 14 Apr, 2024 @ 4:58am 
Originally posted by JermaDrink:
alternatively, being able to customize the amount of infected needed to trigger the angry music if possible would be a cool addition since it would prevent issues like what i'm experiencing testing my mod
yeah thats a good idea, ill implement that as well
Originally posted by ChimiChamo:
Originally posted by JermaDrink:
alternatively, being able to customize the amount of infected needed to trigger the angry music if possible would be a cool addition since it would prevent issues like what i'm experiencing testing my mod
yeah thats a good idea, ill implement that as well
thank you, it's very much appreciated
ChimiChamo  [developer] 14 Apr, 2024 @ 5:19am 
Originally posted by JermaDrink:
I've added some of the stuff you wanted, it's written about in the new "utility functions" discussion.
Unamelable 14 Apr, 2024 @ 9:37pm 
Can you do random track shuffle? Like im subscribe to 3 mods. And they gonna play in random sequence if im gonna add command in autoexec.cfg (Of course mod will be loaded as VPK without mod subscribing, because autoexec command will not find command)
Unamelable 14 Apr, 2024 @ 9:41pm 
It would be logical to add another "transition" when the track switches to "angry" state but with an instrument like "WOOSH" or supercharged with another musical instrument. I saw this mechanic in the recent Project Zomboid update with its music overhaul.
Pc 20 Apr, 2024 @ 12:19am 
help i novice to this i try to do it so far but i cant do nothing so can someone pls break it down for me thx :)
Last edited by Pc; 20 Apr, 2024 @ 12:21am
It would be nice for some of us to know where or what the maps are called...not like the "c5m5 known as bridge.
Clockwork_Croww 29 Apr, 2024 @ 12:26pm 
it might just be a me issue, but I've noticed that with tracks that have consistency set to 'false' it ignores horde size and only plays the angry track when someone's pinned, down, or when there's a tank around. am I missing something?
ChimiChamo  [developer] 29 Apr, 2024 @ 2:36pm 
Originally posted by Clockwork_Crow:
it might just be a me issue, but I've noticed that with tracks that have consistency set to 'false' it ignores horde size and only plays the angry track when someone's pinned, down, or when there's a tank around. am I missing something?
That’s odd. I’ll take a look tomorrow
< >
Showing 1-15 of 22 comments
Per page: 1530 50