Global sound for helicopter flying away.

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Global sound for helicopter flying away.

Postby Graaicko » Fri May 22, 2020 10:02 pm

I'm trying to make a helicopter which is a projectile to fly away with global sounds. The sound fades out realistically sound wise. But I need the sound to be global, after frustratingly figuring it out of course a new problem has to occure. The sound is played multiple times in an obnoxious fashion. I only want it to play one sound. It does not loop. The sound stops when it is done playing the .OGG file. Figuring out how to use the global sound function was stressful.

Here is the actor I'm working with.
Code: Select allExpand view
ACTOR TransportHelicopterFast
{
  Radius 11
  Height 8
  Speed 14
  Damage 1000
  Projectile
  +BOSS
  +RANDOMIZE
  +DEHEXPLOSION
  +EXTREMEDEATH
  +PIERCEARMOR
  States
  {
  Spawn:
   TRNS A 2 A_PlaySound("HELIFLY",CHAN_AUTO,1,0,0,ATTN_NONE)
   TRNS B 2
    Loop
  Death:
    XXXX X 1
      stop
   }
}
User avatar
Graaicko
I don't do requests. Working on Shadow Elite. I miss Windows 7. :(
 
Joined: 18 Jun 2014
Location: Somewhere, somehow.
Discord: private
Twitch ID: lol why?
Github ID: gitgud, pleb
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Legacy GZDoom)

Re: Global sound for helicopter flying away.

Postby Stopsignal » Fri May 22, 2020 10:53 pm

You are wanting to play the sound yet not have it play multiple times, i think that's what you want? It's playing multiple times because you are looping the Spawn state, and the first frame of it makes it play the sound.
I'd probably do it like this:
Spawn:
TNT1 A 0 A_PlaySound("HELIFLY",CHAN_AUTO,1,0,0,ATTN_NONE)
TRNS A 2
TRNS B 2
Goto Spawn+2//Or Spawn+1? i don't remember very well

Goto Spawn+2 would make it skip the first frame that is playing the sound, therefore it would not play again.
TNT1 A is just an invisible texture. It has nothing. MAking it lasts 0 frames makes the code that it plays happen instantly.
Hope it helps!

i have no idea why i responded to this i usually read these and never respond hahahahah
User avatar
Stopsignal
Pixel Artist
 
Joined: 21 Apr 2015
Discord: Stopsignal#2168

Re: Global sound for helicopter flying away.

Postby Graaicko » Sat May 23, 2020 1:05 am

Doesn't seem to work. :/
User avatar
Graaicko
I don't do requests. Working on Shadow Elite. I miss Windows 7. :(
 
Joined: 18 Jun 2014
Location: Somewhere, somehow.
Discord: private
Twitch ID: lol why?
Github ID: gitgud, pleb
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia (Legacy GZDoom)

Re: Global sound for helicopter flying away.

Postby Blue Shadow » Sat May 23, 2020 6:56 am

Since you're attempting to execute a function on the first state of the Spawn sequence (A_PlaySound in this case), you need to add the NoDelay state flag, otherwise the function won't execute the first time the actor enters the Spawn state, which it does upon spawning.

Code: Select allExpand view
Spawn:
    TNT1 A 0 NoDelay A_PlaySound(...) 


Stopsignal wrote:Goto Spawn+2 would make it skip the first frame that is playing the sound, therefore it would not play again.

That would make it skip the second state and jump to the third, so it should be "Goto Spawn+1".
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Global sound for helicopter flying away.

Postby Stopsignal » Sat May 23, 2020 8:45 am

Huh, alright! Thanks for clearing that up!!
User avatar
Stopsignal
Pixel Artist
 
Joined: 21 Apr 2015
Discord: Stopsignal#2168


Return to Scripting

Who is online

Users browsing this forum: BLEX [Bot] and 2 guests