AddCSLuaFile() SWEP.HoldType = "ar2" if CLIENT then SWEP.PrintName = "L96 Dragon" SWEP.Author = "Primus" SWEP.Slot = 2 SWEP.Icon = "VGUI/spec_dm/icon_sdm_asiimov" end SWEP.Base = "weapon_tttbase" SWEP.Kind = WEAPON_HEAVY SWEP.Primary.Delay = 1.3 SWEP.Primary.Recoil = 5 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "357" SWEP.Primary.Damage = 80 SWEP.Primary.Cone = 0.001 SWEP.Primary.ClipSize = 5 SWEP.Primary.DefaultClip = 5 SWEP.Primary.ClipMax = 10 SWEP.Primary.Sound = Sound("weapons/CF_L96/G_MZC_AWM_FIRE.wav") -- script that calls the primary fire sound SWEP.DrawCrosshair = true SWEP.HeadshotMultiplier = 4 SWEP.Secondary.Sound = Sound("weapons/tfa_csgo/awp/zoom.wav") SWEP.AutoSpawnable = false SWEP.AmmoEnt = "item_ammo_357_ttt" SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 70 SWEP.ViewModel = "models/weapons/v_snip_awm.mdl" -- Weapon view model SWEP.WorldModel = "models/weapons/w_snip_awm.mdl" -- Weapon world model SWEP.IronSightsPos = Vector( 5, -15, -2 ) SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 ) SWEP.AllowDrop = true SWEP.IsSilent = false function SWEP:Initialize() --Tells the script what to do when the player "Initializes" the SWEP. util.PrecacheSound(self.Primary.Sound) util.PrecacheSound(self.Secondary.Sound) self:SetWeaponHoldType( self.HoldType ) end function SWEP:SetZoom( state ) if CLIENT then return elseif IsValid( self.Owner ) and self.Owner:IsPlayer() then if state then self.Owner:SetFOV( 20, 0.3 ) else self.Owner:SetFOV( 0, 0.2 ) end end end -- Add some zoom to ironsights for this gun function SWEP:SecondaryAttack() if not self.IronSightsPos then return end if self:GetNextSecondaryFire() > CurTime() then return end bIronsights = not self:GetIronsights() self:SetIronsights( bIronsights ) if SERVER then self:SetZoom( bIronsights ) else self:EmitSound( self.Secondary.Sound ) end self:SetNextSecondaryFire( CurTime() + 0.3 ) end function SWEP:PreDrop() self:SetZoom( false ) self:SetIronsights( false ) return self.BaseClass.PreDrop( self ) end function SWEP:Reload() if ( self:Clip1() == self.Primary.ClipSize or self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end self:DefaultReload( ACT_VM_RELOAD ) self:SetIronsights( false ) self:SetZoom( false ) end function SWEP:Holster() self:SetIronsights( false ) self:SetZoom( false ) return true end if CLIENT then local scope = surface.GetTextureID( "sprites/scope" ) function SWEP:DrawHUD() if self:GetIronsights() then surface.SetDrawColor( 0, 0, 0, 255 ) local x = ScrW() / 2.0 local y = ScrH() / 2.0 local scope_size = ScrH() --Crosshair local gap = 80 local length = scope_size surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) gap = 0 length = 50 surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) -- Cover edges local sh = scope_size / 2 local w = ( x - sh ) + 2 surface.DrawRect( 0, 0, w, scope_size ) surface.DrawRect( x + sh - 2, 0, w, scope_size ) surface.SetDrawColor( 255, 0, 0, 255 ) surface.DrawLine( x, y, x + 1, y + 1 ) -- Scope surface.SetTexture( scope ) surface.SetDrawColor( 255, 255, 255, 255 ) surface.DrawTexturedRectRotated( x, y, scope_size, scope_size, 0 ) else --return self.BaseClass.DrawHUD( self ) end end function SWEP:AdjustMouseSensitivity() return ( self:GetIronsights() and 0.2 ) or nil end end SWEP.Offset = { Pos = {Up = -0.5, Right = 1, Forward = 0, }, Ang = {Up = 0, Right = 0, Forward = 180,} } function SWEP:DrawWorldModel( ) local hand, offset, rotate local pl = self:GetOwner() if IsValid( pl ) then local boneIndex = pl:LookupBone( "ValveBiped.Bip01_R_Hand" ) if boneIndex then local pos, ang = pl:GetBonePosition( boneIndex ) pos = pos + ang:Forward() * self.Offset.Pos.Forward + ang:Right() * self.Offset.Pos.Right + ang:Up() * self.Offset.Pos.Up ang:RotateAroundAxis( ang:Up(), self.Offset.Ang.Up) ang:RotateAroundAxis( ang:Right(), self.Offset.Ang.Right ) ang:RotateAroundAxis( ang:Forward(), self.Offset.Ang.Forward ) self:SetRenderOrigin( pos ) self:SetRenderAngles( ang ) self:DrawModel() end else self:SetRenderOrigin( nil ) self:SetRenderAngles( nil ) self:DrawModel() end end