Scriptname MorrowindBardsSongsScript extends Quest Conditional ;---------------------------------------------------------------------------------------- Scene Property MWBardSongsFluteSong1 Auto Scene Property MWBardSongsFluteSong2 Auto Scene Property MWBardSongsLuteSong1 Auto Scene Property MWBardSongsLuteSong2 Auto Scene Property MWBardSongsDrumSong1 Auto Scene Property MWBardSongsDrumSong2 Auto Scene Property MWBardSongsInstrumentalSet1 Auto Scene Property MWBardSongsInstrumentalSet2 Auto Scene Property MWBardSongsInstrumentalSet3 Auto Scene Property MWBardSongsBreakTime Auto ;---------------------------------------------------------------------------------------- ReferenceAlias Property BardSongs_MWBard Auto ReferenceAlias Property BardSongsInstrumental_MWBard Auto Faction Property CurrentFollowerFaction Auto Keyword Property LocTypeInn Auto Bool Property BardRest Auto Conditional ;---------------------------------------------------------------------------------------- Actor Property PlayerREF Auto MusicType Property MUSTavernSILENCE Auto ;---------------------------------------------------------------------------------------- String SavedInstrument Bool SavedPlayContinuous int SavedSongToPlay Int LastSongPlayed Bool ProcessingDialogueRequest Bool StopSong = False objectReference BardHandoff String InstrumentHandoff Bool PlayContinuousHandoff Int SongToPlayHandoff Bool ChangeSettingsHandoff Float LocationOwner Conditional Int Playing = 0 Conditional Int InstrumentalSong = 1 Conditional Int MusicSet = 1 Conditional Int Rest = 1 Conditional ;---------------------------------------------------------------------------------------- int Function GetRandomSong(objectReference PassedBard) debug.Trace("accessing function Get Random Song") Int BardSongToPlay = LastSongPlayed While BardSongToPlay == LastSongPlayed debug.Trace("running while loop to choose song") BardSongToPlay = Utility.RandomInt(1,9) ;If not randomize the rest. Endwhile debug.Trace("Returning Random Song #"+BardSongToPlay) Return (BardSongToPlay) EndFunction ;---------------------------------------------------------------------------------------- Function PlayChosenSong(Int ChosenSong) Int Intro = Utility.RandomInt(0,1) If ChosenSong < 9 LastSongPlayed = ChosenSong EndIf If ChosenSong == 10 debug.Trace("MWBard Takes a Break") InstrumentalSong = Utility.RandomInt(1,1) MWBardSongsBreakTime.Start() EndIf If ChosenSong == 1 debug.Trace("MWBardSong Flute 1") InstrumentalSong = Utility.RandomInt(1,6) MWBardSongsFluteSong1.Start() EndIf If ChosenSong == 2 debug.Trace("MWBardSong Flute 2") InstrumentalSong = Utility.RandomInt(1,6) MWBardSongsFluteSong2.Start() EndIf If ChosenSong == 3 debug.Trace("MWBardSong Lute 1") InstrumentalSong = Utility.RandomInt(1,6) MWBardSongsLuteSong1.Start() EndIf If ChosenSong == 4 debug.Trace("MWBardSong Lute 2") InstrumentalSong = Utility.RandomInt(1,6) MWBardSongsLuteSong2.Start() EndIf If ChosenSong == 5 debug.Trace("MWBardSong Drum 1") InstrumentalSong = Utility.RandomInt(1,6) MWBardSongsDrumSong1.Start() EndIf If ChosenSong == 6 debug.Trace("MWBardSong Drum 2") InstrumentalSong = Utility.RandomInt(1,6) MWBardSongsDrumSong2.Start() EndIf If ChosenSong == 7 debug.Trace("MWBard Instrumental Set 1") MusicSet = Utility.RandomInt(1,3) MWBardSongsInstrumentalSet1.Start() EndIf If ChosenSong == 8 debug.Trace("MWBard Instrumental Set 2") MusicSet = Utility.RandomInt(1,3) MWBardSongsInstrumentalSet2.Start() EndIf If ChosenSong == 9 debug.Trace("MWBard Instrumental Set 3") MusicSet = Utility.RandomInt(1,3) MWBardSongsInstrumentalSet3.Start() EndIf EndFunction ;-------------------------------------------------------------------------------------- Function PlaySongRequest(objectReference MWBard, String Instrument = "Any", Bool PlayContinuous = True, int SongToPlay = 0, Bool ChangeSettings = True) BardHandoff= MWBard InstrumentHandoff = Instrument PlayContinuousHandoff = PlayContinuous SongToPlayHandoff = SongToPlay ChangeSettingsHandoff = ChangeSettings RegisterForSingleUpdate(1) EndFunction ;-------------------------------------------------------------------------------------- Event OnUpdate() PlaySong(BardHandoff, InstrumentHandoff, PlayContinuousHandoff,SongToPlayHandoff, ChangeSettingsHandoff) EndEvent ;--------------------------------------------------------------------------------------- Function PlaySong(objectReference MWBard, String Instrument = "Any", Bool PlayContinuous = True, int SongToPlay = 0, Bool ChangeSettings = True) Debug.tracestack() While MWBard.IsInDialogueWithPlayer() if Changesettings == False && (Stopsong == True || SavedPlayContinuous == False) Return endif Utility.Wait(1) Debug.Trace("Playsongs is waiting...") EndWhile While (MWBard.GetCurrentPackage() == MWBardBreakPackage) if Changesettings == False && (Stopsong == True || SavedPlayContinuous == False) Return endif Utility.Wait(1) Debug.Trace("Playsongs is waiting...") EndWhile debug.Trace("Function Called. Stopsong is " + Stopsong) if Changesettings == False && (Stopsong == True || SavedPlayContinuous == False) Playing = 0 Return endif if Changesettings == True StopAllSongs() endif Playing = 1 If (MWBard as Actor).IsInFaction(CurrentFollowerFaction) debug.Trace("Bard is a follower! Aborting song.") Playing = 0 Return Else BardSongs_MWBard.forcerefto(MWBard) ;Force the passed in character into the aliases required to play BardSongsInstrumental_MWBard.forcerefto(MWBard) Endif If ChangeSettings == False ;Allows the sytem to recall the function without changing the previous settings. debug.Trace("Using Previous Settings") Instrument = SavedInstrument PlayContinuous = SavedPlayContinuous SongToPlay = 0 Else ;Saves the settings of the original call. debug.Trace("Using New Settings") SavedInstrument = Instrument SavedPlayContinuous = PlayContinuous endif debug.Trace("Instrument is " + Instrument) debug.Trace("SongToPlay is " + SongToPlay) If Instrument == "Instrumental" debug.Trace("Requested Instrumental") ;Randomly choose instrument to play if Instrumental was chosen SongToPlay = Utility.RandomInt(1,6) endif If Instrument == "MusicSet" debug.Trace("Requested Instrumental") ;Randomly choose instrument to play if Instrumental was chosen SongToPlay = Utility.RandomInt(7,9) endif If Instrument == "Rest" debug.Trace("Bard Rests") ;Randomly choose instrument to play if Instrumental was chosen SongToPlay = 10 endif If Instrument == "Flute" ;Play Flute song if Flute was chosen debug.Trace("Requested flute") If LastSongPlayed == 1 SongToPlay = 2 Else SongToPlay =1 endIf endif If Instrument == "Lute" ;Play Lute song if Lute was chosen If LastSongPlayed == 3 SongToPlay = 4 Else SongToPlay = 3 endIf endif If Instrument == "Drum" ;Play Drum song if Drum was chosen If LastSongPlayed == 5 SongToPlay = 6 Else SongToPlay = 5 endIf endif debug.Trace("SongToPlay is now " + SongToPlay) if SongToPlay == 0 ;if a particular song hasn't been requested, get a random song. debug.Trace("Choosing Random Song") SongToPlay = GetRandomSong(MWBard) endif debug.Trace("Executing Play Chosen function Song " + SongToPlay) If (MWBard as Actor).IsInFaction(CurrentFollowerFaction) debug.Trace("Bard is a follower! Aborting song.") Playing = 0 Return Endif If !MWBard.Is3dLoaded() debug.Trace("Bard has no 3D! Aborting song.") Playing = 0 Return Endif PlayChosenSong(SongToPlay) Utility.Wait(1) StopSong = False EndFunction ;-------------------------------------------------------------------------------------- Function StopAllSongs() Debug.Trace("StopAllSongs hapenning now.") StopSong = True MWBardSongsFluteSong1.Stop() MWBardSongsLuteSong1.Stop() MWBardSongsDrumSong1.Stop() MWBardSongsFluteSong2.Stop() MWBardSongsLuteSong2.Stop() MWBardSongsDrumSong2.Stop() MWBardSongsInstrumentalSet1.Stop() MWBardSongsInstrumentalSet2.Stop() MWBardSongsInstrumentalSet3.Stop() MWBardSongsBreakTime.Stop() Playing = 0 EndFunction ;-------------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- Function StopInnMusic() Game.GetPlayer().HasKeyword(LocTypeInn) MUSTavernSilence.Add() EndFunction Package Property MWBardBreakPackage Auto