Advertisement
Guest User

asfasf

a guest
Feb 23rd, 2014
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile( "shared.lua" )
  3. end
  4.  
  5. SWEP.HoldType = "revolver"
  6.  
  7. if CLIENT then
  8. SWEP.PrintName = "Healing Rifle"
  9.  
  10. SWEP.Slot = 6
  11.  
  12. SWEP.Icon = "VGUI/ttt/icon_scout"
  13. end
  14.  
  15.  
  16. SWEP.Base = "weapon_tttbase"
  17. SWEP.Spawnable = true
  18. SWEP.AdminSpawnable = true
  19.  
  20. SWEP.Kind = WEAPON_EQUIP
  21. SWEP.WeaponID = AMMO_HEALRIFLE
  22. SWEP.CanBuy = {ROLE_DETECTIVE} -- only detectives can buy
  23. SWEP.LimitedStock = true -- only buyable once
  24.  
  25. SWEP.Primary.Delay = 3
  26. SWEP.Primary.Recoil = 7
  27. SWEP.Primary.Automatic = true
  28. SWEP.Primary.Ammo = "357"
  29. SWEP.HealAmount = ( math.Rand( 30,100 ) )
  30. SWEP.Primary.Cone = 0.003
  31. SWEP.Primary.ClipSize = 3
  32. SWEP.Primary.ClipMax = 3
  33. SWEP.Primary.DefaultClip = 3
  34.  
  35. SWEP.HeadshotMultiplier = 0
  36.  
  37. SWEP.AutoSpawnable = false
  38. SWEP.AmmoEnt = "item_ammo_feringun"
  39.  
  40. SWEP.UseHands = true
  41. SWEP.ViewModelFlip = false
  42. SWEP.ViewModelFOV = 54
  43. SWEP.ViewModel = Model("models/weapons/cstrike/c_snip_scout.mdl")
  44. SWEP.WorldModel = Model("models/weapons/w_snip_scout.mdl")
  45.  
  46. SWEP.Primary.Sound = Sound(")weapons/scout/scout_fire-1.wav")
  47.  
  48. SWEP.Secondary.Sound = Sound("Default.Zoom")
  49.  
  50. SWEP.IronSightsPos = Vector( 5, -15, -2 )
  51. SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
  52.  
  53. function SWEP:SetZoom(state)
  54. if CLIENT then
  55. return
  56. elseif IsValid(self.Owner) and self.Owner:IsPlayer() then
  57. if state then
  58. self.Owner:SetFOV(20, 0.3)
  59. else
  60. self.Owner:SetFOV(0, 0.2)
  61. end
  62. end
  63. end
  64.  
  65. -- Add some zoom to ironsights for this gun
  66. function SWEP:SecondaryAttack()
  67. if not self.IronSightsPos then return end
  68. if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
  69.  
  70. bIronsights = not self:GetIronsights()
  71.  
  72. self:SetIronsights( bIronsights )
  73.  
  74. if SERVER then
  75. self:SetZoom(bIronsights)
  76. else
  77. self:EmitSound(self.Secondary.Sound)
  78. end
  79.  
  80. self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
  81. end
  82.  
  83. function SWEP:PreDrop()
  84. self:SetZoom(false)
  85. self:SetIronsights(false)
  86. return self.BaseClass.PreDrop(self)
  87. end
  88.  
  89. function SWEP:Reload()
  90. self.Weapon:DefaultReload( ACT_VM_RELOAD );
  91. self:SetIronsights( false )
  92. self:SetZoom(false)
  93. end
  94.  
  95.  
  96. function SWEP:Holster()
  97. self:SetIronsights(false)
  98. self:SetZoom(false)
  99. return true
  100. end
  101.  
  102. if CLIENT then
  103. local scope = surface.GetTextureID("sprites/scope")
  104. function SWEP:DrawHUD()
  105. if self:GetIronsights() then
  106. surface.SetDrawColor( 0, 0, 0, 255 )
  107.  
  108. local x = ScrW() / 2.0
  109. local y = ScrH() / 2.0
  110. local scope_size = ScrH()
  111.  
  112. -- crosshair
  113. local gap = 80
  114. local length = scope_size
  115. surface.DrawLine( x - length, y, x - gap, y )
  116. surface.DrawLine( x + length, y, x + gap, y )
  117. surface.DrawLine( x, y - length, x, y - gap )
  118. surface.DrawLine( x, y + length, x, y + gap )
  119.  
  120. gap = 0
  121. length = 50
  122. surface.DrawLine( x - length, y, x - gap, y )
  123. surface.DrawLine( x + length, y, x + gap, y )
  124. surface.DrawLine( x, y - length, x, y - gap )
  125. surface.DrawLine( x, y + length, x, y + gap )
  126.  
  127.  
  128. -- cover edges
  129. local sh = scope_size / 2
  130. local w = (x - sh) + 2
  131. surface.DrawRect(0, 0, w, scope_size)
  132. surface.DrawRect(x + sh - 2, 0, w, scope_size)
  133.  
  134. surface.SetDrawColor(255, 0, 0, 255)
  135. surface.DrawLine(x, y, x + 1, y + 1)
  136.  
  137. -- scope
  138. surface.SetTexture(scope)
  139. surface.SetDrawColor(255, 255, 255, 255)
  140.  
  141. surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
  142.  
  143. else
  144. return self.BaseClass.DrawHUD(self)
  145. end
  146. end
  147.  
  148. function SWEP:AdjustMouseSensitivity()
  149. return (self:GetIronsights() and 0.2) or nil
  150. end
  151. end
  152.  
  153. function SWEP:PrimaryAttack()
  154. if ( !self:CanPrimaryAttack() ) then return end
  155.  
  156. if ( !SERVER ) then return end
  157.  
  158. local tr = util.TraceLine( {
  159. start = self.Owner:GetShootPos(),
  160. endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 99999999,
  161. filter = self.Owner
  162. } )
  163.  
  164. local ent = tr.Entity
  165.  
  166. if ( IsValid( ent ) && ( ent:IsPlayer() or ent:IsNPC() ) ) then
  167.  
  168. if self.Owner:KeyDown(IN_USE) then
  169. if ent:Health() <= 1 then
  170. return false
  171. else
  172. self.Owner:EmitSound( self.Primary.Sound )
  173. self.Owner:EmitSound( self.Secondary.Sound )
  174. ent:SetHealth( ent:Health() - self.HurtAmount )
  175. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  176. self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  177. self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  178. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  179. if ent:Health() <= 1 then ent:SetHealth( self.MinAmount ) end
  180. end
  181. else
  182. self.Owner:EmitSound( self.Primary.Sound )
  183. self.Owner:EmitSound( self.Secondary.Sound )
  184. ent:SetHealth( math.min( ent:GetMaxHealth(), ent:Health() + self.HealAmount ) )
  185. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  186. self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  187. self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  188. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  189. end
  190. timer.Simple( self:SequenceDuration(), function() if ( !IsValid( self ) ) then return end self:SendWeaponAnim( ACT_VM_IDLE ) end )
  191.  
  192. end
  193.  
  194. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement