local PLUGIN = PLUGIN

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

AddCSLuaFile()

-- names and stuff
SWEP.PrintName = "Benelli M4"
SWEP.Category = "Tactical RP"

SWEP.SubCatTier = "1Elite"
SWEP.SubCatType = "5Shotgun"

SWEP.Description = "Semi-automatic shotgun with very high damage output. Reloading may be a chore."
SWEP.Description_Quote = "There's nothing seven 12 Gauge shotshells can't solve."

SWEP.Trivia_Caliber = "12 Gauge"
SWEP.Trivia_Manufacturer = "Benelli Armi S.p.A."
SWEP.Trivia_Year = "1999"

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

SWEP.ViewModel = "models/weapons/tacint/v_m4star10.mdl"
SWEP.WorldModel = "models/weapons/tacint/w_m4star10.mdl"

SWEP.Slot = 2
SWEP.SlotAlt = 3


SWEP.BalanceStats = {
	[PLUGIN.BALANCE_SBOX] = {
		Damage_Max = 10,
		Damage_Min = 5,

		FreeAimMaxAngle = 5,
	},
	[PLUGIN.BALANCE_TTT] = {
		Damage_Max = 7,
		Damage_Min = 3,
		Range_Min = 300,
		Range_Max = 2000,
		RPM = 180,

		FreeAimMaxAngle = 5,

		RecoilSpreadPenalty = 0.02,

		BodyDamageMultipliers = {
			[HITGROUP_HEAD] = 2,
			[HITGROUP_CHEST] = 1,
			[HITGROUP_STOMACH] = 1,
			[HITGROUP_LEFTARM] = 1,
			[HITGROUP_RIGHTARM] = 1,
			[HITGROUP_LEFTLEG] = 0.75,
			[HITGROUP_RIGHTLEG] = 0.75,
			[HITGROUP_GEAR] = 0.9
		},
	},
	[PLUGIN.BALANCE_PVE] = {
		Damage_Max = 11,
		Damage_Min = 7,
		RPM = 240,

		RecoilKick = 8,
		RecoilSpreadPenalty = 0.0075,
		Spread = 0.02,

		BodyDamageMultipliers = {
			[HITGROUP_HEAD] = 1.5,
			[HITGROUP_CHEST] = 1,
			[HITGROUP_STOMACH] = 1,
			[HITGROUP_LEFTARM] = 0.75,
			[HITGROUP_RIGHTARM] = 0.75,
			[HITGROUP_LEFTLEG] = 0.5,
			[HITGROUP_RIGHTLEG] = 0.5,
			[HITGROUP_GEAR] = 0.9
		},
	},
	[PLUGIN.BALANCE_OLDSCHOOL] = {
		RecoilMaximum = 3,
		RecoilDissipationRate = 5,
		RecoilResetTime = 0.3,
	}
}

-- "ballistics"

SWEP.ShootTimeMult = 0.5

SWEP.Damage_Max = 12
SWEP.Damage_Min = 9
SWEP.Range_Min = 900  -- distance for which to maintain maximum damage
SWEP.Range_Max = 2000 -- distance at which we drop to minimum damage
SWEP.Penetration = 1  -- units of metal this weapon can penetrate
SWEP.ArmorPenetration = 0.8
SWEP.ArmorBonus = 2

SWEP.Num = 8

SWEP.MuzzleVelocity = 9000

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

-- misc. shooting

SWEP.Firemode = 1

SWEP.RPM = 240

SWEP.Spread = 0.03
SWEP.ShotgunPelletSpread = 0.01

SWEP.HipFireSpreadPenalty = 0.015
SWEP.MidAirSpreadPenalty = 0

SWEP.RecoilPerShot = 1
SWEP.RecoilMaximum = 2
SWEP.RecoilResetTime = 0.2   -- time after you stop shooting for recoil to start dissipating
SWEP.RecoilDissipationRate = 3.5
SWEP.RecoilFirstShotMult = 1 -- multiplier for the first shot's recoil amount

SWEP.RecoilVisualKick = 1.5
SWEP.RecoilKick = 10
SWEP.RecoilStability = 0.1

SWEP.RecoilSpreadPenalty = 0.025

SWEP.CanBlindFire = true

-- handling

SWEP.MoveSpeedMult = 0.9
SWEP.ShootingSpeedMult = 0.65
SWEP.SightedSpeedMult = 0.75

SWEP.ReloadSpeedMult = 0.5

SWEP.AimDownSightsTime = 0.35
SWEP.SprintToFireTime = 0.35

-- hold types

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

SWEP.GestureShoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW
SWEP.GestureReload = ACT_HL2MP_GESTURE_RELOAD_SHOTGUN

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

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

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

SWEP.SightAng = Angle(0.2, 0.5, 0)
SWEP.SightPos = Vector(-2.9, -5, -4.2)

SWEP.SightPos = Vector(-2.815, -4, -4.025)
SWEP.SightAng = Angle(0.4, -0.75, 0)

SWEP.CorrectivePos = Vector(-0.05, 0, -0.1)
SWEP.CorrectiveAng = Angle(0.395, 1.039, 0)

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

SWEP.Sway = 0.8
SWEP.ScopedSway = 0.25

SWEP.FreeAimMaxAngle = 3.5

-- reload

SWEP.ClipSize = 7
SWEP.Ammo = "buckshot"
SWEP.ShotgunReload = true

SWEP.ReloadTimeMult = 1.15

SWEP.JamBaseMSB = 9

-- sounds

-- local path = "tacrp/weapons/m4star10/"

SWEP.Sound_Shoot = "^tacrp/weapons/m4star10/fire-2.wav"
SWEP.Sound_Shoot_Silenced = "tacint/weapons/sg551/sg551_fire_silenced-1.wav"

SWEP.Vol_Shoot = 130
SWEP.ShootPitchVariance = 0 -- amount to vary pitch by each shot

-- effects

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

SWEP.MuzzleEffect = "muzzleflash_m3"
SWEP.EjectEffect = 3

-- anims

SWEP.AnimationTranslationTable = {
	["fire"] = { "shoot1", "shoot2" },
	["blind_fire"] = { "blind_shoot1" },
	["melee"] = { "melee1", "melee2" },
	["reload"] = { "reload", "reload2" },
	["jam"] = "reload_finish"
}

-- attachments

SWEP.Attachments = {
	[1] = {
		PrintName = "Optic",
		Category = { "optic_cqb", "optic_medium" },
		Bone = "ValveBiped._ROOT_Super90",
		InstalledElements = { "sights" },
		AttachSound = "tacrp/weapons/optic_on.wav",
		DetachSound = "tacrp/weapons/optic_off.wav",
		VMScale = 0.75,
		Pos_VM = Vector(-5.25, 0.2, 8),
		Pos_WM = Vector(11, 1.5, -5.5),
		Ang_VM = Angle(90, 0, 0),
		Ang_WM = Angle(0, 0, 180),
	},
	[2] = {
		PrintName = "Tactical",
		Category = "tactical",
		Bone = "ValveBiped._ROOT_Super90",
		AttachSound = "tacrp/weapons/flashlight_on.wav",
		DetachSound = "tacrp/weapons/flashlight_off.wav",
		InstalledElements = { "tactical" },
		VMScale = 1.25,
		Pos_VM = Vector(-3, 1, 15),
		Pos_WM = Vector(19, 0.25, -3.75),
		Ang_VM = Angle(90, 0, 90),
		Ang_WM = Angle(0, 0, -90),
	},
	[3] = {
		PrintName = "Accessory",
		Category = { "acc", "acc_duffle", "acc_extmag_shotgun", "acc_sling" },
		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",
	},
	[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_shotgun" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	}
}

local function addsound(name, spath)
	sound.Add({
		name = name,
		channel = 16,
		volume = 1.0,
		sound = spath
	})
end

addsound("tacint_fp6.Insertshell",
	{
		"tacrp/weapons/fp6/fp6_insertshell-1.wav",
		"tacrp/weapons/fp6/fp6_insertshell-2.wav",
		"tacrp/weapons/fp6/fp6_insertshell-3.wav",
	}
)
addsound("tacint_Bekas.Movement", "tacrp/weapons/bekas/movement-1.wav")
addsound("tacint_M4Star10.Bolt_Back", "tacrp/weapons/m4star10/bolt_back.wav")
addsound("tacint_M4Star10.Bolt_release", "tacrp/weapons/m4star10/bolt_release.wav")
addsound("tacint_m4.throw_catch", "tacrp/weapons/m4/m4_throw_catch.wav")
