Silencer
Created By: Marius
eMail: lordshoel@yahoo.com
Difficulty Scale: Easy


In this tutorial I'll show you how to add a simple but cool Silencer for both of the Nailguns. It is very easy to add and quite fun to play with, also this would be great in a multiplayer patch... You will need silencer.zip which contains one wave file Silencer.wav which must be placed in the weapons folder within the Sound folder as follows:

	\Quake\Mymod\Sound\Weapons\silencer.wav
Note: Mymod is the directory of this modification.

Step 1.

Open up Defs.qc and scroll to the very bottom. Then add the following varibles:

//Silencer 
.float silencer_on;
The above does not need to be at the bottom but it is easy and will not interfere with anything that might cause errors.

Step 2.

Ok open up Weapons.qc and scroll to the ImpulseCommands function. Once there paste the following code above the QuadCheat impulse.

if (self.impulse == 15)		
{
		if (self.silencer_on == FALSE) 
		{ 
			self.silencer_on = TRUE; 
			centerprint (self, "Silencer Acivated\n");
		}
		else if (self.silencer_on == TRUE) 
		{ 
			self.silencer_on = FALSE; 
			centerprint (self, "Silencer Deacivated\n");
		}
}
When you've finished there scroll up to the function W_Precache. At the bottom of that function paste:

	precache_sound ("weapons/silencer.wav");
Once that is done save and go onto Step 3.

Step 3.

Still in Weapons.qc find the functions W_FireSpikes & W_FireSuperSpikes. Found them? If you have find the sound for each weapon.

For the Super Spikes replace:

	sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
With the following:

	if (self.silencer_on == TRUE) 
	sound (self, CHAN_WEAPON, "weapons/silencer.wav", 1, ATTN_NORM);
	else sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
For the normal spikes replace:

	sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
With the following:

	if (self.silencer_on == TRUE) 
	sound (self, CHAN_WEAPON, "weapons/silencer.wav", 1, ATTN_NORM);
	else sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);

Step 4.

Once done there close Weapons.qc and open Client.qc. Scroll down to the PutClientInServer function. When you have found that function scroll about half way through it till you find W_SetCurrentAmmo(); Then above that paste:

	self.silencer_on = FALSE;
The above line turns the silencer off when entering the server, so when you die and respawn or start a new level the silencer is automatically off.

Step 5.

Open up Player.qc. Find the functions Player_Nail1 and Player_Nail2. Once you have found them delete the following line from each:

	SuperDamageSound();
That was the last part of code to be modified. All thats left is Step 6...

Step 6.

Save and Compile. Pretty simple wasn't it? Have fun playing with your 'new toy'...