Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.59 KB | None | 0 0
  1. if CLIENT then
  2. SWEP.WepSelectIcon = surface.GetTextureID( "vgui/hud/weapon_cofbrowning" )
  3. SWEP.DrawWeaponInfoBox = false
  4. SWEP.BounceWeaponIcon = false
  5. killicon.Add( "weapon_cofbrowning", "vgui/hud/weapon_cofbrowning", Color( 0, 0, 0, 255 ) )
  6. end
  7.  
  8. SWEP.PrintName = "Browning HP 9mm (Improved)"
  9.  
  10. SWEP.Category = "Cry of Fear"
  11.  
  12. SWEP.Spawnable= true
  13. SWEP.AdminSpawnable= true
  14. SWEP.AdminOnly = false
  15.  
  16. SWEP.ViewModelFOV = 80
  17. SWEP.ViewModel = "models/gonzo/cofbrowning/v_cofbrowning.mdl"
  18. SWEP.WorldModel = "models/gonzo/cofbrowning/w_cofbrowning.mdl"
  19. SWEP.ViewModelFlip = false
  20.  
  21. SWEP.AutoSwitchTo = false
  22. SWEP.AutoSwitchFrom = false
  23. SWEP.Weight = 5
  24.  
  25. SWEP.Slot = 1
  26. SWEP.SlotPos = 0
  27.  
  28. SWEP.UseHands = false
  29. SWEP.HoldType = "pistol"
  30. SWEP.FiresUnderwater = false
  31. SWEP.DrawCrosshair = false
  32. SWEP.DrawAmmo = true
  33. SWEP.CSMuzzleFlashes = true
  34. SWEP.Base = "weapon_base"
  35.  
  36. SWEP.Iron = 0
  37. SWEP.Sprint = 0
  38. SWEP.BobTimer = CurTime()
  39. SWEP.Bob = 0
  40. SWEP.FirstTime = 0
  41.  
  42. SWEP.Primary.Sound = Sound( "Weapon_CoFBrowning.Single" )
  43. SWEP.Primary.ClipSize = 13
  44. SWEP.Primary.DefaultClip = 13
  45. SWEP.Primary.Automatic = false
  46. SWEP.Primary.Ammo = "pistol"
  47. SWEP.Primary.Damage = 17
  48. SWEP.Primary.TakeAmmo = 1
  49. SWEP.Primary.Recoil = 1
  50. SWEP.Primary.RecoilView = 1.5
  51. SWEP.Primary.Spread = 0.015
  52. SWEP.Primary.NumberofShots = 1
  53. SWEP.Primary.Delay = 0.3
  54. SWEP.Primary.Force = 5
  55.  
  56. SWEP.Secondary.ClipSize = 0
  57. SWEP.Secondary.DefaultClip = 0
  58. SWEP.Secondary.Automatic = false
  59. SWEP.Secondary.Ammo = "none"
  60.  
  61. function SWEP:Initialize()
  62. self:SetWeaponHoldType( self.HoldType )
  63. self.FirstTime = 1
  64. end
  65.  
  66. function SWEP:Deploy()
  67. if self.FirstTime == 0 then
  68. if self.Weapon:Clip1() > 0 then
  69. self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
  70. end
  71. if self.Weapon:Clip1() <= 0 then
  72. self.Weapon:SendWeaponAnim( ACT_VM_DRAW_EMPTY )
  73. end
  74. end
  75. if self.FirstTime == 1 then
  76. self.Weapon:SendWeaponAnim( ACT_DEPLOY )
  77. end
  78. self:SetNextPrimaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
  79. self:SetNextSecondaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
  80. self.Primary.Spread = 0.03
  81. self.Iron = 0
  82. self.Sprint = 0
  83. self.BobTimer = CurTime()
  84. self.Bob = 0
  85. self.FirstTime = 0
  86. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  87. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  88. self.Owner:SetWalkSpeed( 200 )
  89. if SERVER then
  90. self.Owner:AllowFlashlight( true )
  91. self.Owner:Flashlight( false )
  92. self.Owner:AllowFlashlight( false )
  93. end
  94. self.Owner:StopSound( "HL2Player.FlashLightOn" )
  95. self.Weapon:EmitSound( "Weapon_CoF.SleeveGeneric"..math.random( 1, 2 ) )
  96. end
  97.  
  98. function SWEP:Holster()
  99. self.Primary.Spread = 0.03
  100. self.Iron = 0
  101. self.Sprint = 0
  102. self.BobTimer = CurTime()
  103. self.Bob = 0
  104. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  105. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  106. self.Owner:AllowFlashlight( true )
  107. self.Owner:SetWalkSpeed( 200 )
  108. return true
  109. end
  110.  
  111. function SWEP:PrimaryAttack()
  112. if self.Sprint == 1 then return end
  113. if self.Weapon:Clip1() <= 0 and !( self.Owner:WaterLevel() == 3 ) then
  114. self.Weapon:EmitSound( "Weapon_CoFBrowning.Empty" )
  115. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  116. end
  117. if self.FiresUnderwater == false and self.Owner:WaterLevel() == 3 then
  118. self.Weapon:EmitSound( "Weapon_CoFBrowning.Empty" )
  119. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  120. end
  121. if self.Weapon:Clip1() <= 0 then return end
  122. if self.FiresUnderwater == false and self.Owner:WaterLevel() == 3 then return end
  123. local bullet = {}
  124. bullet.Num = self.Primary.NumberofShots
  125. bullet.Src = self.Owner:GetShootPos()
  126. bullet.Dir = self.Owner:GetAimVector()
  127. bullet.Spread = Vector( self.Primary.Spread * 1, self.Primary.Spread * 1, 0 )
  128. bullet.Tracer = 1
  129. bullet.Force = self.Primary.Force
  130. bullet.Damage = self.Primary.Damage
  131. bullet.AmmoType = self.Primary.Ammo
  132. self.Owner:FireBullets( bullet )
  133. self:EmitSound( self.Primary.Sound )
  134. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  135. self.Owner:MuzzleFlash()
  136. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  137. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  138. self.Owner:SetEyeAngles( self.Owner:EyeAngles() + self.RecoilViewDir )
  139. self.Owner:ViewPunch( self.RecoilDir )
  140. self:TakePrimaryAmmo( self.Primary.TakeAmmo )
  141. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  142. self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  143. if self.Weapon:Clip1() > 0 then
  144. if self.Iron == 0 then
  145. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  146. end
  147. if self.Iron == 1 then
  148. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_DEPLOYED )
  149. end
  150. end
  151. if self.Weapon:Clip1() <= 0 then
  152. if self.Iron == 0 then
  153. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_EMPTY )
  154. end
  155. if self.Iron == 1 then
  156. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_DEPLOYED_EMPTY )
  157. end
  158. end
  159. end
  160.  
  161. function SWEP:SecondaryAttack()
  162. if self.Sprint == 1 then return end
  163. if self.Iron == 0 then
  164. if self.Weapon:Clip1() > 0 then
  165. self.Weapon:SendWeaponAnim( ACT_VM_DEPLOY )
  166. end
  167. if self.Weapon:Clip1() <= 0 then
  168. self.Weapon:SendWeaponAnim( ACT_VM_DEPLOY_EMPTY )
  169. end
  170. self:SetNextPrimaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
  171. self:SetNextSecondaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
  172. self.Primary.Spread = 0
  173. self.Owner:SetFOV( 50, 0.1 )
  174. self.Iron = 1
  175. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  176. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  177. self.Owner:SetWalkSpeed( 100 )
  178. else
  179. if self.Iron == 1 then
  180. if self.Weapon:Clip1() > 0 then
  181. self.Weapon:SendWeaponAnim( ACT_VM_UNDEPLOY )
  182. end
  183. if self.Weapon:Clip1() <= 0 then
  184. self.Weapon:SendWeaponAnim( ACT_VM_UNDEPLOY_EMPTY )
  185. end
  186. self:SetNextPrimaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
  187. self:SetNextSecondaryFire( CurTime() + self.Owner:GetViewModel():SequenceDuration() )
  188. self.Primary.Spread = 0.03
  189. self.Owner:SetFOV( 0, 0.1 )
  190. self.Iron = 0
  191. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  192. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  193. self.Owner:SetWalkSpeed( 200 )
  194. end
  195. end
  196. end
  197.  
  198. function SWEP:Reload()
  199. if self.Sprint == 1 then return end
  200. if self.Weapon:Clip1() < self.Primary.ClipSize and self.Weapon:Ammo1() > 0 then
  201. if self.Weapon:Clip1() > 0 then
  202. self.Weapon:DefaultReload( ACT_VM_RELOAD )
  203. end
  204. if self.Weapon:Clip1() <= 0 then
  205. self.Weapon:DefaultReload( ACT_VM_RELOAD_EMPTY )
  206. end
  207. self.Primary.Spread = 0.03
  208. self.Owner:SetFOV( 0, 0.1 )
  209. self.Iron = 0
  210. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  211. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  212. self.Owner:SetWalkSpeed( 200 )
  213. end
  214. end
  215.  
  216. function SWEP:Think()
  217. if self.Sprint == 0 then
  218. if self.Bob == 0 and ( self.Owner:KeyDown( IN_FORWARD ) || self.Owner:KeyDown( IN_BACK ) || self.Owner:KeyDown( IN_MOVELEFT ) || self.Owner:KeyDown( IN_MOVERIGHT ) ) then
  219. self.BobTimer = CurTime()
  220. self.Bob = 1
  221. end
  222. if self.BobTimer <= CurTime() and self.Bob == 1 then
  223. self.Owner:ViewPunch( Angle( -0.1, -0.1, -0.1 ) )
  224. self.BobTimer = CurTime() + 0.3
  225. self.Bob = 2
  226. end
  227. if self.BobTimer <= CurTime() and self.Bob == 2 then
  228. self.Owner:ViewPunch( Angle( 0.1, -0.1, 0.1 ) )
  229. self.BobTimer = CurTime() + 0.3
  230. self.Bob = 1
  231. end
  232. if !( self.Owner:KeyDown( IN_FORWARD ) || self.Owner:KeyDown( IN_BACK ) || self.Owner:KeyDown( IN_MOVELEFT ) || self.Owner:KeyDown( IN_MOVERIGHT ) ) then
  233. self.BobTimer = CurTime()
  234. self.Bob = 0
  235. end
  236. end
  237. if self.Sprint == 0 and self.Owner:KeyDown( IN_SPEED ) and ( self.Owner:KeyDown( IN_FORWARD ) || self.Owner:KeyDown( IN_BACK ) || self.Owner:KeyDown( IN_MOVELEFT ) || self.Owner:KeyDown( IN_MOVERIGHT ) ) then
  238. if SERVER then
  239. if self.Weapon:Clip1() > 0 then
  240. self.Weapon:SendWeaponAnim( ACT_VM_SPRINT_IDLE )
  241. end
  242. if self.Weapon:Clip1() <= 0 then
  243. self.Weapon:SendWeaponAnim( ACT_VM_SPRINT_LEAVE )
  244. end
  245. end
  246. self.Primary.Spread = 0.03
  247. self.Owner:SetFOV( 0, 0.1 )
  248. self.Sprint = 1
  249. self.Iron = 0
  250. self.BobTimer = CurTime()
  251. self.Bob = 1
  252. self.RecoilDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.Recoil
  253. self.RecoilViewDir = Angle( -1, math.random( -0.15, 0.15 ), 0 ) * self.Primary.RecoilView
  254. self.Owner:SetWalkSpeed( 200 )
  255. end
  256. if self.Sprint == 1 and self.BobTimer <= CurTime() and self.Bob == 1 then
  257. self.Owner:ViewPunch( Angle( -0.5, -0.5, -0.5 ) )
  258. self.BobTimer = CurTime() + 0.3
  259. self.Bob = 2
  260. end
  261. if self.Sprint == 1 and self.BobTimer <= CurTime() and self.Bob == 2 then
  262. self.Owner:ViewPunch( Angle( 0.5, -0.5, 0.5 ) )
  263. self.BobTimer = CurTime() + 0.3
  264. self.Bob = 1
  265. end
  266. if self.Sprint == 1 and !self.Owner:KeyDown( IN_SPEED ) then
  267. if SERVER then
  268. if self.Weapon:Clip1() > 0 then
  269. self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
  270. end
  271. if self.Weapon:Clip1() <= 0 then
  272. self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
  273. end
  274. end
  275. self:SetNextPrimaryFire( CurTime() + 0.2 )
  276. self:SetNextSecondaryFire( CurTime() + 0.2 )
  277. self.Sprint = 0
  278. self.BobTimer = CurTime()
  279. self.Bob = 0
  280. end
  281. if self.Sprint == 1 and !( self.Owner:KeyDown( IN_FORWARD ) || self.Owner:KeyDown( IN_BACK ) || self.Owner:KeyDown( IN_MOVELEFT ) || self.Owner:KeyDown( IN_MOVERIGHT ) ) then
  282. if SERVER then
  283. if self.Weapon:Clip1() > 0 then
  284. self.Weapon:SendWeaponAnim( ACT_VM_IDLE )
  285. end
  286. if self.Weapon:Clip1() <= 0 then
  287. self.Weapon:SendWeaponAnim( ACT_VM_IDLE_EMPTY )
  288. end
  289. end
  290. self:SetNextPrimaryFire( CurTime() + 0.2 )
  291. self:SetNextSecondaryFire( CurTime() + 0.2 )
  292. self.Sprint = 0
  293. self.BobTimer = CurTime()
  294. self.Bob = 0
  295. end
  296. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement