2021-10-05 22:15:58 +00:00
|
|
|
Scriptname _00E_Gaboff_GrammophoneSC extends ObjectReference
|
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Message Property _00E_Gaboff_GrammophoneMSG Auto
|
|
|
|
Message Property _00E_PlayerhousingKoppophonVolume Auto
|
|
|
|
Sound Property _00E_MUS_Special_OceansWidowM Auto
|
|
|
|
MiscObject Property Gold001 Auto
|
|
|
|
Actor Property PlayerREF Auto
|
|
|
|
|
|
|
|
Int iSoundID = -1
|
|
|
|
Float fVolume = 0.5
|
|
|
|
Bool bMusicLocked = False
|
|
|
|
|
|
|
|
Float Property MUSIC_LENGTH = 212.3 AutoReadOnly
|
|
|
|
|
|
|
|
|
|
|
|
;=====================================================================================
|
|
|
|
; FUNCTIONS
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Function PlayMusic(Sound musicSound, Float fMusicLength)
|
|
|
|
If fVolume <= 0.0 || fVolume > 1.0
|
|
|
|
fVolume = 0.5
|
|
|
|
EndIf
|
|
|
|
RegisterForModEvent("BardsLoadGame", "OnBardsLoadGame")
|
|
|
|
iSoundID = musicSound.Play(Self)
|
|
|
|
Sound.SetInstanceVolume(iSoundID, fVolume)
|
2024-01-09 22:00:18 +00:00
|
|
|
RegisterForSingleUpdate(_00E_TimeControl.AdjustTimePeriodByEngineTimerError(fMusicLength))
|
2021-10-12 02:10:35 +00:00
|
|
|
GoToState("")
|
|
|
|
_00E_PlayerhousingKoppophonVolume.Show(fVolume * 100.0)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function ChangeMusicVolume()
|
|
|
|
If fVolume >= 0.0 && fVolume < 1.0
|
|
|
|
fVolume += 0.25
|
|
|
|
Else ; fVolume >= 1.0 or something is wrong with fVolume
|
|
|
|
fVolume = 0.0
|
|
|
|
EndIf
|
|
|
|
Sound.SetInstanceVolume(iSoundID, fVolume)
|
|
|
|
_00E_PlayerhousingKoppophonVolume.Show(fVolume * 100.0)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function StopMusic()
|
|
|
|
bMusicLocked = True
|
|
|
|
|
|
|
|
GoToState("DoneCleanup")
|
|
|
|
UnregisterForModEvent("BardsLoadGame")
|
|
|
|
UnregisterForUpdate()
|
|
|
|
|
|
|
|
If iSoundID != -1
|
|
|
|
Sound.StopInstance(iSoundID)
|
|
|
|
iSoundID = -1
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
bMusicLocked = False
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function TryStopMusic()
|
|
|
|
If bMusicLocked == False
|
|
|
|
StopMusic()
|
|
|
|
Else
|
|
|
|
RegisterForSingleUpdate(0.5)
|
|
|
|
EndIf
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; EVENTS
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Event OnInit()
|
|
|
|
GoToState("DoneCleanup")
|
2021-10-05 22:15:58 +00:00
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnActivate(ObjectReference akActionRef)
|
2021-10-12 02:10:35 +00:00
|
|
|
If akActionRef == PlayerREF && bMusicLocked == False
|
|
|
|
bMusicLocked = True
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
If iSoundID == -1
|
|
|
|
If _00E_Gaboff_GrammophoneMSG.Show() == 0
|
|
|
|
PlayerREF.RemoveItem(Gold001, 5)
|
|
|
|
PlayMusic(_00E_MUS_Special_OceansWidowM, MUSIC_LENGTH)
|
|
|
|
EndIf
|
2021-10-05 22:15:58 +00:00
|
|
|
Else
|
2021-10-12 02:10:35 +00:00
|
|
|
ChangeMusicVolume()
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-12 02:10:35 +00:00
|
|
|
|
|
|
|
bMusicLocked = False
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
EndEvent
|
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Event OnUpdate()
|
|
|
|
TryStopMusic()
|
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Event OnBardsLoadGame(string eventName, string strArg, float numArg, Form sender)
|
|
|
|
; Player just loaded a save with the gramophone playing. The sound is dead by now.
|
|
|
|
TryStopMusic()
|
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Event OnCellAttach()
|
|
|
|
TryStopMusic()
|
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Event OnLoad()
|
|
|
|
TryStopMusic()
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnCellDetach()
|
|
|
|
TryStopMusic()
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnUnload()
|
|
|
|
TryStopMusic()
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
State DoneCleanup
|
|
|
|
Event OnCellAttach()
|
|
|
|
; Do nothing
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnLoad()
|
|
|
|
; Do nothing
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnCellDetach()
|
|
|
|
; Do nothing
|
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-12 02:10:35 +00:00
|
|
|
Event OnUnload()
|
|
|
|
; Do nothing
|
|
|
|
EndEvent
|
|
|
|
EndState
|