Jump to content

Home

play an ambient track for part of a dialog tree?


Terravant

Recommended Posts

Can someone tell me if its possible to have an ambient track play for just part of a dialog tree in TSL? If it is can you tell me how? If it isn't what do I have to do? Do I have to create a new dialog for that part of my tree and script it in? If that's the case can someone tell me how that's done or show me where I can read about it?

Thanks

Link to comment
Share on other sites

Can someone tell me if its possible to have an ambient track play for just part of a dialog tree in TSL? If it is can you tell me how? If it isn't what do I have to do? Do I have to create a new dialog for that part of my tree and script it in? If that's the case can someone tell me how that's done or show me where I can read about it?

Thanks

 

The dialog file itself only supports changing the ambient music for the whole file, as far as I know. But you could probably use an action script you set on the dialog node you want to have different music, that changes the track.

 

A script like this might work:

void main() {
   object oArea = GetArea(OBJECT_SELF);
   int iDayTrack, iNightTrack;

   if (GetScriptParameter(2) == TRUE) {
       iDayTrack = GetGlobalNumber("DLG_MUSIC_DAY");
       iNightTrack = GetGlobalNumber("DLG_MUSIC_NIGHT");
       SetGlobalNumber("DLG_MUSIC_DAY", 0);
       SetGlobalNumber("DLG_MUSIC_NIGHT", 0);          
   }
   else {
       SetGlobalNumber("DLG_MUSIC_DAY", MusicBackgroundGetDayTrack(oArea));
       SetGlobalNumber("DLG_MUSIC_NIGHT", MusicBackgroundGetNightTrack(oArea));    
       iDayTrack = GetScriptParameter(1);
       iNightTrack = GetScriptParameter(1);
   }

   MusicBackgroundStop(oArea);
   MusicBackgroundChangeDay(oArea, iDayTrack);
   MusicBackgroundChangeNight(oArea, iNightTrack);
   MusicBackgroundPlay(oArea);         
}

 

You'd need to call it twice. First when you want the new music to start playing. Set the P1 parameter to the script on the dialog node to the line number in ambientmusic.2da of the track you want to play.

 

Then you'll have to run the script again at the end node where the area should go back to playing its normal music again. This time set the P1 parameter on the dialog node to 0, and set the P2 parameter to 1.

 

This script requires you to add two global number variables to the globalcat.2da file in order to work, named DLG_MUSIC_DAY and DLG_MUSIC_NIGHT. Those two variables are needed to keep track of what the original music track of the area was.

Link to comment
Share on other sites

Actually I've having more problems. The music I want to play I can't seem to find in ambientmusic.2da, I can't find it anywhere but I know its there... Hiding... It's the music that plays when Kreia contacts you telepathically called "mus_s_telepathy". Where is it, anyone know? It has to be listed somewhere so it can be referenced right?

Link to comment
Share on other sites

Actually I've having more problems. The music I want to play I can't seem to find in ambientmusic.2da, I can't find it anywhere but I know its there... Hiding... It's the music that plays when Kreia contacts you telepathically called "mus_s_telepathy". Where is it, anyone know? It has to be listed somewhere so it can be referenced right?

 

Those "theme" music tracks aren't added as ambient music, they are run directly from the DLG file. If you use tk102's DLG Editor you can click on the root/top node in the tree view to see the field where it's set. That will be played any time that whole DLG file is used though.

 

It probably works to add it as a new line at the end of ambientmusic.2da, if you still want to use the method posted above.

 

If you don't want to do that you can make it more complicated by creating a Sound object (.UTS template) that plays the music sound file in a loop, set to play over the entire area, and then make a script that spawns such a sound object when the music should play, and then stops it when the music should stop. That's more work than just adding it to the 2DA file though, IMO. :)

 

Or you could set the ambient track in the dialog file, and just use multiple DLG files for when different music should be played.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...