[DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 5:30 pm

So i am started working on varius ambient effects in my mod and one them is this, at random spawns this actor and its supposed to play a sound from the 4 possible spawns and can be heard globally, but no sounds play at all! can anyone help me?

Code:
Actor AnomalyAmbientSound
{
 Radius 2
 Height 2
 +NOINTERACTION
 States
 {
  Spawn:
   NULL A 0 NoDelay A_Jump(255, "SpawnScreams", "SpawnGunShots", "SpawnWhispers", "SpawnGhosts")
  SpawnScreams:
   TNT1 A 1
   TNT1 A 1 A_PlaySound ("Ambience/Screams", ATTN_NONE )
   TNT1 A 1
   Loop
  SpawnGunShots:
   TNT1 A 1
   TNT1 A 1 A_PlaySound ("Ambience/GunShots", ATTN_NONE )
   TNT1 A 1
   Loop
  SpawnWhispers:
   TNT1 A 1
   TNT1 A 1 A_PlaySound ("Ambience/Whispers", ATTN_NONE )
   TNT1 A 1
   Loop
  SpawnGhosts:
   TNT1 A 1
   TNT1 A 1 A_PlaySound ("Ambience/Ghosts", ATTN_NONE )
   TNT1 A 1
   Loop
  }
}


Code:
$random Ambience/Screams    { AmbScream1  AmbScream2 AmbScream3 AmbScream4 AmbScream5 AmbScream6 AmbScream7}
AmbScream1                        AmbScream1
AmbScream2                        AmbScream2
AmbScream3                        AmbScream3
AmbScream4                        AmbScream4
AmbScream5                        AmbScream5
AmbScream6                        AmbScream6
AmbScream7                        AmbScream7

$random Ambience/GunShots    { AmbGunShots1  AmbGunShots2 AmbGunShots3 AmbGunShots4 AmbGunShots5 AmbGunShots6 AmbGunShots7}
AmbGunShots1                      AmbGunShots1
AmbGunShots2                      AmbGunShots2
AmbGunShots3                      AmbGunDie1
AmbGunShots4                      AmbGunDie2
AmbGunShots5                      AmbGunDie3
AmbGunShots6                      AmbGunDie4
AmbGunShots7                      AmbGunDie5

$random Ambience/Ghosts    { AmbGhosts1  AmbGhosts2 AmbGhosts3 AmbGhosts4 AmbGhosts5 AmbGhosts6 AmbGhosts7}
AmbGhosts1                        AmbGhosts1
AmbGhosts2                        AmbGhosts2
AmbGhosts3                        AmbGhosts3
AmbGhosts4                        AmbGhosts4
AmbGhosts5                        AmbGhosts5
AmbGhosts6                        AmbGhosts6
AmbGhosts7                        AmbGhosts7

$random Ambience/Whispers   { AmbWhispers1  AmbWhispers2 }
AmbWhispers1                      AmbWhispers1
AmbWhispers2                      AmbWhispers2

Re: [DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 5:35 pm

Try adding a state of a few ticks before the jump to your sound states, it might be skipping the jump. I seem to remember the engine isn't super happy about 0-length frames in the spawn function? But I could be wrong, or it could be an outdated rule of thumb.

Re: [DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 5:50 pm

ATTN_NONE? This is the 5th parameter. The secund one is "Slot".

https://zdoom.org/wiki/A_PlaySound

Re: [DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 5:53 pm

Logan MTM wrote:ATTN_NONE? This is the 5th parameter. The secund one is "Slot".

https://zdoom.org/wiki/A_PlaySound

Even without the ATTN and just the A_PlaySound the sounds dont play

Re: [DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 6:02 pm

Without seeing the full picture I'm limited in what I can offer you.

However, the first thing that comes to mind is you're using the filenames and not a full path... when there's more than 8 characters.

If you're using a ZIP/PK3... Try this:

Code:
AmbScream1                        "sounds/AmbScream1.wav" // replace .wav with whatever extension the sound is, like .ogg or .flac


if you're using WAD I have no idea.

Re: [DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 6:36 pm

SanyaWaffles wrote:Without seeing the full picture I'm limited in what I can offer you.

However, the first thing that comes to mind is you're using the filenames and not a full path... when there's more than 8 characters.

If you're using a ZIP/PK3... Try this:

Code:
AmbScream1                        "sounds/AmbScream1.wav" // replace .wav with whatever extension the sound is, like .ogg or .flac


if you're using WAD I have no idea.


This was very helpful, so i changed a bit the code and instead of 1 actor with multiple states i decided to make diferent actors but the problem i have is that i dont know how to make the sound play on the entire map

Code:
Actor AnomalyAmbientSound1
{
 Radius 2
 Height 2
 +NOINTERACTION
 States
 {
  Spawn:
   TNT1 A 1
   TNT1 A 8 A_PlaySound ("Ambience/Screams")
   TNT1 A 1
   Loop
  }
}

Re: [DECORATE] Ambient Sound Actor

Tue Sep 21, 2021 6:40 pm

Use the $attenuation flag in SNDINFO as detailed here: https://zdoom.org/wiki/SNDINFO. Set to zero and it will never fade with distance, although it will still have directionality.

The ATTN_NONE flag also should do it, seems like that does the same thing. You just need to put it as the 5th argument for the PlaySound function.

Actually, to someone who knows more, will it have directionality? I suddenly can't remember.