local PLUGIN = PLUGIN

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

AddCSLuaFile()

-- names and stuff
SWEP.PrintName = "Molot Bekas-16M"
SWEP.AbbrevName = "Bekas-16M"
SWEP.Category = "Tactical RP"

SWEP.SubCatTier = "4Consumer"
SWEP.SubCatType = "5Shotgun"

SWEP.Description = "Accurate hunting shotgun with a low fire rate.\nLimited effectiveness against armor."

SWEP.Trivia_Caliber = "16 Gauge"
SWEP.Trivia_Manufacturer = "Molot"
SWEP.Trivia_Year = "1999"

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

SWEP.ViewModel = "models/weapons/tacint/v_bekas.mdl"
SWEP.WorldModel = "models/weapons/tacint/w_bekas.mdl"

SWEP.Slot = 2
SWEP.SlotAlt = 3

SWEP.BalanceStats = {
	[PLUGIN.BALANCE_SBOX] = {
	},
	[PLUGIN.BALANCE_TTT] = {
		Damage_Max = 14,
		Damage_Min = 6,
		Range_Min = 400,
		Range_Max = 2500,
		Num = 6,

		BodyDamageMultipliers = {
			[HITGROUP_HEAD] = 2.5,
			[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 = 8,
		Damage_Min = 4,

		Range_Min = 500,
		Range_Max = 2500,

		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] = {
		RecoilDissipationRate = 5,
		RecoilMaximum = 12,
		RecoilSpreadPenalty = 0.01,
		HipFireSpreadPenalty = 0.015,
	}
}

-- "ballistics"

SWEP.Damage_Max = 17
SWEP.Damage_Min = 8
SWEP.Range_Min = 1250 -- distance for which to maintain maximum damage
SWEP.Range_Max = 3500 -- distance at which we drop to minimum damage
SWEP.Penetration = 1  -- units of metal this weapon can penetrate
SWEP.ArmorPenetration = 0.47
SWEP.ArmorBonus = 1.25

SWEP.Num = 8

SWEP.MuzzleVelocity = 11000

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.FiremodeName = "Pump-Action" -- only used externally for firemode name distinction

SWEP.RPM = 60

SWEP.ShootTimeMult = 0.85

SWEP.Spread = 0.02
SWEP.ShotgunPelletSpread = 0.005

SWEP.HipFireSpreadPenalty = 0.01
SWEP.MidAirSpreadPenalty = 0

SWEP.ScopedSpreadPenalty = 0

SWEP.RecoilPerShot = 1
SWEP.RecoilMaximum = 3
SWEP.RecoilResetTime = 0.25 -- time after you stop shooting for recoil to start dissipating
SWEP.RecoilDissipationRate = 1
SWEP.RecoilFirstShotMult = 1.1

SWEP.RecoilVisualKick = 2
SWEP.RecoilKick = 15
SWEP.RecoilStability = 0.4

SWEP.RecoilSpreadPenalty = 0.02

SWEP.CanBlindFire = true

-- handling

SWEP.MoveSpeedMult = 0.925
SWEP.ShootingSpeedMult = 0.85
SWEP.SightedSpeedMult = 0.7

SWEP.ReloadSpeedMult = 0.5

SWEP.AimDownSightsTime = 0.34
SWEP.SprintToFireTime = 0.38

SWEP.Sway = 1
SWEP.ScopedSway = 0.2

SWEP.FreeAimMaxAngle = 5

-- hold types

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

SWEP.GestureShoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN
SWEP.GestureReload = ACT_HL2MP_GESTURE_RELOAD_SHOTGUN

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

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.57, -0.6, 2)
SWEP.SightPos = Vector(-3.45, -5, -2.7)

SWEP.CorrectivePos = Vector(0.275, 0, -0.2)
SWEP.CorrectiveAng = Angle(1.21, 0.1, 0)

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

-- reload

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

SWEP.ReloadTimeMult = 1

-- sounds

local path = "TacRP/weapons/bekas/"

SWEP.Sound_Shoot = "^" .. path .. "fire-1.wav"
SWEP.Sound_Shoot_Silenced = "TacRP/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_shotgun"
SWEP.EjectEffect = 3
SWEP.EjectDelay = 0.5

-- 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.bekas_rootbone",
		WMBone = "ValveBiped.Bip01_R_Hand",
		InstalledElements = { "sights" },
		AttachSound = "TacRP/weapons/optic_on.wav",
		DetachSound = "TacRP/weapons/optic_off.wav",
		VMScale = 0.75,
		Pos_VM = Vector(-2.75, 0, 7),
		Ang_VM = Angle(90, 0, 0),
		Pos_WM = Vector(11, 0.85, -7),
		Ang_WM = Angle(-25, 3.5, 180),
	},
	[2] = {
		PrintName = "Tactical",
		Category = "tactical",
		Bone = "ValveBiped.bekas_rootbone",
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
		InstalledElements = { "tactical" },
		VMScale = 1.25,
		Pos_VM = Vector(-1, -0.3, 24),
		Ang_VM = Angle(90, 0, -90),
		Pos_WM = Vector(25, 0, -12),
		Ang_WM = Angle(-25, 3.5, 90),
	},
	[3] = {
		PrintName = "Accessory",
		Category = { "acc", "acc_sling", "acc_duffle", "acc_extmag_shotgun" },
		AttachSound = "tacrp/weapons/flashlight_on.wav",
		DetachSound = "tacrp/weapons/flashlight_off.wav",
	},
	[4] = {
		PrintName = "Bolt",
		Category = { "bolt_manual" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	},
	[5] = {
		PrintName = "Trigger",
		Category = { "trigger_manual", "trigger_pump2" },
		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",
	},
	[7] = {
		PrintName = "Perk",
		Category = { "perk", "perk_melee", "perk_shooting", "perk_reload" },
		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_Bekas.Insertshell", path .. "insertshell-1.wav")
addsound("TacInt_Bekas.Movement", path .. "movement-1.wav")
addsound("TacInt_Bekas.PumpBack", path .. "pump_backward-1.wav")
addsound("TacInt_Bekas.PumpForward", path .. "pump_forward-1.wav")
