Zorkaz Posted May 21, 2021 Share Posted May 21, 2021 1. I'm currently having a script where an NPC approaches you and at a certain distance a looping sound (Heartbeat) starts to play 2. Now the sound does not stop when you go away from him.I tried making it a condition that the sound only appears between a certain distance from him but it does not work. 3. I know that there's StopInstance() but it only seems to work within a specific function or Event, not separate ones. Any ideas? The base script on the NPC Sound Property TWHearbeatFastFxCompound Auto ImageSpaceModifier Property Poison Auto Event Onload() Somefunction() EndEvent Function SomeFunction() RegisterForDistanceLessThanEvent(Game.GetPlayer(), Self, 400.0) RegisterForDistanceGreaterThanEvent(Game.GetPlayer(), Self, 400.0) EndFunction Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance) TWHearbeatFastFxCompound.play(Game.Getplayer()) Poison.Apply() EndEvent Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance) SomeFunction() EndEvent Link to comment Share on other sites More sharing options...
Zorkaz Posted May 21, 2021 Author Share Posted May 21, 2021 Oh that's the condition from the sound Link to comment Share on other sites More sharing options...
SKKmods Posted May 21, 2021 Share Posted May 21, 2021 Yes make the sound instance variable script level like this; Int iVertibirdSoundInstance = -1 Event OnCombatStateChanged(Actor akTarget, int aeCombatState) If ((akTarget == None) || (aeCombatState == 0)) ;not in combat If (iVertibirdSoundInstance != -1) Sound.StopInstance(iVertibirdSoundInstance) iVertibirdSoundInstance = -1 EndIf ElseIf (akTarget == (pPlayerREF as Actor)) && (iVertibirdSoundInstance == -1) ; Player gets PsiWarOp iVertibirdSoundInstance = pSKK_CSRadioInstituteWagnerRideOfTheValkyries.Play((Self as ReferenceAlias).GetReference()) Sound.SetInstanceVolume(iVertibirdSoundInstance, 1.0) ; make it loud EndIf EndEvent Dont forget handlers for OnDeath and OnUnload events to clean up as well. Link to comment Share on other sites More sharing options...
Zorkaz Posted May 22, 2021 Author Share Posted May 22, 2021 Thanks Link to comment Share on other sites More sharing options...
Recommended Posts