Advertisement
Guest User

Deagle That Blows Up In Your Hand

a guest
Nov 12th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.58 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. SWEP.PrintName          = "Unstable Deagle" -- This will be shown in the spawn menu, and in the weapon selection menu
  5. SWEP.Author             = "Greenhourglass" -- These two options will be shown when you have the weapon highlighted in the weapon selection menu
  6. SWEP.Instructions       = "It may or may not blow your arm off"
  7. SWEP.Category           = "Other"
  8.  
  9. SWEP.Spawnable = true
  10. SWEP.AdminOnly = false
  11. SWEP.DisableDuplicator  = false
  12.  
  13. SWEP.HoldType       = "pistol"
  14. SWEP.UseHands       = true
  15. SWEP.ViewModel      = Model( "models/weapons/cstrike/c_pist_deagle.mdl" )
  16. SWEP.WorldModel     = Model( "models/weapons/w_pist_deagle.mdl" )
  17. SWEP.ViewModelFlip  = false
  18. SWEP.ViewModelFOV   = 54
  19. SWEP.CSMuzzleFlashes    = true
  20. SWEP.CSMuzzleX          = true
  21.  
  22. SWEP.Primary.Damage         = 50
  23. SWEP.Primary.Force          = 10
  24. SWEP.Primary.Num            = 1
  25. SWEP.Primary.Cone           = 0.06
  26. SWEP.Primary.ClipSize       = 7
  27. SWEP.Primary.DefaultClip    = 14
  28. SWEP.Primary.Automatic      = false
  29. SWEP.Primary.Ammo           = "357"
  30. SWEP.Primary.Delay          = 0.15
  31. SWEP.Primary.BlowUpChance   = 0.2
  32.  
  33. SWEP.Secondary.ClipSize     = -1
  34. SWEP.Secondary.DefaultClip  = -1
  35. SWEP.Secondary.Automatic    = true
  36. SWEP.Secondary.Ammo         = "none"
  37. SWEP.Secondary.Delay        = 0.2
  38.  
  39. SWEP.Weight                 = 5
  40. SWEP.AutoSwitchTo           = false
  41. SWEP.AutoSwitchFrom         = false
  42.  
  43. SWEP.BobScale   = 1
  44. SWEP.SwayScale  = 3
  45. SWEP.m_WeaponDeploySpeed    = 1
  46.  
  47. SWEP.Slot               = 1
  48. SWEP.SlotPos            = 2
  49. SWEP.BounceWeaponIcon   = true
  50. SWEP.DrawWeaponInfoBox  = true
  51. if CLIENT then
  52. SWEP.WepSelectIcon = surface.GetTextureID( "weapons/swep" )
  53. end
  54. SWEP.DrawAmmo           = false
  55. SWEP.DrawCrosshair      = true
  56. SWEP.AccurateCrosshair  = false
  57.  
  58. SWEP.SoundPrimary       = Sound( "Weapon_DEagle.Single" )
  59.  
  60. function SWEP:SetupDataTables()
  61.  
  62. end
  63.  
  64. --[[---------------------------------------------------------------
  65. --                      PREDICTED functions
  66. --]]---------------------------------------------------------------
  67.  
  68. function SWEP:PrimaryAttack()
  69.     if ( !self:CanPrimaryAttack() ) then return end -- Make sure we can shoot first
  70.    
  71.     self:TakePrimaryAmmo( 1 )
  72.     self.Owner:ViewPunch( Angle( math.Rand(-1,-3), math.Rand(-2,2), 0 ) )
  73.     self.Weapon:EmitSound( self.SoundPrimary )
  74.     self:ShootBullet( self.Primary.Damage, self.Primary.Num, self.Primary.Cone, self.Primary.Force )
  75.  
  76.     if math.Rand(0,1) <= self.Primary.BlowUpChance then
  77.         self:BlowUp()
  78.     end
  79.    
  80.     self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  81. end
  82.  
  83. function SWEP:SecondaryAttack()
  84.     self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
  85. end
  86.  
  87. function SWEP:ShootBullet( damage, num_bullets, aimcone, force )
  88.     local bullet = {}
  89.     bullet.Num      = num_bullets
  90.     bullet.Src      = self.Owner:GetShootPos()          -- Source
  91.     bullet.Dir      = self.Owner:GetAimVector()         -- Dir of bullet
  92.     bullet.Spread   = Vector( aimcone, aimcone, 0 )     -- Aim Cone
  93.     bullet.Tracer   = 1                                 -- Show a tracer on every x bullets
  94.     bullet.Force    = force                             -- Amount of force to give to phys objects
  95.     bullet.Damage   = damage
  96.     bullet.AmmoType = "Pistol"
  97.  
  98.     self.Owner:FireBullets( bullet )
  99.     self:ShootEffects()
  100. end
  101.  
  102. --[[---------------------------------------------------------------
  103. --                      SHARED functions
  104. --]]---------------------------------------------------------------
  105.  
  106. -- Think is technically predicted but IS called clientside in singleplayer.
  107. function SWEP:Think()
  108. end
  109.  
  110. function SWEP:Initialize()
  111.     self:SetHoldType( self.HoldType )
  112. end
  113.  
  114. function SWEP:DoImpactEffect( tr, nDamageType )
  115.     if ( tr.HitSky ) then return end
  116.     local effectdata = EffectData()
  117.     effectdata:SetOrigin( tr.HitPos + tr.HitNormal )
  118.     effectdata:SetNormal( tr.HitNormal )
  119.     effectdata:SetMagnitude( 1 )
  120.     if (tr.MatType == MAT_METAL) or (tr.MatType == MAT_VENT) then
  121.         util.Effect( "ElectricSpark", effectdata )
  122.     else
  123.         util.Effect( "AR2Impact", effectdata )
  124.     end
  125. end
  126.  
  127. --[[---------------------------------------------------------------
  128. --                      SERVER functions
  129. --]]---------------------------------------------------------------
  130.  
  131. function SWEP:BlowUp()
  132.     if not SERVER then return end
  133.  
  134.     local ply = self.Owner
  135.     local expPos = ply:GetShootPos()
  136.     local boneid = ply:LookupBone( "ValveBiped.Bip01_R_Hand" )
  137.     if boneid then
  138.         local newPos,ang = ply:GetBonePosition( boneid )
  139.         if newPos and !(newPos == Vector(0,0,0)) and util.IsInWorld(newPos) then
  140.             expPos = newPos
  141.         end
  142.     end
  143.  
  144.     local explosion = ents.Create( "env_explosion" )
  145.     explosion:SetPos( expPos )
  146.     explosion:Spawn()
  147.     explosion:SetKeyValue( "iMagnitude", 150 )
  148.     explosion:SetKeyValue( "iRadiusOverride", 100 )
  149.     explosion:SetOwner( ply )
  150.    
  151.     self.Owner:StripWeapon( self:GetClass() )
  152.     explosion:Fire( "Explode" )
  153.     util.ScreenShake( expPos, 100, 80, 0.5, 100 )
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement