This tutorial is very basic, and is directed towards newer coders.
First, let's take a look at what a sound function looks like.
1. Self, is the entity that is playing the sound. If you are calling the FireFunction like W_FireShotgun, then self is whoever is calling that function (In this case, Firing the weapon)
2. CHAN_WEAPON is the channel that the sound effect is on. There are multiple channels, and I would suggest putting different sound effects on different channels. If not, then the entity that is calling the sound will override any other sounds it uses. Let's say you make the jump sound effects CHAN_WEAPON and keep the Fire sound CHAN_WEAPON. Then One of the sounds will stop playing when another is called. So try to put pain sounds and other Player sounds on CHAN_VOICE. Here is the list of the channels.
You can find these definitions of the channels in defs.qc
So those are your channels to work with. Try to put sounds that are played alot on different channels.
3. The string is to show the function where the sound effect is located. That is pretty obvious
4. The value (#1 in this function), is how loud the sound is. It needs to be between 0.0-1.0, or else you will get an error.
5. ATTN_NORM.That is the sound fall off. The farther away you go from the sound, the more it Gets Quieter. Here is the list of them, again, you can find it in defs.qc
Then if you are using a new sound effect that isn't In Quake or the mod, then you must precache it so Quake knows what the sound is. A precache looks like this...
You can add this to 2 default locations in the Code.
First, is weapons.qc at the very top in the function void() W_Precache =
Or you can do it in World.qc in the function void() worldspawn =
Doesn't really matter which you do it on. It is all a matter of Choice.
And that wraps this infotutorial up!
-Mexicougr
First, let's take a look at what a sound function looks like.
sound (self, CHAN_WEAPON, "weapons/ar/fire.wav", 1, ATTN_NORM);
1. Self, is the entity that is playing the sound. If you are calling the FireFunction like W_FireShotgun, then self is whoever is calling that function (In this case, Firing the weapon)
2. CHAN_WEAPON is the channel that the sound effect is on. There are multiple channels, and I would suggest putting different sound effects on different channels. If not, then the entity that is calling the sound will override any other sounds it uses. Let's say you make the jump sound effects CHAN_WEAPON and keep the Fire sound CHAN_WEAPON. Then One of the sounds will stop playing when another is called. So try to put pain sounds and other Player sounds on CHAN_VOICE. Here is the list of the channels.
You can find these definitions of the channels in defs.qc
// sound channels
// channel 0 never willingly overrides
// other channels (1-7) allways override a playing sound on that channel
float CHAN_AUTO = 0;
float CHAN_WEAPON = 1;
float CHAN_VOICE = 2;
float CHAN_ITEM = 3;
float CHAN_BODY = 4;
So those are your channels to work with. Try to put sounds that are played alot on different channels.
3. The string is to show the function where the sound effect is located. That is pretty obvious
4. The value (#1 in this function), is how loud the sound is. It needs to be between 0.0-1.0, or else you will get an error.
5. ATTN_NORM.That is the sound fall off. The farther away you go from the sound, the more it Gets Quieter. Here is the list of them, again, you can find it in defs.qc
float ATTN_NONE = 0; //No fall off. You can hear it anywhere in the level.
float ATTN_NORM = 1; // A decent fall off in Sound/ DEFAULT
float ATTN_IDLE = 2; //Kind of Quiet to hear
float ATTN_STATIC = 3; //Very hard to hear from a ways away.
Then if you are using a new sound effect that isn't In Quake or the mod, then you must precache it so Quake knows what the sound is. A precache looks like this...
precache_sound ("weapons/ar/fire.wav");
You can add this to 2 default locations in the Code.
First, is weapons.qc at the very top in the function void() W_Precache =
Or you can do it in World.qc in the function void() worldspawn =
Doesn't really matter which you do it on. It is all a matter of Choice.
And that wraps this infotutorial up!
-Mexicougr