Random Pickup Sound clips
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Random Pickup Sound clips
Can someone please help me with the code needed to make the engine choose a random sound clip (from a few that I choose) to play when picking up a weapon or item? Also, the ability to play two at once - ie; pick up a shotgun (making the clicking sound like usual) but also play a voice clip like "just what i was looking for" for example. Really having trouble with this. Thank you in advance.
Re: Random Pickup Sound clips
SNDINFO code looks like this:
In the item/weapon's DECORATE code you use PickupSound "Items/Pickup" and not the 1-3 ones.
As for the 2nd sound, you need to play that manually on a separate channel using A_PlaySound.
Code: Select all
Items/Pickup1 PICKUP1
Items/Pickup2 PICKUP2
Items/Pickup3 PICKUP3
$random Items/Pickup {Items/Pickup1 Items/Pickup2 Items/Pickup3}
As for the 2nd sound, you need to play that manually on a separate channel using A_PlaySound.
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Random Pickup Sound clips
So if it was a shotgun for example, it would look like this?
Is that it? Or is something missing?Does this go in SNDINFO or DECORATE? And where does the A_Playsound go exactly in the code?
Code: Select all
Weapon/Shotgun SHOTGUN1
Weapon/Shotgun SHOTGUN2
Weapon/Shotgun SHOTGUN3
$random Weapon/Shotgun {Wepon/Shotgun1 Weapon/Shotgun2 Weapon/Shotgun3}
Re: Random Pickup Sound clips
It does not matter what you name the sounds in SNDINFO. What matters is that the SHOTGUN1 (both the actual file and SNDINFO entry) must be 8 characters long, otherwise you have to specify the full path. Also, the sound definitions go into SNDINFO.
You can name it like Wut/WTFIsThis and it'll still work.
A_PlaySound is a DECORATE function and will probably go into the Pickup state. I forgot about an issue you'll most likely face when using this method. You need to create a separate pickup actor inheriting from CustomInventory that gives you the shotgun And plays the sound. Tbh I think it's easier if you just combine the two sounds using sound editing software. Reason why you need to create a CustomInventory actor is because only CustomInventory items have Pickup states.
You can name it like Wut/WTFIsThis and it'll still work.
A_PlaySound is a DECORATE function and will probably go into the Pickup state. I forgot about an issue you'll most likely face when using this method. You need to create a separate pickup actor inheriting from CustomInventory that gives you the shotgun And plays the sound. Tbh I think it's easier if you just combine the two sounds using sound editing software. Reason why you need to create a CustomInventory actor is because only CustomInventory items have Pickup states.