63 lines
1.5 KiB
Plaintext
63 lines
1.5 KiB
Plaintext
|
Scriptname _00E_PlaceableGrammophonPlay extends ObjectReference
|
||
|
|
||
|
Sound Property soundToPlay Auto
|
||
|
MusicType Property _00E_SilenceTransitionHighPriority Auto
|
||
|
GlobalVariable Property _00E_AchievementsEnabled Auto
|
||
|
Message Property _00E_PlayerhousingKoppophonVolume Auto
|
||
|
bool bDone
|
||
|
float Property soundLengthInSeconds Auto
|
||
|
|
||
|
int playbackId = -1
|
||
|
float volume = 0.5
|
||
|
bool bmuted = true
|
||
|
|
||
|
Event OnCellAttach()
|
||
|
playbackId = -1
|
||
|
bmuted = true
|
||
|
Endevent
|
||
|
|
||
|
Event OnLoad()
|
||
|
playbackId = -1
|
||
|
bmuted = true
|
||
|
Endevent
|
||
|
|
||
|
Event OnCellDetach()
|
||
|
_00E_SilenceTransitionHighPriority.Remove()
|
||
|
Sound.StopInstance(playbackId)
|
||
|
playbackId = -1
|
||
|
UnregisterForUpdate()
|
||
|
Endevent
|
||
|
|
||
|
Event OnActivate(ObjectReference triggerRef)
|
||
|
if playbackId == -1
|
||
|
playbackId = soundToPlay.Play(Self)
|
||
|
RegisterForSingleUpdate(soundLengthInSeconds)
|
||
|
If volume == 0
|
||
|
volume = 0.5
|
||
|
endif
|
||
|
Sound.setInstanceVolume(playbackId, volume)
|
||
|
_00E_SilenceTransitionHighPriority.Add()
|
||
|
If _00E_AchievementsEnabled.GetValueInt() == 1 && !bDone
|
||
|
bDone = true
|
||
|
Game.UnlockAchievement("END_KOPPOPHON_01")
|
||
|
EndIf
|
||
|
else
|
||
|
volume = volume + 0.25
|
||
|
if volume > 1
|
||
|
volume = 0
|
||
|
bmuted = false
|
||
|
_00E_SilenceTransitionHighPriority.Remove()
|
||
|
elseif bmuted == false
|
||
|
bmuted = true
|
||
|
_00E_SilenceTransitionHighPriority.Add()
|
||
|
Endif
|
||
|
Sound.SetInstanceVolume(playbackId, volume)
|
||
|
Endif
|
||
|
_00E_PlayerhousingKoppophonVolume.Show(volume*100)
|
||
|
Endevent
|
||
|
|
||
|
Event OnUpdate()
|
||
|
_00E_SilenceTransitionHighPriority.Remove()
|
||
|
Sound.StopInstance(playbackId)
|
||
|
playbackId = -1
|
||
|
Endevent
|