Advertisement
BuilderGaming

L85

Jul 4th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.17 KB | None | 0 0
  1. if CLIENT then
  2.    SWEP.PrintName = "L85"
  3.    SWEP.Slot      = 2
  4.  
  5.    SWEP.ViewModelFOV  = 72
  6.    SWEP.ViewModelFlip = true
  7. end
  8.  
  9. SWEP.Base       = "weapon_tttbase"
  10.  
  11. SWEP.HoldType     = "ar2"
  12.  
  13.  
  14. SWEP.Primary.Delay       = 0.15
  15. SWEP.Primary.Recoil      = 1.2
  16. SWEP.Primary.Automatic   = true
  17. SWEP.Primary.Damage      = 21
  18. SWEP.Primary.Cone        = 0.025
  19. SWEP.Primary.Ammo        = "smg1"
  20. SWEP.Primary.ClipSize    = 30
  21. SWEP.Primary.ClipMax     = 60
  22. SWEP.Primary.DefaultClip = 30
  23. SWEP.Primary.Sound       = Sound( "Weapon_l85.Single" )
  24. SWEP.Secondary.Sound = Sound("Default.Zoom")
  25.  
  26. SWEP.IronSightsPos = Vector (2.275, -2.9708, -1.5303)
  27. SWEP.IronSightsAng = Vector (0, 0, 0)
  28.  
  29. SWEP.ViewModel  = "models/weapons/l85/v_rif_l85.mdl"
  30. SWEP.WorldModel = "models/weapons/l85/w_l85a2.mdl"
  31.  
  32. SWEP.Kind = WEAPON_HEAVY
  33. SWEP.AutoSpawnable = true
  34. SWEP.AmmoEnt = "item_ammo_smg1_ttt"
  35.  
  36. function SWEP:SetZoom(state)
  37.     if CLIENT then
  38.        return
  39.     elseif IsValid(self.Owner) and self.Owner:IsPlayer() then
  40.        if state then
  41.           self.Owner:SetFOV(20, 0.3)
  42.        else
  43.           self.Owner:SetFOV(0, 0.2)
  44.        end
  45.     end
  46. end
  47.  
  48. -- Add some zoom to ironsights for this gun
  49. function SWEP:SecondaryAttack()
  50.     if not self.IronSightsPos then return end
  51.     if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
  52.    
  53.     bIronsights = not self:GetIronsights()
  54.    
  55.     self:SetIronsights( bIronsights )
  56.    
  57.     if SERVER then
  58.         self:SetZoom(bIronsights)
  59.      else
  60.         self:EmitSound(self.Secondary.Sound)
  61.     end
  62.    
  63.     self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
  64. end
  65.  
  66. function SWEP:PreDrop()
  67.     self:SetZoom(false)
  68.     self:SetIronsights(false)
  69.     return self.BaseClass.PreDrop(self)
  70. end
  71.  
  72. function SWEP:Reload()
  73.     self.Weapon:DefaultReload( ACT_VM_RELOAD );
  74.     self:SetIronsights( false )
  75.     self:SetZoom(false)
  76. end
  77.  
  78.  
  79. function SWEP:Holster()
  80.     self:SetIronsights(false)
  81.     self:SetZoom(false)
  82.     return true
  83. end
  84.  
  85. if CLIENT then
  86.    function SWEP:DrawHUD()
  87.       if self:GetIronsights() then
  88.          local iScreenWidth = surface.ScreenWidth()
  89.          local iScreenHeight = surface.ScreenHeight()
  90.  
  91.          self.ScopeTable = {}
  92.          self.ScopeTable.l = (iScreenHeight + 1)*0.5 -- I don't know why this works, but it does.
  93.  
  94.          self.QuadTable = {}
  95.          self.QuadTable.h1 = 0.5*iScreenHeight - self.ScopeTable.l
  96.          self.QuadTable.w3 = 0.5*iScreenWidth - self.ScopeTable.l
  97.  
  98.          self.LensTable = {}
  99.          self.LensTable.x = self.QuadTable.w3
  100.          self.LensTable.y = self.QuadTable.h1
  101.          self.LensTable.w = 2*self.ScopeTable.l
  102.          self.LensTable.h = 2*self.ScopeTable.l
  103.  
  104.          self.ReticleTable = {}
  105.          self.ReticleTable.wdivider = 3.125
  106.          self.ReticleTable.hdivider = 1.7579/0.5    -- Draws the texture at 512 when the resolution is 1600x900
  107.          self.ReticleTable.x = (iScreenWidth/2)-((iScreenHeight/self.ReticleTable.hdivider)/2)
  108.          self.ReticleTable.y = (iScreenHeight/2)-((iScreenHeight/self.ReticleTable.hdivider)/2)
  109.          self.ReticleTable.w = iScreenHeight/self.ReticleTable.hdivider
  110.          self.ReticleTable.h = iScreenHeight/self.ReticleTable.hdivider
  111.  
  112.          -- Draw the SCOPE
  113.          surface.SetDrawColor(0, 0, 0, 255)
  114.          surface.SetTexture(surface.GetTextureID("scope/gdcw_closedsight"))
  115.          surface.DrawTexturedRect(self.LensTable.x, self.LensTable.y, self.LensTable.w, self.LensTable.h)
  116.  
  117.           -- Draw the CHEVRON
  118.           surface.SetDrawColor(0, 0, 0, 255)
  119.           surface.SetTexture(surface.GetTextureID("scope/gdcw_acogchevron"))
  120.           surface.DrawTexturedRect(self.ReticleTable.x, self.ReticleTable.y, self.ReticleTable.w, self.ReticleTable.h)
  121.  
  122.           -- Draw the ACOG REFERENCE LINES
  123.           surface.SetDrawColor(0, 0, 0, 255)
  124.           surface.SetTexture(surface.GetTextureID("scope/gdcw_acogcross"))
  125.          surface.DrawTexturedRect(self.ReticleTable.x, self.ReticleTable.y, self.ReticleTable.w, self.ReticleTable.h)
  126.       else
  127.          return self.BaseClass.DrawHUD(self)
  128.       end
  129.    end
  130.  
  131.    function SWEP:AdjustMouseSensitivity()
  132.       return (self:GetIronsights() and 0.2) or nil
  133.    end
  134. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement