Advertisement
BuilderGaming

Scoped Raging Bull

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