Author Topic: 2D Sound Effects in Weapons?  (Read 3200 times)

Okay, i'll keep it simple:
I'm trying to make a silenced pistol. I got all the code sorted out and everything, and I was a bit puzzled on one aspect.

Usually, guns use AudioClosest3d to play 3D sounds to other clients, such as a firing sound, or reload, etc.

As well as having a 3d sound effect, is it possible to add a 2d sound effect that plays only to the client/wielder of the weapon? I want to have a barely audible 3d firing noise, and a separate, louder firing noise that plays only to the client.

Is this possible? If so, what steps should I take to make it happen?

All help is appreciated.

2D sound: is not possible
What you want: to an extent, is possible

the way how I see this could work, is that you make the player emit a sound with a modified sound profile; the sound heard by everyone keeps the default sound profile and is emitted by the weapon, but the one only the wielder hears will have an extremely short-range profile, and will emit from the player

idk try a profile like this
Code: [Select]
datablock AudioDescription(newProfile3d : AudioClose3d)
{
maxDistance = 1;
referenceDistance = 1;
};

2D sound: is not possible

LOL, what?

Code: [Select]
new AudioDescription(blahblah)
{
     is3D = false;
     isLooping = false;
     type = 8;
};

Proven and tested to work using alxPlay(alxCreateSource(blahblah, "Filepath"));

Edit:
I use this as client-side, idk if the same would apply server-side, but it should so long as you define your audio description as 2D like above.
« Last Edit: July 21, 2014, 12:44:39 AM by Thorfin25 »

Datablock type is normal, as in

datablock AudioProfile(bigrichardSound)
{
   filename    = "./bigrichard.wav";
   description = AudioClose3d;
   preload = true;
};



The important thing is using it.

serverplay2d(bigrichardSound);

Datablock type is normal, as in

datablock AudioProfile(bigrichardSound)
{
   filename    = "./bigrichard.wav";
   description = AudioClose3d;
   preload = true;
};



The important thing is using it.

serverplay2d(bigrichardSound);

Tried this already. Unfortunately, that plays the 2d sound serverwide, which is not what I want. This is identical to:

datablock AudioProfile(bigrichardSound)
{
   filename    = "./bigrichard.wav";
   description = Audio2d;
   preload = true;
};



Anyways, maybe some people may be confused by the way I worded it. Here is a more simplified manner:




This image was taken from the Fallout 3 GECK, which handles audio in a similar manner to what I want.

Attack Sound (2d) is the audio file played ONLY to the wielder of the weapon, so in blockland's case, whichever client fired the gun in the first place. When they fire, only that ONE client will hear the 2d audio.

Attack Sound (3d) is the audio file played to EVERY CLIENT in range. Basically AudioClosest3d. This will also be played to the client that fired the gun. I don't mind this.

Attack Sound (DIST) is some random bullstuff I don't care about. Ignore that.



So far, I've tried every solution mentioned above to no avail. They either play the 2d sound serverwide so everybody can hear it regardless of their range, or it doesn't play at all. If there really is no way to have correct 2d sound, i'll just forget about this and lock the topic. I understand that Weapons are server-sided mods, so I won't be surprised if it doesn't work, but thank you anybody who tried to help.

Did you try this?
Code: [Select]
new AudioDescription(blahblah)
{
     is3D = false;
     isLooping = false;
     type = 8;
};

Then slap it in your AudioProfile as the description.
Code: [Select]
datablock AudioProfile(smallrichardSound)
{
    filename = ".smallrichard.wav";
    description= Blahblah;
    preload = true;
}

Okay well I found out the solution, which was to simply remove the stateSound[] sequence and instead insert this into the WeaponImage::onFire() function:

Code: [Select]
if(isObject(%obj.client))
{
%obj.client.play2d(gunshot1sound);
}

Solved. Locking now...
[Thanks to Zeblote for solution]