No Ammo Weapons
Author: [SL1CK]-=MERL1N=-Source: https://www.insideqc.com/qctut/qctut-45.shtml
Step 1
Everybody who first gets into QC makes a patch with an unbearable amount of weapons with every weapon model they can find :) But what happens when you have more than 1 axe/knife/sword/hammer/fist ? We dont want nails turning up when we select a knife do we? Just follow these steps to give it no ammo :)We will make the shotgun have no ammo for this example, but you can use it on any weapon :)
Open up "weapons.qc" and go to the shotgun fire thing "W_FireShotgun"
remove this line :
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
So you wont loose ammo when you fire...
..
Step 2
Go down to "player weapon use" (you should be familiar with this by now) and in "W_SetCurentAmmo" go to the shotgun, which looks like this...
else if (self.weapon == IT_SHOTGUN)
{
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
self.items = self.items | IT_SHELLS;
}
Change it to this...
{
self.currentammo = 0; // no ammo
self.weaponmodel = "progs/v_shot.mdl"; // same weapon model
self.weaponframe = 0; // same weaponframe
}
..
Step 3
notice we took out self.items ? you can guess why :) now scroll down to "W_CheckNoAmmo" under the axe bit add in this...
else if (self.weapon == IT_SHOTGUN) // if its the shotgun
return TRUE; // thats ok
..
Step 4
Right, scroll down a little further to "W_ChangeWeapon", and go to the shotgun bit.
Delete the lines that say...
W_CheckNoAmmo();
am = 1;
So that it looks like the axe above it (but with IT_SHOTGUN :)
..
Step 5
Under all that there are the cycle weapon functions, find the shotgun in both and delete the lines about the ammo
if (self.ammo_shells < 1) //this one
am = 1; // and this one
Dont forget to do it later in the reveerse cycle commands as well :)
..
Step 6
Thats it for "weapons.qc" save and close and open up "client.qc"
Go down to "PlayerPreThink (3/4 down) and new the end you will see sumthin like this...
if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE)
Change it to this...
if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE && self.weapon != IT_SHOTGUN)
..
Step 7
OK time out, what the hell is "&&" and that "!=" stuff?
That "&&" means "and", like "||" means or, it says if your weapon is an axe (do sumthing) AND if its a shotgun (do sumthin)
As for the "!=" that basically means "if its not" so, regarding your weapon IF ITS NOT a shotgun/axe (do sumthin), its kinda like an exception statement, youll get used to it.
..
Step 8
That's about it, now go and shoot your shotgun for eternity, and then try it with another weapon (preferably a melee weap :)