Fred Tetra Posted September 29, 2005 Share Posted September 29, 2005 Setting music tracks for a new area (original thread for discussion: http://www.lucasforums.com/showthread.php?t=153072 ) The values you need to set are in the module's .GIT file's AreaProperties structure The AmbientSnd fields (day and night) are indices into ambientsnd.2da Here we see that the sound specified for both is "204tel Ambient Bed". AmbientSndDay Field- Type: int Value: 17 AmbientSndNight Field- Type: int Value: 17 AmbientSndDayVol Field- Type: int Value: 127 AmbientSndNitVol Field- Type: int Value: 127 The EnvAudio field is an index into soundeax.2da. It sets the overall module acoustic model. Here the default model is specified. EnvAudio Field- Type: int Value: 0 The music fields are indices into ambientmusic.2da. Here we see that "Citadel Station" is specified for day and night music, and "Citadel Station Battle" for the battle music. MusicBattle Field- Type: int Value: 41 MusicDay Field- Type: int Value: 15 MusicNight Field- Type: int Value: 15 Link to comment Share on other sites More sharing options...
Darth333 Posted September 30, 2005 Share Posted September 30, 2005 Changing music in an area or during a certain event ( this post summarizes the discussion of this thread: http://lucasforums.com/showthread.php?t=150387 ) 1. Adding your custom track to the game: It is as simple as adding a line to ambientmusic.2da and dropping the new track in .mp3 format in the streammusic folder. It is also possible to replace an existing track. (more details to come) 2. Changing the ambient music and battle music tracks in an area: It is possible to edit the .git file of an area as described above by Fred Tetra with K-GFF (make sure you are using this gff editor made especially for Kotor and TSL as other editors will corrupt the file) and repack the module with Kotor tool's ERF builder. However, this method is considered overkill when not creating a custom area but simply editing an existing area. When editing the music of an existing area, we recommend using scripts. (example by stoffe -mbk- ) 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); } The above script changes 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). 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. Note that using the AreaEnter event will only change the music until the first battle finishes: after the battle, the music will revert back to the original area tracks. To avoid reverting back to the old tracks, a script like this one could be inserted in the OnHeartbeat event of the area: (example by Darth333) void main() { int nTrack= MusicBackgroundGetDayTrack(oArea); if nTrack!= 3 { MusicBackgroundChangeDay(oArea, 3, FALSE)); } } 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. 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. 3. Changing the music temporarily during a cutscene or other event: The music played during a cinematic can be specified in the AmbientTrack field of the .dlg or using a script. If you modify the sound file, the music should change in the cinematics as well. Here is a sample script that will change the music after 3 seconds and revert back to the original track after 45 seconds: (by Darth333) 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 desired track - replace number 4 by the ambientmusic.2da row corresponding the the track:: DelayCommand(3.0,MusicBackgroundChangeDay(oArea, 4, FALSE)); // Back to the old track: DelayCommand(45.0,MusicBackgroundChangeDay(oArea, nTrack)); } Want to go fancy and add some fade in/out effect during your cutscene? Here is an example provided by stoffe -mbk- 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...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.