Randomizing On Hit Sounds

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.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Randomizing On Hit Sounds

Re: Randomizing On Hit Sounds

by Hexereticdoom » Mon Sep 10, 2018 2: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 all

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-)

Re: Randomizing On Hit Sounds

by Enjay » Sun Sep 09, 2018 1: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?

Re: Randomizing On Hit Sounds

by Mr. Fancy Pants » Sun Sep 09, 2018 12: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.

Re: Randomizing On Hit Sounds

by Enjay » Sun Sep 09, 2018 4:58 am

What happens if you bring down the console and type

playsound weapons/wiff

:?:

Re: Randomizing On Hit Sounds

by Mr. Fancy Pants » Sat Sep 08, 2018 5:34 pm

I did find out that editing the decorate code from:

Code: Select all

axeg F 1 A_PlayWeaponSound("weapons/wiff")
to:

Code: Select all

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.

Re: Randomizing On Hit Sounds

by Mr. Fancy Pants » Sat Sep 08, 2018 1:28 pm

It's just flat out not playing at all. Ogg files are in the wad files sounds folder.

Re: Randomizing On Hit Sounds

by Enjay » Sat Sep 08, 2018 1: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?

Re: Randomizing On Hit Sounds

by Mr. Fancy Pants » Sat Sep 08, 2018 1:02 pm

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

SNDINFO:

Code: Select all

$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 all

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.

Re: Randomizing On Hit Sounds

by Mr. Fancy Pants » Sat Sep 08, 2018 12: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 all

$random weapons/tink    {weapons/tink1 weapons/tink2 weapons/tink3}
weapons/tink1 tink
weapons/tink2 tink2
weapons/tink3 tink3

Re: Randomizing On Hit Sounds

by wildweasel » Sat Sep 08, 2018 11:56 am

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 all

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 all

$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.

Re: Randomizing On Hit Sounds

by Mr. Fancy Pants » Sat Sep 08, 2018 11:43 am

I know about that command, but I have no clue what a aliasname, logicalname or lumpname is.

Re: Randomizing On Hit Sounds

by Blue Shadow » Mon Sep 03, 2018 9:43 am

You need to use the $random command. Look it up [wiki=SNDINFO]here[/wiki].

Randomizing On Hit Sounds

by Mr. Fancy Pants » Mon Sep 03, 2018 9: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 all

weapons/tink    tink
I've tried simply changing it to:

Code: Select all

weapons/tink    tink tink2 tink3
as well as adding in more lines like:

Code: Select all

weapons/tink    tink

Code: Select all

weapons/tink    tink2

Code: Select all

weapons/tink    tink3
however with all of these I'm just getting the standard tink sound. Any ideas?

Top