OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: jphilapy on 30 Dec 2005, 21:53:04

Title: Weapon sounds
Post by: jphilapy on 30 Dec 2005, 21:53:04
Is it possible to add a custom weapon sound to a mission without requiring someone to download a seperate download? If so how?

Thanks,
Jeff
Title: Re:Weapon sounds
Post by: Baddo on 30 Dec 2005, 22:15:37
You can use playSound command in a fired event handler to play your desired sound file every time unit fires his weapon. You can also add a condition with if () then {} straight to the event handler so you can control when and where the sound is allowed to play. This way you can easily modify the sound of weapons and no addons are needed. I recommend you try it out. Do not start a script file from the fired event handler, that would cause unnecessary load for the computer. You can put all necessary commands straight into the event handler.

I did an example for this some time ago. If you have difficulties trying the method I described, I might find that example from somewhere but just now I don't have the time to look for it.

For sure there are some conditions needed for the event handler. For example to prevent the sound from playing when a grenade has been thrown etc... I'll try to post an example during the weekend if you don't figure it out first by yourself.
Title: Re:Weapon sounds
Post by: jphilapy on 31 Dec 2005, 22:52:01
I would need an example of this, thx.

Jeff

You can use playSound command in a fired event handler to play your desired sound file every time unit fires his weapon. You can also add a condition with if () then {} straight to the event handler so you can control when and where the sound is allowed to play. This way you can easily modify the sound of weapons and no addons are needed. I recommend you try it out. Do not start a script file from the fired event handler, that would cause unnecessary load for the computer. You can put all necessary commands straight into the event handler.

I did an example for this some time ago. If you have difficulties trying the method I described, I might find that example from somewhere but just now I don't have the time to look for it.

For sure there are some conditions needed for the event handler. For example to prevent the sound from playing when a grenade has been thrown etc... I'll try to post an example during the weekend if you don't figure it out first by yourself.
Title: Re:Weapon sounds
Post by: Baddo on 02 Jan 2006, 16:36:08
I will give you an example as soon as possible. I have the old example but it needs to be modified (I left it in an uncompleted state last time I modified it)  until I can post it here, and I am a bit busy with other things. :P But I will post it here for sure.
Title: Re:Weapon sounds
Post by: Baddo on 02 Jan 2006, 21:18:17
OK now there is an example mission attached. You need to have version 1.85 or newer for this to work. Look in init.sqs to find out how it works. A fired event handler plays a different sound for each firing mode. It is best that the commands are put into the event handler so we get minimal computer load. Do not start a script file from a fired event handler.

Note that the original weapon sound is still being played and the custom sound is played in addition to it.

Only tested in single player.
Title: Re:Weapon sounds
Post by: jphilapy on 06 Jan 2006, 14:06:47
ok, will give it a try and will get back to you.

Thanks alot,
jeff
Title: Re:Weapon sounds
Post by: jphilapy on 10 Jan 2006, 03:18:00
Hi baddo,

Thanks greatly for providing this example. I played with the mission you provided. I am now going to try and implement my own sounds.  Just  another question, is it possible to change smoke and muzzle flash on guns without using an addon?

Also where do I find a .wss player or converter?

EDITED: I noticed that I can hear the sound only when I shoot my gun. However if anyone else shoots their gun it sounds like the old gun from my perspective, but from their perspective it uses the new sound.  And likewise my gun sounds like the old gun from their perspective.  Also I tried to change this by adding the script to each persons initialize field and commenting it out in the init field. No matter where the other person is on the map, when he fires the gun sounds like it is mine firing, not the person who is over 300 m from me. Any way around this?

Thanks for a great snippet.

Jeff
Title: Re:Weapon sounds
Post by: Baddo on 10 Jan 2006, 20:33:16
WSS File Decoding/Encoding Utils (http://www.ofpec.com/editors/resource_view.php?id=354)