Author Topic: Weapon sound layers *need help*  (Read 6857 times)

In my TDM server i have relatively large maps, and again if any of you guys have played battlefield you would know that the weapons have sound layers, here is an Example:
A SCAR-H at 25 m would have the base sound
50 m would be a loud pop
75 m would be a quieter pop
100 m would sound like popcorn

Can someone help me out on how to make this?

This is pretty straightforward. You can use different audioProfiles to define the distance and volume of sounds, and you create different audioDatas for each version of your sound effect, then call each one when appropriate.

For each version of your weapon, you're inevitably going to need to duplicate it into new datablocks. So just use a different sound for each weapon.

For each client, find the distance to the origin and play the appropriate sound with GameConnection::play3D(AudioProfile profile, Vector3F origin).

i think i follow, give me an example.

I've done this by simply just playing a distant gunshot sound to all players, and the gun just has it's own sound.
But yes, if Port could elaborate, that would be beautiful.

yea the concept sounds simple, but i am an extremely naive coder :p examples are great

Some pseudocode

Code: [Select]
origin = origin-of-sound.getTransform();
for all clients
{
     transform = client.Transform()
     distance = vectorDist(origin, transform)

     if(dist < 50)
          play sound 1 - client.play3D(yourSound, origin)
     else if(dist < 100)
          play sound 2
     else
          play sound 3
}

would i put this in the Onfire function, if not where?

Bump* i need to know where in the code to put this strip ^

Bump* i need to know where in the code to put this strip ^
If you knew how to code at all or knew the definition of pseudocode, you'd realize that isn't any scripting language and you can't just plop it in. Or maybe you realize this and are just wondering where such code would go. And yes, you would put similar code in the onFire function.

alright, and ive seen a couple of your comments on other topics, mind teaching me how to code? ;)


What people seem to always miss is that while it's easy to find mentorship from other scripters, nobody actually wants to sit down and teach you the basics. It's a shame the existing resources for starting scripters are hard to find, I know there were some uncompleted lesson series that covered the bare basics.

What people seem to always miss is that while it's easy to find mentorship from other scripters, nobody actually wants to sit down and teach you the basics. It's a shame the existing resources for starting scripters are hard to find, I know there were some uncompleted lesson series that covered the bare basics.
I know right. It's so much easier to teach someone to code by sitting down with them and just doing it, but who wants to do that?

thats a shame, i guess thats what the coding help section is for, so for all you people saying that "instead of asking people for a code, learn to script" lets see you come up with the time to sit down and teach someone ;) just how i look at it.