Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
teamswag

how do you make a sound play when you select a weapon

Recommended Posts

i was wondering how would you make a sound play when you select a weapon

 

example: you press the "6" key and select the rocket launcher and a sound plays.

 

how would you do that 

 

thx.

Share this post


Link to post
Actor NewRocketLauncher : RocketLauncher replaces RocketLauncher
{
Weapon.UpSound "Weapons/LauncherUp"
}

In the decorate text.

Then in the sndinfo:

Weapons/LauncherUp DSLAUNUP

 

Share this post


Link to post

i tried doing it, only worked if i picked up the weapon. i need to have a sound play each time the player selects the weapon

 

 

another example:

you press 4 for the chaingun and a sound plays

Edited by teamswag

Share this post


Link to post

Weapon.UpSound is the sound played when the weapon is raised. What I put there is correct.

Inventory.PickupSound is the sound played when the item is picked up.

The code I provided will make the sound DSLAUNUP play when the rocket launcher is selected, but I did not provide the sound itself.

Share this post


Link to post

i tried again and it still didn't work.

 

 

when you first messaged me with the code you gave.

 

 i copyed and pasted the code and modyfied to fit the sound i needed,

 

here's what i put

 

in decorate:

Actor NewRocketLauncher : RocketLauncher replaces RocketLauncher
{
Weapon.UpSound "Weapons/LauncherUp"
}

 

in sndinfo:

Weapons/LauncherUp METAL_SL

 

 

the sound file name i used 

METAL_SL.wav

Share this post


Link to post

Then the sound is the problem. Everything written there is perfectly correct because it comes from code that I know for a fact works.

If you check the ZDoom Wiki page for the chainsaw, you'll see that the sound that plays when it's selected is its UpSound.

Share this post


Link to post

for some reason, after trying that out, for some reason i am getting this error

 

Script error, "map1.wad:DECORATE" line 4:
Unexpected character: ï (ASCII -17)

Share this post


Link to post

There's a character in your decorate text that ZDoom is finding where there shouldn't be anything on line four, it looks like.

It's probably outside the brace, which would cause that error, though I don't see where that character would've come from.

Share this post


Link to post

here is what i put in decorate 

 

Actor NewRocketLauncher : RocketLauncher replaces RocketLauncher
{
Weapon.UpSound "Weapons/LauncherUp"
}

 

 

i still don't know why it says the error because there is still nothing

 

also here is a screenshot

Capture.PNG

Share this post


Link to post

Don't forget you need to replace the player class to include the new weapon too, then add the class to playerclasses in MAPINFO. Everyone always forgets this part!

Share this post


Link to post

I don't see why it's spitting that error. I've never had this happen before.

Try rewriting it instead of copy-pasting, then remove the "old" code and see if that fixes the error.

Another thing I hadn't considered is you need to be able to select the weapon, so you can create a keyconf text file and write this:

setslot 5 NewRocketLauncher

Or you can go in the console and type "use NewRocketLauncher" and you'll switch to it.

Share this post


Link to post

You don't need one. The default player class can use any weapon, and my keyconf solution above will allow you to switch to the new launcher, but not the old one.

Share this post


Link to post

Are you sure you're using the file you edited and not a copy?  It happened to me once

As for the sounds, and since you're using a WAD instead of PK3, do you have the sound file outside any type of marker?

Share this post


Link to post

i actually figured out the problem. but i need to know. what is the name of chaingun in the game. and also i need to know what is the name that goes with "Weapons/[insertname]Up"

Share this post


Link to post

I picked sound info names that made sense to me, so the sndinfo I use for the vanilla weapons is as such:

Weapons/M9Up
Weapons/ShotgunUp
Weapons/DBShotgunUp
Weapons/ChaingunUp
Weapons/LauncherUp
Weapons/PlasmaUp
Weapons/BFGUp

From top to bottom, I made these for the pistol, single shotgun, super shotgun, chaingun, rocket launcher, plasma rifle, and BFG.

Share this post


Link to post
On 9/4/2018 at 4:30 PM, teamswag said:

i actually figured out the problem. but i need to know. what is the name of chaingun in the game. and also i need to know what is the name that goes with "Weapons/[insertname]Up"

The "regular" name for the chaingun (fire sound) according to ZDoom-sndinfo.txt Is:

      "weapons/chngun"

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×