Skip to content

Mod Development: Weapons Scripting

vingard edited this page May 27, 2024 · 9 revisions

Basics

If you view your game directory, and look inside the tacint folder, you will see lots of txt files. These are scripts. Any of these files can be editied in a mod. When editing scripts it is important to remember, the server and the client will both need to have the same script files for most edits to work. This depends on what the script does, for example, you can still edit most sound scripts on the client only. However weapons, must also be edited on the server for all properties to be applied correctly.

Note

  • You may also see some ctx files, these are encrypted script files. You can safely ignore these as any txt script with the same name will overwrite them and be loaded instead!

Weapon scripts

Weapon scripts can be found in the scripts folder of the tacint directory. They are prefixed with weapon_. To get started, copy the script of the weapon you wish to edit/replace and make a new mod. Create a scripts folder and paste the script inside. Do not edit the tacint directory directly.

Now inside your mod, feel free to edit the weapon script, any changes you make will be applied once you mount/sync your mod and restart your game. To start with, try decreasing the CycleTime value (fire-rate value) to make the weapon fire super fast.

Vehicle scripts

Vehicle scripts work just like weapon scripts and are located in the scripts/vehicles directory.

Example of the AK47 weapon script

"WeaponData"
{
	"WeaponType"		"Rifle"
	"Damage"		"31"
	"Bullets"		"1"
	"CycleTime"		"0.092308"
	"MaxSpeed"		"300"
	"WeaponPrice"		"3200"
	"WeaponArmorRatio"		"1.400000"
	"CrosshairMinDistance"		"3"
	"CrosshairDeltaDistance"		"3"
	"Penetration"		"2"
	"ReloadTime"		"2.900000"
	"DeployTime"		"1.15"
	"Range"				"6950"
	"RangeModifier"		"0.980000"
	"AccuracyDivisor"	"200"
	"AccuracyOffset"	"0.350000"
	"MaxInaccuracy"		"1.250000"
	"Mobility"			"42"
	"BlindOffset"		"2.2"
	
	"printname"		"AK47"
	"viewmodel"		"models/weapons/v_ak47.mdl"
	"playermodel"		"models/weapons/w_ak47.mdl"
	"playermodelattachment"		"rifle_attachment"
	"PlayerAnimationExtension"		"sg551"
	"anim_prefix"		"anim"
	"bucket"		"0"
	"bucket_position"		"2"
	"clip_size"		"30"
	"primary_ammo"		"AMMO_RIFLE_762MM"
	"secondary_ammo"		"None"
	"weight"		"25"
	"item_flags"		"0"
	"MuzzleFlash"	"x"
	
	"RecoilSeed"			223
	
	//const float ak47kick_table[]	= {	0.75,	10.3,	0.5,	0.25,	9,	75	};
	"KickData"
	{
		"up_base"						"0.35"
		"up_max"						"9.3"
		"lateral_max"					"0.5"
		"bias"							"0.40"
		"midpoint"						"12"
		"direction_change"				"75"
	}
	//const float spreadBaseAK47[]		= { 0.45f,		0.171f,	0.12f,		0.0035f	};
	"Inaccuracy"
	{
		"air"							"0.45"
		"running"						"0.13085"
		"walking"						"0.0955"
		"idle"							"0.0035"
	}
	//#define AK47_SPREADRATIO		0.123f
	//#define AK47_SPREADBIAS			0.43f	
	"SpreadRatio"	"0.123"				//and have a tighter cone than amd65
	"SpreadBias"	"0.46"				//get worse "slower" than amd65
	
	"SoundData"
	{
		"reload"		"Player.SG551Reload"
		"deploy"		"Player.SG551Deploy"
		"empty"		"Weapon_GenericRifle.DryFire"
		"single_shot"		"Weapon_AK47.Fire"
		"special1"		"Weapon_AK47.Fire_Silenced"
		"melee_hit"		"Weapon.Melee_Body_Hit"
		"melee_hit_world"		"Weapon.Melee_Hit"
	}

	"ModelBounds"
	{
		"Viewmodel"
		{
			"Mins"		"-10 -4 -13"
			"Maxs"		"21 9 -1"
		}
		"World"
		{
			"Mins"		"-10 -7 -6"
			"Maxs"		"22 8 9"
		}
	}
}
Clone this wiki locally