Mono_Giganto Posted August 2, 2005 Share Posted August 2, 2005 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 More sharing options...
TheProphet Posted August 2, 2005 Share Posted August 2, 2005 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 More sharing options...
Det. Bart Lasiter Posted August 2, 2005 Share Posted August 2, 2005 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 But perhaps there's a new K2 function I've overlooked (it's 4:31 AM here...) Link to comment Share on other sites More sharing options...
stoffe Posted August 2, 2005 Share Posted August 2, 2005 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 More sharing options...
TheProphet Posted August 2, 2005 Share Posted August 2, 2005 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 More sharing options...
Darth333 Posted August 2, 2005 Share Posted August 2, 2005 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 More sharing options...
Mono_Giganto Posted August 2, 2005 Author Share Posted August 2, 2005 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 Yeah, I was hoping to avoid that too. Thanks for the tips everyone, I'll look into it. Link to comment Share on other sites More sharing options...
Mono_Giganto Posted August 2, 2005 Author Share Posted August 2, 2005 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. Link to comment Share on other sites More sharing options...
Det. Bart Lasiter Posted August 3, 2005 Share Posted August 3, 2005 You could try to put something like this in the OnHeartbeat event: On a related note, what is the 'OnHeartbeat' event? Link to comment Share on other sites More sharing options...
Tupac Amaru Posted August 3, 2005 Share Posted August 3, 2005 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 More sharing options...
stoffe Posted August 3, 2005 Share Posted August 3, 2005 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 More sharing options...
The_Maker Posted August 3, 2005 Share Posted August 3, 2005 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 More sharing options...
TheProphet Posted August 3, 2005 Share Posted August 3, 2005 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 More sharing options...
Darth333 Posted August 3, 2005 Share Posted August 3, 2005 In fact adding your new custom track is pretty easy: just add a line to ambientmusic.2da and drop a mp3 file in the streammusic folder Link to comment Share on other sites More sharing options...
stingerhs Posted August 13, 2005 Share Posted August 13, 2005 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 More sharing options...
darkwarrior Posted August 13, 2005 Share Posted August 13, 2005 I'm struggling with the same problem. I'm restoring a cutscene between Nihilus and Sion and think it would look amazing to have Nihilus attack as his theme tune plays but I can't seem to make it override the background theme. Link to comment Share on other sites More sharing options...
stingerhs Posted August 14, 2005 Share Posted August 14, 2005 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)?? Link to comment Share on other sites More sharing options...
stoffe Posted August 14, 2005 Share Posted August 14, 2005 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 More sharing options...
stingerhs Posted August 14, 2005 Share Posted August 14, 2005 i kinda figured i'd have to do some tweaking by going that route. at least it'll get the job done. thanx. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.