Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: torc on June 25, 2012, 03:10:15 am

Title: Feature request: Adding custom impact sounds for different weapons.
Post by: torc on June 25, 2012, 03:10:15 am

i'll try to explain it better:

In sounds.tbl there's 4 kind of sounds when the player ship has been hit by an enemy:

two for primary impact on shields and hull (sound n. 39,40)
two for secondary impact on shields and hull (sound n. 36,37)

Anyway the limitations are obvious: capship flaks or beams (as istance) don't have any impact feedback sound when them hit the player.

So,i wonder if it's possible to have directly in weapons.tbl the chance to assign at single weapons the sound you want as example using 2 strings like:

$Player ShieldHitSnd:
$Player HullHitSnd:

in  this way, youcan assign the sound you want to a specific weapon (laser,missile beam flak artillery etc)

thanks in advance.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: m!m on June 25, 2012, 04:58:21 am
This seems to be a fairly easy feature to implement. In weapons.cpp from line 5396 everything that needs to be done would be to replace the occurrences of SND_SHIELD_HIT_YOU, SND_PLAYER_HIT_MISSILE and SND_PLAYER_HIT_LASER with the field values of new values in the weapon_info struct.

The attached patch implements the suggested behavior and a code review would be great.

[attachment deleted by a ninja]
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: Spoon on June 25, 2012, 08:22:54 am
While we are on the subject of sound
How about being able to assign multiple launch sounds for a weapon? Instead of pewpewpewpewpew we could do pewblewmewpewbew when firing a subach.

And hell, instead of limiting this to the Player. I'd love to see a shield hit impact sound option for whatever weapon. Cause right now when you fire the biggest deadliest missile you have on the enemy. It will only play its GIANT SPACE NUKE SOUND EFFECT when it directly impacts with the hull. If it hits the shield its just 'btzz'.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: z64555 on June 25, 2012, 01:54:40 pm
While we are on the subject of sound
How about being able to assign multiple launch sounds for a weapon? Instead of pewpewpewpewpew we could do pewblewmewpewbew when firing a subach.

On another engine I worked with, you had a few more options with sounds.


A bit more complicated, but a bunch more flexible. I'm not sure how difficult it will be to get it implemented, however...
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: Spoon on June 25, 2012, 04:35:56 pm
I would highly approve of that
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: Thaeris on June 25, 2012, 05:08:14 pm
Why not use science!?

Use the distance and the frequency of the files own effect file to let the computer determine the sound distortion for you?
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: torc on June 25, 2012, 05:14:13 pm
well,same thing for a lowpass filter...when a sound is far away it should sound more muffed....this would be better and more natural than  other solutions.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: pecenipicek on June 25, 2012, 06:21:44 pm
While we are on the subject of sound
How about being able to assign multiple launch sounds for a weapon? Instead of pewpewpewpewpew we could do pewblewmewpewbew when firing a subach.

On another engine I worked with, you had a few more options with sounds.

  • Any sound can have its pitch and/or volume randomized by some defined amount.
  • Sounds can be grouped into sound sets. When the sound set is called, one of the sounds in the set is played.
  • Sound sets can either sequentially cycle (forward or backward) between the included sounds, or randomly pick a sound whenever the sound set is played.

A bit more complicated, but a bunch more flexible. I'm not sure how difficult it will be to get it implemented, however...

i would like to throw my support behind this one as well.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: z64555 on June 25, 2012, 10:22:01 pm
Possible table format for soundsets:

Code: [Select]
#Sound Sets

$Set: 0               ;; The ID number for this set
    +Cycle: random    ;; Will cycle randomly. Defaults to forward cycling (top of the list down)
$Sound: 10                     ;; The ID number of the first sound
    +Randomize Pitch: 0.3      ;; Pitch Randomization percentage ( between +/- 30%)
    +Randomize Volume: +0.1    ;; Volume Randomization percentage ( up to +10%)
$Sound: 11                     ;; Second Sound ID
$Sound: 12                     ;; Last sound in this set

$Set: 1
$Sound: 13

#End

The + and - there is an additional feature, which would essentially allow the tabler some flexibility for the randomization. The value is a % of the volume or pitch (might actually be the .wav's total playtime), and has to be a float value to allow for fine adjustments (especially for randomizing the pitch).

Next problem for the .tbl's would be to figure out how to differentiate between individual sounds and sound sets with the existing system. Ideally, the implementation would be backwards compatible... so if you don't specify to use a sound set somewhere, the sound ID will be used.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: zookeeper on June 26, 2012, 02:25:36 am
Wouldn't it be better to just expand the functionality of sounds.tbl? I don't see why that wouldn't be entirely possible. Also, places where you reference sound names/id's/numbers (such as $LaunchSnd:) could simply accept lists of sounds ("$LaunchSnd: (231, 232, 233)") as well.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: m!m on June 26, 2012, 03:02:35 am
Wouldn't it be better to just expand the functionality of sounds.tbl? I don't see why that wouldn't be entirely possible. Also, places where you reference sound names/id's/numbers (such as $LaunchSnd:) could simply accept lists of sounds ("$LaunchSnd: (231, 232, 233)") as well.
That would essentially need as much work as the proposed sound set feature with less flexibility as you would still need to change every invocation of snd_play and friends to use the list so we could just as easily refactor the sound management system and add that feature on the way.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: assasing123 on June 26, 2012, 12:53:53 pm
I HATE sounds.tbl.


personally if i could reference sounds directly from the weapon tables as files it would be perfect.

stuff like a line that says:

fileSndlaunch:      rocketlaunch.ogg,65,  rocketlaunch2ogg,35
filesndflyby:    rocketfly.ogg,
fileshieldsndhit: rockethit.ogg,45, rockethit2.ogg,55
filehullsndhit: rockethit.ogg,45, rockethit2.ogg,55

the "," used to separate each sound and the number is the weight for randomness

and as mentioned before use the sound engine to handle the distortion from distance and alike by using the file frequency.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: Spoon on June 26, 2012, 02:52:59 pm
You can't do without sounds.tbl. Min/max sound distance and volume etc.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: torc on June 26, 2012, 04:20:34 pm
sounds table works fine IMO:
It's pretty much intuitive, we'd need just to ''expand'' some functions.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: torc on July 05, 2012, 04:08:13 pm
BUMP!!! Just a little reminder: the patch has been done....it needs only review...

If somebody have the time to take a look at it would be great.

thanks a lot.

http://www.hard-light.net/forums/index.php?action=dlattach;topic=81216.0;attach=19503
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: Iss Mneur on July 05, 2012, 10:20:29 pm
m!m: that looks good to me.

I agree with Spoon (uh oh, the end of the world may actually come in 2012 :P) that this should be extended to not just be a player only feature and allow individual weapons to specify the impact sound for not player impacts as well.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: torc on July 05, 2012, 11:50:52 pm
If you wanna implement this too, i'm fine...but i hope there will be the way to assign 2 different sounds: one for the player and one for the other ships, since you'll be able to use 2 different sounds and entry in sounds table giving different pitch and distance values.
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: m!m on July 06, 2012, 04:36:20 am
I attached a patch which now also includes custom shield impact sounds for all weapons for both armed and disarmed states.
I also noticed that "$Disarmed ImpactSnd" never actually worked as it saved the index specified in the table as the impact sound of the weapon so I also fixed that in the attached patch.

[attachment deleted by a ninja]
Title: Re: Feature request: Adding custom impact sounds for different weapons.
Post by: ChaosityZ on July 10, 2012, 02:40:50 pm
While we are on the subject of sound
How about being able to assign multiple launch sounds for a weapon? Instead of pewpewpewpewpew we could do pewblewmewpewbew when firing a subach.

And hell, instead of limiting this to the Player. I'd love to see a shield hit impact sound option for whatever weapon. Cause right now when you fire the biggest deadliest missile you have on the enemy. It will only play its GIANT SPACE NUKE SOUND EFFECT when it directly impacts with the hull. If it hits the shield its just 'btzz'.


Or maybe the sound can be altered based on the strength of the shields remaining when hit?   (Full strength shields vs only 1/2 remaining?)
When firing something weak like the subach over and over, you cant tell how low the enemy shields are until you start hearing the impact to the hull.
Maybe even the visual effect could be different as the shields get weaker!