Scriptname SoSCivSnore extends ObjectReference  
{Script attached to Render Window bed references that allows specific NPCs to play the snore SFX.}
 
Actor Property SnoringActor  Auto  
Sound Property SnoringSoundFX  Auto
globalvariable property SnoringGV auto
 
Int Property SnoringPlay Auto
Int Property CurrentlySnoring Auto
 
Event OnInit()
        RegisterForsingleUpdate(0.5)
EndEvent
 
Auto State Snoring
 
    Event OnUpdate()
        unregisterforupdate() ; pour supprimer le registerforupdate() de la précédente version.
        If CurrentlySnoring == 0
            If (SnoringActor.GetSleepState() == 3)
                Debug.Trace("Currently Sleeping")
                SnoringPlay = SnoringSoundFX.Play(SnoringActor)
                CurrentlySnoring = 1
            endif
        Endif
 
        If CurrentlySnoring == 1
            If (SnoringActor.GetSleepState() != 3)
                Debug.Trace("Currently Awake")
                Sound.StopInstance(SnoringPlay)
                CurrentlySnoring = 0
            Endif
        Endif
 
        if SnoringGV.getvalueint() == 1
            RegisterForsingleUpdate(0.5)
        endif
    EndEvent
 
EndState