Item Pickups that have their own PICKUP sound

Ask about ACS, DECORATE, ZScript, or any other scripting questions 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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Item Pickups that have their own PICKUP sound

Post by Hidden Hands »

Maybe someone can help me here. I'm trying to make a special jingle play when you pick up a key in my game. I only want it to play this for keys though, not health or armour or ammo. How can I make it so that just that one type of item plays the sound? Does it have to call an ACS Script? Because when I tried doing that, it plays the new sound but also the original sound at the same time. I only want it to play the one key jingle sound. Can it be done please? How?

Thanks in advance.
User avatar
Enjay
 
 
Posts: 27307
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Item Pickups that have their own PICKUP sound

Post by Enjay »

The various pickup types already have their own sounds defined, it's just that they are mapped to the same sound lump.

Code: Select all

misc/w_pkup			dswpnup		// Pickup weapon
misc/p_pkup			dsgetpow	// Pickup powerup
misc/i_pkup			dsitemup	// Pickup item
misc/k_pkup			dsitemup	// Pickup key
So, if you just want to change all keys, map misc/k_pkup to your own sound lump in SNDINFO.

If you want any individual items to have their own specific sound, this can be done by defining a unique pickup sound in SNDINFO and then telling the item to use that sound as its pickup sound in its DECORATE or ZScript.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Item Pickups that have their own PICKUP sound

Post by Hidden Hands »

Enjay wrote:The various pickup types already have their own sounds defined, it's just that they are mapped to the same sound lump.

Code: Select all

misc/w_pkup			dswpnup		// Pickup weapon
misc/p_pkup			dsgetpow	// Pickup powerup
misc/i_pkup			dsitemup	// Pickup item
misc/k_pkup			dsitemup	// Pickup key
So, if you just want to change all keys, map misc/k_pkup to your own sound lump in SNDINFO.

If you want any individual items to have their own specific sound, this can be done by defining a unique pickup sound in SNDINFO and then telling the item to use that sound as its pickup sound in its DECORATE or ZScript.
Okay, so basically, if I'm getting this right, my SOUNDINFO should have this:

Code: Select all

misc/w_pkup			weappick	// Pickup weapon
misc/p_pkup			powrpick	// Pickup powerup
misc/i_pkup			itempick	// Pickup item
misc/k_pkup			keyspick	// Pickup key
But how would the engine know the difference? Do I actually need anything else or will adding this sound lump just fix all that? Does it know automatically to seperate them?

EDIT: Well I did it and it worked great. Wonderful work man, thank you so much! :)
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Item Pickups that have their own PICKUP sound

Post by Arctangent »

For reference, the engine knows which sound to use because each superclass of item has its Inventory.PickupSound property set to the appropriate sound name, and the individual item types inherit that. If you ever need to give a specific item its own unique pickup sound, you can toss that into the item's definition and it'll work just fine ... provided you've set up the sound in SNDINFO, anyway.
Post Reply

Return to “Scripting”