Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Chubzdoomer

ACS - Stopping Sounds

Recommended Posts

Is it possible to stop lengthy sounds using ZDoom's ACS scripting? Let's say for example I turn on a "television" and it starts playing a long song. If I shoot it and script it to "break" by playing a glass break sound and changing the texture to a broken screen, is it also possible to stop the currently-playing song to simulate a now non-functional television?

I've thoroughly searched throughout the ZDoom Wiki but haven't been able to locate commands that make this happen. I've even tried deactivating and removing the Thing that the sound is playing through, but the sound continues to play regardless! This is very frustrating.

Thanks for any help!

Share this post


Link to post

I know for a fact you can Thing_Move an ambient sound thing. If the sound is still playing, you might have the sound defined wrong (world instead of point). Honestly, I've never read about a proper way to stop sounds either, although I'm sure there is.

You could also try Thing_Remove or possibly even Thing_ChangeTID (to remove it's reference to the script assigning the sound). Have you tried "overwriting" the sound with another (say the glass break sound)?

By the way, which special/function are you using to play the sound to begin with?

Share this post


Link to post

I don't mean to confuse you guys, but I have a setup that's a little complex. I'm using an "Ambient Sound 5" thing to play an ambient TV static sound. When you activate the television, I deactivate that Thing to stop the static sound, then use a "ThingSound" line of code to start playing the TV song on the "Ambient Sound 5" thing (which is now disabled). The song plays just fine, and the static is no longer heard. My problem, though, is that if I assign a projectile-triggered line hidden behind the TV screen that plays a glass-breaking sound and changes the texture to broken glass, the glass sound does play (on the "Ambient Sound 5" thing) but the song is also playing on the same Thing at the same time!

And if I remove the Thing after I start playing either sound? They still play through! I think once I even tried throwing in a "Map Spot" thing, assigning it a unique ID, and playing a sound on it while deactivating/removing it, but I encountered the same problem in which the song simply would not stop. It just seems borderline insane to me that with all of the great scripting features available to us when using ACS, this hasn't yet been considered. I can think of at least several other occassions in which this might cause problems, too, such as when actors giving speeches are killed and you want the speeches to completely stop, etc.

Share this post


Link to post

Her's what I suggest you do: create a new actor with DECORATE, kinda like this:

Actor tvspot : mapspot 1337
{
    States
    {
    Spawn:
        TNT1 A -1
        Wait
    On:
        TNT1 A -1 A_PlaySound("tv/working")
        Wait
    Off:
        TNT1 A -1 A_PlaySound("tv/explode")
        Stop
    }
}
Place it at the same place as your ambient sound thing and give it its own unique TID. When you deactivate the ambient sound thing, use SetActorState to put your tvspot in the "On" state. When the TV explode, use this function again to put it in the "Off" state.

Since A_PlaySound by default uses the BODY channel, the second call will override the first and interrupt the "tv/working" sound. Whereas ThingSound uses the AUTO channel which automatically searches for a free channel, allowing up to eight sounds to be played at once on the same source.

(I do agree it's odd you can't specify channels with ThingSound and the lack of a ThingStopSound is also an oversight, but at least you have a workaround.)

Share this post


Link to post

It would be sweet if ambient sound objects were operable at game-time: make them play sound, dynamically change their volume, dynamically change their pitch, halt their sound, transport them around. Could make for some crazy ambient noise.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×