Making a custom Leader use existant Leader Music without replacing any leader!

Leugi

Supreme Libertador
Joined
Jan 25, 2013
Messages
1,677
Location
Bolivia
Yes, I have discovered a fancy (and quite funny) way of achieving this.

So, let's say you have a custom mod with a new leader, or are making a mod with a new leader. The first sad thing you'll notice, is that once you change the leader of a civilization, they lose their Leader Music. And thus when you meet them for the first time, its quite anticlimatic... And thus when you start playing with them, it feels odd...

A way for solving this is replacing your leader with, say, Napoleon. That way you get Napoleon's music for free... Well, not for free, Napoleon no loger exists in your game. So this method has a huge price to pay.

I have found a new way of achieving this, which sadly isn't completelly modular (this is our price, but honestly, its a small price in comparison to losing a whole civ), but works out nicely.

Use any custom civ you wish. For this example I'll use my Qullana Civ Mod, which adds Tupac Katari as a Leader (why?, because it will be a nice example of using Leader music and Game music for your Leader), don't worry, I'm not forcing you to download anything :P , you can use these same stuff with any modded civ.

Tools you need
  • Something to open .ogg music files, I heavily reccomend VLC media player
  • Something to work in .xml files, though you can use notepad for that, its up to you :P

Step One: What is the name of our Leader?

So of course, we need to know the Leader Type from our leader. Its usually defined on a xml. Pretty much the bolded blue part is what we need:

Code:
<GameData>
	<Leaders>
		<Row>
			[B][COLOR="Navy"]<Type>LEADER_KATARI</Type>[/COLOR][/B]
			<Description>TXT_KEY_LEADER_KATARI</Description>
			<Civilopedia>TXT_KEY_LEADER_KATARI_PEDIA</Civilopedia>
			<CivilopediaTag>TXT_KEY_CIVILOPEDIA_LEADER_KATARI</CivilopediaTag>
			<ArtDefineTag>Katari_Scene.xml</ArtDefineTag>
			<VictoryCompetitiveness>5</VictoryCompetitiveness>
			<WonderCompetitiveness>3</WonderCompetitiveness>
			<MinorCivCompetitiveness>9</MinorCivCompetitiveness>
			<Boldness>10</Boldness>
			<DiploBalance>3</DiploBalance>
			<WarmongerHate>10</WarmongerHate>
			<DenounceWillingness>10</DenounceWillingness>
			<DoFWillingness>6</DoFWillingness>
			<Loyalty>8</Loyalty>
			<Neediness>10</Neediness>
			<Forgiveness>1</Forgiveness>
			<Chattiness>10</Chattiness>
			<Meanness>3</Meanness>
			<PortraitIndex>1</PortraitIndex>
			<IconAtlas>CIV_COLOR_ATLAS_QULLANA</IconAtlas>
		</Row>
............
..............
..............

So, our leader's type is LEADER_KATARI... We'll need this for the last magic step.

Step 2: Understanding the Audio Defines

Well, we got our leader type. Now we must check something interesting. Go to your Civilization folder, and search the Assets folder.
-Inside the Assets Folder, search for the Sounds Folder​
Inside the Sounds Folder, search for the XML folder​
And inside the XML Folder, open any xml file which ends with "2DScripts.xml". In this case I'll open up Alexander​

You'll be faced with this:
Code:
<Script2DFile>
  <Script2DSounds>
  	
    <!--Alexander Leader Speech-->
    <Script2DSound>
      <ScriptID>AS2D_LEADER_SPEECH_ALEXANDER_ATTACKED</ScriptID>
      <SoundID>SND_LEADER_SPEECH_ALEXANDER_ATTACKED</SoundID>
      <iMaxVolume>95</iMaxVolume>
      <iMinVolume>95</iMinVolume>
      <fTaperSoundtrackVolume>0.85</fTaperSoundtrackVolume>
      <SoundType>GAME_SPEECH</SoundType>
    </Script2DSound>
    <Script2DSound>
      <ScriptID>AS2D_LEADER_SPEECH_ALEXANDER_DECLARE_WAR</ScriptID>
      <SoundID>SND_LEADER_SPEECH_ALEXANDER_DECLARE_WAR</SoundID>
      <iMaxVolume>95</iMaxVolume>
      <iMinVolume>95</iMinVolume>
      <fTaperSoundtrackVolume>0.85</fTaperSoundtrackVolume>
      <SoundType>GAME_SPEECH</SoundType>
    </Script2DSound>
...............
..........
..........

If you search there, you will find the following code lines:

Code:
<!--Alexander Music-->
    <Script2DSound>
      <ScriptID>AS2D_LEADER_MUSIC_ALEXANDER_PEACE</ScriptID>
      <SoundID>SND_LEADER_MUSIC_ALEXANDER_PEACE</SoundID>
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>
    <Script2DSound>
      <ScriptID>AS2D_LEADER_MUSIC_ALEXANDER_WAR</ScriptID>
      <SoundID>SND_LEADER_MUSIC_ALEXANDER_WAR</SoundID>
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>

So, there's where Leader Music is defined, with an ScriptID... If you open the AlexanderAudioDefines.xml you'll finde the SoundID which is being referenced, with the proper file being referenced.

We'll copy the code we have found. I will not tell you where to paste it yet :P

Step 3: Search for your favorite music inside the game folders

Well, in the Sounds folder, you will also find a "Streamed" folder. Open it and then open the "Music" Folder.

There you will find all (Non-expansion and non-dlc) music. From Ingame to Leader Music. If you also want to check Expansion or DLC music, go back to the Assets folder, and search the DLC folder... Take your pick on which DLC folder to chekc (or better the Expansion folder) and search for Sounds and all that again.

Search for a suitable Peace Music and for a nice War Music.

In this case, we'll use Jach's_Marka.ogg from the "Assets\Sounds\Streamed\Music\America\Peace" folder for Peace
And for War we'll use Pacal_War.ogg from "assets\DLC\Expansion\Sounds\Streamed\Music\Leader Music" folder for War

Step 4:Search for the right Audio Defines

So, we know which music we want, and we know where to find *.*AudioDefines.xml ... You must search inside your assets folder where the right music is being defined.

A good way of doing that is using the Search function, searching inside the files. You must put the file name without the extension (".ogg") since the Audio Defines don't use it. In my case these are the files I need:
  • For Jach'sMarka, its AmericaRegionAudioDefines.xml in "assets\Sounds\XML"
  • For Pacal_War, its PacalAudioDefines.xml in "assets\DLC\Expansion\Sounds\XML"

Open them and search where the music is being defined. Like this:

Code:
...
<SoundData>
			[B][COLOR="Navy"]<SoundID>SND_AMERICAREGIONS_PEACE_24</SoundID>[/B][/COLOR]
			<Filename>Jach's_Marka</Filename>
			<LoadType>STREAMED</LoadType>
		</SoundData>
...
Code:
...
<SoundData>
      [B][COLOR="Navy"]<SoundID>SND_LEADER_MUSIC_PACAL_WAR</SoundID>[/B][/COLOR]
      <Filename>Pacal_War</Filename>
      <bDontCache/>
      <LoadType>STREAMED</LoadType>
    </SoundData>
...

Copy both SoundID's, as we'll need them for the next step

Step 5: Funky Magic!

So, this is the fun part, the part which makes no sense at first, but then helps you understand well.

Before proceeding, you must realize which music you're using. I'm using a music from the core game, and an expansion music. This is important, because if we modify a file from before the expansion, we won't make it in.

You must open any *2DAudioScripts.xml file you find, it is better if you open generic ones, so you'll know where to change them later one. Since we are using a music from the expansion, we'll open Audio2DScriptsExpansion1.xml from "assets\DLC\Expansion\Sounds\XML"

You must search where the <Script2DSounds> bracket is opened (in some cases there are few things before it):

Code:
<Script2DFile>
  <Script2DSounds>
...
....

After that <Script2DSounds>, we'll paste our defining from Alexander:


Code:
<Script2DFile>
  <Script2DSounds>
[B][COLOR="Navy"]<!--Alexander Music-->
    <Script2DSound>
      <ScriptID>AS2D_LEADER_MUSIC_ALEXANDER_PEACE</ScriptID>
      <SoundID>SND_LEADER_MUSIC_ALEXANDER_PEACE</SoundID>
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>
    <Script2DSound>
      <ScriptID>AS2D_LEADER_MUSIC_ALEXANDER_WAR</ScriptID>
      <SoundID>SND_LEADER_MUSIC_ALEXANDER_WAR</SoundID>
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>[/B][/COLOR]

We'll change the Comment "--Alexander Music--" to whatever we want, so we remember where we are adding this, in my case "--Tupac Katari Music--"... And then...

Check the ScriptID, right now it says "AS2D_LEADER_MUSIC_ALEXANDER_PEACE"... well, our leader type is "LEADER_KATARI", so we'll change that to "AS2D_LEADER_MUSIC_KATARI_PEACE"...

Why? Because that's our magical step... It doesn't even make much sense, since its not even the same define, but it seems that whatever script Firaxis made for defining Leader^Music it transforms the define automatically. We'll do the same with the War thing.

Code:
<!--Tupac Katari Music-->
    <Script2DSound>
      [B][COLOR="Navy"]<ScriptID>AS2D_LEADER_MUSIC_KATARI_PEACE</ScriptID>[/B][/COLOR]
      <SoundID>SND_LEADER_MUSIC_ALEXANDER_PEACE</SoundID>
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>
    <Script2DSound>
      [B][COLOR="Navy"]<ScriptID>AS2D_LEADER_MUSIC_KATARI_WAR</ScriptID>[/B][/COLOR]
      <SoundID>SND_LEADER_MUSIC_ALEXANDER_WAR</SoundID>
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>

Note we didn't change the SoundID just yet... That's where we'll put our new lovely music! So, now we change it with the SoundIDs we found...

Code:
<!--Tupac Katari Music-->
    <Script2DSound>
      <ScriptID>AS2D_LEADER_MUSIC_KATARI_PEACE</ScriptID>
      [B][COLOR="Navy"]<SoundID>SND_AMERICAREGIONS_PEACE_24</SoundID>[/B][/COLOR]
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>
    <Script2DSound>
      <ScriptID>AS2D_LEADER_MUSIC_KATARI_WAR</ScriptID>
      [B][COLOR="Navy"]<SoundID>SND_LEADER_MUSIC_PACAL_WAR</SoundID>[/B][/COLOR]
      <SoundType>GAME_MUSIC</SoundType>
      <iMaxVolume>40</iMaxVolume>
      <iMinVolume>40</iMinVolume>
      <bIsMusic>True</bIsMusic>
    </Script2DSound>

And there you have it...

Step 6: Test!

Well, test your fancy modification, and... Rejoice! It works! (note: if it didn't work, check back your steps and rejoice afterwards once it works)

Also, for the next times you do this, you're free to skip certain steps, since what matters is the xml part of the end.

Important Questions

Why isn't this modular? Couldn't you just put an .xml with the same structure as the 2DAudioScripts?

Well, I tried... Theoretically it should work, however it doesn't. I suppose one needs a different action than "OnModActivated - UpdateDatabase" on ModBuddy... But I don't know which one would work. Until anyone discovers that, this is not really that modular... Not that it affects however, since the modification won't break anything when the mod isn't loaded.

Would this allow us to have our custom leader music for a custom leader?

Yes! Follow this tutorial to manage that!

Anyway, any other questions will be answered, thank you.
 
I was under the impression that this could be achieved with just <SoundtrackTag>China</SoundtrackTag> or w/e to get the desired music

SoundtrackTag allows you to use the Civilization's music for your custom Civilization ingame, but adds no leader music at all... So, when you meet, say, Tupac Katari, it doesn't change the background music. Also, when you start playing, it goes directly to the normal musics, instead of using a leader music.

This tutorial allows for Leader music aside from Civilization's music... And it's also what allows custom music too.
 
Why couldn't you just add the file to VFS to overwrite the stuff? Or will that not work either? You know, name it the same thing as the file you'd be adding stuff to (be sure to put the original leader's values in there too!) and add it to VFS.


Also, I like you Leugi. Would you consider contributing to (or even joining) Project Civ? We're in dire need of a decent LH artist such as yourself, and I've seen that you're not that bad of a mech designer. Perhaps we could put our heads together?

Sorry if public negotiations bother you, but I absolutely love transparency.
 
Why couldn't you just add the file to VFS to overwrite the stuff? Or will that not work either? You know, name it the same thing as the file you'd be adding stuff to (be sure to put the original leader's values in there too!) and add it to VFS.

I suppose that way it would actually be less modular. If two mods would do that, one would replace the other, so in a way it would cause bigger compatibility issues.

Unless we find out an alternate way, instead of OnModActivated - UpdateDatabase, that works for using SoundDefines xml, this will have to do.
 
Why couldn't you just add the file to VFS to overwrite the stuff? Or will that not work either?
Unfortunately, there are certain assets (including ScriptID and SoundID) that can't be added by a mod, although they can be added by core game and DLC files. See my thread on this here.

Btw, this is altering core game installation files. It's been characterized here as a "no no", though I don't necessarily hold that opinion myself. The problem is that all your work will be overwritten automatically (without warning) with any new patches. And there will be new patches coming with the expansion. I suspect that when Civ5 development ceases, then modders will start modding more and more a la Civ4 (i.e., changing installation files).

if you are willing to alter installation files, then that opens a couple other possibilities:
  1. You can take this all the way and add entirely new music (or sound) tracks. In fact, .mp3 files load just fine with VFS = true (.ogg files don't, but you can replace all .ogg files with .mp3 files anyway). So, technically speaking, you can add music by "normal" modding; the problem is that you can't use it because you can't add ScriptID and SoundID.
  2. A cleaner way to do this would be to add your SoundID and ScriptID's via the DLC method. You can't actually add a DLC, but you can modify an existing one, say, Mongolia (which everyone has). DLCs already add SoundID and ScirptIDs (and other "modder forbidden" assets), so you can open existing ones and just copy what they do there. Note that this won't fix the "patch overwrite" problem above. But it is more modular in the sense that your changes are all in one place, rather than scattered through various core game files.
 
Unfortunately, there are certain assets (including ScriptID and SoundID) that can't be added by a mod, although they can be added by core game and DLC files. See my thread on this here.

Btw, this is altering core game installation files. It's been characterized here as a "no no", though I don't necessarily hold that opinion myself. The problem is that all your work will be overwritten automatically (without warning) with any new patches. And there will be new patches coming with the expansion. I suspect that when Civ5 development ceases, then modders will start modding more and more a la Civ4 (i.e., changing installation files).

if you are willing to alter installation files, then that opens a couple other possibilities:
  1. You can take this all the way and add entirely new music (or sound) tracks. In fact, .mp3 files load just fine with VFS = true (.ogg files don't, but you can replace all .ogg files with .mp3 files anyway). So, technically speaking, you can add music by "normal" modding; the problem is that you can't use it because you can't add ScriptID and SoundID.
  2. A cleaner way to do this would be to add your SoundID and ScriptID's via the DLC method. You can't actually add a DLC, but you can modify an existing one, say, Mongolia (which everyone has). DLCs already add SoundID and ScirptIDs (and other "modder forbidden" assets), so you can open existing ones and just copy what they do there. Note that this won't fix the "patch overwrite" problem above. But it is more modular in the sense that your changes are all in one place, rather than scattered through various core game files.

In a way, this is what I do here too. I'm actually adding the SoundID and ScriptId to the Expansion defines. Of course, the patch warning is important... (I use this for my Gran Colombia and my Bolivia mods, although one still has to add something to core files, technically we no longer replace anything... All leaders survive this process, which is more forgiving)

Of course, it isn't 100% nice, and as you say its sort of "no no", but this one isn't so bad, its pretty much a little optional thing.
 
Since we are using a music from the expansion, we'll open Audio2DScriptsExpansion1.xml from "assets\DLC\Expansion\Sounds\XML"

Ah! I didn't see that. So yes, you are adding via DLC. But I'd suggest that you do it via the Mongolia DLC (rather than expansion DLC) because all players have that. The only tricky step here is getting SoundID and ScriptID into the game. There is no reason why that has to be done from the expansion DLC in particular.

As you noted, mods can add mp3 files with VFS=true, but not ogg files. Since you're changing DLC files anyway, you could go ahead and add ogg files there rather than by "mod VFS=true" (I'm pretty sure I've seen ogg files added by DLCs). However, it doesn't matter because any ogg file can be replaced by an mp3 with the same name, and it's easy to find free conversion on-line. (My mod replaces all music by simply adding mp3 replacements with the same names as the original ogg files. It's a very inelegant and annoying way to mod but it worked for my purposes.)

[Edited after I actually read your OP.]
 
Back
Top Bottom