Jump to content

Home

Questions Concerning Music


Mono_Giganto

Recommended Posts

I've been playing around with music files lately, and I just had a few questions.

 

1. Is it possible to play a song via script? I think it is, but I'm not sure. If so, how "overriding" is the song played by script? For example, if I played a song via script, then entered battle, would it continue playing my song, or would it switch to the default battle music?

 

2. Is it possible to edit a module so that a single music track is played constantly regardless of fighting, rather than the normal In Battle/Out Of Battle switch?

 

3. This one is somewhat specific. Would it be possible to edit the bridge module on the Ravager so that Nihilus has a separate battle theme from the other fights that take place on the bridge?

Link to comment
Share on other sites

As for your first question, I believe that there is a script line in the nwnscript.nss called Change BGM Music that should work out for you. As for the second, I too need to be able do do that for one of my levels in my mod. Perhaps we can work together to figure this out.

Link to comment
Share on other sites

Try:

void main()
{
   PlaySound("sound_name");
}

I've never used this function before, but it looks very straight forward, and it's the only function I can see that contains a reference to sound-related stuff.

Then try:

void main()
{
   object oNih = GetObjectByTag("DarthNihilus");
   object oAttackee = GetLastHostileTarget(GetFirstPC());

   if (oNih == oAttackee)
   {
       PlaySound("sound_name");
   }
}

Again I'm not sure about the 'PlaySound()' function.

 

***edit***

I can't find a function of file that sets the background music though, just to play the music or get the music :ball: But perhaps there's a new K2 function I've overlooked (it's 4:31 AM here...)

Link to comment
Share on other sites

1. Is it possible to play a song via script? I think it is, but I'm not sure. If so, how "overriding" is the song played by script? For example, if I played a song via script, then entered battle, would it continue playing my song, or would it switch to the default battle music?

 

1) Yes, there are a set of functions that changes the ambient and battle music through scripts. For example, this script...

 

void main() {
   object oArea = GetArea(OBJECT_SELF);

   // Index in ambientmusic.2da
   int nAmbientMusic = 3;
   int nBattleMusic = 47;

   MusicBattleStop(oArea);
   MusicBattleChange(oArea, nBattleMusic);
   // MusicBattlePlay(oArea);

   MusicBackgroundStop(oArea);
   MusicBackgroundChangeDay(oArea, nAmbientMusic);
   MusicBackgroundChangeNight(oArea, nAmbientMusic);
   MusicBackgroundPlay(oArea);
}

 

...would change the ambient (non-combat) music in the current area to Darth Sion's theme, and the battle music to the Dxun Jungle battle track. Use MusicBackgroundPlay() to play the background new music or MusicBattlePlay() to play the battle music again.

 

The numbers you specify are indexes in the ambientmusic.2da file (for both ambient and combat music).

 

2) You can use those functions to set the ambient and battle music to play the same track in the AreaEnter script or somewhere else suitable. Unless you want to repackage the whole module just to change the music in the GIT file, which IMHO is slight overkill. :)

 

While you might still get the transition part played, it will just transition to more battle music when the fight ends.

 

3) You can use those functions in the trigger script that runs the "Nihilus dazes the player" cutscene when you reach the end of the bridge catwalk, to change the area's battle/ambient music to Nihilus theme.

Link to comment
Share on other sites

2) You can use those functions to set the ambient and battle music to play the same track in the AreaEnter script or somewhere else suitable. Unless you want to repackage the whole module just to change the music in the GIT file, which IMHO is slight overkill.

 

Actually I have tried it this way myself. Unfortunately whenever you leave a battle the song restarts and I’m a bit of a stickler for that.

 

-Gsccc

Link to comment
Share on other sites

You could try to put something like this in the OnHeartbeat event:

void main()
{
int nTrack= MusicBackgroundGetDayTrack(oArea);
if nTrack!= 3
       {
MusicBackgroundChangeDay(oArea, 3, FALSE));
       }
}

 

Another thing I use when I want to change the music temporarily during a cutscene per example, is this:

void main()
{
//Check what's currently playing - lazy method but it's usable in any module 
// and there is no need to manuallt check what's playing
   int nTrack = MusicBackgroundGetDayTrack(oArea);

//Play the track I want: 
   DelayCommand(3.0,MusicBackgroundChangeDay(oArea, 4, FALSE));

// Back to the old track:
   DelayCommand(45.0,MusicBackgroundChangeDay(oArea, nTrack)); 
} 

Link to comment
Share on other sites

Oh, I do have one other question. I'm not familiar with cinematics, so I want to ask. If I edit a track played during a cinematic, will it change for that cinematic? I'm not sure if the music is part of the cinematic itself or not.

The music played during a cinematic can be specified in the AmbientTrack field of the .dlg. If you modify the sound file, the music should change in the cinematics as well.

Link to comment
Share on other sites

On a related note, what is the 'OnHeartbeat' event?

 

The Heartbeat is an event that usually triggers once every round (every 6 seconds) for some types of objects. The Module, areas, placeables, creatures, triggers, doors etc all have Heartbeat events, while some objects, like items, waypoints and stores/merchants, do not.

 

The objects that have heartbeat events can be assigned a script that will be run whenever their heartbeat event is triggered.

 

Heartbeat scripts are useful for things that must be done (or checked for) continually. The creature AI uses them for playing ambient animations (looking around, scratching head etc) and for following you around, for example.

Link to comment
Share on other sites

Oh, I do have one other question. I'm not familiar with cinematics, so I want to ask. If I edit a track played during a cinematic, will it change for that cinematic? I'm not sure if the music is part of the cinematic itself or not.

I opened up a .bik file from my Kotor movie directory and it played the sound you hear when in game so I am thinking the sound is part of the cinematic itself and not an individual file. could be wrong though but I am pretty sure the sound and the .bik file are joined together.

Link to comment
Share on other sites

Well I guess that depends on which cinematic you are talking about, in the bik movies you cant change it unless you use RAD video tools to decompress it and edit it then bink it back to the original file.

 

In an in game cutscene all you have to do is change the ambient track in the .dlg file, and yes if you change the track in the StreamMusic file that plays in the cinematic the cinematic music will change too. Though just changing the ambient track is much less messy.

 

If you want to add a new musical track completely without hurting any of the old ones, you have to do a bit of 2da edititng. PM me if you have any questions on that as I do it all the time for my mod.

Link to comment
Share on other sites

  • 2 weeks later...

okay, i have a quicky: i've been using stoffe's script to change the area music to a special cutscene track that i made. the problem is that i've also included another script to revert the area music back to the module's original track, and it cuts the cutscene music short.

 

is there a way to extend the length of the cutscene in the script to make it so that the cutscene won't end until the music does??

Link to comment
Share on other sites

okay, well, let me rephrase the question a bit (with a bit of creativity, hehe). anyways, would it be possible to have the cutscene slowly fade to black and pause for a specified amount of time (theoretically until the music quits playing)??

 

That should be possible. I think this example should work like that:

void main() {
   SetGlobalFadeOut(0.0, 5.0);
   DelayCommand(5.0, MusicBackgroundStop(GetArea(OBJECT_SELF)));
   SetGlobalFadeIn(6.0, 0.5);  
}

 

That should fade to black for 5 seconds. When it reaches black after 5 seconds, it stops the ambient music and fades back in.

 

You'd have to tweak the timing for when the music stops manually, since there is no way of checking in a script if the music has stopped yet.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...