Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.PrintName = "M1014"
- SWEP.PrintName = "Headcrab Canister Launcher"
- SWEP.Slot = 3
- SWEP.SlotPos = 1
- SWEP.DrawAmmo = false
- SWEP.DrawCrosshair = true
- SWEP.Weight = 5
- SWEP.AutoSwitchTo = true
- SWEP.AutoSwitchFrom = true
- SWEP.Author = "Jimbomcb"
- SWEP.Contact = ""
- SWEP.Purpose = ""
- SWEP.Instructions = "Launches a Headcrab Canister where you aim."
- SWEP.ViewModel = "models/weapons/v_357.mdl"
- SWEP.WorldModel = "models/weapons/w_357.mdl"
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = -1
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "none"
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = "none"
- local ShootSoundFire = Sound( "Airboat.FireGunHeavy" )
- local ShootSoundFail = Sound( "WallHealth.Deny" )
- local YawIncrement = 20
- local PitchIncrement = 10
- function SWEP:PrimaryAttack()
- local tr = self.Owner:GetEyeTrace()
- self:ShootEffects(self)
- if (SERVER) then
- local aBaseAngle = tr.HitNormal:Angle()
- local aBasePos = tr.HitPos
- local bScanning = true
- local iPitch = 10
- local iYaw = -180
- local iLoopLimit = 0
- local iProcessedTotal = 0
- local tValidHits = {}
- while (bScanning == true && iLoopLimit < 500) do
- iYaw = iYaw + YawIncrement
- iProcessedTotal = iProcessedTotal + 1
- if (iYaw >= 180) then
- iYaw = -180
- iPitch = iPitch - PitchIncrement
- end
- local tLoop = util.QuickTrace( aBasePos, (aBaseAngle+Angle(iPitch,iYaw,0)):Forward()*40000 )
- if (tLoop.HitSky) then
- table.insert(tValidHits,tLoop)
- end
- if (iPitch 0) then
- local iRand = math.random(1,iHits)
- local tRand = tValidHits[iRand]
- local ent = ents.Create( "env_headcrabcanister" )
- ent:SetPos( aBasePos )
- ent:SetAngles( (tRand.HitPos-tRand.StartPos):Angle() )
- ent:SetKeyValue( "HeadcrabType", math.random(0,2) )
- ent:SetKeyValue( "HeadcrabCount", math.random(1,3) )
- ent:SetKeyValue( "FlightSpeed", math.random(2500,6000) )
- ent:SetKeyValue( "FlightTime", math.random(2,5) )
- ent:SetKeyValue( "Damage", math.random(50,90) )
- ent:SetKeyValue( "DamageRadius", math.random(300,512) )
- ent:SetKeyValue( "SmokeLifetime", math.random(5,10) )
- ent:SetKeyValue( "StartingHeight", 1000 )
- ent:Spawn()
- ent:Input("FireCanister", self.Owner, self.Owner)
- undo.Create("NPC")
- undo.AddEntity( ent )
- undo.SetPlayer( self.Owner )
- undo.Finish()
- self:EmitSound( ShootSoundFire )
- else
- self:EmitSound( ShootSoundFail )
- end
- tLoop = nil
- tValidHits = nil
- end
- end
- end
- function SWEP:SecondaryAttack() self:PrimaryAttack() end
- function SWEP:ShouldDropOnDie() return false end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement