Page 1 of 1

How do I script the waterspout sound to stop and start?

PostPosted: Mon Jul 05, 2010 11:26 pm
by Tes96
I have a waterspout in Pelagiad Expanded and it shuts off at 2000 and starts back up again at 0600. I have a unique ID waterspout sound red activator thing there as well and it needs a script to stream the sound but I also want to add in a script to turn off the sound at 2000 and start the sound back up again at 0600.

I tried doing this but the sound still plays continuously:

Code: Select all
Begin PE_Sound_Water_Spout

if ( CellChanged == 0 )
       if ( GetSoundPlaying "Cave_Waterfall" == 0 )
               PlayLoopSound3DVP "Cave_Waterfall", 1.0, 1.0
       endif
endif


if ( GameHour > 6 )
  If ( GameHour <= 20 )  
    If (Getdisabled == 1 )
       Enable
   endif
    return
  endif
endif

if ( GameHour > 20 )
   if (getdisabled == 0)
      Disable
   endif
   return
endif
 
if ( GameHour <= 6 )
   if (getdisabled == 1)
     Disable
  endif
endif

End


That first part is for the sound. The second part is what is attached to the waterspout activator, which is how it shuts on and off at those times. So somehow, I need to rewrite the script so that the sound activator shuts on and off, too. Can someone help me rewrite it please? If not for me, then do it for Pelagiad. :)

Re: How do I script the waterspout sound to stop and start?

PostPosted: Tue Jul 06, 2010 12:24 am
by Fliggerty
This is entirely untested, I just slapped it together.  The problem is that you have nothing that ever tells the sound to stop playing, and you even have a call that starts the sound every single frame no matter what.  Also note that sound will not stop playing if the object is disabled.

Code: Select all
Begin PE_Sound_Water_Spout

       short start

       if ( CellChanged == 1 )
               set start to 1
       endif

       if ( start == 1 )
               if ( GetSoundPlaying "Cave_Waterfall" == 0 )
                       PlayLoopSound3DVP "Cave_Waterfall", 1.0, 1.0
               endif
               set start to 0
       endif

       if ( stop == 1 )
               if ( GetSoundPlaying "Cave_Waterfall" == 0 )
                       StopSound "Cave_Waterfall"
               endif
               set stop to 0
       endif

       if ( GameHour > 6 )
               If ( GameHour <= 20 )
                       If (Getdisabled == 1 )
                               set start to 1
                               Enable
                       endif
                       return
               endif
       endif

       if ( GameHour > 20 )
               if (getdisabled == 0)
                       set stop to 1
                       Disable
               endif
               return
       endif

       if ( GameHour <= 6 )
               if (getdisabled == 1)
                       set stop to 1
                       Disable
               endif
       endif

End

Re: How do I script the waterspout sound to stop and start?

PostPosted: Tue Jul 06, 2010 2:01 am
by Tes96

Re: How do I script the waterspout sound to stop and start?

PostPosted: Tue Jul 06, 2010 3:23 am
by Fliggerty
Looks like I just forgot to declare the short variable stop at the top.

Re: How do I script the waterspout sound to stop and start?

PostPosted: Tue Jul 06, 2010 12:24 pm
by Tes96
I added in the short stop at the top but now the sound is not even there.
Maybe write it to where it moves the red sound activator like, super far beneath the surface so that you can't hear the sound. That would be the z axis? Or is it easier to just disable and enable it? This script works fine for the actual water spout itself so I'm not sure why it's not working for the sound activator.

Code: Select all
Begin PE_Sound_Water_Spout

  short start
  short stop

  if ( CellChanged == 1 )
     set start to 1
  endif

  if ( start == 1 )
     if ( GetSoundPlaying "Cave_Waterfall" == 0 )
        PlayLoopSound3DVP "Cave_Waterfall", 1.0, 1.0
     endif
     set start to 0
  endif

  if ( stop == 1 )
     if ( GetSoundPlaying "Cave_Waterfall" == 0 )
        StopSound "Cave_Waterfall"
     endif
     set stop to 0
  endif

  if ( GameHour > 6 )
     If ( GameHour <= 20 )
        If (Getdisabled == 1 )
           set start to 1
           Enable
        endif
        return
     endif
  endif

  if ( GameHour > 20 )
     if (getdisabled == 0)
        set stop to 1
        Disable
     endif
     return
  endif

  if ( GameHour <= 6 )
     if (getdisabled == 1)
        set stop to 1
        Disable
     endif
  endif

End PE_Sound_Water_Spout

Re: How do I script the waterspout sound to stop and start?

PostPosted: Fri Jul 09, 2010 12:25 am
by Tes96
Nevermind, Abot wrote it for me. It works now. Thanks for taking a stab at it, Fliggerty.


Code: Select all
Begin PE_Sound_Water_Spout

if ( CellChanged )
       return  ; not sure this is needed, but Bethesda always skips playing sounds on cellchanged...
endif

if ( GameHour <= 6 )
       return   ;   too early, skip
endif

if ( GameHour >= 20 )
       return    ;  too late, skip
endif

if ( GetSoundPlaying "Cave_Waterfall" )
       return   ; already playing, skip
endif

PlaySound3DVP "Cave_Waterfall" 1.0 1.0
; you could use something like this to test a different sound  instead
; PlaySound3DVP "Sound_Boat_Hull00" 1.0 1.0


End