Advertisement
Guest User

Untitled

a guest
Jan 6th, 2014
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. include( "ai_translations.lua" )
  3. include("sh_anim.lua")
  4.  
  5. /*-----------------------------------------------------------
  6.  
  7. Remake of Leeroy's first base.
  8.  
  9. -----------------------------------------------------------*/
  10.  
  11. if !ConVarExists("Lee_WeaponsSpeed") then
  12. CreateConVar("Lee_WeaponsSpeed", '1', FCVAR_NOTIFY)
  13. end
  14.  
  15. if !ConVarExists("Lee_WeaponDamageMul") then
  16. CreateConVar("Lee_WeaponDamageMul", '1', FCVAR_NOTIFY)
  17. end
  18.  
  19. if !ConVarExists("Lee_WeaponRecoilMul") then
  20. CreateConVar("Lee_WeaponRecoilMul", '1.4', FCVAR_NOTIFY)
  21. end
  22.  
  23. if !ConVarExists("Lee_WeaponEDT") then
  24. CreateConVar("Lee_WeaponEDT", '1', FCVAR_NOTIFY)
  25. end
  26.  
  27. if !ConVarExists("Lee_WeaponEDC") then
  28. CreateConVar("Lee_WeaponEDC", '3', FCVAR_NOTIFY)
  29. end
  30.  
  31. if !ConVarExists("Lee_WeaponViewKick") then
  32. CreateConVar("Lee_WeaponViewKick", '1', FCVAR_NOTIFY)
  33. end
  34.  
  35. if !ConVarExists("Lee_WeaponInfiniteAmmo") then
  36. CreateConVar("Lee_WeaponInfiniteAmmo", '0', FCVAR_NOTIFY)
  37. end
  38.  
  39. if !ConVarExists("Lee_WeaponShakeMul") then
  40. CreateConVar("Lee_WeaponShakeMul", '5', FCVAR_NOTIFY)
  41. end
  42.  
  43. if !ConVarExists("Lee_WeaponHitEffect") then
  44. CreateConVar("Lee_WeaponHitEffect", '0', FCVAR_NOTIFY)
  45. end
  46.  
  47. if !ConVarExists("Lee_AttachViewModelToView") then
  48. CreateConVar("Lee_AttachViewModelToView", '0', FCVAR_NOTIFY)
  49. end
  50.  
  51. if !ConVarExists("Lee_WeaponAutoReload") then
  52. CreateConVar("Lee_WeaponAutoReload", '0', FCVAR_NOTIFY)
  53. end
  54.  
  55.  
  56.  
  57.  
  58. SWEP.ViewModelFlip = false
  59. SWEP.ViewModel = "models/weapons/v_pistol.mdl"
  60. SWEP.WorldModel = "models/weapons/w_357.mdl"
  61. SWEP.AnimPrefix = "python"
  62.  
  63. SWEP.HoldType = "pistol"
  64.  
  65. SWEP.Spawnable = false
  66. SWEP.AdminSpawnable = false
  67.  
  68. SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" )
  69. SWEP.Primary.Recoil = 1.5
  70. SWEP.Primary.Damage = 40
  71. SWEP.Primary.NumShots = 1
  72. SWEP.Primary.Cone = 0.02
  73. SWEP.Primary.Delay = 0.15
  74. SWEP.Primary.SmokeTrail = "smoke_trail"
  75.  
  76. SWEP.Secondary.ClipSize = -1
  77. SWEP.Secondary.DefaultClip = -1
  78. SWEP.Secondary.Automatic = false
  79. SWEP.Secondary.Ammo = "none"
  80.  
  81. SWEP.IronSightTime = 0.15
  82. SWEP.RunSetTime = 0.30
  83. SWEP.IronSightZoom = 1.35
  84. SWEP.SetHolsterTime = 0.35
  85.  
  86. SWEP.TracerRate = 1
  87.  
  88. SWEP.CanZoom = true
  89. SWEP.Running = false
  90. SWEP.Reloading = false
  91. SWEP.CanShellEject = true
  92. SWEP.ViewAnim = false
  93. SWEP.UseScope = false
  94. SWEP.EjectSmoke = true
  95. SWEP.MuzzleSmoke = true
  96. SWEP.NearWall = false
  97. SWEP.Silenced = false
  98. SWEP.UseSilencer = true
  99. SWEP.SilencerAnim = false
  100. SWEP.DryFireAnim = false
  101. SWEP.CanIdle = true
  102.  
  103. SWEP.RecoverTime = 0.15
  104. SWEP.MinRecoil = 0
  105. SWEP.MaxRecoil = 1
  106. SWEP.MinSpread = 0
  107. SWEP.MaxSpread = 0.06
  108.  
  109. SWEP.MuzzleEffect = "lee_muzzle_pistol"
  110. SWEP.MuzzleAttachment = "1"
  111.  
  112. SWEP.EjectAttachment = "2"
  113. SWEP.EjectTime = 0.01
  114.  
  115. SWEP.SmokeMuzzleAttachment = "1"
  116. SWEP.SmokeEjectAttachment = "2"
  117.  
  118. SWEP.Burst = {} -- best burst evar 8D
  119. SWEP.Burst.Enable = false
  120. SWEP.Burst.NumShots = 3
  121. SWEP.Burst.NextShotDelay = 0.05
  122. SWEP.Burst.NextBurst = 1
  123.  
  124. SWEP.SmokeMuzzleAttachment = "1"
  125. SWEP.SmokeEjectAttachment = "5"
  126.  
  127. SWEP.HolsterPos = Vector (0.2425, 0, 2.1846)
  128. SWEP.HolstersAng = Vector (-68.267, 2.6728, 0)
  129.  
  130. SWEP.NewOriginPos = Vector (2.9742, 0, 0.5123)
  131. SWEP.NewOriginAng = Vector (0, 0, 0)
  132.  
  133. SWEP.PistolNearWallPos = Vector (-0.6027, -11.384, -6.2741)
  134. SWEP.PistolNearWallAng = Vector (67.6324, 4.9439, -3.6316)
  135.  
  136. SWEP.NearWallPos = Vector (-1.0416, -11.4198, -2.2259)
  137. SWEP.NearWallAng = Vector (40.6435, -56.4456, -17.6906)
  138.  
  139. SWEP.ShotgunNearWallPos = Vector (3.1884, -13.3188, -2.7605)
  140. SWEP.ShotgunNearWallAng = Vector (59.4118, 1.7834, 9.1462)
  141.  
  142. /*---------------------------------------------------------
  143. Name: SWEP:Initialize( )
  144. Desc: Called when the weapon is first loaded
  145. ---------------------------------------------------------*/
  146. function SWEP:Initialize()
  147.  
  148. if SERVER and IsValid(self.Owner) and self.Owner:IsNPC() then
  149. self:SetWeaponHoldType( self.HoldType )
  150. self:SetNPCMinBurst(1)
  151. self:SetNPCMaxBurst(3)
  152. self:SetNPCFireRate(1)
  153. self.Weapon:SetCurrentWeaponProficiency( WEAPON_PROFICIENCY_VERY_GOOD )
  154. end
  155.  
  156. if self.WeaponType == "pistol" then
  157. self.CanZoom = false
  158. self.UseScope = false
  159. elseif self.WeaponType == "smg" then
  160. self.CanZoom = true
  161. self.UseScope = false
  162. elseif self.WeaponType == "rifle" then
  163. self.CanZoom = true
  164. self.UseScope = false
  165. elseif self.WeaponType == "shotgun" then
  166. self.CanZoom = true
  167. self.HoldType = "shotgun"
  168. self.UseScope = false
  169. elseif self.WeaponType == "sniper" then
  170. self.CanZoom = true
  171. self.UseScope = true
  172. elseif self.WeaponType == "winchester" then
  173. self.CanZoom = true
  174. self.UseScope = false
  175. elseif self.WeaponType == "aa12" then
  176. self.CanZoom = true
  177. self.UseScope = false
  178. end
  179.  
  180. self:SetUpFiremode()
  181. self:SetupDataTables()
  182. self:ResetVar()
  183.  
  184. end
  185.  
  186. function SWEP:ResetVar()
  187. self.Weapon:SetDTBool(0, false)
  188. self:SetIronsights( false )
  189. self.Weapon:SetDTBool(2, false)
  190. self.Weapon:SetNWBool("DoReloadBlur", false)
  191.  
  192. self.Weapon:SetDTFloat(0, 0)
  193.  
  194. self.Reloading = false
  195. self.DontNearWall = false
  196. self.NearWall = false
  197. self.ShotGunReloading = false
  198. self.LastSilBool = false
  199.  
  200. self.ActionDelay = CurTime()
  201. self.NextMod = CurTime()
  202. self.NextHolster = CurTime()
  203. self.ReloadTimer = CurTime()
  204.  
  205. self.IronFiremode = nil
  206. self.SpreadModifyTime = nil
  207. self.RemoveClipDelay = nil
  208. self.SetClipDelay = nil
  209. self.ShellEjectTime = nil
  210. self.MuzzleTime = nil
  211. self.BurstTime = nil
  212. self.NextBurstShot = nil
  213. self.MuzzleSmokeTrailTime = nil
  214. self.EjectSmokeTrailTime = nil
  215. self.ViewModelCenterFix = nil
  216. self.AddSpreadTime = nil
  217.  
  218. self.CurrentSpread = 0
  219. self.CurrentRecoil = 0
  220. self.BurstCounter = 0
  221. self.AddSpread = 0
  222. end
  223.  
  224. function SWEP:SetupDataTables()
  225.  
  226. self.Weapon:DTVar("Bool", 0, "Holstered")
  227. self.Weapon:DTVar("Bool", 1, "Ironsights")
  228. self.Weapon:DTVar("Bool", 2, "Lee_Scope")
  229.  
  230. self.Weapon:DTVar("Float", 0, "CurrentSpread")
  231.  
  232. end
  233.  
  234. /*---------------------------------------------------------
  235. DoViewAnim
  236. ---------------------------------------------------------*/
  237. function SWEP:DoViewAnim(Time)
  238.  
  239. if SERVER then
  240. umsg.Start( "SendViewAnim" )
  241. umsg.Float( Time )
  242. umsg.End( )
  243. end
  244. self.ViewAnimFinishTime = CurTime() + Time
  245.  
  246. end
  247.  
  248. /*---------------------------------------------------------
  249. GetTimeDivider
  250. ---------------------------------------------------------*/
  251. function SWEP:GetTimeDivider() -- make your weapon on cocaine
  252.  
  253. if !self.Owner:GetNWBool("Extention_Adrenaline") then
  254. TimeDivider = (GetConVarNumber("Lee_WeaponsSpeed") or 1)
  255. elseif self.Owner:GetNWBool("Extention_Adrenaline") then
  256. TimeDivider = 1.5
  257. end
  258.  
  259. return TimeDivider
  260. end
  261.  
  262. function SWEP:SetUpFiremode() -- initialize the fire mode
  263. if self.Primary.Mode and self.Primary.Mode == "semi" then
  264. self.Primary.Automatic = false
  265. elseif self.Primary.Mode and self.Primary.Mode == "auto" then
  266. self.Primary.Automatic = true
  267. elseif self.Primary.Mode and self.Primary.Mode == "burst" then
  268. self.Primary.Automatic = false
  269. elseif !self.Primary.Mode then
  270. self.Primary.Automatic = false
  271. end
  272. end
  273.  
  274. /*---------------------------------------------------------
  275. Name: SWEP:Precache( )
  276. Desc: Use this function to precache stuff
  277. ---------------------------------------------------------*/
  278. function SWEP:Precache()
  279. end
  280.  
  281.  
  282. /*---------------------------------------------------------
  283. Name: SWEP:PrimaryAttack( )
  284. Desc: +attack1 has been pressed
  285. ---------------------------------------------------------*/
  286. function SWEP:PrimaryAttack()
  287.  
  288. local vm = self.Owner:GetViewModel()
  289.  
  290. if self.ShotGunReloading then
  291. self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
  292. self.Weapon:SetNWBool("DoReloadBlur", false)
  293. self.AnimDuration = vm:SequenceDuration() / self:GetTimeDivider()
  294. vm:SetPlaybackRate ( self:GetTimeDivider() )
  295. self:DoViewAnim(self.AnimDuration)
  296. self.ShotGunReloading = false
  297. self.Reloading = false
  298. self.ActionDelay = CurTime() + self.AnimDuration
  299. self.ViewModelCenterFix = CurTime() + self.AnimDuration
  300. self.Weapon:SetNextPrimaryFire(CurTime() + self.AnimDuration)
  301. self.Weapon:SetNextSecondaryFire(CurTime() + self.AnimDuration)
  302. if self.Primary.Automatic != true then
  303. timer.Simple(self.PumpTime / self:GetTimeDivider(), function()
  304. if self.PumpPunch then
  305. self.Owner:ViewPunch(Angle(self.PumpPunch[1],self.PumpPunch[2],self.PumpPunch[3]))
  306. end
  307. end, self.Weapon)
  308. end
  309. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  310. self.Weapon:SetNetworkedFloat( "CrossHairGap", CurTime() )
  311. end
  312. else
  313. if self.Owner:KeyDown(IN_USE) then
  314. local SetHolster = !self:GetHolster()
  315. self:SetHolster( SetHolster )
  316. end
  317.  
  318. if ( !self:CanPrimaryAttack() ) then return end
  319.  
  320. if !self.Owner:KeyDown(IN_USE) then
  321. if !self.Burst.Enable then
  322. self:AttackCode()
  323. else
  324. self.BurstCounter = self.Burst.NumShots
  325. self:AttackCode()
  326. self.BurstTime = CurTime() + (self.Primary.Delay * self.BurstCounter)
  327. self.NextBurstShot = CurTime() + self.Primary.Delay
  328. end
  329.  
  330. end
  331. end
  332.  
  333. end
  334.  
  335. function SWEP:AttackCode()
  336.  
  337. local vm = self.Owner:GetViewModel()
  338.  
  339. if !self:GetSilencer() then
  340. self.Weapon:EmitSound( self.Primary.Sound )
  341. else
  342. self.Weapon:EmitSound( self.Primary.Silenced )
  343. end
  344.  
  345. self:ShootBullet( self.Primary.Damage, self.Primary.NumShots, self.CurrentSpread, self.CurrentRecoil )
  346.  
  347. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay)
  348. self.ActionDelay = CurTime() + self.Primary.Delay
  349.  
  350. self:TakePrimaryAmmo( 1 )
  351.  
  352. if ( self.Owner:IsNPC() ) then return end
  353.  
  354. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  355.  
  356. self.AddSpread = self.AddSpread + 1
  357. self.RecoverSpreadTime = CurTime() + self.RecoverTime
  358.  
  359. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  360. end
  361.  
  362. end
  363.  
  364. /*---------------------------------------------------------
  365. GetIronsights
  366. ---------------------------------------------------------*/
  367. function SWEP:GetIronsights()
  368. return self.Weapon:GetDTBool( 1 )
  369. end
  370.  
  371. /*---------------------------------------------------------
  372. SetIronsights
  373. ---------------------------------------------------------*/
  374. function SWEP:SetIronsights( b )
  375.  
  376. if self.Owner and self.Weapon then
  377. if (b) then
  378. if self.UseScope == true then
  379. self.ScopeTime = CurTime() + self.IronSightTime
  380. self.NextReload = CurTime() + self.IronSightTime
  381. end
  382. else
  383. /*
  384. if self:GetScope() then
  385. self:SetScope(false, self.Owner)
  386. end
  387. */
  388. end
  389. end
  390.  
  391. if SERVER then
  392. if IsValid(self.Owner) then
  393. umsg.Start("CallIronTilt", self.Owner)
  394. umsg.Float(self.IronSightTime)
  395. umsg.End()
  396. end
  397. end
  398.  
  399. self.LastIron = self:GetIronsights()
  400. self.Weapon:SetDTBool(1, b)
  401.  
  402. end
  403.  
  404. /*---------------------------------------------------------
  405. SetHolster
  406. ---------------------------------------------------------*/
  407. function SWEP:SetHolster( b )
  408.  
  409. if self.NextHolster and self.NextHolster <= CurTime() then
  410. self.Weapon:SetDTBool(0, b)
  411. local Time = self.SetHolsterTime - 0.05
  412. self.NextHolster = CurTime() + Time
  413. self.Weapon:SetNextPrimaryFire(CurTime() + Time)
  414. end
  415.  
  416. end
  417.  
  418. function SWEP:GetHolster()
  419. return self.Weapon:GetDTBool( 0 )
  420. end
  421.  
  422. /*---------------------------------------------------------
  423. SetFireMode
  424. ---------------------------------------------------------*/
  425. function SWEP:SetFireMode(mode, cansound, cantext)
  426. if !self.NextMod or self.NextMod > CurTime() or !IsFirstTimePredicted() or OneTime then return end
  427.  
  428. local Text = ""
  429. OneTime = true
  430. self:SetIronsights(false)
  431. self:SetHolster( true )
  432.  
  433. if mode == "semi" then
  434. self.Primary.Automatic = false
  435. self.Primary.Mode = "semi"
  436. self.Burst.Enable = false
  437. if cansound then
  438. self.Owner:EmitSound("firemode/firemode_semi.wav", 80)
  439. end
  440. Text = "Firemode switched to semi automatic."
  441. elseif mode == "auto" then
  442. self.Primary.Automatic = true
  443. self.Primary.Mode = "auto"
  444. self.Burst.Enable = false
  445. if cansound then
  446. self.Owner:EmitSound("firemode/firemode_auto.wav", 80)
  447. end
  448. Text = "Firemode switched to automatic."
  449. elseif mode == "burst" then
  450. self.Primary.Automatic = false
  451. self.Primary.Mode = "burst"
  452. self.Burst.Enable = true
  453. if cansound then
  454. self.Owner:EmitSound("firemode/firemode_burst.wav", 80)
  455. end
  456. Text = "Firemode switched to burst shots."
  457. end
  458. if IsValid(self.Owner) and IsValid(self.Weapon) and self.Owner:GetActiveWeapon() == self.Weapon and Text != "" and cantext then
  459. self.Owner:ChatPrint(Text)
  460. end
  461. self.NextMod = CurTime() + 0.5
  462. self.Weapon:SetNextSecondaryFire(CurTime() + 0.8)
  463.  
  464. self.IronFiremode = CurTime() + self.IronSightTime
  465.  
  466. OneTime = false
  467. return
  468. end
  469.  
  470. SWEP.NextSecondaryAttack = 0
  471. /*---------------------------------------------------------
  472. SecondaryAttack
  473. ---------------------------------------------------------*/
  474. function SWEP:SecondaryAttack()
  475. if not IsFirstTimePredicted() then return end
  476. if self.Owner and !self.Owner:KeyDown(IN_USE) then
  477.  
  478. if !self.IronSightsPos or self.Reloading or self.ShotGunReloading or self.NearWall then return end
  479. if self.NextSecondaryAttack > CurTime() then return end
  480.  
  481. bIronsights = !self:GetIronsights()
  482. self:SetIronsights( bIronsights )
  483. self.NextSecondaryAttack = CurTime() + 0.3
  484.  
  485. elseif self.Owner and self.Owner:KeyDown(IN_USE) then
  486. self:DoMode()
  487. end
  488.  
  489. end
  490.  
  491. function SWEP:DoMode()
  492. if !table.HasValue(self.AvailableFireMode, "burst") and table.HasValue(self.AvailableFireMode, "auto") and self.Primary.Mode == "semi" then
  493. self:SetFireMode("auto", true, true)
  494. elseif !table.HasValue(self.AvailableFireMode, "burst") and table.HasValue(self.AvailableFireMode, "semi") and self.Primary.Mode == "auto" then
  495. self:SetFireMode("semi", true, true)
  496. elseif table.HasValue(self.AvailableFireMode, "burst") and !table.HasValue(self.AvailableFireMode, "semi") and self.Primary.Mode == "auto" then
  497. self:SetFireMode("burst", true, true)
  498. elseif table.HasValue(self.AvailableFireMode, "auto") and !table.HasValue(self.AvailableFireMode, "semi") and self.Primary.Mode == "burst" then
  499. self:SetFireMode("auto", true, true)
  500. elseif table.HasValue(self.AvailableFireMode, "burst") and !table.HasValue(self.AvailableFireMode, "auto") and self.Primary.Mode == "semi" then
  501. self:SetFireMode("burst", true, true)
  502. elseif table.HasValue(self.AvailableFireMode, "semi") and !table.HasValue(self.AvailableFireMode, "auto") and self.Primary.Mode == "burst" then
  503. self:SetFireMode("semi", true, true)
  504. elseif table.HasValue(self.AvailableFireMode, "semi") and table.HasValue(self.AvailableFireMode, "auto") and table.HasValue(self.AvailableFireMode, "burst") and self.Primary.Mode == "semi" then
  505. self:SetFireMode("auto", true, true)
  506. elseif table.HasValue(self.AvailableFireMode, "semi") and table.HasValue(self.AvailableFireMode, "auto") and table.HasValue(self.AvailableFireMode, "burst") and self.Primary.Mode == "auto" then
  507. self:SetFireMode("burst", true, true)
  508. elseif table.HasValue(self.AvailableFireMode, "semi") and table.HasValue(self.AvailableFireMode, "auto") and table.HasValue(self.AvailableFireMode, "burst") and self.Primary.Mode == "burst" then
  509. self:SetFireMode("semi", true, true)
  510. end
  511. end
  512.  
  513. /*---------------------------------------------------------
  514. Name: SWEP:CheckReload( )
  515. Desc: CheckReload
  516. ---------------------------------------------------------*/
  517. function SWEP:CheckReload()
  518.  
  519. end
  520.  
  521. /*---------------------------------------------------------
  522. Name: SWEP:Reload( )
  523. Desc: Reload is being pressed
  524. ---------------------------------------------------------*/
  525. function SWEP:Reload()
  526.  
  527. if self.Owner:IsPlayer() then
  528. local vm = self.Owner:GetViewModel()
  529. if !self.Owner:KeyDown(IN_USE) then
  530. if self.WeaponType != "shotgun" and self.WeaponType != "winchester" then
  531. if self.ActionDelay and self.ActionDelay <= CurTime() and ( self.Weapon:Clip1() < self.Primary.ClipSize ) and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  532. if self.Silenced and self.SilencerAnim then
  533. self:CustomReload(ACT_VM_RELOAD_SILENCED)
  534. else
  535. if self.ReloadTable["CanEmptyReload"] then
  536. if self.Weapon:Clip1() > 0 then
  537. self:CustomReload(ACT_VM_RELOAD)
  538. else
  539. self:CustomReload(ACT_VM_RELOAD)
  540. end
  541. else
  542. self:CustomReload(ACT_VM_RELOAD)
  543. end
  544. end
  545. end
  546. else
  547. if self.ActionDelay and self.ActionDelay <= CurTime() and (self.Weapon:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then
  548. if self.Owner:KeyPressed(IN_RELOAD) and !self.ShotGunReloading then
  549. self.ViewModelCenterFix = nil
  550. self.ShotGunReloading = true
  551. vm:SetSequence("reload_start")
  552. self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START)
  553. vm:SetPlaybackRate ( self:GetTimeDivider() )
  554. self.Weapon:SetNWBool("DoReloadBlur", true)
  555. self.AnimDuration = vm:SequenceDuration() / self:GetTimeDivider()
  556. self:DoViewAnim(self.AnimDuration)
  557. self.ActionDelay = CurTime() + self.AnimDuration
  558. self.ReloadTimer = CurTime() + self.AnimDuration
  559. self.Weapon:SetNextPrimaryFire(CurTime() + self.AnimDuration)
  560. self:SetIronsights(false)
  561. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  562. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  563. end
  564. end
  565. end
  566. if self.ShotGunReloading and self.ReloadTimer < CurTime() and self.ActionDelay and self.ActionDelay <= CurTime() and self.Owner:KeyPressed(IN_RELOAD) then
  567. if (self.Weapon:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then
  568. vm:SetPlaybackRate ( self:GetTimeDivider() )
  569. self.Weapon:SendWeaponAnim(ACT_VM_RELOAD)
  570. vm:SetPlaybackRate ( self:GetTimeDivider() )
  571. self.AnimDuration = vm:SequenceDuration() / self:GetTimeDivider()
  572. /* -- for killing floor
  573. self.StopShotgunAnim = CurTime() + self.AnimDuration
  574. */
  575. if self.AddShellPunch then
  576. self.Owner:ViewPunch(Angle(self.AddShellPunch[1],self.AddShellPunch[2],self.AddShellPunch[3]))
  577. end
  578. self:DoViewAnim(self.AnimDuration)
  579. self.Weapon:SetNetworkedInt( "reloadtimer", CurTime() + self.AnimDuration - 0.1)
  580. self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
  581. self.Owner:SetAnimation (PLAYER_RELOAD)
  582. self.ActionDelay = CurTime() + self.AnimDuration
  583. self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
  584. self.Weapon:SetNextPrimaryFire(CurTime() + self.AnimDuration)
  585. self.Weapon:SetNextSecondaryFire(CurTime() + self.AnimDuration)
  586. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  587. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  588. end
  589. end
  590. end
  591. end
  592. elseif self.Owner:KeyDown(IN_USE) and self.UseSilencer and self.WeaponType != "shotgun" then
  593. if !self.ActionDelay or self.ActionDelay > CurTime() then return end
  594. if !self.SilencerAnim then
  595. local SilBool = !self:GetSilencer()
  596. local SilencerDelay = 2
  597.  
  598. self.SetSilencerTime = CurTime() + SilencerDelay / 2
  599. self.ActionDelay = CurTime() + SilencerDelay + 0.5
  600. if SERVER then
  601. self:SetIronsights(false)
  602. umsg.Start("ClSetSilencerTime", self.Owner)
  603. umsg.Float(SilencerDelay)
  604. umsg.Bool(SilBool)
  605. umsg.End()
  606. end
  607. timer.Simple(0.3, function()
  608. if SERVER then
  609. if SilBool then
  610. self.Weapon:EmitSound( "Weapon_USP.AttachSilencer" )
  611. else
  612. self.Weapon:EmitSound( "Weapon_USP.DetachSilencer" )
  613. end
  614. end
  615. end, self.Weapon)
  616. else
  617. if !self.Silenced then
  618. self.Weapon:SendWeaponAnim(ACT_VM_ATTACH_SILENCER)
  619. self.Silenced = true
  620. else
  621. self.Weapon:SendWeaponAnim(ACT_VM_DETACH_SILENCER)
  622. self.Silenced = false
  623. end
  624.  
  625. umsg.Start("ClSendSilencer", self.Owner)
  626. umsg.Bool(self.Silenced)
  627. umsg.End()
  628.  
  629. self:SetIronsights(false)
  630.  
  631. self.AnimDuration = vm:SequenceDuration() / self:GetTimeDivider()
  632. vm:SetPlaybackRate(self:GetTimeDivider())
  633. self.ActionDelay = CurTime() + self.AnimDuration
  634. self.ViewModelCenterFix = CurTime() + self.AnimDuration
  635. self.Weapon:SetNextPrimaryFire(CurTime() + self.AnimDuration)
  636. self.Weapon:SetNextSecondaryFire(CurTime() + self.AnimDuration)
  637. end
  638. end
  639. else
  640. self.Weapon:DefaultReload( ACT_VM_RELOAD );
  641. end
  642.  
  643. end
  644.  
  645. function SWEP:GetSilencer()
  646.  
  647. return self.Silenced
  648.  
  649. end
  650.  
  651. function SWEP:CustomReload(anim) -- i hate the DefaultReload
  652.  
  653. if !anim then return end
  654.  
  655. self.ViewModelCenterFix = nil
  656.  
  657. local Vm = self.Owner:GetViewModel()
  658. self.Owner:SetAnimation (PLAYER_RELOAD)
  659.  
  660. self.Weapon:SendWeaponAnim(anim or "")
  661.  
  662. self.AnimDuration = Vm:SequenceDuration()
  663. self:SetIronsights(false)
  664. self.Reloading = true
  665. self.EmptyReload = false
  666. self.Weapon:SetNWBool("DoReloadBlur", true)
  667. Vm:SetPlaybackRate ( self:GetTimeDivider() )
  668. local ReloadSpeed = self.AnimDuration / self:GetTimeDivider()
  669. local SetClipvalue = math.Clamp( self.Owner:GetAmmoCount(self.Primary.Ammo), 0, self.Primary.ClipSize )
  670.  
  671. if self.ReloadTable then
  672. local EmptyRemoveClipTime = self.ReloadTable["RemoveClip"].EmptyTime
  673. local EmptySetClipTime = self.ReloadTable["SetClip"].EmptyTime
  674.  
  675. local RemoveClipTime = self.ReloadTable["RemoveClip"].Time
  676. local SetClipTime = self.ReloadTable["SetClip"].Time
  677.  
  678. if self.ReloadTable["CanEmptyReload"] and self.Weapon:Clip1() <= 0 and EmptyRemoveClipTime and EmptySetClipTime and EmptyRemoveClipTime > 0 and EmptySetClipTime > 0 then
  679. self.RemoveClipDelay = CurTime() + (EmptyRemoveClipTime / self:GetTimeDivider())
  680. self.SetClipDelay = CurTime() + (EmptySetClipTime / self:GetTimeDivider())
  681. self.Weapon:SetNextSecondaryFire( CurTime() + ReloadSpeed )
  682. self.Weapon:SetNextPrimaryFire( CurTime() + ReloadSpeed )
  683. self:DoViewAnim(ReloadSpeed)
  684. self.ActionDelay = CurTime() + ReloadSpeed
  685. self.NextSecondaryAttack = CurTime() + ReloadSpeed
  686. self.FinishReloadTime = CurTime() + ReloadSpeed
  687. self.ReloadBlurTime = CurTime() + ReloadSpeed - 0.35
  688. else
  689. self.RemoveClipDelay = CurTime() + (RemoveClipTime / self:GetTimeDivider())
  690. self.SetClipDelay = CurTime() + (SetClipTime / self:GetTimeDivider())
  691. self.Weapon:SetNextSecondaryFire( CurTime() + ReloadSpeed )
  692. self.Weapon:SetNextPrimaryFire( CurTime() + ReloadSpeed )
  693. self:DoViewAnim(ReloadSpeed)
  694. self.ActionDelay = CurTime() + ReloadSpeed
  695. self.NextSecondaryAttack = CurTime() + ReloadSpeed
  696. self.FinishReloadTime = CurTime() + ReloadSpeed
  697. self.ReloadBlurTime = CurTime() + ReloadSpeed - 0.35
  698. end
  699. else
  700. timer.Simple( ReloadSpeed, function() --shitty reload
  701. self.Reloading = false
  702. self.Weapon:SetNWBool("DoReloadBlur", false)
  703. self.Weapon:SetNWBool("DoReloadViewAnim", false)
  704. self.Weapon:SetClip1( SetClipvalue )
  705. self.Owner:RemoveAmmo( SetClipvalue, self.Primary.Ammo, false )
  706. end, self.Weapon)
  707. end
  708.  
  709. end
  710.  
  711. function SWEP:ReloadEffect()
  712.  
  713. if self.Reloading == false then return end
  714.  
  715. if self.RemoveClipDelay and CurTime() >= self.RemoveClipDelay then
  716. self.RemoveClipDelay = nil
  717.  
  718. local RemoveClipTime = self.ReloadTable["RemoveClip"].Time
  719. local HaveCylinder = self.ReloadTable["RemoveClip"].Cylinder
  720.  
  721. if self.Weapon:Clip1() > 0 then
  722. if HaveCylinder == false then
  723. self.Weapon:SetClip1( 1 )
  724. else
  725. self.Weapon:SetClip1( 0 )
  726. end
  727. else
  728. self.Weapon:SetClip1( 0 )
  729. end
  730.  
  731. if ( self.Owner:IsNPC() ) then return end
  732. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  733. self.Weapon:SetNetworkedFloat( "CrossHairGap", CurTime() )
  734. end
  735. end
  736.  
  737. if self.SetClipDelay and CurTime() >= self.SetClipDelay then
  738. self.SetClipDelay = nil
  739. local SetClipvalue = math.Clamp( self.Owner:GetAmmoCount(self.Primary.Ammo) , 0 , self.Primary.ClipSize )
  740. if self.Weapon:Clip1() < 1 then
  741. self.Weapon:SetClip1( SetClipvalue )
  742. else
  743. self.Weapon:SetClip1( SetClipvalue + 1 )
  744. end
  745.  
  746. if GetConVarNumber("Lee_WeaponInfiniteAmmo") <= 0 then
  747. self.Owner:RemoveAmmo( SetClipvalue, self.Primary.Ammo, false )
  748. end
  749.  
  750. if self.EmptyReload == true then
  751. self.EmptyReload = false
  752. end
  753.  
  754. if ( self.Owner:IsNPC() ) then return end
  755. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  756.  
  757. self.Weapon:SetNetworkedFloat( "CrossHairGap", CurTime() )
  758. end
  759. end
  760.  
  761. if self.ReloadBlurTime and self.ReloadBlurTime <= CurTime() then
  762. self.ReloadBlurTime = nil
  763. self.Weapon:SetNWBool("DoReloadBlur", false)
  764. end
  765.  
  766. if self.FinishReloadTime and self.FinishReloadTime <= CurTime() then
  767. self.FinishReloadTime = nil
  768. self.Reloading = false
  769. if IsValid(self.Weapon) and IsValid(self.Owner) and self.Owner and self.Owner:Health() > 0 and self.Owner:KeyDown(IN_ATTACK2) and !self.Owner:KeyDown(IN_SPEED) then
  770. self:SetIronsights(true, true)
  771. end
  772. end
  773.  
  774. end
  775.  
  776. function SWEP:AltThink()
  777.  
  778. end
  779.  
  780. function SWEP:CalcWeaponVar()
  781.  
  782. self.CurrentSpread = self.Primary.Cone
  783. self.CurrentRecoil = self.Primary.Recoil
  784.  
  785. if self.Owner:IsPlayer() then
  786.  
  787. local vel = self.Owner:GetVelocity()
  788. local vellen = vel:Length()
  789.  
  790. if self.WeaponType != "shotgun" then
  791.  
  792. if self.RecoverSpreadTime and self.RecoverSpreadTime < CurTime() and self.AddSpread > 0 then
  793. local Dist = self.AddSpread - 0
  794. self.AddSpread = self.AddSpread - FrameTime() * (Dist * 10)
  795. if self.AddSpread < 0 then
  796. self.AddSpread = 0
  797. end
  798. end
  799.  
  800. if self.Owner:OnGround() and self.Owner:KeyDown(IN_DUCK) then
  801. self.CurrentSpread = self.CurrentSpread / 1.5
  802. self.CurrentRecoil = self.CurrentRecoil / 1.5
  803. self.AddSpread = self.AddSpread / 1.2
  804. end
  805.  
  806. if !self.Owner:OnGround() then
  807. self.CurrentSpread = self.CurrentSpread * 2
  808. self.CurrentRecoil = self.CurrentRecoil * 2
  809. self.AddSpread = self.AddSpread * 1.5
  810. end
  811.  
  812. if self:GetIronsights() then
  813. self.CurrentSpread = self.CurrentSpread / 1.5
  814. self.CurrentRecoil = self.CurrentRecoil / 1.5
  815. self.AddSpread = self.AddSpread / 1.2
  816. end
  817.  
  818. self.CurrentSpread = self.CurrentSpread
  819.  
  820. self.CurrentSpread = math.Clamp(self.CurrentSpread + (vellen / 16000), self.MinSpread, self.MaxSpread)
  821. self.CurrentRecoil = self.CurrentRecoil + (vellen / 1200)
  822.  
  823. self.Weapon:SetDTFloat(0, self.CurrentSpread)
  824.  
  825. end
  826.  
  827. end
  828.  
  829. end
  830.  
  831. /*---------------------------------------------------------
  832. Name: SWEP:Think( )
  833. Desc: Called every frame
  834. ---------------------------------------------------------*/
  835. function SWEP:Think()
  836.  
  837.  
  838. if !self.Running and !self.Owner:KeyDown(IN_DUCK) and self.Owner:KeyDown(IN_SPEED) and self.Owner:GetVelocity():Length() > self.Owner:GetWalkSpeed() and !self:GetIronsights() and !self:GetHolster() and self.Owner:IsOnGround() then
  839. self.Running = true
  840. self:SetIronsights(false)
  841. elseif self.Running and (!self.Owner:KeyDown(IN_SPEED) or self.Owner:KeyDown(IN_DUCK)) then
  842. self.Running = false
  843. if !self.Reloading then
  844. self.Weapon:SetNextPrimaryFire( CurTime() + 0.15 )
  845. end
  846. elseif self.Running and self:GetIronsights() or self.Running and self.Owner:GetVelocity():Length() <= self.Owner:GetWalkSpeed() or self.Running and self.Owner:KeyDown(IN_SPEED) and !self.Owner:KeyDown(IN_FORWARD) and !self.Owner:KeyDown(IN_BACK) and !self.Owner:KeyDown(IN_MOVELEFT) and !self.Owner:KeyDown(IN_MOVERIGHT) or self.Running and !self.Owner:IsOnGround() or self.Running and self.Owner:KeyDown(IN_DUCK) then
  847. self.Running = false
  848. if !self.Reloading then
  849. self.Weapon:SetNextPrimaryFire( CurTime() + 0.15 )
  850. end
  851. end
  852.  
  853. local Tr = self.Owner:GetEyeTrace()
  854.  
  855. if Tr.Entity:IsValid() and Tr.Entity:IsNPC() or Tr.Entity:IsPlayer() then
  856. self.DontNearWall = true
  857. elseif Tr.Entity:IsValid() then
  858. self.DontNearWall = false
  859. end
  860.  
  861. if Tr.Hit and Tr.HitPos:Distance(self.Owner:GetShootPos()) < 40 and !self.NearWall and self.SetSilencerTime == nil and !self.DontNearWall then
  862. self.NearWall = true
  863. self:SetIronsights(false)
  864. elseif Tr.HitPos:Distance(self.Owner:GetShootPos()) > 40 and self.NearWall or self.SetSilencerTime and self.SetSilencerTime >= CurTime() or self.NearWall and self.DontNearWall then
  865. self.NearWall = false
  866. self.Weapon:SetNextPrimaryFire(CurTime() + 0.15)
  867. self.Weapon:SetNextSecondaryFire(CurTime() + 0.15)
  868. if self.LastIron and !self.DontNearWall then
  869. self:SetIronsights(true)
  870. end
  871. end
  872.  
  873. if self.IronFiremode and self.IronFiremode <= CurTime() then
  874. self.IronFiremode = nil
  875. self.Weapon:SetDTBool( 0, false )
  876. if self.LastIron then
  877. self:SetIronsights(true)
  878. end
  879. end
  880.  
  881. if self.BurstTime and self.BurstTime > CurTime() then
  882. if self.NextBurstShot and self.NextBurstShot <= CurTime() and self:CanPrimaryAttack() and self.Owner and self.Owner:KeyDown(IN_ATTACK) then
  883. self.NextBurstShot = CurTime() + self.Primary.Delay
  884. self.BurstCounter = self.BurstCounter - 1
  885. self.Weapon:SetNextPrimaryFire(CurTime() + self.Burst.NextBurst)
  886. self:AttackCode()
  887. end
  888. end
  889.  
  890. if self.MuzzleSmokeTrailTime and self.MuzzleSmokeTrailTime <= CurTime() then
  891. self.MuzzleSmokeTrailTime = nil
  892. self:MuzzleSmokeTrailEffect()
  893. end
  894.  
  895. if self.EjectSmokeTrailTime and self.EjectSmokeTrailTime <= CurTime() then
  896. self.EjectSmokeTrailTime = nil
  897. self:EjectSmokeTrailEffect()
  898. end
  899.  
  900. if self.Running or self:GetHolster() and !self:GetIronsights() or self.NearWall and !self:GetIronsights() then
  901. if self.WeaponType != "pistol" and !self.Owner:Crouching() then
  902. self:SetWeaponHoldType("passive")
  903. else
  904. self:SetWeaponHoldType("normal")
  905. end
  906. self.MeleeAttack = false
  907. self.MeleeAttackTime = nil
  908. else
  909. self:SetWeaponHoldType(self.HoldType)
  910. if self.WeaponType == "sniper" and self:GetIronsights() then
  911. self:SetWeaponHoldType("ar2")
  912. else
  913. self:SetWeaponHoldType(self.HoldType)
  914. end
  915. end
  916.  
  917. if self.ViewModelCenterFix and self.ViewModelCenterFix <= CurTime() and self.CanIdle then
  918. self.ViewModelCenterFix = nil
  919. if self.WeaponType == "pistol" then
  920. if self.Weapon:Clip1() > 0 then
  921. if self.Silenced and self.SilencerAnim then
  922. self.Weapon:SendWeaponAnim(ACT_VM_IDLE_SILENCED)
  923. else
  924. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  925. end
  926. elseif self.Weapon:Clip1() <= 0 and self.DryFireAnim then
  927. self.Weapon:SendWeaponAnim(ACT_VM_IDLE_EMPTY)
  928. end
  929. else
  930. if self.Silenced and self.SilencerAnim then
  931. self.Weapon:SendWeaponAnim(ACT_VM_IDLE_SILENCED)
  932. else
  933. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  934. end
  935. end
  936.  
  937. if self.Weapon:Clip1() > 0 then
  938. self.Owner:GetViewModel():SetPlaybackRate(0)
  939. end
  940.  
  941. end
  942.  
  943. self:AltThink()
  944. self:CalcWeaponVar()
  945. self:ReloadEffect()
  946. self:WeaponElements()
  947. end
  948.  
  949. function SWEP:SetSilencer( b )
  950.  
  951. self.Silenced = b
  952.  
  953. if SERVER then
  954. if self.LastSilBool != b then
  955. self.LastSilBool = b
  956. umsg.Start("ClSendSilencer", self.Owner)
  957. umsg.Bool(b)
  958. umsg.End()
  959. end
  960. end
  961.  
  962. end
  963.  
  964. function SWEP:WeaponElements()
  965. if self.SetSilencerTime and self.SetSilencerTime <= CurTime() then
  966. self.SetSilencerTime = nil
  967. local SilBool = !self:GetSilencer()
  968. if SERVER then
  969. self:SetSilencer(SilBool)
  970. end
  971. self:ResetVar() -- make the weapon stop doing shit
  972. if GetConVarNumber("Lee_NewPlayerView") >= 1 then
  973. self.Weapon:SetNextPrimaryFire(CurTime() + 2)
  974. else
  975. self.Weapon:SetNextPrimaryFire(CurTime() + 1.5)
  976. end
  977. elseif self.SetSilencerTime and self.SetSilencerTime > CurTime() then
  978. self:SetIronsights(false)
  979. self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
  980. end
  981.  
  982. if self.SetLaserPointerTime and self.SetLaserPointerTime <= CurTime() then
  983. self.SetLaserPointerTime = nil
  984. self:SetHolster( false )
  985. local SilBool = !self.Weapon:GetNetworkedBool( "havelaserpointer" )
  986. self:SetNWBool( "havelaserpointer", SilBool )
  987. self:ResetVar() -- make the weapon stop doing shit
  988. self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
  989. if self.LastIron then
  990. self:SetIronsights(true)
  991. end
  992. elseif self.SetLaserPointerTime and self.SetLaserPointerTime > CurTime() then
  993. self:SetHolster( true )
  994. self:SetIronsights(false)
  995. end
  996. end
  997.  
  998. /*---------------------------------------------------------
  999. Name: SWEP:Holster( weapon_to_swap_to )
  1000. Desc: Weapon wants to holster
  1001. RetV: Return true to allow the weapon to holster
  1002. ---------------------------------------------------------*/
  1003. function SWEP:Holster( wep )
  1004. self:ResetVar()
  1005. return true
  1006. end
  1007.  
  1008. /*---------------------------------------------------------
  1009. Deploy
  1010. ---------------------------------------------------------*/
  1011. function SWEP:Deploy()
  1012.  
  1013. local vm = self.Owner:GetViewModel()
  1014.  
  1015. self:ResetVar()
  1016.  
  1017. if !self.Silenced then
  1018. if self.Weapon:Clip1() <= 0 then
  1019. self.Weapon:SendWeaponAnim(ACT_VM_DRAW_EMPTY)
  1020. else
  1021. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  1022. end
  1023. elseif self.Silenced and self.SilencerAnim then
  1024.  
  1025. self.Weapon:SendWeaponAnim(ACT_VM_DRAW_SILENCED)
  1026.  
  1027. end
  1028.  
  1029.  
  1030.  
  1031. vm:SetPlaybackRate ( self:GetTimeDivider() )
  1032. self.AnimDuration = vm:SequenceDuration() / self:GetTimeDivider()
  1033. self.Weapon:SetNextPrimaryFire(CurTime() + self.AnimDuration)
  1034. self.Weapon:SetNextSecondaryFire(CurTime() + self.AnimDuration)
  1035.  
  1036. self:DoViewAnim(self.AnimDuration)
  1037.  
  1038. self.ActionDelay = CurTime() + self.AnimDuration
  1039.  
  1040. if (SERVER) or (CLIENT) then
  1041. self.Owner:EmitSound(Sound("player/deploysound.wav"))
  1042. end
  1043.  
  1044. return true
  1045.  
  1046. end
  1047.  
  1048.  
  1049. /*---------------------------------------------------------
  1050. Name: SWEP:ShootBullet( )
  1051. Desc: A convenience function to shoot bullets
  1052. ---------------------------------------------------------*/
  1053.  
  1054.  
  1055.  
  1056. function SWEP:ShootEffects()
  1057. local vm = self.Owner:GetViewModel()
  1058. local ShellEjectTime = self.EjectTime or 0.05
  1059.  
  1060. if self.Weapon:Clip1() == 1 and self.DryFireAnim then
  1061. if self.Silenced and self.SilencerAnim then
  1062. self.Weapon:SendWeaponAnim( ACT_VM_DRYFIRE_SILENCED )
  1063. else
  1064. self.Weapon:SendWeaponAnim( ACT_VM_DRYFIRE )
  1065. end
  1066. self.ViewModelCenterFix = nil
  1067. else
  1068. if self.Silenced and self.SilencerAnim then
  1069. if self.Weapon:GetClass() == "weapon_css_usp" then
  1070. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_SILENCED )
  1071. vm:SetSequence("shoot1")
  1072. else
  1073. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_SILENCED )
  1074. end
  1075. else
  1076. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  1077. end
  1078. self.AnimDuration = vm:SequenceDuration()
  1079. self.ViewModelCenterFix = CurTime() + self.AnimDuration
  1080. end
  1081.  
  1082. if self:GetIronsights() then
  1083. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_SILENCED )
  1084. end
  1085.  
  1086. self.Owner:SetAnimation( PLAYER_ATTACK1 )
  1087.  
  1088. self.ShellEjectTime = CurTime() + ShellEjectTime
  1089. self.MuzzleTime = CurTime()
  1090.  
  1091. if !self.Owner then return end
  1092. if !IsFirstTimePredicted() then return end
  1093. if self.ShellEject != nil and self.CanShellEject then
  1094. if CLIENT then
  1095. if GetViewEntity() == self.Owner then
  1096. if SERVER then
  1097. umsg.Start("CallShellEject", self.Owner)
  1098. umsg.End()
  1099. end
  1100. end
  1101. else
  1102. if self.Owner:GetViewEntity() == self.Owner then
  1103. if SERVER then
  1104. umsg.Start("CallShellEject", self.Owner)
  1105. umsg.End()
  1106. end
  1107. end
  1108. end
  1109. end
  1110.  
  1111. if self.MuzzleEffect != nil then
  1112. if ( self.Owner:IsNPC() ) then return end
  1113. if self.Weapon then
  1114. if CLIENT then
  1115. if GetViewEntity() == self.Owner then
  1116. if not self.Owner then return end
  1117. if not IsFirstTimePredicted() then return end
  1118. if SERVER then
  1119. umsg.Start("CallMuzzleEffect", self.Owner)
  1120. umsg.End()
  1121. end
  1122.  
  1123. end
  1124. else
  1125. if self.Owner:GetViewEntity() == self.Owner then
  1126. if not self.Owner then return end
  1127. if not IsFirstTimePredicted() then return end
  1128. if SERVER then
  1129. umsg.Start("CallMuzzleEffect", self.Owner)
  1130. umsg.End()
  1131. end
  1132. end
  1133. end
  1134. end
  1135. end
  1136.  
  1137. if ( self.Owner:IsNPC() ) then return end
  1138.  
  1139. if SERVER then
  1140. umsg.Start("CallSmokeTrailEffect", self.Owner)
  1141. umsg.Float(0)
  1142. umsg.String(self.SmokeMuzzleAttachment)
  1143. umsg.End()
  1144. umsg.Start("CallSmokeTrailEffect", self.Owner)
  1145. umsg.Float(self.EjectDelay or 0.1)
  1146. umsg.String(self.SmokeEjectAttachment)
  1147. umsg.End()
  1148. end
  1149.  
  1150. end
  1151.  
  1152.  
  1153. /*---------------------------------------------------------
  1154. Name: SWEP:ShootBullet( )
  1155. Desc: A convenience function to shoot bullets
  1156. ---------------------------------------------------------*/
  1157. function SWEP:ShootBullet( damage, num_bullets, aimcone, recoil )
  1158.  
  1159. local bullet = {}
  1160. bullet.Num = num_bullets
  1161. bullet.Src = self.Owner:GetShootPos()
  1162. bullet.Dir = ( self.Owner:EyeAngles() + self.Owner:GetPunchAngle() ):Forward()
  1163. bullet.Spread = Vector( aimcone, aimcone, 0 )
  1164. bullet.Tracer = self.TracerRate
  1165. bullet.Force = 1
  1166. bullet.Damage = damage
  1167. bullet.AmmoType = "Pistol"
  1168.  
  1169. self.Owner:FireBullets( bullet )
  1170.  
  1171. self:ShootEffects()
  1172.  
  1173. if ( self.Owner:IsNPC() ) then return end
  1174. self:CustomRecoil(recoil)
  1175.  
  1176. end
  1177.  
  1178. function SWEP:CustomRecoil(recoil)
  1179. recoil = recoil * GetConVarNumber("Lee_WeaponRecoilMul")
  1180. local SideRecoil = recoil / 1.5
  1181.  
  1182. local anglo = Angle(-recoil, math.Rand(-SideRecoil,SideRecoil), 0)
  1183.  
  1184. if self:GetIronsights() and self.WeaponType != "pistol" and self.WeaponType != "shotgun" then
  1185. anglo = Angle(math.Rand(recoil * -1, 0), math.Rand(SideRecoil * -1,SideRecoil), 0)
  1186. end
  1187.  
  1188. local angle = self.Owner:EyeAngles() + anglo
  1189. self.Owner:ViewPunchReset( 10 )
  1190. self.Owner:ViewPunch(anglo)
  1191.  
  1192. self.Owner:SetEyeAngles(angle + self.Owner:GetPunchAngle())
  1193.  
  1194. end
  1195.  
  1196. /*---------------------------------------------------------
  1197. Name: SWEP:TakePrimaryAmmo( )
  1198. Desc: A convenience function to remove ammo
  1199. ---------------------------------------------------------*/
  1200. function SWEP:TakePrimaryAmmo( num )
  1201.  
  1202. // Doesn't use clips
  1203. if ( self.Weapon:Clip1() <= 0 ) then
  1204.  
  1205. if ( self:Ammo1() <= 0 ) then return end
  1206.  
  1207. self.Owner:RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() )
  1208.  
  1209. return end
  1210.  
  1211. self.Weapon:SetClip1( self.Weapon:Clip1() - num )
  1212.  
  1213. end
  1214.  
  1215.  
  1216. /*---------------------------------------------------------
  1217. Name: SWEP:TakeSecondaryAmmo( )
  1218. Desc: A convenience function to remove ammo
  1219. ---------------------------------------------------------*/
  1220. function SWEP:TakeSecondaryAmmo( num )
  1221.  
  1222. // Doesn't use clips
  1223. if ( self.Weapon:Clip2() <= 0 ) then
  1224.  
  1225. if ( self:Ammo2() <= 0 ) then return end
  1226.  
  1227. self.Owner:RemoveAmmo( num, self.Weapon:GetSecondaryAmmoType() )
  1228.  
  1229. return end
  1230.  
  1231. self.Weapon:SetClip2( self.Weapon:Clip2() - num )
  1232.  
  1233. end
  1234.  
  1235. /*---------------------------------------------------------
  1236. CanPrimaryAttack
  1237. ---------------------------------------------------------*/
  1238. function SWEP:CanPrimaryAttack()
  1239. if self.Owner:IsPlayer() then
  1240. if ( self.Weapon:Clip1() <= 0 ) and self.Primary.ClipSize > -1 and !self.Owner:IsNPC() then
  1241. self.Weapon:SetNextPrimaryFire(CurTime() + (self.Primary.Delay * 2))
  1242. local EmptySound = self.EmptySound or "weapons/clipempty_rifle.wav"
  1243. self.Weapon:EmitSound(EmptySound)
  1244. self.BurstTime = nil
  1245. if GetConVarNumber("Lee_WeaponAutoReload") >= 1 then
  1246. self:Reload()
  1247. end
  1248. return false
  1249. end
  1250. if self.Owner:WaterLevel() > 2 then
  1251. self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
  1252. self.Weapon:EmitSound("weapons/pistol/pistol_empty.wav")
  1253. return false
  1254. end
  1255.  
  1256. if (self:GetHolster() and !self:GetIronsights()) or self.NearWall or (self.Running and !self:GetIronsights()) then
  1257. self.Weapon:SetNextPrimaryFire(CurTime() + 0.1)
  1258. return false
  1259. end
  1260.  
  1261. return true
  1262. elseif self.Owner:IsNPC() then
  1263. if ( self.Weapon:Clip1() <= 0 ) then
  1264. self:EmitSound( "Weapon_Pistol.Empty" )
  1265. self:SetNextPrimaryFire( CurTime() + 0.2 )
  1266. self:Reload()
  1267. return false
  1268. end
  1269. return true
  1270. end
  1271. end
  1272.  
  1273. /*---------------------------------------------------------
  1274. Name: SWEP:CanSecondaryAttack( )
  1275. Desc: Helper function for checking for no ammo
  1276. ---------------------------------------------------------*/
  1277. function SWEP:CanSecondaryAttack()
  1278.  
  1279. if ( self.Weapon:Clip2() <= 0 ) then
  1280.  
  1281. self.Weapon:EmitSound( "Weapon_Pistol.Empty" )
  1282. self.Weapon:SetNextSecondaryFire( CurTime() + 0.2 )
  1283. return false
  1284.  
  1285. end
  1286.  
  1287. return true
  1288.  
  1289. end
  1290.  
  1291.  
  1292. /*---------------------------------------------------------
  1293. Name: ContextScreenClick( aimvec, mousecode, pressed, ply )
  1294. ---------------------------------------------------------*/
  1295. function SWEP:ContextScreenClick( aimvec, mousecode, pressed, ply )
  1296. end
  1297.  
  1298.  
  1299. /*---------------------------------------------------------
  1300. Name: OnRemove
  1301. Desc: Called just before entity is deleted
  1302. ---------------------------------------------------------*/
  1303. function SWEP:OnRemove()
  1304. self:ResetVar()
  1305. end
  1306.  
  1307. function SWEP:OnRestore()
  1308. self:ResetVar()
  1309. end
  1310.  
  1311. /*---------------------------------------------------------
  1312. Name: OwnerChanged
  1313. Desc: When weapon is dropped or picked up by a new player
  1314. ---------------------------------------------------------*/
  1315. function SWEP:OwnerChanged()
  1316. self:ResetVar()
  1317. end
  1318.  
  1319.  
  1320. /*---------------------------------------------------------
  1321. Name: Ammo1
  1322. Desc: Returns how much of ammo1 the player has
  1323. ---------------------------------------------------------*/
  1324. function SWEP:Ammo1()
  1325. return self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() )
  1326. end
  1327.  
  1328.  
  1329. /*---------------------------------------------------------
  1330. Name: Ammo2
  1331. Desc: Returns how much of ammo2 the player has
  1332. ---------------------------------------------------------*/
  1333. function SWEP:Ammo2()
  1334. return self.Owner:GetAmmoCount( self.Weapon:GetSecondaryAmmoType() )
  1335. end
  1336.  
  1337. /*---------------------------------------------------------
  1338. Name: SetDeploySpeed
  1339. Desc: Sets the weapon deploy speed.
  1340. This value needs to match on client and server.
  1341. ---------------------------------------------------------*/
  1342. function SWEP:SetDeploySpeed( speed )
  1343. self.m_WeaponDeploySpeed = tonumber( speed )
  1344. end
  1345.  
  1346. /*---------------------------------------------------------
  1347. Name: DoImpactEffect
  1348. Desc: Callback so the weapon can override the impact effects it makes
  1349. return true to not do the default thing - which is to call UTIL_ImpactTrace in c++
  1350. ---------------------------------------------------------*/
  1351. function SWEP:DoImpactEffect( tr, nDamageType )
  1352.  
  1353. return false;
  1354.  
  1355. end
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement