[Tutorial] How to add new background music

Started by Mightyrick1, April 16, 2016, 11:56:32 PM

Previous topic - Next topic

Mightyrick1

So have you been wondering how to add new background music to the game? I sure have. So let's take a look at it and see what we can discover. It's pretty simple, you just need to know what you are doing.

First, to keep things organised, let's create a map called Defs and place a submap in there called SongDefs. In this map you create a new .xml file, and inside you can put the following code :

Quote
<?xml version="1.0" encoding="utf-8" ?>
<SongDefs>

   <SongDef>
      <clipPath>track1</clipPath>
      <volume>0.9</volume>
      <allowedTimeOfDay>Day</allowedTimeOfDay>
   </SongDef>

   <SongDef>
      <clipPath>track2</clipPath>
      <volume>0.8</volume>
   </SongDef>

   <SongDef>
      <clipPath>track3</clipPath>
      <tense>true</tense>
   </SongDef>

</SongDefs>

The 3 examples provided above all work, except in this particular case "track1" will only play during the day, "track2" can play during day and night, and "track3" is able to play if there is combat involved.

In the above examples I played around with a few variables, there's a few more out there, so let's take a look at all of those :
<volume></volume> : used to independantly increase/decrease the volume level of the track.
<allowedTimeOfDay></AllowedTimeOfDay> : allows you to set wether the track is used only during day- or nighttime.
<playOnMap></playOnMap> : Allows you to use the track as end credits music or as main menu background music.
<tense></tense> : If set to "true" the track will play during combat.

At this stage, you've got the code, but you're not 100% done just yet. Now you need to include a Sounds map in your mod folder, which contains the new music tracks. Do note, in the clipPath you reference "track1" and not "track1.wav", referencing to the latter will give you an error.

Now all you need to do to have a working mod is to include a .wav file corresponding to the correct name in your Sounds folder and you should be good to go! Remember : If you place the music somewhere else than directly in your Sounds folder you do need to include the submap in the clipPath otherwise you will get an error because the game cannot find the track you are looking for.

I hope at least one person is able to make use of this guide to easily make a mod with new music. It might be a basic thing for more experienced coders, but I as a rookie felt that this could have been written down a little better, and I decided to put my money where my mouth is. I might write more guides in the future if I keep experimenting and discover new things that could be made a little more 'rookie friendly'. Have fun modding!
Amateur modder / YT LPer at www.tiny.cc/DDYoutube
mods : Elysian Flags - Mscarsonelle's theme