Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.46 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 - Splinter Cell: Chaos Theory DLC"
  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. SWEP.Sound_Draw = "weapons/pistol/pistol_equip_02.wav"
  46. SWEP.Sound_Holster = "weapons/pistol/pistol_unequip.wav"
  47. SWEP.Secondary.Ammo = nil
  48.  
  49. SWEP.Effect_ShellEject = "astw2_case_5mm"
  50.  
  51. SWEP.MagDrop = ""
  52.  
  53. SWEP.ReloadTime = 1.5
  54. SWEP.CannotChamber = false
  55.  
  56. SWEP.CanRest = false
  57. SWEP.CrosshairOverride = "crosshairs/sc/ct_pistol_crosshair.png"
  58.  
  59. SWEP.Special = "melee"
  60. SWEP.Melee = false // Whether to use the melee attack of the gun.
  61. SWEP.Melee_Damage = 10
  62. SWEP.Melee_Range = 8 // Range of the melee attack trace.
  63. SWEP.Melee_SwingTime = 1
  64. SWEP.Melee_HitSound = "physics/metal/weapon_impact_hard1.wav"
  65. SWEP.Melee_HitHumanSound = "physics/body/body_medium_impact_hard4.wav"
  66. SWEP.Melee_DamageType = DMG_CLUB
  67.  
  68. SWEP.CanRest = false
  69.  
  70. SWEP.HoldType_Lowered = "pistol"
  71. SWEP.HoldType_Aim = "pistol"
  72. SWEP.HoldType_Hipfire = "pistol"
  73. SWEP.Anim_Reload = ACT_HL2MP_GESTURE_RELOAD_PISTOL
  74. SWEP.Anim_Shoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL
  75. SWEP.Anim_Melee = ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE
  76.  
  77. SWEP.Special = "none"
  78.  
  79. SWEP.EMPAmmoMax = 100
  80. SWEP.EMPNeeded = 100
  81. SWEP.EMPTime = 10
  82. SWEP.EMPDelay = 2
  83. SWEP.EMPRegenDelay = 0.065
  84. SWEP.EMPRange = 5000
  85. SWEP.EMPDisableTime = 10
  86.  
  87. SWEP.UniqueFiremode = true
  88.  
  89. AddCSLuaFile()
  90.  
  91. function SWEP:OnInitialize()
  92.    self.EMPSound = nil
  93.    self:SetNWInt("Light", 0)
  94.    self:SetNWInt("EMPammo", self.EMPAmmoMax)
  95.    self:SetNWFloat("EMPnextregen", CurTime() + self.EMPRegenDelay)
  96.    self:SetNWBool("EMPmode", false)
  97.    
  98.    --Ent fire list
  99.     self.Disable = {"npc_turret_floor","npc_combine_camera","npc_turret_ceiling","gmod_lamp","gmod_light","prop_thumper","hl2_thumper_large"}
  100.     self.IgniteFire = {"hl2_npc_turret_ground"}
  101.     self.Break = {"npc_cscanner","npc_clawscanner"}
  102.     self.InteractivePowerDown = {"npc_manhack"}
  103.     self.Recharge = {"item_suitcharger","item_healthcharger"}
  104.     self.TurnOff = {"npc_rollermine"}
  105.     self.Disarm = {"combine_mine"}
  106.     self.DisableShooting = {"npc_hunter"}
  107.     self.DropBomb = {"npc_helicopter"}
  108.     self.LookOff = {"npc_combine_s","npc_metropolice"}
  109.    
  110.     --Sound
  111.     self.Turrets = {"npc_turret_floor","npc_turret_ceiling","hl2_npc_turret_ground"}
  112.     self.Other = {"npc_rollermine", "combine_mine" }
  113.     self.Light = {"gmod_lamp","gmod_light"}
  114.    
  115. end
  116.  
  117. function SWEP:SpecialAttack()
  118.    if self:GetNWInt( "EMPammo" ) < self.EMPNeeded then return end
  119.     self:EmitSound( "weapons/pistol/pistol_emp.wav", 50, 100 )
  120.  
  121.    local shootpos = self:GetShootPosASTW()
  122.  
  123.    local Dir = (self.Owner:EyeAngles() + self.Fire_AngleOffset):Forward()
  124.  
  125.    local tr = util.TraceLine({
  126.       start = shootpos,
  127.       endpos = shootpos + (Dir * self.EMPRange)
  128.    })
  129.  
  130.    self:SetNextPrimaryFire( CurTime() + self.EMPDelay )
  131.  
  132.    PrintTable(tr)
  133.    print("meem")
  134.  
  135.    -- do stuff here
  136.  
  137.    local k = tr.Entity
  138.  
  139.    local newammo = self.Owner:GetNWInt( "EMPammo" )
  140.    local oked = true
  141.    local trclass = k:GetClass()
  142.    local DoEMPTimer = false
  143.    local DoTurnOnTimer = false
  144.    local idloop = nil
  145.    
  146.    if !tr.Hit or tr.HitWorld or tr.HitSky or !tr.Entity or !IsValid(tr.Entity) then
  147.       newammo = newammo + self.EMPNeeded
  148.       oked = false
  149.    elseif table.HasValue( self.Disable, trclass ) then --Fire Disable
  150.         if SERVER then
  151.         k:Fire("Disable", "", 0) end
  152.         DoEMPTimer = true
  153.     elseif table.HasValue( self.IgniteFire, trclass ) then --Fire Ignite
  154.         if SERVER then
  155.         k:Fire("Ignite", "", 0) end
  156.         DoEMPTimer = true
  157.     elseif table.HasValue( self.Break, trclass ) then --Fire Break
  158.         if SERVER then
  159.         k:Fire("Break", "", 0) end
  160.     elseif table.HasValue( self.InteractivePowerDown, trclass ) then --Fire InteractivePowerDown
  161.         if SERVER then
  162.         k:Fire("InteractivePowerDown", "", 0) end
  163.     elseif table.HasValue( self.Recharge, trclass ) then --Fire Recharge
  164.         if SERVER then
  165.         k:Fire("Recharge", "", 0) end
  166.     elseif table.HasValue( self.TurnOff, trclass ) then --Fire TurnOff
  167.         if SERVER then
  168.         k:Fire("TurnOff", "", 0) end
  169.         DoTurnOnTimer = true
  170.     elseif table.HasValue( self.Disarm, trclass ) then --Fire Disarm
  171.         if SERVER then
  172.         k:Fire("Disarm", "", 0) end
  173.     elseif table.HasValue( self.DisableShooting, trclass ) then --Fire DisableShooting
  174.         if SERVER then
  175.         k:Fire("DisableShooting", "", 0) end
  176.     elseif table.HasValue( self.DropBomb, trclass ) then --Fire DropBomb
  177.         if SERVER then
  178.         k:Fire("DropBomb", "", 0) end
  179.     elseif table.HasValue( self.LookOff, trclass ) then --Fire LookOff
  180.         if SERVER then
  181.         k:Fire("LookOff", "", 0) end
  182.    
  183.    
  184.    else
  185.       -- failure
  186.       newammo = newammo + self.EMPNeeded
  187.       oked = false
  188.    end
  189.    
  190.    if DoEMPTimer then
  191.          timer.Simple(self.EMPDisableTime, function()
  192.          if !k:IsValid() then return end
  193.          if SERVER then
  194.          k:Fire("Enable", "", 0) end
  195.       end)
  196.    end
  197.    
  198.    if DoTurnOnTimer then
  199.          timer.Simple(self.EMPDisableTime, function()
  200.          if !k:IsValid() then return end
  201.          if SERVER then
  202.          k:Fire("TurnOn", "", 0) end
  203.       end)
  204.    end
  205.    
  206.        if table.HasValue(self.Turrets,trclass) then
  207.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
  208.    elseif trclass == "npc_combine_camera" then
  209.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/camera_bugged_loop.wav"))
  210.  elseif trclass == "combine_mine" then
  211.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/other_bugged_loop" .. math.random(2,3) .. ".wav"))
  212.  elseif trclass == "item_healthcharger" then
  213.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/other_bugged_loop" .. math.random(2,3) .. ".wav"))
  214.  elseif trclass == "item_suitcharger" then
  215.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/other_bugged_loop" .. math.random(2,3) .. ".wav"))
  216.  elseif trclass == "prop_thumper" then
  217.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/generator_malfunction.wav"))
  218.    elseif trclass == "npc_cscanner" then
  219.         idloop = k:StartLoopingSound(Sound("weapons/sc/sticky_shocker3.wav"))
  220.    elseif trclass == "npc_manhack" then
  221.         idloop = k:StartLoopingSound(Sound("weapons/sc/sticky_shocker3.wav"))
  222.    elseif trclass == "npc_clawscanner" then
  223.         idloop = k:StartLoopingSound(Sound("weapons/sc/sticky_shocker3.wav"))
  224.  elseif trclass == "hl2_thumper_large" then
  225.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/generator_malfunction.wav"))
  226.    elseif table.HasValue(self.Other, trclass) then
  227.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/other_bugged_loop" .. math.random(2,3) .. ".wav"))
  228.    elseif table.HasValue(self.Light, trclass) then
  229.         idloop = k:StartLoopingSound(Sound("weapons/misc_effects/light_bugged_loop" .. math.random(1,5) .. ".wav"))
  230.        end
  231.    
  232.  
  233.    self:SetNWInt("EMPammo", newammo)
  234.  
  235.    if oked then
  236.     newammo = newammo - self.EMPNeeded
  237.       timer.Simple(self.EMPTime, function()
  238.          if !self:IsValid() then return end
  239.          k:StopLoopingSound(idloop)
  240.       end)
  241.       self:SetNWInt("Light", 2)
  242.    else
  243.       self:SetNWInt("Light", 1)
  244.    end
  245.  
  246.    timer.Simple(self.EMPDelay, function()
  247.       if !self:IsValid() then return end
  248.       self:SetNWInt("Light", 0)
  249.    end)
  250. end
  251.  
  252. function SWEP:GetUniqueFiremode()
  253.    if self:GetNWBool("EMPmode") then
  254.       return "EMP"
  255.    else
  256.       return "SEMI"
  257.    end
  258. end
  259.  
  260. function SWEP:GetAmmoDisplay()
  261.    if self:GetNWBool("EMPmode") then
  262.       return self:GetNWInt("EMPammo", 0) .. "%"
  263.    end
  264. end
  265.  
  266. local lmat = Material("engine/lightsprite")
  267.  
  268. function SWEP:OnThink()
  269.    if !self:IsValid() then return end
  270.  
  271.    if self:GetNWFloat("EMPnextregen", 0) < CurTime() then
  272.       self:SetNWInt("EMPammo", math.Clamp(self:GetNWInt("EMPammo", 0) + 1, 0, self.EMPAmmoMax))
  273.       self:SetNWFloat("EMPnextregen", CurTime() + self.EMPRegenDelay)
  274.    end
  275.  
  276.    if self.Owner:KeyPressed(IN_USE) and self.Owner:KeyDown(IN_ATTACK2) then
  277.       self:SetNWBool("EMPmode", !self:GetNWBool("EMPmode"))
  278.       if self:GetNWBool("EMPmode") then
  279.          self.Special = "uniqueaimed"
  280.       else
  281.          self.Special = "none"
  282.       end
  283.    end
  284.  
  285. end
  286.  
  287. function SWEP:DrawWorldModel()
  288.    self:DrawModel()
  289.  
  290.    local lm = self:GetNWInt("Light", 0)
  291.  
  292.    local sppos = self:GetAttachment(3).Pos
  293.  
  294.    render.SetMaterial(lmat)
  295.  
  296.    if lm == 1 then
  297.       render.DrawSprite(sppos, 4, 4, Color(255, 0, 0))
  298.    elseif lm == 2 then
  299.       render.DrawSprite(sppos, 4, 4, Color(0, 255, 0))
  300.    end
  301. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement