Music Scripts

Post » Sun May 01, 2011 1:16 pm

Music Scripts

I want to make a little sound mod that requires some scripting. It all started when I came across Carnithus' Armamentarium. It has a sweet script that changes the music upon entering the Armamentarium. Better yet, it also disabled the music when leaving the area, even through teleportation and such.
I believe the sound is one of the most importnant thing in any game and sadly gets over looked now days. Especially in Morrowind where its all about immersion. So I want to make a mod that will change the music for different locations, nice cheery music in taverns, mystical tones for the magic guild halls, creepy loops in daedric ruins... you get the idea.
I know there are mods that have attempted to do something like that. But I always found them to be either incomplete, corny, low quality or just too much of everything. I'd like to create my own for my own taste.

Alright, now first of all, I'm a complete newb when it comes to scripting, I've never written one in my life, but I understand the concept and all that, so I'm not completley desperate (yet), just never really tried.


Now looking at Carnithus' Armamentarium, I believe there are only 3 scripts regarding the music and they seem rather simple:



Begin _ar_crn_musicScript


if ( OnActivate == 1 )

"_ar_crn_carnithus"-> equip _ar_crn_myhead_1 1
"_ar_crn_carnithus"-> equip _ar_crn_myboots_1 1
"_ar_crn_carnithus"-> equip _ar_crn_mychest_1 1
"_ar_crn_carnithus"-> equip _ar_crn_mygauntlet_l 1
"_ar_crn_carnithus"-> equip _ar_crn_mygauntlet_r 1
"_ar_crn_carnithus"-> equip _ar_crn_mygreaves_1 1
"_ar_crn_carnithus"-> equip _ar_crn_mypauldron_l 1
"_ar_crn_carnithus"-> equip _ar_crn_mypauldron_r 1

StartScript _ar_crn_musicScriptGlob

Activate

endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Begin _ar_crn_musicScript_2


if ( OnActivate == 1 )

StreamMusic "Explore/mx_explore_1.mp3"
Activate

endif


End


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


begin _ar_crn_musicScriptGlob

short framecounter
float musictimer


if ( musictimer == 0 )
StreamMusic "ARM.mp3"
endif

set musictimer to ( musictimer + GetSecondsPassed )

if ( musictimer >= 480 )
set musictimer to 0
endif

if ( framecounter > 100 )
if ( GetPCCell, "Carnithus' Armamentarium" == 0 )
set musictimer to 0
StreamMusic "Explore/mx_explore_1.mp3"
StopScript _ar_crn_musicScriptGlob
endif
else
set framecounter to ( framecounter + 1 )
endif

end


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



The last one looks especially interesting to me. You can see the line

StreamMusic "ARM.mp3"

this is the track that plays upon entering the Armamentarium. So I figure I'd just have to include new tracks and put their name between the " ".
The next thing that grabbed my attention is the following line:

if ( GetPCCell, "Carnithus' Armamentarium" == 0 )

Obviously thats the cell where we hear the music. My rookie senses tell me if I'd place, lets say, "Balmora, Guild of Mages" the track would play there ?

I've done that but it didn't work.


So what I need here is someone with more knowledge to tell me what I have to change to create sevral different tracks for different interior cells.
I learn best from examples. Lets stick with the Balmora Mage's Guild. Just write up all 3 scripts so it'd work for that location. I'll be able to figure the rest out by looking at the changes that have been made.


Cheers!
User avatar
Brandon Bernardi
 
Posts: 3481
Joined: Tue Sep 25, 2007 9:06 am

Post » Sun May 01, 2011 1:37 pm

Here's a music script, from Balmora Council Club. It actually plays a range of different tunes depending on time of day. The script is attached to an activator in the room.

Begin jw_bcc_music_schedule; thanks Max_AKA_Nobody, with revisions originally by Qarlshort JW_nightshort bcc_daymusicshort nextSongshort done1short doOnceshort doOnce2short doitshort countershort statefloat Timer5float timer2float timerif ( doOnce != 0 )	if ( CellChanged == 1 )		set Timer5 to 500		set done1 to 0		set doit to 0		set counter to 0		set state to 0	endifendif	if ( GameHour < 6 )	if ( JW_night == 0 )		set JW_night to 1	endifelseif ( GameHour > 20 )	if ( JW_night == 0 )		set JW_night to 1	endifelse	if ( JW_night == 1 )		set JW_night to 0	endifendifif ( jw_night == 0 )	if ( bcc_daymusic == 0 )		StreamMusic "PS\jw_Rest.mp3"			set bcc_daymusic to 1	endifelse ; if jw_night == 1if ( nextSong == 0 )	if ( done1 == 0 )		set done1 to 1		StreamMusic, "PS\jw_BE_tavern.mp3" ; 133 seconds		set bcc_daymusic to 0	endifelseif ( nextSong == 1 )	if ( done1 == 0 )		set done1 to 1		StreamMusic, "PS\Yankee Celtic Consort-Keelhaulin the Bosn.mp3" ; 163 seconds	endifendifendifset Timer5 to ( Timer5 + GetSecondsPassed )if ( nextSong == 0 )		if ( Timer5 < 133 )			return		endif		set nextSong to 1		set done1 to 0		set Timer5 to 0elseif ( nextSong == 1 )		if ( Timer5 < 163 )			return		endif		set nextSong to 0		set done1 to 0		set Timer5 to 0endifend


To restore the game music when leaving the cell, I just attached this script to the door:

Begin jw_bcc_insidedoorif ( onActivate == 1 )	StreamMusic, "Explore\MX_explore_1.mp3"	Activateendifend


Hope that helps
User avatar
Toby Green
 
Posts: 3365
Joined: Sun May 27, 2007 5:27 pm

Post » Mon May 02, 2011 4:32 am

Hey thanks a lot for your answer! I have two problems with that. First of all its almost too much. I don't really want it to change the tracks, at least not for certain places. Other than that, I still don't know how to make this script work for other locations with different tracks.
Can you stick with the original scripts from Carnithus' Armamentarium ? They just seem a lot easier to me.

Again, all I wanna do is one track for one location, another track for another location. (Until my Morrowind folder is 8GB big lol)
User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am

Post » Sun May 01, 2011 3:48 pm

Wow I just figured it out on my own. Didn't know you could attach scripts to the doors. Thanks princess_stomper for your help though. I appreciate it a lot.

Alright, I'll be making a little soundmod :D
User avatar
Sophie Morrell
 
Posts: 3364
Joined: Sat Aug 12, 2006 11:13 am

Post » Mon May 02, 2011 12:55 am

Sorry to bother again but I've got one more question regarding this. It's been going really well so far. Added lots of interior tracks, but the problem is, this script doesn't make them loop. What has to be added to make the tracks loop ? Heres the script one more time:




////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

begin _ar_crn_musicScriptGlob


short framecounter
float musictimer



if ( musictimer == 0 )
StreamMusic "ARM.mp3"
endif

set musictimer to ( musictimer + GetSecondsPassed )

if ( musictimer >= 480 )
set musictimer to 0
endif

if ( framecounter > 100 )
if ( GetPCCell, "Carnithus' Armamentarium" == 0 )
set musictimer to 0
StreamMusic "Explore/mx_explore_1.mp3"
StopScript _ar_crn_musicScriptGlob
endif
else
set framecounter to ( framecounter + 1 )
endif

end

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



Line 8: StreamMusic "ARM.mp3" This track needs to be looped. How ?

Thanks
User avatar
Alexandra Louise Taylor
 
Posts: 3449
Joined: Mon Aug 07, 2006 1:48 pm

Post » Sun May 01, 2011 1:41 pm

Sorry to bother again but I've got one more question regarding this. It's been going really well so far. Added lots of interior tracks, but the problem is, this script doesn't make them loop. What has to be added to make the tracks loop ? Heres the script one more time:




////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

begin _ar_crn_musicScriptGlob


short framecounter
float musictimer



if ( musictimer == 0 )
StreamMusic "ARM.mp3"
endif

set musictimer to ( musictimer + GetSecondsPassed )

if ( musictimer >= 480 )
set musictimer to 0
endif


if ( framecounter > 100 )
if ( GetPCCell, "Carnithus' Armamentarium" == 0 )
set musictimer to 0
StreamMusic "Explore/mx_explore_1.mp3"
StopScript _ar_crn_musicScriptGlob
endif
else
set framecounter to ( framecounter + 1 )
endif

end

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



Line 8: StreamMusic "ARM.mp3" This track needs to be looped. How ?

Thanks


The part of the script I marked in bold is the one that makes the song loop. Essentially it counts 480 seconds and then makes the song start again. If the songs you're using have a duration different from 480 seconds, you must put that duration instead of 480.
User avatar
[Bounty][Ben]
 
Posts: 3352
Joined: Mon Jul 30, 2007 2:11 pm

Post » Sun May 01, 2011 2:55 pm

The part of the script I marked in bold is the one that makes the song loop. Essentially it counts 480 seconds and then makes the song start again. If the songs you're using have a duration different from 480 seconds, you must put that duration instead of 480.



XD Awesome ! Thank you very much! Alright I'll keep working on it and might even release it, though thats probably gonna be some serious copyright violation. :whistling:

Gotta love this forum !
User avatar
Scarlet Devil
 
Posts: 3410
Joined: Wed Aug 16, 2006 6:31 pm

Post » Sun May 01, 2011 7:46 pm

My music script loops just fine but this only works the first time I enter the interior cell. I have this script attached to Margoth's house in Seyda Neen Expanded mod. It plays the interior music you hear in Daggerfall. It loops just fine and when I exit the house, it goes back to the normal explore music. But when I go in the 2nd time, it won't play the "dagger23" music. It just continues to play the explore music. Funny though, every time I exit the interior, it restarts the explore music.

Oh, and I've made the door a unique ID. This script only works for this one interior cell so I made the door ID unique as well. I'll have to do this for every interior I guess. But why does this music script not work the second, third, forth, fifth, etc... time I enter? Why does it only work on the first time?


This script below is attached to an sign activator, which I've given a unique ID and placed in the interior cell.

Begin 1_Seyda Neen, Margoth's Houseshort framecounterfloat musictimerif ( musictimer == 0 )	StreamMusic "dagger23.mp3"endifset musictimer to ( musictimer + GetSecondsPassed )if ( musictimer >= 31 )	set musictimer to 0endifif ( framecounter > 100 )	if ( GetPCCell, "Seyda Neen, Margoth's House" == 0 )			set musictimer to 0			StreamMusic "Explore/mx_explore_1.mp3"			StopScript 1_Seyda Neen, Margoth's House		endif	else	set framecounter to ( framecounter + 1 )endifEnd




This is the script I've attached to the unique ID door on the interior cell, not the exterior cell. Should this be attached to the exterior door of his house? Or is it supposed to be attached to the interior door of his house?

Begin 1_Exiting_Interior_Explore_Returnif ( onactivate == 1 )	StreamMusic, "Explore\MX_explore_1.mp3"	ActivateendifEnd

User avatar
Rachael Williams
 
Posts: 3373
Joined: Tue Aug 01, 2006 6:43 pm

Post » Mon May 02, 2011 3:42 am

For one thing, you shouldn't have commas in your script names. 1_Seyda Neen is fine, 1_Seyda Neen, Margoth's House Margoth's House is not. For the second, you're not reseting the local variable framecounter before the script stops. So, whenever it reaches 100, it'll stop the script and not play the music. You should reset it somewhere in this block:

if ( framecounter > 100 )	if ( GetPCCell, "Seyda Neen, Margoth's House" == 0 )			set musictimer to 0                                          [b]set framecounter to 0[/b]			StreamMusic "Explore/mx_explore_1.mp3"			StopScript 1_Seyda Neen, Margoth's House		endif	else	set framecounter to ( framecounter + 1 )endif

User avatar
FLYBOYLEAK
 
Posts: 3440
Joined: Tue Oct 30, 2007 6:41 am

Post » Sun May 01, 2011 1:13 pm

Okay, I fixed the script name. I added in the line "set framecounter to 0" to the script in the spot you have it, and it still keeps doing the same thing. It'll play the song and loop it. But once I leave and come back in, it doesn't play it anymore. Do I type "reset" or something? The thing that you wrote isn't working.
User avatar
Arnold Wet
 
Posts: 3353
Joined: Fri Jul 07, 2006 10:32 am

Post » Mon May 02, 2011 1:47 am

It's because framecounter never increases. Move set framecounter to ( framecounter + 1 ) line outside of the If block.

Scratch that. If all you need is playing dagger23.mp3 once each time you enter the house, simply do this:
Begin 1_Seyda Neenif ( CellChanged == 0 )	returnendifStreamMusic "dagger23.mp3"end


It has to be attached to something inside the house.

If you want to force Explore/mx_explore_1.mp3 and nothing else after dagger23.mp3, it's more complex, but you better elaborate on how exactly you want your music played.
User avatar
Avril Louise
 
Posts: 3408
Joined: Thu Jun 15, 2006 10:37 pm

Post » Sun May 01, 2011 11:12 pm

No, I want the tavern to play dagger23.mp3 over and over and over for as long as I'm in the tavern. Like how Daggerfall is. When you would go in a tavern, it'd play the tavern music continuously until you left the tavern. Then it'd switch to the outside music. So I want dagger23.mp3 to loop forever inside the house. But once I exit, I want it to go back to explore music. And then if I go back in the tavern, I want dagger23.mp3 to play again, looping forever and ever, until I exit the tavern. Makes sense?
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Sun May 01, 2011 9:38 pm

Ok, then try it like this:
Begin 1_Seyda_Neen	; spaces in names are not a good thing either, they are tolerated only where quotes can be used.float musictimerif ( musictimer == 0 )	StreamMusic "dagger23.mp3"endifset musictimer to ( musictimer + GetSecondsPassed )if ( musictimer >= 31 )	set musictimer to 0endif; Once you're outside the house, scripts for items inside are not running, so you must have a global script to resetif ( ScriptRunning "1_Seyda_Neen_killscript" == 0 )	StartScript "1_Seyda_Neen_killscript"endifend

Begin 1_Seyda_Neen_killscriptif ( CellChanged == 0 )	; faster than checking the cell name, otherwise not necessary	returnendifif ( GetPCCell, "Seyda Neen, Margoth's House" == 1 )	returnendifset 1_Seyda_Neen.musictimer to 0	; It may need either the name of a script OR the name of the activator that the script is attached toStreamMusic "Explore/mx_explore_1.mp3"StopScript 1_Seyda_Neen_killscriptend


EDIT: You may also be interested in http://www.tesnexus.com/downloads/file.php?id=28988.
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Mon May 02, 2011 4:54 am

Yeah, the SeydaNeen_KillScript is giving me this error:

http://img541.imageshack.us/img541/3528/77431210.jpg

And for the first script. what kind of global script are you talking about? Is the KillScript the global? Do I need to make a short global variable or something?
User avatar
OJY
 
Posts: 3462
Joined: Wed May 30, 2007 3:11 pm

Post » Mon May 02, 2011 3:47 am

Yeah, the SeydaNeen_KillScript is giving me this error:
Then, as I said, replace "1_Seyda_Neen" in that line with the name of the activator sign that 1_Seyda_Neen is attached to.

And for the first script. what kind of global script are you talking about? Is the KillScript the global? Do I need to make a short global variable or something?
1_Seyda_Neen_killscript is the global script in this case. No global variable is necessary.
User avatar
Da Missz
 
Posts: 3438
Joined: Fri Mar 30, 2007 4:42 pm

Post » Mon May 02, 2011 2:08 am

Well, I attached the 1_Seyda_Neen script to the activator in Margoth's house.

Begin 1_Seyda_Neenfloat musictimerif ( musictimer == 0 )	StreamMusic "dagger23.mp3"endifset musictimer to ( musictimer + GetSecondsPassed )if ( musictimer >= 32 )	set musictimer to 0endif; Once you're outside the house, scripts for items inside are not running, so you must have a global script to resetif ( ScriptRunning "1_Seyda_Neen_killscript" == 0 )	StartScript "1_Seyda_Neen_killscript"endifEnd




And the global script is still giving me a syntax error: http://img443.imageshack.us/img443/1576/15573601.jpg

It reads:

Begin 1_Seyda_Neen_killscriptif ( CellChanged == 0 )	; faster than checking the cell name, otherwise not necessary	returnendifif ( GetPCCell, "Seyda Neen, Margoth's House" == 1 )	returnendifset 1_Margoth_activator.musictimer to 0StreamMusic "Explore/mx_explore_1.mp3"StopScript 1_Seyda_Neen_killscriptEnd



And you can clearly see in the jpeg that the activator is called 1_Margoth_activator so I'm not sure why it's giving me an error.
User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Sun May 01, 2011 11:23 pm

Blast. I used variables in external scripts before, so I know that it should work, but without seeing the mod with my own eyes I can't tell what could go wrong. All right, another effort:

Begin 1_Seyda_Neen	; spaces in names are not a good thing either, they are tolerated only where quotes can be used.float musictimerif ( CellChanged == 1 )		; <==	set musictimer to 0	; <== This will work once per visitendif				; <==if ( musictimer == 0 )	StreamMusic "dagger23.mp3"endifset musictimer to ( musictimer + GetSecondsPassed )if ( musictimer >= 31 )	set musictimer to 0endif; Once you're outside the house, scripts for items inside are not running, so you must have a global script to resetif ( ScriptRunning "1_Seyda_Neen_killscript" == 0 )	StartScript "1_Seyda_Neen_killscript"endifend

Begin 1_Seyda_Neen_killscriptif ( CellChanged == 0 )	; faster than checking the cell name, otherwise not necessary	returnendifif ( GetPCCell, "Seyda Neen, Margoth's House" == 1 )	returnendif; set 1_Seyda_Neen.musictimer to 0	; <== This is no longer necessaryStreamMusic "Explore/mx_explore_1.mp3"StopScript 1_Seyda_Neen_killscriptend

User avatar
megan gleeson
 
Posts: 3493
Joined: Wed Feb 07, 2007 2:01 pm

Post » Mon May 02, 2011 3:23 am

Horay, it works! Everytime I go in and out it restarts the song and it loops too! Thank you! :celebration:
So now, my goal is to apply this to every house one by one. I know I have to make a unique local script for each interior but can I keep the global script and just keep adding the lines "if ( GetPCCell, "cell name" == 1 ) return" to it, so that eventually the global script will have like, 20 different cells listed in it? Would that work?

So I don't even need to attach a script to the door upon exit, do I? Because that's what I was doing before and it was becoming a real hassle.
User avatar
Joey Bel
 
Posts: 3487
Joined: Sun Jan 07, 2007 9:44 am

Post » Sun May 01, 2011 8:57 pm

I know I have to make a unique local script for each interior but can I keep the global script and just keep adding the lines "if ( GetPCCell, "cell name" == 1 ) return" to it, so that eventually the global script will have like, 20 different cells listed in it? Would that work?
You could... but then again, it could be even simpler. Instead of "if ( GetPCCell, "cell name" == 1 )", use "if ( GetInterior == 1 )". Then it will be universal. Dagger23.mp3 will be terminated as soon as you walk to the open air.
User avatar
Manuel rivera
 
Posts: 3395
Joined: Mon Sep 10, 2007 4:12 pm

Post » Mon May 02, 2011 4:32 am

Yeah, but I don't want this song for all interiors; only homes and stuff. Mages Guild has their own song. Taverns have their own songs. Palaces have their own song. Dungeons and caves have their own song. I'm trying to make it just like Daggefall. Have you played it?

Is there a way to script the music so that it plays certain songs at certain times of the day? There's one piece I want to have played for the evening and one piece that is for midnight up to 6am.
There's also a couple songs that I want to play just for the snowy region of Solstheim
User avatar
Kelsey Hall
 
Posts: 3355
Joined: Sat Dec 16, 2006 8:10 pm

Post » Sun May 01, 2011 4:17 pm

No, I mean that the global script will kill whatever music is played by the local script and start "Explore/mx_explore_1.mp3" once you leave the building where a custom music was started. You only need several different entries in the killscript is you want different music to be the breaker.
User avatar
Hayley O'Gara
 
Posts: 3465
Joined: Wed Nov 22, 2006 2:53 am

Post » Mon May 02, 2011 1:22 am

Not quite sure I get what you're saying. In fact, now that I think about it, I have absolutely 100% no idea what you're saying. lol
But would you know how to script music for certain times and weather conditions? Or would this be a task for the script god, Fliggerty? Not that I'm doubting you or anything.
User avatar
priscillaaa
 
Posts: 3309
Joined: Sat Dec 30, 2006 8:22 pm

Post » Sun May 01, 2011 9:55 pm

Not quite sure I get what you're saying. In fact, now that I think about it, I have absolutely 100% no idea what you're saying. lol

Oh, just look at the script and try to imagine what happens when it's running. It's not actually rocket science.
Begin 1_Seyda_Neen_killscriptif ( CellChanged == 0 )	; A bit faster than the next condition, otherwise not necessary. May be discarded.	returnendifif ( GetInterior == 1 ))		; That's in case there are several cells in a house, like cellar or something.	returnendif; Now player is outsideStreamMusic "Explore/mx_explore_1.mp3"StopScript 1_Seyda_Neen_killscriptend


But would you know how to script music for certain times and weather conditions? Or would this be a task for the script god, Fliggerty? Not that I'm doubting you or anything.
[shrug] You can look at the mod I referenced earlier. Although it doesn't deal with weather conditions and such, you can evaluate the difficulty of the task of doing things in something else than primitive way.
User avatar
Jose ordaz
 
Posts: 3552
Joined: Mon Aug 27, 2007 10:14 pm


Return to III - Morrowind