Advertisement
Guest User

shared.lua

a guest
Feb 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. if ( SERVER ) then
  2.  
  3. AddCSLuaFile( "shared.lua" )
  4.  
  5. end
  6.  
  7. if ( CLIENT ) then
  8.  
  9. SWEP.PrintName = "NPC_E-5"
  10. SWEP.Author = "Syntax_Error752"
  11. SWEP.ViewModelFOV = 50
  12. SWEP.Slot = 2
  13. SWEP.SlotPos = 3
  14. SWEP.WepSelectIcon = surface.GetTextureID("HUD/killicons/E5")
  15.  
  16. killicon.Add( "npc_sw_weapon_752_e5", "HUD/killicons/E5", Color( 255, 80, 0, 255 ) )
  17.  
  18. end
  19.  
  20. SWEP.HoldType = "ar2"
  21. SWEP.Base = "weapon_swsft_base"
  22.  
  23. SWEP.Category = "TFA Star Wars"
  24.  
  25. SWEP.Spawnable = false
  26. SWEP.AdminSpawnable = false
  27.  
  28. SWEP.ViewModel = ""
  29. SWEP.WorldModel = "models/weapons/w_E5.mdl"
  30.  
  31. SWEP.Weight = 5
  32. SWEP.AutoSwitchTo = false
  33. SWEP.AutoSwitchFrom = false
  34.  
  35. local FireSound = Sound ("weapons/E5_fire.wav");
  36. local ReloadSound = Sound ("weapons/E5_reload.wav");
  37.  
  38. SWEP.Primary.Recoil = 0.5
  39. SWEP.Primary.Damage = 25
  40. SWEP.Primary.NumShots = 1
  41. SWEP.Primary.Cone = 0.0125 --0.0125
  42. SWEP.Primary.ClipSize = 50
  43. SWEP.Primary.Delay = 0.175
  44. SWEP.Primary.DefaultClip = 150
  45. SWEP.Primary.Automatic = true
  46. SWEP.Primary.Ammo = "ar2"
  47. SWEP.Primary.Tracer = "effect_sw_laser_red"
  48.  
  49. SWEP.Secondary.Automatic = false
  50. SWEP.Secondary.Ammo = "none"
  51.  
  52. function SWEP:PrimaryAttack()
  53.  
  54. if self:Clip1() <= 0 then self:NpcReload()
  55. return end
  56.  
  57. self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  58. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  59.  
  60. if ( !self:CanPrimaryAttack() ) then return end
  61.  
  62. // Play shoot sound
  63. self.Weapon:EmitSound( FireSound )
  64.  
  65. // Shoot the bullet
  66. self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
  67.  
  68. // Remove 1 bullet from our clip
  69. self:TakePrimaryAmmo( 1 )
  70.  
  71. if ( self.Owner:IsNPC() ) then return end
  72.  
  73. // Punch the player's view
  74. self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
  75.  
  76. // In singleplayer this functpion doesn't get called on the client, so we use a networked float
  77. // to send the last shoot time. In multiplayer this is predicted clientside so we don't need to
  78. // send the float.
  79. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  80. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  81. end
  82.  
  83. end
  84.  
  85. function SWEP:CSShootBullet( dmg, recoil, numbul, cone )
  86.  
  87. numbul = numbul or 1
  88. cone = cone or 0.01
  89.  
  90. local bullet = {}
  91. bullet.Num = numbul
  92. bullet.Src = self.Owner:GetShootPos() // Source
  93. bullet.Dir = self.Owner:GetAimVector() // Dir of bullet
  94. bullet.Spread = Vector( cone, cone, 0 ) // Aim Cone
  95. bullet.Tracer = 1 // Show a tracer on every x bullets
  96. bullet.TracerName = self.Primary.Tracer
  97. bullet.Force = 5 // Amount of force to give to phys objects
  98. bullet.Damage = dmg
  99.  
  100. self.Owner:FireBullets( bullet )
  101. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation
  102. self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation
  103.  
  104. if ( self.Owner:IsNPC() ) then return end
  105.  
  106. self.Owner:MuzzleFlash() // Crappy muzzle light
  107.  
  108. // CUSTOM RECOIL !
  109. if ((game.SinglePlayer() && SERVER) || (!game.SinglePlayer() && CLIENT && IsFirstTimePredicted())) then
  110.  
  111. local eyeang = self.Owner:EyeAngles()
  112. eyeang.pitch = eyeang.pitch - recoil
  113. self.Owner:SetEyeAngles( eyeang )
  114.  
  115. end
  116.  
  117. end
  118.  
  119. function SWEP:Reload()
  120.  
  121. end
  122.  
  123. function SWEP:SecondaryAttack()
  124.  
  125. if ( self.NextSecondaryAttack > CurTime() ) then return end
  126.  
  127. if (Zoom == 0) then
  128. if (SERVER) then
  129. self.Owner:SetFOV( 40, 0.3 )
  130. end
  131. Zoom = 1
  132. self.NextSecondaryAttack = CurTime() + 0.3
  133. return
  134. end
  135. if (Zoom == 1) then
  136. if (SERVER) then
  137. self.Owner:SetFOV( 0, 0.3 )
  138. end
  139. Zoom = 0
  140. self.NextSecondaryAttack = CurTime() + 0.3
  141. return
  142. end
  143. end
  144.  
  145. function SWEP:Holster()
  146. if (SERVER) then
  147. self.Owner:SetFOV( 0, 0.3 )
  148. end
  149. Zoom = 0
  150. return true
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement