Advertisement
brandoooo

Pew Gun LUA

Sep 21st, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.00 KB | None | 0 0
  1. --If you'd like all the files they are available to download: https://mega.nz/#!h9BygCqB!L40NIkKQ1Qg5EOZykaeu3OLJmRWnX6iy20A29-1PBss
  2.  
  3. AddCSLuaFile()
  4. AddCSLuaFile("effects/pewtrace.lua")
  5. AddCSLuaFile("effects/pewbounce.lua")
  6.  
  7. SWEP.HoldType           = "pistol"
  8. SWEP.PrintName          = "Pew Gun"
  9. SWEP.Slot               = 2
  10. SWEP.SlotPos            = 2
  11. SWEP.ViewModelFlip      = false
  12. SWEP.ViewModelFOV       = 45
  13. SWEP.Category           = "BrandoSweps"
  14. SWEP.Base                  = "weapon_base"
  15.  
  16. SWEP.Primary.Recoil        = 0.3
  17. SWEP.Primary.Damage        = 15
  18. SWEP.Primary.Delay         = 0.25
  19. SWEP.Primary.Cone          = 0
  20. SWEP.Primary.ClipSize      = 180
  21. SWEP.Primary.Automatic     = true
  22. SWEP.Primary.DefaultClip   = 180
  23. SWEP.Primary.ClipMax       = 100
  24. SWEP.Primary.Ammo          = "Pistol"
  25. SWEP.Primary.Sound         = Sound( "entities/weapons/pew/pew.wav" )
  26.  
  27. SWEP.Spawnable             = true
  28. SWEP.AutoSpawnable         = false
  29.  
  30. SWEP.AmmoEnt               = "item_ammo_pistol_ttt"
  31. SWEP.Kind                  = WEAPON_PISTOL
  32. --SWEP.Tracer                = "AirboatGunHeavyTracer"
  33.  
  34. SWEP.UseHands              = true
  35. SWEP.ViewModel             = "models/weapons/c_pistol.mdl"
  36. SWEP.WorldModel            = "models/weapons/w_pistol.mdl"
  37.  
  38. ----TTT----
  39. SWEP.EquipMenuData = {
  40.     type = "item_weapon",
  41.     desc = [[The PEW GUN
  42.     Shoots Lasers
  43.     Makes a cool PEW sound
  44.     Has a 1 in 5 chance to set traitors on fire
  45.     ]]
  46. }
  47.  
  48. SWEP.Icon = "pew/ttt_icon.png"
  49. SWEP.Kind = WEAPON_EQUIP2
  50. SWEP.CanBuy = { ROLE_DETECTIVE }
  51. SWEP.LimitedStock = false
  52.  
  53. if ( GAMEMODE.Name == "Trouble in Terrorist Town" ) then
  54.     SWEP.Base = "weapon_tttbase"
  55.     SWEP.Primary.Damage = 14
  56.     SWEP.Primary.ClipSize = 60
  57.     SWEP.Primary.DefaultClip = 60
  58.     SWEP.Primary.ClipMax = 100
  59.     SWEP.Primary.Delay = 0.3
  60.  
  61.     SWEP.Slot = 1
  62. end
  63. ----TTT----
  64.  
  65. function SWEP:DoImpactEffect(trace, dmgType)
  66.     local effectdata = EffectData()
  67.     effectdata:SetStart( trace.HitPos )
  68.     --effectdata:SetOrigin( trace.HitNormal + Vector( math.Rand( -0.5, 1 ), math.Rand( -0.3, 1 ), math.Rand( 0, 0 ) ) )
  69.     effectdata:SetOrigin( trace.HitNormal + Vector(0, 0, 0.01))
  70.     util.Effect( "pewbounce", effectdata )
  71.  
  72.     if trace.HitWorld then
  73.         if SERVER or (CLIENT and IsFirstTimePredicted()) then
  74.         local imp = EffectData()
  75.         imp:SetOrigin(trace.HitPos + trace.HitNormal)
  76.         imp:SetNormal(trace.HitNormal)
  77.         imp:SetMagnitude(1)
  78.         imp:SetScale(1)
  79.         imp:SetRadius(2)
  80.         util.Effect("Sparks", imp)
  81.     end
  82.          else return end
  83. end
  84.  
  85. function SWEP:PrimaryAttack()
  86.     self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
  87.  
  88.     cone = self.Primary.Cone
  89.     pew = {}
  90.     pew.Num       = 1
  91.     pew.Src       = self:GetOwner():GetShootPos()
  92.     pew.Dir       = self:GetOwner():GetAimVector()
  93.     pew.Spread    = Vector( cone, cone, 0 )
  94.     pew.Delay     = self.Primary.Delay
  95.     pew.Tracer    = 1
  96.     pew.Force     = 2
  97.     pew.Damage    = self.Primary.Damage
  98.     pew.TracerName = self.Tracer
  99.     pew.AmmoType = self.Primary.Ammo
  100.     pew.TracerName = "pewtrace"
  101.  
  102.     pew.Callback = function(attacker, trace, dmginfo)
  103.     dmginfo:SetDamageType(DMG_DISSOLVE)
  104.     if ( GAMEMODE.Name == "Trouble in Terrorist Town" ) then
  105.         dmginfo:SetDamageType(DMG_BULLET)
  106.     end
  107.        
  108.     if SERVER or (CLIENT and IsFirstTimePredicted()) then
  109.         local ent = trace.Entity
  110.         if (not trace.HitWorld) and IsValid(ent) then
  111.            local edata = EffectData()
  112.            ent:EmitSound("weapons/stunstick/stunstick_fleshhit".. math.random(1,2) .. ".wav", 60, 130)
  113.            edata:SetEntity(ent)
  114.            edata:SetMagnitude(1)
  115.            edata:SetScale(5)
  116.            util.Effect("TeslaHitboxes", edata)
  117.         end
  118.     if SERVER then
  119.         if (not trace.HitWorld) and ent:IsPlayer() and ent:IsValid() and not ent:IsRagdoll() then
  120.             local rndm = math.random(1, 5)
  121.             if self:GetOwner():GetRole() == ROLE_JESTER then return end
  122.             if ent:GetRole() == ROLE_TRAITOR and rndm == 2 then ent:Ignite(5, 5) end
  123.             if ent:GetRole() == ROLE_INFECTED then ent:Ignite(5, 2) end
  124.         end
  125.     end
  126.     end
  127.     end
  128.     self:TakePrimaryAmmo(1)
  129.  
  130.     if not self:CanPrimaryAttack() then return end
  131.  
  132.     self:EmitSound(self.Primary.Sound, 75, math.random(90, 100))
  133.     self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  134.  
  135.     if IsValid(self:GetOwner()) then
  136.     self:GetOwner():SetAnimation( PLAYER_ATTACK1 )
  137.     end
  138.  
  139.     self:GetOwner():FireBullets( pew )
  140. end
  141.  
  142. function SWEP:SecondaryAttack()
  143.     return false
  144. end
  145.  
  146. function SWEP:GetHeadshotMultiplier()
  147.     return 1.5
  148. end
  149.  
  150. function SWEP:Initialize()
  151.     self:SetHoldType("pistol")
  152. end
  153.  
  154. if SERVER then return end
  155. SWEP.WepSelectIcon = Material( "entities/ttt_icon.png" )
  156. function SWEP:DrawWeaponSelection( x, y, w, h, a )
  157.     surface.SetDrawColor( 255, 255, 255, a )
  158.     surface.SetMaterial( self.WepSelectIcon )
  159.  
  160.     local size = math.min( w, h )
  161.     surface.DrawTexturedRect( x + w / 2 - size / 2, y, size, size )
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement