Greetings!
I am trying via Papyrus to stop a looped sound effect from playing on a certain condition but the script somehow never gets to that part.
Detailed Script Information
The script plays snoring sound effects on actors when they are asleep and stops the sound effects when the actor is awake (Being attacked/killed, talked to or simply finishing sleeping).
The script is attached to an object reference in the same cell as the actor and its properties (Actor, sound to play and two Ints) are defined on the object itself.
The sound effect starts playing fine when the actor goes to sleep, but it won't stop when he's awake. By checking my Papyrus log using the Debug.Trace function, I can see that the script works fine when playing the sound, but the other trace I use when the sound stops does not fire.
Very strange! It was a long time ago, but I recall that it was working fine when I used the infamous RegisterForUpdate, yet RegisterForSingleUpdate should work on the script now.
Here is the script in question:
Scriptname SoSCivSnore extends ObjectReference{Script attached to Render Window hidden object references that allows specific NPCs to play the snore SFX.}Actor Property SnoringActor AutoSound Property SnoringSoundFX AutoInt Property SnoringPlay AutoInt Property CurrentlySnoring AutoEvent OnInit() RegisterForSingleUpdate(0.5) GoToState("Snoring")EndEventState Snoring Event OnUpdate() If CurrentlySnoring == 0 If (SnoringActor.GetSleepState() == 3) Debug.Trace("Currently Sleeping") SnoringPlay = SnoringSoundFX.Play(SnoringActor) CurrentlySnoring = 1 RegisterForSingleUpdate(0.5) Return endif Endif If CurrentlySnoring == 1 If (SnoringActor.GetSleepState() != 3) Debug.Trace("Currently Awake") Sound.StopInstance(SnoringPlay) CurrentlySnoring = 0 RegisterForSingleUpdate(0.5) Return Endif Endif EndEventEndState