local PLUGIN = PLUGIN

SWEP.Base = "exp_tacrp_base"
SWEP.Spawnable = true

AddCSLuaFile()

-- names and stuff
SWEP.PrintName = "Ruger Mini-14"
SWEP.AbbrevName = "Mini-14"
SWEP.Category = "Tactical RP"

SWEP.SubCatTier = "4Consumer"
SWEP.SubCatType = "5Sporter Carbine"

SWEP.Description =
"Lightweight rifle with no stock or optic mount.\nGood hip-fire accuracy among rifles, but range is low."

SWEP.Trivia_Caliber = ".223 Remington"
SWEP.Trivia_Manufacturer = "Sturm, Ruger & Co."
SWEP.Trivia_Year = "1973"

SWEP.Faction = PLUGIN.FACTION_MILITIA
SWEP.Credits = "Assets: Tactical Intervention"

SWEP.ViewModel = "models/weapons/tacint/v_m1.mdl"
SWEP.WorldModel = "models/weapons/tacint/w_m1.mdl"

SWEP.Slot = 2

SWEP.BalanceStats = {
	[PLUGIN.BALANCE_SBOX] = {
		Damage_Max = 22,
		Damage_Min = 14,
		ArmorPenetration = 0.8,
		ArmorBonus = 1,

		BodyDamageMultipliers = {
			[HITGROUP_HEAD] = 4,
			[HITGROUP_CHEST] = 1,
			[HITGROUP_STOMACH] = 1.25,
			[HITGROUP_LEFTARM] = 1,
			[HITGROUP_RIGHTARM] = 1,
			[HITGROUP_LEFTLEG] = 0.9,
			[HITGROUP_RIGHTLEG] = 0.9,
			[HITGROUP_GEAR] = 0.9
		},

		RPM = 600,
		RecoilSpreadPenalty = 0.003,
		HipFireSpreadPenalty = 0.008,
	},
	[PLUGIN.BALANCE_TTT] = {

		Damage_Max = 20,
		Damage_Min = 12,
		Range_Min = 500,
		Range_Max = 1500,
		RPM = 300,

		Spread = 0.0075,
		HipFireSpreadPenalty = 0.005,
		RecoilSpreadPenalty = 0.005,

		BodyDamageMultipliers = {
			[HITGROUP_HEAD] = 3,
			[HITGROUP_CHEST] = 1.25,
			[HITGROUP_STOMACH] = 1,
			[HITGROUP_LEFTARM] = 0.9,
			[HITGROUP_RIGHTARM] = 0.9,
			[HITGROUP_LEFTLEG] = 0.75,
			[HITGROUP_RIGHTLEG] = 0.75,
			[HITGROUP_GEAR] = 0.9
		},
	},
	[PLUGIN.BALANCE_PVE] = {
		Damage_Max = 10,
		Damage_Min = 4,

		RPM = 450,
		RecoilSpreadPenalty = 0.003,
		HipFireSpreadPenalty = 0.008,
	},
	[PLUGIN.BALANCE_OLDSCHOOL] = {
		RecoilSpreadPenalty = 0.007
	},
}

-- "ballistics"

SWEP.Damage_Max = 22
SWEP.Damage_Min = 12
SWEP.Range_Min = 800
SWEP.Range_Max = 2500
SWEP.Penetration = 7
SWEP.ArmorPenetration = 0.775
SWEP.ArmorBonus = 0.75

SWEP.BodyDamageMultipliers = {
	[HITGROUP_HEAD] = 4,
	[HITGROUP_CHEST] = 1,
	[HITGROUP_STOMACH] = 1,
	[HITGROUP_LEFTARM] = 1,
	[HITGROUP_RIGHTARM] = 1,
	[HITGROUP_LEFTLEG] = 0.9,
	[HITGROUP_RIGHTLEG] = 0.9,
	[HITGROUP_GEAR] = 0.9
}

SWEP.MuzzleVelocity = 22000

-- misc. shooting

SWEP.Firemode = 1

SWEP.RPM = 450
SWEP.RPMMultSemi = 0.75

SWEP.Spread = 0.0045
SWEP.RecoilSpreadPenalty = 0.003
SWEP.HipFireSpreadPenalty = 0.0055

SWEP.RecoilResetInstant = false
SWEP.RecoilPerShot = 1
SWEP.RecoilMaximum = 6
SWEP.RecoilResetTime = 0.01
SWEP.RecoilDissipationRate = 18
SWEP.RecoilFirstShotMult = 1.25

SWEP.RecoilVisualKick = 1
SWEP.RecoilKick = 5
SWEP.RecoilStability = 0.25


SWEP.CanBlindFire = true

-- handling

SWEP.MoveSpeedMult = 0.95
SWEP.ShootingSpeedMult = 0.85
SWEP.SightedSpeedMult = 0.8

SWEP.ReloadSpeedMult = 0.5

SWEP.AimDownSightsTime = 0.24
SWEP.SprintToFireTime = 0.3

SWEP.Sway = 0.7
SWEP.ScopedSway = 0.25

SWEP.FreeAimMaxAngle = 2

-- hold types

SWEP.HoldType = "ar2"
SWEP.HoldTypeSprint = "passive"
SWEP.HoldTypeBlindFire = false

SWEP.GestureShoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_AR2
SWEP.GestureReload = ACT_HL2MP_GESTURE_RELOAD_SMG1

SWEP.PassiveAng = Angle(0, 0, 0)
SWEP.PassivePos = Vector(0, -2, -4)

SWEP.BlindFireAng = Angle(0, 5, 0)
SWEP.BlindFirePos = Vector(3, -2, -5)

SWEP.SprintAng = Angle(30, -15, 0)
SWEP.SprintPos = Vector(5, 0, -2)

SWEP.SightAng = Angle(0, -0.9, 0)
SWEP.SightPos = Vector(-5.381, -9, -1.99)

SWEP.HolsterVisible = true
SWEP.HolsterSlot = PLUGIN.HOLSTER_SLOT_BACK
SWEP.HolsterPos = Vector(5, -8, -6)
SWEP.HolsterAng = Angle(0, 0, 0)

-- reload

SWEP.ClipSize = 20
SWEP.Ammo = "smg1"

SWEP.ReloadTimeMult = 1
SWEP.DropMagazineModel = "models/weapons/tacint/magazines/m4.mdl"
SWEP.DropMagazineImpact = "metal"

SWEP.ReloadUpInTime = 1.5
SWEP.DropMagazineTime = 0.5

-- sounds

local path = "tacrp/weapons/m1/"

SWEP.Sound_Shoot = "^" .. path .. "fire-1.wav"
SWEP.Sound_Shoot_Silenced = path .. "fire_silenced-1.wav"

SWEP.Vol_Shoot = 120
SWEP.ShootPitchVariance = 2.5 -- amount to vary pitch by each shot

-- effects

-- the .qc attachment for the muzzle
SWEP.QCA_Muzzle = 1
-- ditto for shell
SWEP.QCA_Eject = 2

SWEP.MuzzleEffect = "muzzleflash_ak47"
SWEP.EjectEffect = 2

-- anims

SWEP.AnimationTranslationTable = {
	["fire1"] = "fire1_M",
	["fire2"] = "fire2_M",
	["fire3"] = "fire3_M",
	["fire4"] = "fire4_M",
	["fire5"] = "fire5_M",
	["melee"] = { "melee1", "melee2" }
}

SWEP.ProceduralIronFire = {
	vm_pos = Vector(0, -0.5, -0.05),
	vm_ang = Angle(0, 0.2, 0),
	t = 0.15,
	tmax = 0.25,
	bones = {
		{
			bone = "bolt_handle",
			pos = Vector(0, 0, -3),
			t0 = 0.05,
			t1 = 0.25,
		},
	},
}

-- attachments

SWEP.AttachmentElements = {
	["foldstock"] = {
		BGs_VM = {
			{ 1, 1 }
		},
		BGs_WM = {
			{ 1, 1 }
		}
	},
	["tactical"] = {
		BGs_VM = {
			{ 2, 1 }
		},
	},
}


SWEP.Attachments = {
	[1] = {
		PrintName = "Muzzle",
		Category = "silencer",
		Bone = "m1_root",
		WMBone = "Box01",
		AttachSound = "tacrp/weapons/silencer_on.wav",
		DetachSound = "tacrp/weapons/silencer_off.wav",
		VMScale = 0.9,
		Pos_VM = Vector(4.9, -0.04, 34.2),
		Pos_WM = Vector(0.1, 29, -0.1),
		Ang_VM = Angle(90, 0, 180),
		Ang_WM = Angle(0, -90, 0),
	},
	[2] = {
		PrintName = "Tactical",
		Category = "tactical",
		Bone = "m1_root",
		WMBone = "Box01",
		AttachSound = "tacrp/weapons/flashlight_on.wav",
		DetachSound = "tacrp/weapons/flashlight_off.wav",
		InstalledElements = { "tactical" },
		Pos_VM = Vector(4, 0.75, 24),
		Pos_WM = Vector(0.9, 17, -1),
		Ang_VM = Angle(90, 0, 90),
		Ang_WM = Angle(-70, -90, 0),
	},
	[3] = {
		PrintName = "Accessory",
		Category = { "acc", "perk_extendedmag", "acc_sling", "acc_duffle" },
		AttachSound = "tacrp/weapons/flashlight_on.wav",
		DetachSound = "tacrp/weapons/flashlight_off.wav",
	},
	[4] = {
		PrintName = "Bolt",
		Category = { "bolt_automatic" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	},
	[5] = {
		PrintName = "Trigger",
		Category = { "trigger_semi" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	},
	[6] = {
		PrintName = "Ammo",
		Category = { "ammo_rifle" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	},
	[7] = {
		PrintName = "Perk",
		Category = { "perk", "perk_melee", "perk_shooting", "perk_reload" },
		AttachSound = "tacrp/weapons/flashlight_on.wav",
		DetachSound = "tacrp/weapons/flashlight_off.wav",
	},
}
