--------------------------------------------------------------------------------------
--------------------[ CONSTANTS ]-----------------------------------------------------
--------------------------------------------------------------------------------------



local Gun = script.Parent
local serverMain = Gun:WaitForChild("serverMain")
local Handle = Gun:WaitForChild("Handle")
local AimPart = Gun:WaitForChild("SightMark")
local Main = Gun:WaitForChild("Flame")

local Ammo = Gun:WaitForChild("Ammo")
local ClipSize = Gun:WaitForChild("ClipSize")
local StoredAmmo = Gun:WaitForChild("StoredAmmo")

local createTweenIndicator = serverMain:WaitForChild("createTweenIndicator")
local deleteTweenIndicator = serverMain:WaitForChild("deleteTweenIndicator")
local getWeldCF = serverMain:WaitForChild("getWeldCF")
local gunSetup = serverMain:WaitForChild("gunSetup")
local lerpCF = serverMain:WaitForChild("lerpCF")
local createBlood = serverMain:WaitForChild("createBlood")
local createBulletImpact = serverMain:WaitForChild("createBulletImpact")
local createShockwave = serverMain:WaitForChild("createShockwave")
local createTrail = serverMain:WaitForChild("createTrail")

local Particle = require(script:WaitForChild("Particle"))
local Spring = require(script:WaitForChild("Spring"))
local Anims = require(Gun:WaitForChild("ANIMATIONS"))
local Plugins = require(Gun:WaitForChild("PLUGINS"))
local S = require(Gun:WaitForChild("SETTINGS"))

local Player = game.Players.LocalPlayer
local Char = Player.Character
local Humanoid = Char:WaitForChild("Humanoid")
local Torso = Char:WaitForChild("Torso")
local Head = Char:WaitForChild("Head")
local HRP = Char:WaitForChild("HumanoidRootPart")
local Root = HRP:WaitForChild("RootJoint")

local Neck = Torso:WaitForChild("Neck")

local LArm = Char:WaitForChild("Left Arm")
local RArm = Char:WaitForChild("Right Arm")
local LLeg = Char:WaitForChild("Left Leg")
local RLeg = Char:WaitForChild("Right Leg")

local M2 = Player:GetMouse()

local mainGUI = script:WaitForChild("mainGUI")
	
local crossHair = mainGUI:WaitForChild("crossHair")
local HUD = mainGUI:WaitForChild("HUD")
local Scope = mainGUI:WaitForChild("Scope")
local fireSelect = mainGUI:WaitForChild("fireSelect")
local hitMarker = mainGUI:WaitForChild("hitMarker")
local Sens = mainGUI:WaitForChild("Sens")

local crossA = crossHair:WaitForChild("A"):WaitForChild("Line")
local crossB = crossHair:WaitForChild("B"):WaitForChild("Line")
local crossC = crossHair:WaitForChild("C"):WaitForChild("Line")
local crossD = crossHair:WaitForChild("D"):WaitForChild("Line")

local Controls = HUD:WaitForChild("Controls")

local gunNameTitle = HUD:WaitForChild("gunName"):WaitForChild("Title")

local scopeMain = Scope:WaitForChild("Main")
local scopeSteady = Scope:WaitForChild("Steady")

local fireModes = fireSelect:WaitForChild("Modes")

local modeGUI = HUD:WaitForChild("Mode"):WaitForChild("Main")
local clipAmmoGUI = HUD:WaitForChild("Ammo"):WaitForChild("Clip")
local storedAmmoGUI = HUD:WaitForChild("Ammo"):WaitForChild("Stored")

local DS = game:GetService("Debris")
local CP = game:GetService("ContentProvider")
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

local Cam = game.Workspace.CurrentCamera

local ABS, HUGE, FLOOR, CEIL = math.abs, math.huge, math.floor, math.ceil
local RAD, SIN, COS, TAN = math.rad, math.sin, math.cos, math.tan
local VEC2, V3 = Vector2.new, Vector3.new
local CF, CFANG = CFrame.new, CFrame.Angles
local INSERT = table.insert

local maxStamina = S.sprintTime * 60
local maxSteadyTime = S.scopeSettings.steadyTime * 60

local LethalIcons = {
	"http://www.roblox.com/asset/?id=194849880";
	"http://www.roblox.com/asset/?id=195727791";
	"http://www.roblox.com/asset/?id=195728137";
	"http://www.roblox.com/asset/?id=218151830";
}

local TacticalIcons = {
	"http://www.roblox.com/asset/?id=195728473";
	"http://www.roblox.com/asset/?id=195728693";
}

local ASCII = {
	071; 117; 110; 032;
	075; 105; 116; 032;
	115; 099; 114; 105;
	112; 116; 101; 100;
	032; 098; 121; 032;
	084; 117; 114; 098;
	111; 070; 117; 115;
	105; 111; 110; 000;
}

local Ignore = {
	Char;
	ignoreModel;
}

local Shoulders = {
	Right = Torso:WaitForChild("Right Shoulder");
	Left = Torso:WaitForChild("Left Shoulder")
}

local armC0 = {
	CF(-1.5, 0, 0) * CFANG(RAD(90), 0, 0);
	CF(1.5, 0, 0) * CFANG(RAD(90), 0, 0);
}

local legC0 = {
	Stand = {
		CF(-0.5, -2, 0);
		CF(0.5, -2, 0);
	};
	Crouch = {
		CF(-0.5, -1.5, 0.5) * CFANG(-RAD(90), 0, 0);
		CF(0.5, -1, -0.75);
	};
	Prone = {
		CF(-0.5, -2, 0);
		CF(0.5, -2, 0);
	};
}

local Sine = function(X)
	return SIN(RAD(X))
end

local Linear = function(X)
	return (X / 90)
end