"the Author" of SMOD created a "Custom Weapons" system for SMOD. This system allows the user to create his own custom bullet-based weapons! With a little tweaks to a simple .txt you can make weapons just like the ones seen in SMOD: Tactical!
As an example we will be looking at SMOD: Tactical custom weapons.
So make sure you have SMOD: Tactical installed so you can follow along

BUT THIS IS NOT FOR GMOD!
Custom Weapons are a feature of SMOD ONLY!


One more thing before we start!
DO NOT REPLACE THE SOUNDMANIFEST.TXT FILE WITH THE ONES FOUND IN CS:S REPLACEMENTS
This will break you HL2 Sounds!
Copy ONLY the files in the scripts/weapons/ folder and place them in the /scripts/weapons folder in SMOD or Tactical.


Ok, lets begin.
To make things simple we will take alook at the pistol first.
Open weapon_custom1.txt

It should look something like this (subject to change as I modify SMOD: Tactical, or as "The Author" makes changes to SMOD) :

weapon_custom1.txt
WeaponData
{
	// Weapon data is loaded by both the Game and Client DLLs.
	"printname"			"1911 .45 ACP"
	"viewmodel"			"models/weapons/v_pist_deagle.mdl"
	"playermodel"			"models/weapons/w_usp.mdl"
	"anim_prefix"			"pistol"
	"bucket"			"1"
	"bucket_position"		"4"

	"clip_size"			"8"
	"clip2_size"			"-1"

	"default_clip"			"16"
	"default_clip2"			"-1"

	"primary_ammo"			"357"
	"secondary_ammo"		"None"

	"weight"			"0"
	"item_flags"			"0"

	"BuiltRightHanded"		"0"
	"AllowFlipping"			"1"

	"CSViewModel"			"1"
	"MuzzleType"			"MZSMG"
	"MuzzleSize"			"1.5"
//	"MuzzleAttach"			"0"
	"LagScale"			".5"
	"CSWorldModel"			"0"

	// SMOD Ironsight setting.
	IronSight
	{
		"right"		"2.35"
		"up"		"1"
		"forward"	"-1"
		"fov"		"-10"
	}


	// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
	SoundData
	{
//		"reload"		"Weapon_Pistol.Reload"
		"reload_npc"		"Weapon_Pistol.NPC_Reload"
		"empty"			"Weapon_Pistol.Empty"
		"single_shot"		"Weapon_DEagle.Single"
		"single_shot_npc"	"Weapon_DEagle.Single"
	}

	// Weapon Sprite data is loaded by the Client DLL.
	TextureData
	{
		"weapon"
		{
				"font"		"WeaponIcons"
				"character"	"d"
		}
		"weapon_s"
		{	
				"font"		"WeaponIconsSelected"
				"character"	"d"
		}
		"ammo"
		{
				"font"		"WeaponIcons"
				"character"	"p"
		}
		"ammo2"
		{
				"font"		"WeaponIcons"
				"character"	"t"
		}
		"crosshair"
		{
				"font"		"Crosshairs"
				"character"	"Q"
		}
		"autoaim"
		{
				"file"		"sprites/crosshairs"
				"x"			"0"
				"y"			"48"
				"width"		"24"
				"height"	"24"
		}
	}
	
	"WeaponSpec"
	{
		//	0 : single
		//	1 : automatic
		//	2 : shotgun
		//	3 : autoshotgun
		"WeaponType"	"0"
		"FireRate"	"0.1"
		"UnderWater"	"0"
		
	
		"Options" {
			"ReloadSound"	"0"
			"LastFireSound"	"0"
			"TurnoffScope"	"0"
			"TurnoffIron"	"0"
			"TimeScale"	"1"
			"LastDryFireActivity"	"1"	// not work
		}
		
		"Recoil" {
			"PunchPitch"	"-1 0"
			"PunchYaw"	"-0.2 .2"
			"EnableSnap"	"0"
			"SnapPitch"	"0 0"
			"SnapYaw"	"0 0"
			"Crouch"	"0.5"
			"Amp"		"1.5"
			"PunchLimit"	"0.5"
		}
		
		"Spread" {
			"Default"	"0.1"
			"MaxSpread"	"1"
			"Run"		"0.3"
			"RunSpeed"	"100"
			"Crouch"	"0.8"
			"Fire"		"10.5"
		}
		
		"Bullet" {
			"AmmoType"	"357"
			"Damage"	"20"
			"ShotCount"	"1"
			"Tracer"	"4"
			"Force"		"0.5"
		}

		"Npc" {
			"RifleAnim"	"0"
			"BurstMax"	"3"
			"BurstMin"	"2"
			"FireRate"	"1.0"
			"Range"		"80000"
			"MuzzleFire"	"1"
		}
	}
	
}


HOLY CRAP THATS COMPLICATED!
Ok, really its not.
Lets break it down!

Name Models & Position in the HUD
	"printname"			"1911 .45 ACP"
	"viewmodel"			"models/weapons/v_pist_deagle.mdl"
	"playermodel"			"models/weapons/w_usp.mdl"
	"anim_prefix"			"pistol"
	"bucket"			"1"
	"bucket_position"		"4"

Ok, here we can customize what the weapon's name is, what it looks like, and where it lives on the hud.


Lets look at the first line:

 	"printname"			"1911 .45 ACP"
	"viewmodel"			"models/weapons/v_pist_deagle.mdl"
	"playermodel"			"models/weapons/w_usp.mdl"
	"anim_prefix"			"pistol"
	"bucket"			"1"
	"bucket_position"		"4"
This snipit changes the name of the weapon. When you see the name listed in the HUD it will show whatever you see here. This would be an important time to cover the importance of quotes "". If you forget to close a quote around a variable or value, the weapon will not work correctly!

Next up is the Models:
	"printname"			"1911 .45 ACP"

	"viewmodel"			"models/weapons/v_pist_deagle.mdl"
	"playermodel"			"models/weapons/w_usp.mdl"

	"anim_prefix"			"pistol"
	"bucket"			"1"
	"bucket_position"		"4"
Ok, there are 2 types of weapon models in Half-Life and most source games. V_ Models, and W_ Models.

The V_ models AKA : viewmodel, is what the player sees in first person.

The W_ model AKA: worldmodel Is what NPCs hold in their hands, and represent the item pickups in the game world.

Special note on W_ models.
Counter-Strike Source worldmodels are created diffrently than HL2 Worldmodels. If you try to place a worldmodel from CS:S into HL2 it will work ok for pickups, but NPCs will not be able to hold them! NPCs (like combine) will have the weapons sticking out of their chests. And sometimes they won't even fire. To prevent this from happening use either the W_ models built in with Half-Life 2, or use a converted one from a GMOD SWEP pack.

Finding models:
The models are located in the /models/weapons directory, in most cases. When installing the custom models for you weapons make sure you follow the directions, and keep the directories together. If you don't see the weapons in the /models/weapons directory, you probably did something wrong.

Textures Missing
Do you get pink and black boxes?
This means the model couldn't find its textures in the correct location! Make sure you installed the textures, and if so, make sure they are in the right location.

Ok, lets look at Buckets
	"printname"			"1911 .45 ACP"
	"viewmodel"			"models/weapons/v_pist_deagle.mdl"
	"playermodel"			"models/weapons/w_usp.mdl"
	"anim_prefix"			"pistol"

	"bucket"			"1"
	"bucket_position"		"4"

Buckets
A bucket is where the gun is placed on the HUD. The buckets are numbered 0-5. You may place you weapons in any bucket you like, but HL2 tends to place them like this.
0 : Melee
1 : Pistole
2 : SMG and Rifles
3 : Shotgun & Sniper Rifles
4 : Explosives
5 : Whisky Tango Foxtrot?!? things

The bucket position is where it exists in that bucket. No two weapons may exist in the same bucket and the same bucket_position! This will give you problems when you pick them both up!

Ok, now off to ammo and what not.

	"clip_size"			"8"

	"clip2_size"			"-1"


	"default_clip"			"16"

	"default_clip2"			"-1"

	"primary_ammo"			"357"
	"secondary_ammo"		"None"

	"weight"			"0"
	"item_flags"			"0"
Ammo Capacity
Ok, the "clip_size" is capacity of the weapon. This is how many bullets the player can fire before they are forced to put in a new magazine, belt, whatever. the "default_clip" is how much ammo you find in the weapon when you start with one, or pick one up from an opponent. Custom weapons cannot support clip2 settings at this time so only focus on changing the clip1 settings.

Now for ammo types:
	"clip_size"			"8"
	"clip2_size"			"-1"
	"default_clip"			"16"
	"default_clip2"			"-1"


	"primary_ammo"			"357"

	"secondary_ammo"		"None"

	"weight"			"0"
	"item_flags"			"0"
Ammo Type
This specifies which ammo type is used. The common types are:

smg1
ar2
357
buckshot
pistol

Now for some SMOD specific settings!

	"BuiltRightHanded"		"0"
	"AllowFlipping"			"1"

	"CSViewModel"			"1"
	"MuzzleType"			"MZSMG"
	"MuzzleSize"			"1.5"
//	"MuzzleAttach"			"0"
	"LagScale"			".5"
	"CSWorldModel"			"0"
Left or Right handed
the "buildrighthanded" is set to "1" if the weapon is either a HL2 weapon, or CS:S weapon that was built for right handed use only. In most cases you need to set it to "0"

Now for some intresting commands...

        "CSViewModel"			"1"
	"MuzzleType"			"MZSMG"
	"MuzzleSize"			"1.5"
//	"MuzzleAttach"			"0"
	"LagScale"			".5"
	"CSWorldModel"			"0"

I'll get back to these commands at a later time. They can be kinna advanced. I suggest leaving as is, for now.

Now for the Ironsights!
	// SMOD Ironsight setting.
	IronSight

	{
		"right"		"2.35"
		"up"		"1"
		"forward"	"-1"
		"fov"		"-10"
	}

Ironsights Ok, this can be a real bitch.
when the "ironsight" button is pushed the model is moved to these coordinates. Sounds simple right? Well... It takes some trial and error to get it to work right.

The variables are:
Right : Moves the model to the right or left, based on the value
up : Moves the model up or down, based on the value
foward: Movies the model foward and back, based on the value
pitch : Rolls the model foward and back
yaw : Rolls the model left and right
fov : Changed the Feild of View,

Do your best to avoid using pitch and yaw, they can be difficult to align


next, lets look at sound effects.
SoundData
	{
//		"reload"		"Weapon_Pistol.Reload"
		"reload_npc"		"Weapon_Pistol.NPC_Reload"
		"empty"			"Weapon_Pistol.Empty"

		"single_shot"		"Weapon_DEagle.Single"
		"single_shot_npc"	"Weapon_DEagle.Single"

	}
Sound Effects
Ok, you shouldn't have to play with anything here, other than the "single_shot" and "single_shot_npc" settings. To find out which sound to use consult the file game_sounds_weapons_cs.txt in the /scripts directory.

You want the sounds that are labled "________.single" for example : "Weapon_Glock.Single" will make the sound of a glock shooting.


Next up is the real meat and potatos! Weapon Specs!
	"WeaponSpec"
		{
		//	0 : single
		//	1 : automatic
		//	2 : shotgun
		//	3 : autoshotgun

		"WeaponType"	"0"

		"FireRate"	"0.1"
		"UnderWater"	"0"
Ok, here is where we specify how a weapon fires, its rate of fire, and if it can be shot underwater.

Weapon Type
The first setting is the most important. "WeaponType"
There are 4 diffrent types of weapons, each have their own limitations:

0 : Single Shot, and bursts only
1 : Fully auto, and bursts only
2 : pump action shotguns
3 : Automatic shotguns

When I made the M4, I gave it burst and single shot fire modes. To do this I had to set its "WeaponType" to 0.


Now lets look at firerate
	"WeaponSpec"
		{
		//	0 : single
		//	1 : automatic
		//	2 : shotgun
		//	3 : autoshotgun
		"WeaponType"	"0"

		"FireRate"	"0.1"

		"UnderWater"	"0"
Fire Rate
This won't come into play with pistols as it does with automatic weapons.

Here is where alittle research goes a long way. First look at the gun your trying to put in, and go hit up wikipedia. For example lets look up a M16. The rate of fire is stated as "750 Rounds Per Min". The setting is based off of "Time Between Shots", or TBS. The forumla for calculating TBS is below.

time (sec)		=	s
time between shots	=	TBS
Rounds per minute	=	RPM
Rounds fired per second =	RPS

RPS = RPM/60s
TBS = 1/RPS

FORUMULA : TBS  =  1/(RPM/60)

Lets try it with what we know!

STEP 1 : TBS  =  1/(750/60)
STEP 2 : TBS  =  1/(12.5)
STEP 3 : TBS  =  0.08
Thanks Shakken, for the forumla!


Now if you don't want to be exact or you don't know feel free to put whatever you want. Hell if you think your M16 should fire like a minigun be my guest.

I'm not going to bother much with "underwater". 0 means the gun can't be fired underwater, while 1 means it can. simple enough.

Next up!
options!
		"Options" {

			"ReloadSound"	"0"
			"LastFireSound"	"0"

			"TurnoffScope"	"0"
			"TurnoffIron"	"0"

			"TimeScale"	"1"
			"LastDryFireActivity"	"1"	// not work

		}
Options
Ok, first LEAVE THE FOLLOWING ALONE:
ReloadSound
LastFireSound
TimeScale
LastDryFireActivity

Lets concentrate with the other options...

		"Options" {
			"ReloadSound"	"0"
			"LastFireSound"	"0"

			"TurnoffScope"	"0"
			"TurnoffIron"	"0"

			"TimeScale"	"1"
			"LastDryFireActivity"	"1"	// not work
		}
Scopes and Ironsights
Ok, you have 2 options in SMOD, Burstfire and Scopes. Currently they are mutually exclusive. I don't know why I bother using a term like that, since it will just bring me 10 posts asking "what does mutually exclusive" mean? Mutually exculsive means cannot exist at the same time. So currently you can't have a weapon with both BURST FIRE and a SCOPE.

However you may use a scope and ironsights at the same time. I have only used this with the G36.

When you use the scope it referes to the settings of the "scope" settings.
If you set either of these options to 0 it disables them.

Next up, Burst fire!

		"Burst" {

			"FireCount"	"3"
			"Delay"		"0.075"

		}
Burst Fire
Ok, for having only two option this can be alittle tricky.

The easy part is "FireCount"
This is how many shots the gun spits out when you fire the burst.

This is how SMOD's burstfire system works. You may toggle between only 2 fire settings. Standard fire and Burst fire. Depending on the weapon type you selected in the options, determines how burstfire acts. Also if you have a scope or not modifies how Burstfire acts.

If you have your weapon type set to "0" (Pistol):
This allows the weapon to fire in single shots or bursts. Default the weapon will fire single shot, and will only fire once shot or one burst per trigger pull.

If you have your weapon type set to "1" (Automatic):
This will allow the weapon to fire in automatic fire or bursts. By Default the weapon will fire automatic. In burst mode the weapon will pause based on the "delay" of the weapon, then fire again.
v If you have a scope enabled, when you activate the scope the weapon will fire its "burst mode" only when the scope is active.

Finally if you don't want a weapon to have Burst. please delete these lines of text. This will disable the ablity to use burst fire.

OK! Now for Recoil!
		"Recoil" {

			"PunchPitch"	"-1 0"
			"PunchYaw"	"-0.2 .2"

			"EnableSnap"	"0"
			"SnapPitch"	"0 0"
			"SnapYaw"	"0 0"

			"Crouch"	"0.5"

			"Amp"		"1.5"

			"PunchLimit"	"0.5"

		}
Weapon Recoil
Ok, when you fire a weapon it should kick alittle.
When using ironsights you want to keep the kick even with the ironsights at all times. To do this only use the "Punch" settings.

We will only be messing with the settings in red.

Ok, the first up is Pitch. Think of this as the up & down movement of the weapon. There are two numbers, they represend the max and min of the setting. Numbers can be both positive and negative.

Next is the yaw setting. Think of this as the left and right movement of the gun. Just like with pitch, ther are two numbers that represent the max and min values, and also they can be both positive and negative numbers.

The Crouch setting modifies reduces the effect of recoil while crouched. The lower the number the less recoil you will see.

Finally, the PunchLimit setting represents the max value of a recoil. When you fire the gun will move off center and then glide back to origin. if you fire before the gun reaches its destination, the gun will move from that postion outward further. The PunchLimit setting sets the max distace the gun is allowed to drift from the origin.

Next up is the Spread.
Put your money back, this has nothing to do with gambling.
	"Spread" {
			"Default"	"4"
			"MaxSpread"	"6"

			"Run"		"100.0"

			"RunSpeed"	"100"
			"Crouch"	"1"
			"Fire"		"1"
		}
Bullet Spread
In most weapons you only will use the Recoil settings. but in the case of a shotgun, you want to invoke these settings. Most weapons you will only modify the "run" setting. And I would suggest setting it to 0.

next we will discuss projectile spread with shotguns
	"Spread" {

			"Default"	"4"
			"MaxSpread"	"6"

			"Run"		"100.0"
			"RunSpeed"	"100"
			"Crouch"	"1"
			"Fire"		"1"
		}
Shotguns
Ok, so lets say you want to make a scatter gun.
First setting in this process is "default" this is the default distance of spread before adding in any other variables.

The "MaxSpread" represents the farthest a projectile will go from the center of the shot.

The other settings I would suggest leaving as is.

Next up! BULLETS!
		"Bullet" {

			"AmmoType"	"ar2"
			"Damage"	"25"
			"ShotCount"	"1"
			"Tracer"	"2"
			"Force"		".2"

		}
Bullet Settings
Here we can change how the projectiles look, and act in the game world.

First up is the "AmmoType" This setting represent the effects, tracer style and sound the bullets make. the type can be:

pistol
ar2
buckshot
smg1

Next up is the "Damage" this is the unmodified damage ammount a projectile does to an opponent on impact.

The "shotcount" setting shows how many bullets are filed from one pull of the trigger. This is usually reserved for shotgun based weapons. If you're going for realism check the "shot count" on the amuntion's stats when doing research. that should equal the amount of "shotcount" you should place in this setting.

After that is "tracer" setting this sets when the tracer fires. In the example above the gun will displace a tracer every two shots. If you "rem" out the line with "//" No tracers will be displayed.

Finally there is "force" thisis how much power is put against physics objects when the bullet impacts with them. This also shows how hard opponents will be knocked back with a deathblow.

Next up!
Bad guys come'n DefCon 62 uahhh!!!
		"Npc" {

			"RifleAnim"	"0"
			"BurstMax"	"3"
			"BurstMin"	"2"
			"FireRate"	"1.0"
			"Range"		"80000"
			"MuzzleFire"	"1"

		}
NPC Weapon Usage
Ok now to setup how the NPCs use the guns!

First up is the "rifleanim" this works just like "type" setting under the "options" settings.
0 Pistol
1 Rifle
3 Shotgun

The "BurstMax" setting determins the max bullets the opponent will fire at you before attempting another action. To set the least amout of bullets fire use the "BurstMin" setting.

The "firerate" specifies how fast the NPCS can fire. This can be tricky for weapons like shotguns. In their case this represents how often they fire at you.

Range Is how far an opponent will attempt to fire his weapon if he can see you. If this setting is too low, and you fire at the oppoent, he won't "wake up" to return fire. I suggest putting this as high as possible.

The "MuzzleFire" setting represetns what type of muzzle flash to display when the gun fires. This is simular to "type" under "options".
0 Pistol
1 Rifle
3 Shotgun

If you have any questions on SMOD custom weapons, please post them below!
END OF WEAPON INSTUCTIONS| EXTRAS BELOW



Weapon Sounds Changes
"Weapon_Glock.Single"
{
	"channel"		"CHAN_WEAPON"
	"volume"		"1.0"
	"CompatibilityAttenuation"	"ATTN_NORM"
	"pitch"		"PITCH_NORM"

	"wave"			")weapons/glock/glock18-1.wav"
}
How sound calls work
When something makes a sound in SMOD, or even HL2 the uses the sound manifests and sound config files for instuctions on where the wave file is placed and how to play it.

Today we will look at the sound for a glock fire sound as a refrence. The orginal script info can be found in the tactical directory /scripts. The file name is "game_sounds_weapons_cs.txt".

First go ahead and leave the "channel", "CompatibilityAttenuation", "pitch" alone.

The "volume" setting mods the volume of the sound. If the sound FX you have is too light, use this option to boost it up inside of the game.

Finally the "wave" setting is the directory relative to the installed game. When the sound file is called it will look here for the sound. If you place your custom sound in its own directory in another location, make sure you place the path here. And make sure its relative to the mod directory.

If you need help finding the coordinates for the ironsites, use the following config