local PLUGIN = PLUGIN

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

AddCSLuaFile()

-- names and stuff
SWEP.PrintName = "Dual MTX"
SWEP.Category = "Tactical RP"

SWEP.SubCatTier = "1Elite"
SWEP.SubCatType = "1Sidearm"

SWEP.Description =
"An indulgent pair of high capacity, high damage, high quality compact pistols.\nWith firepower like this, who needs aiming?"

SWEP.Trivia_Caliber = ".45 ACP"
SWEP.Trivia_Manufacturer = "Detonics Defense"
SWEP.Trivia_Year = "2011"

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

SWEP.ViewModel = "models/weapons/tacint/v_mtx_dual.mdl"
SWEP.WorldModel = "models/weapons/tacint/w_mtx.mdl"

SWEP.Slot = 1

SWEP.BalanceStats = {
	[PLUGIN.BALANCE_SBOX] = {
		Damage_Max = 30,
		Damage_Min = 8,
		RPM = 420,
		Spread = 0.02,
	},
	[PLUGIN.BALANCE_TTT] = {
		Damage_Max = 14,
		Damage_Min = 6,
		Range_Min = 500,
		Range_Max = 1500,
		RPM = 600,

		Spread = 0.02,

		BodyDamageMultipliers = {
			[HITGROUP_HEAD] = 2.5,
			[HITGROUP_CHEST] = 1,
			[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 = 18,
		Damage_Min = 9,
		RPM = 750,

		Spread = 0.01,
	},
	[PLUGIN.BALANCE_OLDSCHOOL] = {
		RecoilSpreadPenalty = 0.003,
		RecoilMax = 25
	}
}

-- "ballistics"

SWEP.Damage_Max = 32
SWEP.Damage_Min = 10
SWEP.Range_Min = 500  -- distance for which to maintain maximum damage
SWEP.Range_Max = 1800 -- distance at which we drop to minimum damage
SWEP.Penetration = 3  -- units of metal this weapon can penetrate
SWEP.ArmorPenetration = 0.55
SWEP.ArmorBonus = 0.5

SWEP.MuzzleVelocity = 11500

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

-- misc. shooting

SWEP.Firemodes = { -2, 2 }
SWEP.Firemode = false
SWEP.RunawayBurst = false
SWEP.PostBurstDelay = 0.06

SWEP.RPM = 500
SWEP.RPMMultBurst = 1.1
SWEP.RPMMultSemi = 1.1

SWEP.Spread = 0.015

SWEP.MoveSpreadPenalty = 0
SWEP.MidAirSpreadPenalty = 0.075
SWEP.HipFireSpreadPenalty = 0

SWEP.RecoilPerShot = 1
SWEP.RecoilMaximum = 20
SWEP.RecoilResetTime = 0.15
SWEP.RecoilDissipationRate = 20
SWEP.RecoilFirstShotMult = 1 -- multiplier for the first shot's recoil amount

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

SWEP.RecoilSpreadPenalty = 0.002

SWEP.Sway = 0.5

SWEP.CanBlindFire = false
SWEP.CanSuicide = true

SWEP.ShootTimeMult = 0.6

-- handling

SWEP.MoveSpeedMult = 0.975
SWEP.ShootingSpeedMult = 0.9
SWEP.SightedSpeedMult = 1

SWEP.ReloadSpeedMult = 0.6

SWEP.AimDownSightsTime = 0.25
SWEP.SprintToFireTime = 0.25

-- hold types

SWEP.HoldType = "duel"
SWEP.HoldTypeSprint = "normal"
SWEP.HoldTypeBlindFire = false
SWEP.HoldTypeSuicide = "duel"

SWEP.GestureShoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_DUEL
SWEP.GestureReload = ACT_HL2MP_GESTURE_RELOAD_DUEL

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

SWEP.CustomizeAng = Angle(0, 35, 0)
SWEP.CustomizePos = Vector(1, 0, -12)

SWEP.BlindFireAng = Angle(0, 0, 0)
SWEP.BlindFirePos = Vector(0, 0, 0)

SWEP.BlindFireSuicideAng = Angle(0, 130, 0)
SWEP.BlindFireSuicidePos = Vector(1, 22, -15)

SWEP.SprintAng = Angle(0, 30, 0)
SWEP.SprintPos = Vector(1, 0, -12)

SWEP.HolsterVisible = true
SWEP.HolsterSlot = PLUGIN.HOLSTER_SLOT_PISTOL
SWEP.HolsterPos = Vector(0, 3, -4)
SWEP.HolsterAng = Angle(60, 5, 0)

-- reload

SWEP.ClipSize = 24
SWEP.Ammo = "pistol"

SWEP.ReloadTimeMult = 1

SWEP.DropMagazineModel = "models/weapons/tacint/magazines/gsr1911.mdl"
SWEP.DropMagazineImpact = "pistol"
SWEP.DropMagazineAmount = 2

SWEP.ReloadUpInTime = 2.8
SWEP.DropMagazineTime = 0.25

-- sounds

local path = "tacrp/weapons/mtx/"

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

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

-- effects

-- the .qc attachment for the muzzle
SWEP.QCA_Muzzle = 4

SWEP.MuzzleEffect = "muzzleflash_pistol"

-- anims

SWEP.AnimationTranslationTable = {
	["deploy"] = "draw",
	["blind_idle"] = "idle",
	["blind_fire"] = "idle",
	["melee"] = { "melee1", "melee2" },
	["shoot_left"] = { "shoot_left-1", "shoot_left-2" },
	["shoot_right"] = { "shoot_right-1", "shoot_right-2" }
}

SWEP.LastShot = true
SWEP.Akimbo = true
SWEP.EffectsAlternate = true

-- attachments

SWEP.Attachments = {
	[1] = {
		PrintName = "Tactical",
		Category = "tactical",
		Bone = "ValveBiped.mtx_root2",
		WMBone = "Box01",
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
		VMScale = 0.9,
		WMScale = 1,
		Pos_VM = Vector(-2, -0.2, 5.45),
		Ang_VM = Angle(90, 0, 180),
		Pos_WM = Vector(-0.1, 8, -1.7),
		Ang_WM = Angle(0, -90, 180),
	},
	[2] = {
		PrintName = "Accessory",
		Category = { "acc_dual", "acc_extmag_dual" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	},
	[4] = {
		PrintName = "Perk",
		Category = { "perk", "perk_melee", "perk_shooting", "perk_reload" },
		AttachSound = "tacrp/weapons/flashlight_on.wav",
		DetachSound = "tacrp/weapons/flashlight_off.wav",
	},
	[2] = {
		PrintName = "Trigger",
		Category = { "trigger_akimbo" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	},
	[3] = {
		PrintName = "Ammo",
		Category = { "ammo_pistol" },
		AttachSound = "TacRP/weapons/flashlight_on.wav",
		DetachSound = "TacRP/weapons/flashlight_off.wav",
	}
}

SWEP.AttachmentCapacity = 30 -- amount of "Capacity" this gun can accept

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

addsound("tacint_mtx.clip_in_left", path .. "clip_in-1.wav")
addsound("tacint_mtx.clip_in_right", path .. "clip_in-2.wav")
addsound("tacint_mtx.clip_out", path .. "clip_out.wav")
addsound("tacint_mtx.slide_back", path .. "slide_back.wav")
addsound("tacint_mtx.slide_release", path .. "slide_release.wav")
addsound("tacint_mtx.slide_shut", {
	path .. "slide_shut.wav",
	path .. "slide_shut-1.wav",
	path .. "slide_shut-2.wav",
})

SWEP.Scope = false

SWEP.FreeAim = false
