Randomizing On Hit Sounds

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!
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.

Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Mon Sep 03, 2018 10:15 am

I'm attempting to alter the hit sound for a specific weapon to go from playing only a single sound file to playing one of three sound files at random. I've identified the line that pertains to the sound in the wad's sndinfo.txt file as

Code: Select allExpand view
weapons/tink    tink


I've tried simply changing it to:

Code: Select allExpand view
weapons/tink    tink tink2 tink3


as well as adding in more lines like:

Code: Select allExpand view
weapons/tink    tink

Code: Select allExpand view
weapons/tink    tink2

Code: Select allExpand view
weapons/tink    tink3


however with all of these I'm just getting the standard tink sound. Any ideas?
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby Blue Shadow » Mon Sep 03, 2018 10:43 am

You need to use the $random command. Look it up here.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI Radeon (Modern GZDoom)

Re: Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Sat Sep 08, 2018 12:43 pm

I know about that command, but I have no clue what a aliasname, logicalname or lumpname is.
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby wildweasel » Sat Sep 08, 2018 12:56 pm

lumpname is the name of the file inside your WAD or PK3. Therefore, if it's called DSPISTOL, DSPISTOL is the lump's name. logicalname is what the individual entry is in SNDINFO - if the line reads like:
Code: Select allExpand view
weapons/pistol DSPISTOL

then weapons/pistol is the logical name to DSPISTOL's lump name.

When using $random, you give it a list of logical names, then define which lumps they go to. So if you have 3 tink sounds, you'd probably have something looking like this:
Code: Select allExpand view
$random weapons/tink { tink1 tink2 tink3 }
tink1 TINK1
tink2 TINK2
tink3 TINK3


Then any time you need to play a tink sound, you'd specify weapons/tink and ZDoom will pick randomly from the three in the list.
User avatar
wildweasel
「お前はもうトースト」[you are already toast.]
Moderator Team Lead
 
Joined: 15 Jul 2003

Re: Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Sat Sep 08, 2018 1:03 pm

Yea sorry about that silly last post, I figured it out through some experimentation. Final code looks like this and functions perfectly:

Code: Select allExpand view
$random weapons/tink    {weapons/tink1 weapons/tink2 weapons/tink3}
weapons/tink1 tink
weapons/tink2 tink2
weapons/tink3 tink3
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Sat Sep 08, 2018 2:02 pm

Well, now I'm having trouble replicating the same behavior with a different weapon.

SNDINFO:

Code: Select allExpand view
$random weapons/wiff {weapons/wiff1 weapons/wiff2 weapons/wiff3 weapons/wiff4}
weapons/wiff1 wiff1
weapons/wiff2 wiff2
weapons/wiff3 wiff3
weapons/wiff4 wiff4


Decorate code:

Code: Select allExpand view
fire:   
      axeg BCDE 1
      tnt1 a 2
      axeg F 1 A_PlayWeaponSound("weapons/wiff")
      axeg G 1 A_CustomPunch(6,0,0,"axePuff2")
      axeg H 1
      tnt1 a 5
      axeg Edcb 1
      axeg A 0 A_ReFire   
      Goto Ready


All 4 of my "wiff" sounds are in OGG format, if that matters.
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby Enjay » Sat Sep 08, 2018 2:16 pm

Looks right to me. Is it not working entirely (i.e. no sound) or is it just that the randomisation isn't happening?

If it's the former, obvious checks - are the ogg files actually in your project? Are they in the sounds folder?
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Sat Sep 08, 2018 2:28 pm

It's just flat out not playing at all. Ogg files are in the wad files sounds folder.
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Sat Sep 08, 2018 6:34 pm

I did find out that editing the decorate code from:


Code: Select allExpand view
axeg F 1 A_PlayWeaponSound("weapons/wiff")


to:

Code: Select allExpand view
axeg F 1 A_PlayWeaponSound("weapons/wiff1")


does cause my wiff1 sound to be played, and making it wiff2 causes wiff2 to play etc.

Not sure why it isn't reading it otherwise.
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby Enjay » Sun Sep 09, 2018 5:58 am

What happens if you bring down the console and type

playsound weapons/wiff

:?:
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Randomizing On Hit Sounds

Postby Mr. Fancy Pants » Sun Sep 09, 2018 1:25 pm

Enjay wrote:What happens if you bring down the console and type

playsound weapons/wiff

:?:


No message at all and no sound playing - it doesn't give me the "not a sound" message.
User avatar
Mr. Fancy Pants
 
Joined: 04 Apr 2018
Location: Housewares

Re: Randomizing On Hit Sounds

Postby Enjay » Sun Sep 09, 2018 2:36 pm

That's odd because I just used an exact copy/paste of the code that you posted and it worked perfectly for me using some ogg files I have lying around here.

do

playsound weapons/wiff1

playsound weapons/wiff2

playsound weapons/wiff3

and

playsound weapons/wiff4

work?
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Randomizing On Hit Sounds

Postby Hexereticdoom » Mon Sep 10, 2018 3:43 pm

Hello there, if for some weird reason the sound randomize function is not working correctly, as a last resort you could try this alternative Decorate code that should work always:

Code: Select allExpand view
Fire:   
      AXEG BCDE 1
      TNT1 A 2
      TNT1 A 0 A_Jump(128, 2, 3, 4)
      AXEG F 1 A_PlayWeaponSound("weapons/wiff1")
      Goto EndFire
      AXEG F 1 A_PlayWeaponSound("weapons/wiff2")
      Goto EndFire
      AXEG F 1 A_PlayWeaponSound("weapons/wiff3")
      Goto EndFire
      AXEG F 1 A_PlayWeaponSound("weapons/wiff4")
      Goto EndFire
EndFire:
      AXEG G 1 A_CustomPunch(6, 0, 0, "AxePuff2")
      AXEG H 1
      TNT1 A 5
      AXEG EDCB 1
      AXEG A 0 A_ReFire   
      Goto Ready


Hope this helps! 8-)
User avatar
Hexereticdoom
Don't make me angry or I'll bite you! Heheheee...
 
Joined: 08 Aug 2013
Location: Spain


Return to Assets (and other stuff)

Who is online

Users browsing this forum: No registered users and 3 guests