Advertisement
TerryPeppers

Untitled

Jul 31st, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. function SWEP:SecondaryAttack()
  2. if self:GetNWBool("Scoped") then
  3. self.Weapon:SetNWBool("Scoped", false)
  4. self.Owner:GetViewModel():SetNoDraw(false)
  5. self.Owner:SetFOV( 0, 0.25 )
  6. self:AdjustMouseSensitivity()
  7. elseif not self:GetNWBool("Scoped") then
  8. self.Weapon:SetNWBool("Scoped", true)
  9. self.Owner:GetViewModel():SetNoDraw(true)
  10. self.Owner:SetFOV( 10, 0.25 )
  11. self:AdjustMouseSensitivity()
  12. end
  13. end
  14.  
  15. function SWEP:AdjustMouseSensitivity()
  16. if self:GetNWBool("Scoped") then
  17. return 0.25
  18. else if not self:GetNWBool("Scoped") then
  19. return -1
  20. end
  21. end
  22. end
  23.  
  24. function SWEP:DrawHUD()
  25. if (CLIENT) then
  26. if not self:GetNWBool("Scoped") then
  27.  
  28. local x, y
  29. if ( self.Owner == LocalPlayer() && self.Owner:ShouldDrawLocalPlayer() ) then
  30.  
  31. local tr = util.GetPlayerTrace( self.Owner )
  32. // tr.mask = ( CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE|CONTENTS_AUX )
  33. local trace = util.TraceLine( tr )
  34.  
  35. local coords = trace.HitPos:ToScreen()
  36. x, y = coords.x, coords.y
  37.  
  38. else
  39. x, y = ScrW() / 2.0, ScrH() / 2.0
  40. end
  41.  
  42. local scale = 10 * self.Primary.Cone
  43.  
  44. local LastShootTime = self.Weapon:GetNetworkedFloat( "LastShootTime", 0 )
  45. scale = scale * (2 - math.Clamp( (CurTime() - LastShootTime) * 5, 0.0, 1.0 ))
  46.  
  47. surface.SetDrawColor( 255, 0, 0, 255 )
  48.  
  49. local gap = 40 * scale
  50. local length = gap + 20 * scale
  51. surface.DrawLine( x - length, y, x - gap, y )
  52. surface.DrawLine( x + length, y, x + gap, y )
  53. surface.DrawLine( x, y - length, x, y - gap )
  54. surface.DrawLine( x, y + length, x, y + gap )
  55. return;
  56. end
  57.  
  58. local Scale = ScrH()/480
  59. local w, h = 320*Scale, 240*Scale
  60. local cx, cy = ScrW()/2, ScrH()/2
  61. local scope_sniper_lr = surface.GetTextureID("sprites/scopes/752/scope_synbf3_lr")
  62. local scope_sniper_ll = surface.GetTextureID("sprites/scopes/752/scope_synbf3_ll")
  63. local scope_sniper_ul = surface.GetTextureID("sprites/scopes/752/scope_synbf3_ul")
  64. local scope_sniper_ur = surface.GetTextureID("sprites/scopes/752/scope_synbf3_ur")
  65. local SNIPERSCOPE_MIN = -0.75
  66. local SNIPERSCOPE_MAX = -2.782
  67. local SNIPERSCOPE_SCALE = 0.4
  68. local x = ScrW() / 2.0
  69. local y = ScrH() / 2.0
  70.  
  71. surface.SetDrawColor( 0, 0, 0, 255 )
  72. local gap = 0
  73. local length = gap + 9999
  74.  
  75. surface.SetDrawColor( 0, 0, 0, 255 )
  76. surface.DrawLine( x - length, y, x - gap, y )
  77. surface.DrawLine( x + length, y, x + gap, y )
  78. surface.DrawLine( x, y - length, x, y - gap )
  79. surface.DrawLine( x, y + length, x, y + gap )
  80. render.UpdateRefractTexture()
  81. surface.SetDrawColor(255, 255, 255, 255)
  82. surface.SetTexture(scope_sniper_lr)
  83. surface.DrawTexturedRect(cx, cy, w, h)
  84. surface.SetTexture(scope_sniper_ll)
  85. surface.DrawTexturedRect(cx-w, cy, w, h)
  86. surface.SetTexture(scope_sniper_ul)
  87. surface.DrawTexturedRect(cx-w, cy-h, w, h)
  88. surface.SetTexture(scope_sniper_ur)
  89. surface.DrawTexturedRect(cx, cy-h, w, h)
  90. surface.SetDrawColor(0, 0, 0, 255)
  91. if cx-w > 0 then
  92. surface.DrawRect(0, 0, cx-w, ScrH())
  93. surface.DrawRect(cx+w, 0, cx-w, ScrH())
  94. end
  95. end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement