Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SWEP.Spawnable = true
- SWEP.AdminOnly = false
- SWEP.Base = "astw2_base"
- SWEP.PrintName = "SC Pistol (Chaos Theory)"
- SWEP.Category = "ASTW2 - Pistols"
- SWEP.Slot = 1
- SWEP.Author = "Arctic"
- SWEP.Contact = "/id/ArcticWinterZzZ/"
- SWEP.Purpose = "Disables electronics."
- SWEP.Instructions = "ATTACK2 to aim, ATTACK1 to fire."
- if CLIENT then
- SWEP.WepSelectIcon = surface.GetTextureID( "sc/vgui/hud/sc_pistol" )
- SWEP.DrawWeaponInfoBox = false
- SWEP.BounceWeaponIcon = false
- killicon.Add( "astw2_sc_pistol_ct", "sc/vgui/hud/sc_pistol", Color( 255, 255, 255, 255 ) )
- end
- SWEP.ViewModel = nil
- SWEP.WorldModel = "models/weapons/w_fiveseven_ct.mdl"
- SWEP.Primary.Damage = 12
- SWEP.Primary.Delay = 60 / 350
- SWEP.Primary.Acc = 1 / 75
- SWEP.Primary.Recoil = 200
- SWEP.Primary.RecoilAcc = 100
- SWEP.Primary.Num = 1
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = "5mm"
- SWEP.Primary.ClipSize = 20
- SWEP.Projectile = nil
- SWEP.ProjectileForce = 2500
- SWEP.Effect_MuzzleFlash = "astw2_muzzleflash_scpistol"
- SWEP.Tracer = "Tracer"
- SWEP.Sound = "weapons/pistol/scpistol_fire.wav"
- SWEP.Sound_Vol = 60
- SWEP.Sound_Pitch = 100
- SWEP.Sound_Magout = "weapons/pistol/scpistol_clipout.wav"
- SWEP.Sound_Magin = "weapons/pistol/scpistol_clipin.wav"
- SWEP.Sound_Boltpull = "weapons/silence.wav"
- SWEP.Secondary.Ammo = nil
- SWEP.Effect_ShellEject = "astw2_case_5mm"
- SWEP.MagDrop = ""
- SWEP.ReloadTime = 1.5
- SWEP.CannotChamber = false
- SWEP.CanRest = false
- SWEP.CrosshairOverride = "crosshairs/sc/ct_pistol_crosshair.png"
- SWEP.Special = "melee"
- SWEP.Melee = false // Whether to use the melee attack of the gun.
- SWEP.Melee_Damage = 10
- SWEP.Melee_Range = 8 // Range of the melee attack trace.
- SWEP.Melee_SwingTime = 1
- SWEP.Melee_HitSound = "physics/metal/weapon_impact_hard1.wav"
- SWEP.Melee_HitHumanSound = "physics/body/body_medium_impact_hard4.wav"
- SWEP.Melee_DamageType = DMG_CLUB
- SWEP.CanRest = false
- SWEP.HoldType_Lowered = "pistol"
- SWEP.HoldType_Aim = "pistol"
- SWEP.HoldType_Hipfire = "pistol"
- SWEP.Anim_Reload = ACT_HL2MP_GESTURE_RELOAD_PISTOL
- SWEP.Anim_Shoot = ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL
- SWEP.Anim_Melee = ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE
- SWEP.Special = "none"
- SWEP.EMPAmmoMax = 100
- SWEP.EMPNeeded = 100
- SWEP.EMPTime = 10
- SWEP.EMPDelay = 2
- SWEP.EMPRegenDelay = 0.065
- SWEP.EMPRange = 5000
- SWEP.EMPDisableTime = 10
- SWEP.UniqueFiremode = true
- AddCSLuaFile()
- function SWEP:OnInitialize()
- self.EMPSound = nil
- self:SetNWInt("Light", 0)
- self:SetNWInt("EMPammo", self.EMPAmmoMax)
- self:SetNWFloat("EMPnextregen", CurTime() + self.EMPRegenDelay)
- self:SetNWBool("EMPmode", false)
- end
- function SWEP:SpecialAttack()
- if self:GetNWInt( "EMPammo" ) < self.EMPNeeded then return end
- self:EmitSound( "weapons/pistol/pistol_emp.wav" )
- local shootpos = self:GetShootPosASTW()
- local Dir = (self.Owner:EyeAngles() + self.Fire_AngleOffset):Forward()
- local tr = util.TraceLine({
- start = shootpos,
- endpos = shootpos + (Dir * self.EMPRange)
- })
- self:SetNextPrimaryFire( CurTime() + self.EMPDelay )
- PrintTable(tr)
- print("meem")
- -- do stuff here
- local k = tr.Entity
- local newammo = self.Owner:GetNWInt( "EMPammo" )
- local oked = true
- if !tr.Hit or tr.HitWorld or tr.HitSky or !tr.Entity or !IsValid(tr.Entity) then
- newammo = newammo + self.EMPNeeded
- oked = false
- elseif k:GetClass() == "npc_turret_floor" then
- k:Fire("Disable", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_combine_camera" then
- k:Fire("Disable", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/camera_bugged_loop.wav"))
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_turret_ceiling" then
- k:Fire("Disable", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "hl2_npc_turret_ground" then
- k:Fire("Ignite", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/turret_broke_loop.wav"))
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_cscanner" then
- k:Fire("Break", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_clawscanner" then
- k:Fire("Break", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_manhack" then
- k:Fire("InteractivePowerDown", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "item_suitcharger" then
- k:Fire("Recharge", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "item_healthcharger" then
- k:Fire("Recharge", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_rollermine" then
- k:Fire("TurnOff", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/other_bugged_loop" .. math.random(2,3) .. ".wav"))
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("TurnOn", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "combine_mine" then
- k:Fire("Disarm", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_hunter" then
- k:Fire("DisableShooting", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "gmod_lamp" then
- k:Fire("Disable", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/light_bugged_loop" .. math.random(1,5) .. ".wav"))
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "gmod_light" then
- k:Fire("Disable", "", 0)
- k:EmitSound(Sound("weapons/misc_effects/light_bugged_loop" .. math.random(1,5) .. ".wav"))
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "prop_thumper" then
- k:Fire("Disable", "", 0)
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "hl2_thumper_large" then
- k:Fire("Disable", "", 0)
- timer.Simple(self.EMPDisableTime, function()
- if !k:IsValid() then return end
- k:Fire("Enable", "", 0)
- end)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_helicopter" then
- k:Fire("DropBomb", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_combine_s" then
- k:Fire("LookOff", "", 0)
- newammo = newammo - self.EMPNeeded
- elseif k:GetClass() == "npc_metropolice" then
- k:Fire("LookOff", "", 0)
- newammo = newammo - self.EMPNeeded
- else
- -- failure
- newammo = newammo + self.EMPNeeded
- oked = false
- end
- self:SetNWInt("EMPammo", newammo)
- if oked then
- local id = self:StartLoopingSound("ambient/atmosphere/laundry_amb.wav")
- timer.Simple(self.EMPTime, function()
- if !self:IsValid() then return end
- self:StopLoopingSound(id)
- end)
- self:SetNWInt("Light", 2)
- else
- self:SetNWInt("Light", 1)
- end
- timer.Simple(self.EMPDelay, function()
- if !self:IsValid() then return end
- self:SetNWInt("Light", 0)
- end)
- end
- function SWEP:GetUniqueFiremode()
- if self:GetNWBool("EMPmode") then
- return "EMP"
- else
- return "SEMI"
- end
- end
- function SWEP:GetAmmoDisplay()
- if self:GetNWBool("EMPmode") then
- return self:GetNWInt("EMPammo", 0) .. "%"
- end
- end
- local lmat = Material("engine/lightsprite")
- function SWEP:OnThink()
- if !self:IsValid() then return end
- if self:GetNWFloat("EMPnextregen", 0) < CurTime() then
- self:SetNWInt("EMPammo", math.Clamp(self:GetNWInt("EMPammo", 0) + 1, 0, self.EMPAmmoMax))
- self:SetNWFloat("EMPnextregen", CurTime() + self.EMPRegenDelay)
- end
- if self.Owner:KeyPressed(IN_USE) and self.Owner:KeyDown(IN_ATTACK2) then
- self:SetNWBool("EMPmode", !self:GetNWBool("EMPmode"))
- if self:GetNWBool("EMPmode") then
- self.Special = "uniqueaimed"
- else
- self.Special = "none"
- end
- end
- end
- function SWEP:DrawWorldModel()
- self:DrawModel()
- local lm = self:GetNWInt("Light", 0)
- local sppos = self:GetAttachment(3).Pos
- render.SetMaterial(lmat)
- if lm == 1 then
- render.DrawSprite(sppos, 2, 2, Color(255, 0, 0))
- elseif lm == 2 then
- render.DrawSprite(sppos, 2, 2, Color(0, 255, 0))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement