Advertisement
MoNoLidThZ

Silent AWP (Magic Cat old TTT Fork 2013/12/5)

Oct 23rd, 2014
146
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( "shared.lua" )
  3. end
  4.  
  5. SWEP.HoldType           = "ar2"
  6.  
  7. if CLIENT then
  8.    SWEP.PrintName          = "Silent AWP"
  9.  
  10.    SWEP.Slot               = 2
  11.  
  12.    SWEP.Icon = "VGUI/ttt/icon_awp"
  13.    
  14. end
  15.  
  16. SWEP.Kind = WEAPON_EQUIP
  17. SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
  18. SWEP.LimitedStock = true -- only buyable once
  19.  
  20.  
  21. SWEP.Base               = "weapon_tttbase"
  22. SWEP.Kind = WEAPON_HEAVY
  23. SWEP.WeaponID = AMMO_SAWP
  24. SWEP.IsSilent = true
  25. SWEP.Primary.Delay          = 1.5
  26. SWEP.Primary.Recoil         = 7
  27. SWEP.Primary.Automatic = true
  28. SWEP.Primary.Ammo = "357"
  29. SWEP.Primary.Damage = 50
  30. SWEP.Primary.Cone = 0.005
  31. SWEP.Primary.ClipSize = 5
  32. SWEP.Primary.ClipMax = 15 -- keep mirrored to ammo
  33. SWEP.Primary.DefaultClip = 15
  34. SWEP.HeadshotMultiplier = 4
  35.  
  36. SWEP.AmmoEnt = "item_ammo_357_ttt"
  37. SWEP.ViewModel          = Model("models/weapons/v_snip_awp.mdl")
  38. SWEP.WorldModel         = Model("models/weapons/w_snip_awp.mdl")
  39. SWEP.Primary.Sound = Sound ("Weapon_M4A1.Silenced")
  40.  
  41. SWEP.Secondary.Sound = Sound("Default.Zoom")
  42. SWEP.IronSightsPos      = Vector( 5, -15, -2 )
  43. SWEP.IronSightsAng      = Vector( 2.6, 1.37, 3.5 )
  44.  
  45. function SWEP:SetZoom(state)
  46.     if CLIENT then
  47.        return
  48.     else
  49.        if state then
  50.           self.Owner:SetFOV(20, 0.3)
  51.        else
  52.           self.Owner:SetFOV(0, 0.2)
  53.        end
  54.     end
  55. end
  56.  
  57. -- Add some zoom to ironsights for this gun
  58. function SWEP:SecondaryAttack()
  59.     if not self.IronSightsPos then return end
  60.     if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
  61.    
  62.     bIronsights = not self:GetIronsights()
  63.    
  64.     self:SetIronsights( bIronsights )
  65.    
  66.     if SERVER then
  67.         self:SetZoom(bIronsights)
  68.      else
  69.         self:EmitSound(self.Secondary.Sound)
  70.     end
  71.    
  72.     self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
  73. end
  74.  
  75. function SWEP:PreDrop()
  76.     self:SetZoom(false)
  77.     self:SetIronsights(false)
  78.     return self.BaseClass.PreDrop(self)
  79. end
  80.  
  81. function SWEP:Reload()
  82.     self.Weapon:DefaultReload( ACT_VM_RELOAD );
  83.     self:SetIronsights( false )
  84.     self:SetZoom(false)
  85. end
  86.  
  87.  
  88. function SWEP:Holster()
  89.     self:SetIronsights(false)
  90.     self:SetZoom(false)
  91.     return true
  92. end
  93.  
  94. if CLIENT then
  95.    local scope = surface.GetTextureID("sprites/scope")
  96.    function SWEP:DrawHUD()
  97.       if self:GetIronsights() then
  98.          surface.SetDrawColor( 0, 0, 0, 255 )
  99.          
  100.          local x = ScrW() / 2.0
  101.          local y = ScrH() / 2.0
  102.          local scope_size = ScrH()
  103.  
  104.          -- crosshair
  105.          local gap = 80
  106.          local length = scope_size
  107.          surface.DrawLine( x - length, y, x - gap, y )
  108.          surface.DrawLine( x + length, y, x + gap, y )
  109.          surface.DrawLine( x, y - length, x, y - gap )
  110.          surface.DrawLine( x, y + length, x, y + gap )
  111.  
  112.          gap = 0
  113.          length = 50
  114.          surface.DrawLine( x - length, y, x - gap, y )
  115.          surface.DrawLine( x + length, y, x + gap, y )
  116.          surface.DrawLine( x, y - length, x, y - gap )
  117.          surface.DrawLine( x, y + length, x, y + gap )
  118.  
  119.  
  120.          -- cover edges
  121.          local sh = scope_size / 2
  122.          local w = (x - sh) + 2
  123.          surface.DrawRect(0, 0, w, scope_size)
  124.          surface.DrawRect(x + sh - 2, 0, w, scope_size)
  125.  
  126.          surface.SetDrawColor(255, 0, 0, 255)
  127.          surface.DrawLine(x, y, x + 1, y + 1)
  128.  
  129.          -- scope
  130.          surface.SetTexture(scope)
  131.          surface.SetDrawColor(255, 255, 255, 255)
  132.  
  133.          surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
  134.  
  135.       else
  136.          return self.BaseClass.DrawHUD(self)
  137.       end
  138.    end
  139.  
  140.    function SWEP:AdjustMouseSensitivity()
  141.       return (self:GetIronsights() and 0.2) or nil
  142.    end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement