• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Discussion Music question..?

In "music_standard.c", you added this:
Code:
    //============ KRAKEN ATTACK =======
   tmpref.music_kraken_attacl.f1.name = "MUSIC\krakenattack.ogg";
The possible mis-spelling "attacl" is in the file.

In "NK.c", in the definition of function 'KrakenAttackEnabled':
Code:
   if(CheckAttribute(pchar, "KrakenAttack"))                       return false;   // No Kraken attack is available until a set time after the previous attack
   if(CheckAttribute(pchar, "ship.SubmergeDutchman"))               return false;   // No Kraken attack is available while the Dutchman is submerged
Your version in that thread returns 'true' for both. It also returns 'true' by default whereas the normal version returns 'false'.

Also added, in the definition of function 'KrakenAttack' in "NK.c", is this code:
Code:
       PauseAllSounds();
       FadeOutMusic(150);
       PlaystereoOGG("music_krakenattack");
       //FadeOutMusic(500);
       if (!bDisableMapEnter)   PostEvent("LoadSceneSound", 110000);
       else                   PostEvent("LoadSceneSound", 41500);
That won't work because it's trying to play "music_krakenattack". So "music_standard.c" will need to change "music_kraken_attacl" to "music_krakenattack".

Additionally, both files are out of date, especially "music_standard.c" which now has several additions from @Jack Rackham and myself related to our storylines.
 
I'm sorry, but the music of the kraken does not appear as I evoke the kraken, but there was a change: when I evoked the kraken the music stopped, now the music continues:dance
 
Thanks, @Grey Roger .
Indeed looks like you caught a typo there.
With that fixed, maybe it does work.

Do keep the Build Default values 'false'.
Setting those 'true' is a cheat to disable the semi-realistic limitation imposed on the Kraken attack.
 
So I guess it will take some time for custom music in the various storylines ...?
That depends. I don't think anyone has it on their to-do list, so it could take literally an infinite amount of time.
Unless you're willing to do it yourself, in which case we're willing to help you figure out how to do it.
It's not very difficult so you can probably manage it just fine. :onya
 
I would very much like to do it on my own, although I'm not good at code, it's just been signed up and I'm looking at some tutorials in the meantime. I got an idea with the "modding tutorials and history" manual (I think it made a certain @Talisman) in the first sections dedicated to these difficult codes
 
I would very much like to do it on my own, although I'm not good at code, it's just been signed up and I'm looking at some tutorials in the meantime. I got an idea with the "modding tutorials and history" manual (I think it made a certain @Talisman) in the first sections dedicated to these difficult codes
Relevant files are (you can edit these with Notepad/Notepad++):
PROGRAM\sound\ALIAS\music_standard.c

And (example):
PROGRAM\Storyline\Bartolomeu\StartStoryline.c:
Code:
//ASVS --->
    PChar.main_theme.value = "10";
    PChar.main_theme.musicname = "music_Bart_main_theme";
//ASVS <---
PROGRAM\Storyline\Bartolomeu\quests\quests_reaction.c:
Code:
Change_MainThemeMusic_Chance(5);

Yes, while trying to find out exactly what 'FadeOutMusic' does. I couldn't figure out what it does because it eventually ends up at a 'SendMessage' command, and I've no idea how those work. It's also how I know I need to deal separately with night and day sailing music. Storm music isn't going to be an issue because the end theme doesn't work too well with a storm anyway, so a 'SetNextWeather' command means it's going to be a clear day (or night) when you sail off into free-play.

So I'm back to trying a bunch of commands to store the values of the current "tmpref.music_day_sailing.f*.name" attributes, set the attributes all to "Silence.ogg", and play my end theme. A further quest, triggered by "MapEnter", can put the attributes back from wherever I stored them.
PROGRAM\sound\sound.c this is the section of code you'll want to tweak:
Code:
void SetSchemeForSea()
{
    ResetSoundScheme();

    AddSoundScheme("sea");
    if (Whr_IsStorm())
    {
        AddSoundScheme("sea_weather_storm");
        int rainSoundID = PlayStereoSoundLooped_JustCache("rain_storm");
        SendMessage(Sound,"llf",MSG_SOUND_SET_VOLUME, rainSoundID, 0.5);
        SendMessage(Sound,"lll",MSG_SOUND_RESUME, rainSoundID, 0);
        int windSoundID = PlayStereoSoundLooped_JustCache("water_sea_storm");
        SendMessage(Sound,"llf",MSG_SOUND_SET_VOLUME, windSoundID, 0.45);
        SendMessage(Sound,"lll",MSG_SOUND_RESUME, windSoundID, 0);
        SetMusic("music_storm");
    }
    else
    {
        // LDH to get night sailing music when you're sailing - 20Jan09
        // if we're not using night music, use this line instead of the section below
//        SetMusic("music_day_sailing");

        // LDH set night music properly - 11Feb09
        ref pchar = GetMainCharacter();
        // LDH 30Mar09
        if (sti(pchar.Ship.POS.Mode) == SHIP_WAR) // PB: !bMapEnter doesn't have the same effect
            SetMusic("music_sea_battle");
        else
        {
            if(Whr_IsNight())        SetMusicAlarm("music_night_sailing");
            else
            {
                if(Whr_IsFog())        SetMusicAlarm("music_fog_sailing");
                else                SetMusicAlarm("music_day_sailing");
            }
        }

        if (Whr_IsRain())
        {
            AddSoundScheme("sea_weather_rain");
            PlayStereoSoundLooped("rain");
            int waterSoundID = PlayStereoSoundLooped_JustCache("water_sea");
            SendMessage(Sound,"llf",MSG_SOUND_SET_VOLUME, waterSoundID, 0.6);
            SendMessage(Sound,"lll",MSG_SOUND_RESUME, waterSoundID, 0);
        }
        else
        {
            AddSoundScheme("sea_weather");
            int water2SoundID = PlayStereoSoundLooped_JustCache("water_sea");
            SendMessage(Sound,"llf",MSG_SOUND_SET_VOLUME, water2SoundID, 0.35);
            SendMessage(Sound,"lll",MSG_SOUND_RESUME, water2SoundID, 0);
        }
    }
    ResumeAllSounds();
}
You'll probably want to add a quest override like this:
Code:
        // LDH set night music properly - 11Feb09
        ref pchar = GetMainCharacter();
        if (CheckAttribute(pchar, "seamusic"))
        {
               if (sti(pchar.Ship.POS.Mode) == SHIP_WAR) // PB: !bMapEnter doesn't have the same effect
                   SetMusic(pchar.seamusic);
                else
               {
                    SetMusicAlarm(pchar.seamusic);
                }
        }
        else
        {
               // LDH 30Mar09
               if (sti(pchar.Ship.POS.Mode) == SHIP_WAR) // PB: !bMapEnter doesn't have the same effect
                    SetMusic("music_sea_battle");
                else
               {
                   if(Whr_IsNight())        SetMusicAlarm("music_night_sailing");
                   else
                   {
                       if(Whr_IsFog())        SetMusicAlarm("music_fog_sailing");
                        else                SetMusicAlarm("music_day_sailing");
                   }
               }
        }
I don't know what is the difference between 'SetMusic' and 'SetMusicAlarm' and if there IS a difference, I'd expect it to be the reverse of how it is used here.
But it is what it is, so I'm just replicating that. :confused:
 
The code:

Code:
//ASVS --->
    PChar.main_theme.value = "10";
    PChar.main_theme.musicname = "music_Bart_main_theme";
//ASVS <---

What are you talking about?
 
"music_Bart_main_theme" refers to music_standard.c .

The idea is that you start with a 10 percent chance of the main theme randomly playing instead of the ordinary scene music.
This 10 percent decreases over time until you stop hearing it.
That is where Change_MainThemeMusic_Chance(5); comes in, because that increases the current value again by 5 percent.

The idea is that you increase the chance at specific story points (and possibly decrease it if you do something very much AGAINST the story).
So if you deviate from the story a lot, you won't hear the main theme. But if you continue the story again, it'll start showing up after whatever "big events" you linked it to.

I think only the Bartolomeu storyline makes full use of that, but it's easy enough to add to any of the others.
 
@Pieter Boelen: thanks for the code to alter "sound.c". I'd already written my code to store, change and subsequently restore all the sailing music attributes, but your method is a lot neater. It also has the advantage of setting up a mechanism which other people can use. So I suggest this alteration:
Code:
       bool musicdone = false;
       if (CheckAttribute(PChar, "seabattlemusic") && sti(pchar.Ship.POS.Mode) == SHIP_WAR)
       {
               SetMusic(PChar.seabattlemusic);
               musicdone = true;
       }
       if (CheckAttribute(PChar, "seamusic") && sti(pchar.Ship.POS.Mode) != SHIP_WAR)
       {
               SetMusicAlarm(PChar.seamusic);
               musicdone = true;
       }
       if (!musicdone)
<normal sound code>
That ought to provide for separate attributes "seabattlemusic" and "seamusic", to allow different custom themes for battle and non-battle sea settings.
 
Update: it didn't work, or at least, not most of the time. This is because if you start at peace and then close to combat range, so that the music starts off with normal sailing and then switches to battle, it's handled by a different function, 'Sound_OnSeaAlarm'. So I modified that as well:
Code:
void Sound_OnSeaAlarm(bool _seaAlarmed)
{
   ref PChar = GetMainCharacter();
   seaAlarmed = _seaAlarmed;
   if (seaAlarmed == oldSeaAlarmed)
       return;

   if (seaAlarmed)
   { //alarm on!
       if (CheckAttribute(PChar, "seabattlemusic"))
       {
           SetMusic(PChar.seabattlemusic);
       }
       else
       {
           SetMusic("music_sea_battle");
       }
   }
   else
   { //alarm off
       SetMusic(oldMusicName);
   }
   oldSeaAlarmed = seaAlarmed;
}
I tested this by using console to set "seabattlemusic" to something completely inappropriate so that there would be no possible doubt that the music was replaced by the one I'd picked, which is why the next battle I tried was accompanied by Hornblower's wedding theme. xD
 
Instead, I just finished the battle between the Black Pearl and The Interceptor. But the background music was not the right one, but it was 'Sailing01'. Is there a way to place custom music here at this time of battle?
 
Instead, I just finished the battle between the Black Pearl and The Interceptor. But the background music was not the right one, but it was 'Sailing01'. Is there a way to place custom music here at this time of battle?
With @Grey Roger's recent change, I think it is. :cheeky
 
Back
Top