Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.07 KB | None | 0 0
  1.  
  2. SWEP.Spawnable = true
  3. SWEP.AdminOnly = false
  4. SWEP.Base = "astw2_base"
  5.  
  6. SWEP.PrintName = "SC Pistol (Chaos Theory)"
  7. SWEP.Category = "ASTW2 - Pistols"
  8. SWEP.Slot = 1
  9. SWEP.Author = "Arctic"
  10. SWEP.Contact = "/id/ArcticWinterZzZ/"
  11. SWEP.Purpose = "Disables electronics."
  12. SWEP.Instructions = "ATTACK2 to aim, ATTACK1 to fire."
  13.  
  14. if CLIENT then
  15. SWEP.WepSelectIcon = surface.GetTextureID( "sc/vgui/hud/sc_pistol" )
  16. SWEP.DrawWeaponInfoBox  = false
  17. SWEP.BounceWeaponIcon = false
  18. killicon.Add( "astw2_sc_pistol_ct", "sc/vgui/hud/sc_pistol", Color( 255, 255, 255, 255 ) )
  19. end
  20.  
  21. SWEP.ViewModel = nil
  22. SWEP.WorldModel = "models/weapons/w_fiveseven_ct.mdl"
  23.  
  24. SWEP.Primary.Damage = 12
  25. SWEP.Primary.Delay = 60 / 350
  26. SWEP.Primary.Acc = 1 / 75
  27. SWEP.Primary.Recoil = 200
  28. SWEP.Primary.RecoilAcc = 100
  29. SWEP.Primary.Num = 1
  30. SWEP.Primary.Automatic = false
  31. SWEP.Primary.Ammo = "5mm"
  32. SWEP.Primary.ClipSize = 20
  33.  
  34. SWEP.Projectile = nil
  35. SWEP.ProjectileForce = 2500
  36. SWEP.Effect_MuzzleFlash = "astw2_muzzleflash_scpistol"
  37. SWEP.Tracer = "Tracer"
  38.  
  39. SWEP.Sound = "weapons/pistol/scpistol_fire.wav"
  40. SWEP.Sound_Vol = 60
  41. SWEP.Sound_Pitch = 100
  42. SWEP.Sound_Magout = "weapons/pistol/scpistol_clipout.wav"
  43. SWEP.Sound_Magin = "weapons/pistol/scpistol_clipin.wav"
  44. SWEP.Sound_Boltpull = "weapons/silence.wav"
  45.  
  46. SWEP.Secondary.Ammo = nil
  47.  
  48. SWEP.Effect_ShellEject = "astw2_case_5mm"
  49.  
  50. SWEP.MagDrop = ""
  51.  
  52. SWEP.ReloadTime = 1.5
  53. SWEP.CannotChamber = false
  54.  
  55. SWEP.CanRest = false
  56. SWEP.CrosshairOverride = "crosshairs/sc/ct_pistol_crosshair.png"
  57.  
  58. SWEP.Special = "melee"
  59. SWEP.Melee = false // Whether to use the melee attack of the gun.
  60. SWEP.Melee_Damage = 10
  61. SWEP.Melee_Range = 8 // Range of the melee attack trace.
  62. SWEP.Melee_SwingTime = 1
  63. SWEP.Melee_HitSound = "physics/metal/weapon_impact_hard1.wav"
  64. SWEP.Melee_HitHumanSound = "physics/body/body_medium_impact_hard4.wav"
  65. SWEP.Melee_DamageType = DMG_CLUB
  66.  
  67. SWEP.CanRest = false
  68.  
  69. SWEP.HoldType_Lowered = "pistol"
  70. SWEP.HoldType_Aim = "pistol"
  71. SWEP.HoldType_Hipfire = "pistol"
  72. SWEP.Anim_Reload = ACT_HL2MP_GESTURE_RELOAD_PISTOL
  73. SWEP.Anim_Shoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL
  74. SWEP.Anim_Melee = ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE
  75.  
  76. SWEP.Special = "none"
  77.  
  78. SWEP.EMPAmmoMax = 100
  79. SWEP.EMPNeeded = 100
  80. SWEP.EMPTime = 10
  81. SWEP.EMPDelay = 2
  82. SWEP.EMPRegenDelay = 0.065
  83. SWEP.EMPRange = 5000
  84. SWEP.EMPDisableTime = 10
  85.  
  86. SWEP.UniqueFiremode = true
  87.  
  88. AddCSLuaFile()
  89.  
  90. function SWEP:OnInitialize()
  91.    self.EMPSound = nil
  92.    self:SetNWInt("Light", 0)
  93.    self:SetNWInt("EMPammo", self.EMPAmmoMax)
  94.    self:SetNWFloat("EMPnextregen", CurTime() + self.EMPRegenDelay)
  95.    self:SetNWBool("EMPmode", false)
  96. end
  97.  
  98. function SWEP:SpecialAttack()
  99.    if self:GetNWInt( "EMPammo" ) < self.EMPNeeded then return end
  100.     self:EmitSound( "weapons/pistol/pistol_emp.wav" )
  101.  
  102.    local shootpos = self:GetShootPosASTW()
  103.  
  104.    local Dir = (self.Owner:EyeAngles() + self.Fire_AngleOffset):Forward()
  105.  
  106.    local tr = util.TraceLine({
  107.       start = shootpos,
  108.       endpos = shootpos + (Dir * self.EMPRange)
  109.    })
  110.  
  111.    self:SetNextPrimaryFire( CurTime() + self.EMPDelay )
  112.  
  113.    PrintTable(tr)
  114.    print("meem")
  115.  
  116.    -- do stuff here
  117.  
  118.    local k = tr.Entity
  119.  
  120.    local newammo = self.Owner:GetNWInt( "EMPammo" )
  121.    local oked = true
  122.  
  123.    if !tr.Hit or tr.HitWorld or tr.HitSky or !tr.Entity or !IsValid(tr.Entity) then
  124.       newammo = newammo + self.EMPNeeded
  125.       oked = false
  126.    elseif k:GetClass() == "npc_turret_floor" then
  127.         k:Fire("Disable", "", 0)
  128.       k:EmitSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
  129.       timer.Simple(self.EMPDisableTime, function()
  130.          if !k:IsValid() then return end
  131.          k:Fire("Enable", "", 0)
  132.       end)
  133.       newammo = newammo - self.EMPNeeded
  134.     elseif k:GetClass() == "npc_combine_camera" then
  135.         k:Fire("Disable", "", 0)
  136.       k:EmitSound(Sound("weapons/misc_effects/camera_bugged_loop.wav"))
  137.       timer.Simple(self.EMPDisableTime, function()
  138.          if !k:IsValid() then return end
  139.          k:Fire("Enable", "", 0)
  140.       end)
  141.       newammo = newammo - self.EMPNeeded
  142.     elseif k:GetClass() == "npc_turret_ceiling" then
  143.         k:Fire("Disable", "", 0)
  144.       k:EmitSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
  145.       newammo = newammo - self.EMPNeeded
  146.     elseif k:GetClass() == "hl2_npc_turret_ground" then
  147.         k:Fire("Ignite", "", 0)
  148.       k:EmitSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
  149.       timer.Simple(self.EMPDisableTime, function()
  150.          if !k:IsValid() then return end
  151.          k:Fire("Enable", "", 0)
  152.       end)
  153.       newammo = newammo - self.EMPNeeded
  154.     elseif k:GetClass() == "npc_cscanner" then
  155.       k:Fire("Break", "", 0)
  156.       newammo = newammo - self.EMPNeeded
  157.     elseif k:GetClass() == "npc_clawscanner" then
  158.       k:Fire("Break", "", 0)
  159.       newammo = newammo - self.EMPNeeded
  160.     elseif k:GetClass() == "npc_manhack" then
  161.       k:Fire("InteractivePowerDown", "", 0)
  162.       newammo = newammo - self.EMPNeeded
  163.     elseif k:GetClass() == "item_suitcharger" then
  164.       k:Fire("Recharge", "", 0)
  165.       newammo = newammo - self.EMPNeeded
  166.     elseif k:GetClass() == "item_healthcharger" then
  167.       k:Fire("Recharge", "", 0)
  168.       newammo = newammo - self.EMPNeeded
  169.     elseif k:GetClass() == "npc_rollermine" then
  170.         k:Fire("TurnOff", "", 0)
  171.       k:EmitSound(Sound("weapons/misc_effects/other_bugged_loop" .. math.random(2,3) .. ".wav"))
  172.       timer.Simple(self.EMPDisableTime, function()
  173.          if !k:IsValid() then return end
  174.          k:Fire("TurnOn", "", 0)
  175.       end)
  176.       newammo = newammo - self.EMPNeeded
  177.     elseif k:GetClass() == "combine_mine" then
  178.       k:Fire("Disarm", "", 0)
  179.       newammo = newammo - self.EMPNeeded
  180.     elseif k:GetClass() == "npc_hunter" then
  181.       k:Fire("DisableShooting", "", 0)
  182.       newammo = newammo - self.EMPNeeded
  183.     elseif k:GetClass() == "gmod_lamp" then
  184.         k:Fire("Disable", "", 0)
  185.       k:EmitSound(Sound("weapons/misc_effects/light_bugged_loop" .. math.random(1,5) .. ".wav"))
  186.       timer.Simple(self.EMPDisableTime, function()
  187.          if !k:IsValid() then return end
  188.          k:Fire("Enable", "", 0)
  189.       end)
  190.       newammo = newammo - self.EMPNeeded
  191.     elseif k:GetClass() == "gmod_light" then
  192.         k:Fire("Disable", "", 0)
  193.       k:EmitSound(Sound("weapons/misc_effects/light_bugged_loop" .. math.random(1,5) .. ".wav"))
  194.       timer.Simple(self.EMPDisableTime, function()
  195.          if !k:IsValid() then return end
  196.          k:Fire("Enable", "", 0)
  197.       end)
  198.       newammo = newammo - self.EMPNeeded
  199.     elseif k:GetClass() == "prop_thumper" then
  200.       k:Fire("Disable", "", 0)
  201.       timer.Simple(self.EMPDisableTime, function()
  202.          if !k:IsValid() then return end
  203.          k:Fire("Enable", "", 0)
  204.       end)
  205.       newammo = newammo - self.EMPNeeded
  206.     elseif k:GetClass() == "hl2_thumper_large" then
  207.       k:Fire("Disable", "", 0)
  208.       timer.Simple(self.EMPDisableTime, function()
  209.          if !k:IsValid() then return end
  210.          k:Fire("Enable", "", 0)
  211.       end)
  212.       newammo = newammo - self.EMPNeeded
  213.     elseif k:GetClass() == "npc_helicopter" then
  214.       k:Fire("DropBomb", "", 0)
  215.       newammo = newammo - self.EMPNeeded
  216.     elseif k:GetClass() == "npc_combine_s" then
  217.       k:Fire("LookOff", "", 0)
  218.       newammo = newammo - self.EMPNeeded
  219.     elseif k:GetClass() == "npc_metropolice" then
  220.       k:Fire("LookOff", "", 0)
  221.       newammo = newammo - self.EMPNeeded
  222.    else
  223.       -- failure
  224.       newammo = newammo + self.EMPNeeded
  225.       oked = false
  226.    end
  227.  
  228.    self:SetNWInt("EMPammo", newammo)
  229.  
  230.    if oked then
  231.       local id = self:StartLoopingSound("ambient/atmosphere/laundry_amb.wav")
  232.       timer.Simple(self.EMPTime, function()
  233.          if !self:IsValid() then return end
  234.          self:StopLoopingSound(id)
  235.       end)
  236.       self:SetNWInt("Light", 2)
  237.    else
  238.       self:SetNWInt("Light", 1)
  239.    end
  240.  
  241.    timer.Simple(self.EMPDelay, function()
  242.       if !self:IsValid() then return end
  243.       self:SetNWInt("Light", 0)
  244.    end)
  245. end
  246.  
  247. function SWEP:GetUniqueFiremode()
  248.    if self:GetNWBool("EMPmode") then
  249.       return "EMP"
  250.    else
  251.       return "SEMI"
  252.    end
  253. end
  254.  
  255. function SWEP:GetAmmoDisplay()
  256.    if self:GetNWBool("EMPmode") then
  257.       return self:GetNWInt("EMPammo", 0) .. "%"
  258.    end
  259. end
  260.  
  261. local lmat = Material("engine/lightsprite")
  262.  
  263. function SWEP:OnThink()
  264.    if !self:IsValid() then return end
  265.  
  266.    if self:GetNWFloat("EMPnextregen", 0) < CurTime() then
  267.       self:SetNWInt("EMPammo", math.Clamp(self:GetNWInt("EMPammo", 0) + 1, 0, self.EMPAmmoMax))
  268.       self:SetNWFloat("EMPnextregen", CurTime() + self.EMPRegenDelay)
  269.    end
  270.  
  271.    if self.Owner:KeyPressed(IN_USE) and self.Owner:KeyDown(IN_ATTACK2) then
  272.       self:SetNWBool("EMPmode", !self:GetNWBool("EMPmode"))
  273.       if self:GetNWBool("EMPmode") then
  274.          self.Special = "uniqueaimed"
  275.       else
  276.          self.Special = "none"
  277.       end
  278.    end
  279.  
  280. end
  281.  
  282. function SWEP:DrawWorldModel()
  283.    self:DrawModel()
  284.  
  285.    local lm = self:GetNWInt("Light", 0)
  286.  
  287.    local sppos = self:GetAttachment(3).Pos
  288.  
  289.    render.SetMaterial(lmat)
  290.  
  291.    if lm == 1 then
  292.       render.DrawSprite(sppos, 2, 2, Color(255, 0, 0))
  293.    elseif lm == 2 then
  294.       render.DrawSprite(sppos, 2, 2, Color(0, 255, 0))
  295.    end
  296. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement