PDA

View Full Version : Music script


Mindtwistah
12-18-2007, 11:59 AM
Is there a script for K1 to change the backround music in your current module to another one? And I don't mean to another one in a .2da file but another one in the musics folder.

Darth InSidious
12-18-2007, 01:32 PM
You will need to add any custom music files to the relevant 2da file before you can make them play in-game.

Mindtwistah
12-18-2007, 01:45 PM
Wasn't there a mp3 player mod for Kotor? An armband that let you play music? If there was one and it's not me dreaming, how did that armband play music?

Darth InSidious
12-18-2007, 01:46 PM
That only worked because of some clever use of TSLPatcher. It still had to add the files to the 2da file.

Mindtwistah
12-18-2007, 01:51 PM
Oh.. That's.. to bad :(
But is there a way to turn of the backround music while in a dialog?

Darth InSidious
12-18-2007, 02:10 PM
You know, I could've sworn there was a tutorial on this...:(

Nevertheless, you should be able to stop the music using the MusicBackgroundStop(001EBO) script function. Just replace 001EBO with the relevant module.

Also, KotOR Tool's Text Editor does come with a script function search, so you can find them more easily than by poring over nwscript.nss. :)

Mindtwistah
12-20-2007, 04:35 PM
Thanks InSidious

By the way, found a little script by Stoffe.

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);
}


Now since I am a total sucker in scripting I have a "few" questions about the script.
1.Will it play a certain soundfile just like that if i trigger it?
2.If I trigger it and a certain music plays, will battle music start playing if you engage in a battle?
3.Will it return to the main backround music when the song is over, or will it loop?
4.Will it go back to the main sound file if I step in and out of the module?
5.And most importantly, will it work for K1?

Yes, I know. I have a lot of questions :p

Darth InSidious
12-20-2007, 05:13 PM
1.Yes.
2.Probably.
3.I don't know.
4.Yes, unless you put it in the module's OnEnter or OnHeartbeat slot.
5.That depends on whether the function is available in K1. I'd assume yes.

Mindtwistah
12-22-2007, 02:46 PM
For some reason, my script doesn't work :S It only makes the original music go away, but doesn't play my track :S

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

// Index in ambientmusic.2da
int nAmbientMusic = #2DAMEMORY1#;
int nBattleMusic = #2DAMEMORY1#;

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

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

I've put all the sound files in the streammusic folder, they are in MP3 format. Why doesn't it work?? :(