Advertisement
BuilderGaming

Barret M82

Jul 4th, 2015
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.71 KB | None | 0 0
  1. if SERVER then
  2.    AddCSLuaFile()
  3. end
  4.  
  5. SWEP.HoldType        = "ar2"
  6.  
  7.  
  8. if CLIENT then
  9.  
  10.    SWEP.PrintName       = "Barret M82"
  11.    SWEP.Slot            = 2
  12.  
  13.    SWEP.Icon = "vgui/ttt/icon_sttts_barret_m82"
  14. end
  15.  
  16.  
  17. SWEP.Base            = "weapon_tttbase"
  18.  
  19. SWEP.Kind = WEAPON_HEAVY
  20.  
  21. SWEP.Primary.Delay         = 1.5
  22. SWEP.Primary.Recoil        = 5
  23. SWEP.Primary.Automatic     = true
  24. SWEP.Primary.Ammo          = "357"
  25. SWEP.Primary.Damage        = 75
  26. SWEP.Primary.Cone          = 0.005
  27. SWEP.Primary.ClipSize      = 10
  28. SWEP.Primary.ClipMax         = 20
  29. SWEP.Primary.DefaultClip   = 10
  30. SWEP.AutoSpawnable         = false
  31. SWEP.AmmoEnt               = "item_ammo_357_ttt"
  32.  
  33. SWEP.HeadshotMultiplier = 6
  34.  
  35. SWEP.UseHands        = true
  36. SWEP.ViewModelFlip      = true
  37. SWEP.ViewModelFOV    = 70
  38. SWEP.ViewModel       = "models/weapons/m82/v_50calm82.mdl"
  39. SWEP.WorldModel         = "models/weapons/m82/w_barret_m82.mdl"
  40.  
  41. SWEP.Primary.Sound = Sound( "BarretM82.Single" )
  42. SWEP.Secondary.Sound = Sound("Default.Zoom")
  43.  
  44. SWEP.IronSightsPos = Vector (2.894, 0, -1.7624)
  45. SWEP.IronSightsAng = Vector (0, 0, 0)
  46.  
  47.  
  48. function SWEP:SetZoom(state)
  49.     if CLIENT then
  50.        return
  51.     elseif IsValid(self.Owner) and self.Owner:IsPlayer() then
  52.        if state then
  53.           self.Owner:SetFOV(20, 0.3)
  54.        else
  55.           self.Owner:SetFOV(0, 0.2)
  56.        end
  57.     end
  58. end
  59.  
  60. -- Add some zoom to ironsights for this gun
  61. function SWEP:SecondaryAttack()
  62.     if not self.IronSightsPos then return end
  63.     if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
  64.    
  65.     bIronsights = not self:GetIronsights()
  66.    
  67.     self:SetIronsights( bIronsights )
  68.    
  69.     if SERVER then
  70.         self:SetZoom(bIronsights)
  71.      else
  72.         self:EmitSound(self.Secondary.Sound)
  73.     end
  74.    
  75.     self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
  76. end
  77.  
  78. function SWEP:PreDrop()
  79.     self:SetZoom(false)
  80.     self:SetIronsights(false)
  81.     return self.BaseClass.PreDrop(self)
  82. end
  83.  
  84. function SWEP:Reload()
  85.     self.Weapon:DefaultReload( ACT_VM_RELOAD );
  86.     self:SetIronsights( false )
  87.     self:SetZoom(false)
  88. end
  89.  
  90.  
  91. function SWEP:Holster()
  92.     self:SetIronsights(false)
  93.     self:SetZoom(false)
  94.     return true
  95. end
  96.  
  97. if CLIENT then
  98.    local scope = surface.GetTextureID("sprites/scope")
  99.    function SWEP:DrawHUD()
  100.       if self:GetIronsights() then
  101.          surface.SetDrawColor( 0, 0, 0, 255 )
  102.          
  103.          local x = ScrW() / 2.0
  104.          local y = ScrH() / 2.0
  105.          local scope_size = ScrH()
  106.  
  107.          -- crosshair
  108.          local gap = 80
  109.          local length = scope_size
  110.          surface.DrawLine( x - length, y, x - gap, y )
  111.          surface.DrawLine( x + length, y, x + gap, y )
  112.          surface.DrawLine( x, y - length, x, y - gap )
  113.          surface.DrawLine( x, y + length, x, y + gap )
  114.  
  115.          gap = 0
  116.          length = 50
  117.          surface.DrawLine( x - length, y, x - gap, y )
  118.          surface.DrawLine( x + length, y, x + gap, y )
  119.          surface.DrawLine( x, y - length, x, y - gap )
  120.          surface.DrawLine( x, y + length, x, y + gap )
  121.  
  122.  
  123.          -- cover edges
  124.          local sh = scope_size / 2
  125.          local w = (x - sh) + 2
  126.          surface.DrawRect(0, 0, w, scope_size)
  127.          surface.DrawRect(x + sh - 2, 0, w, scope_size)
  128.  
  129.          surface.SetDrawColor(255, 0, 0, 255)
  130.          surface.DrawLine(x, y, x + 1, y + 1)
  131.  
  132.          -- scope
  133.          surface.SetTexture(scope)
  134.          surface.SetDrawColor(255, 255, 255, 255)
  135.  
  136.          surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
  137.  
  138.       else
  139.          return self.BaseClass.DrawHUD(self)
  140.       end
  141.    end
  142.  
  143.    function SWEP:AdjustMouseSensitivity()
  144.       return (self:GetIronsights() and 0.2) or nil
  145.    end
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement