AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( 'shared.lua' ) function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( "sla_shell" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() self.Spawner = ply return ent end /*--------------------------------------------------------- Name: Initialize ---------------------------------------------------------*/ function ENT:Initialize( ) self.Entity:SetModel( "models/props/de_nuke/light_red2.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end self.Active = false self.Drop = false self.Smoke = ents.Create("env_smoketrail") self.Smoke:SetPos(self.Entity:GetPos()) self.Smoke:SetParent(self.Entity) self.Smoke:SetKeyValue("self.Smokesprite","sprites/whitepuff.spr" ) self.Smoke:SetKeyValue("spawnrate","25") self.Smoke:SetKeyValue("spawnradius","5" ) self.Smoke:SetKeyValue("opacity","0.5" ) self.Smoke:SetKeyValue("endsize","10" ) self.Smoke:SetKeyValue("startcolor","100 100 100" ) self.Smoke:SetKeyValue("endcolor","255 255 255" ) self.Smoke:SetKeyValue("lifetime","1" ) self.Smoke:Spawn() end /*--------------------------------------------------------- Name: PhysicsCollide ---------------------------------------------------------*/ function ENT:PhysicsCollide() end /*--------------------------------------------------------- Name: OnTakeDamage ---------------------------------------------------------*/ function ENT:OnTakeDamage( dmginfo ) self.Entity:TakePhysicsDamage( dmginfo ) end /*--------------------------------------------------------- Name: Use ---------------------------------------------------------*/ function ENT:Use( activator ) end function ENT:Detonate() local explode = ents.Create("env_explosion") explode:SetPos(self.Entity:GetPos()) explode:SetOwner(self.Entity:GetOwner()) explode:SetKeyValue("iMagnitude", "200") explode:Spawn() explode:Fire("explode", "", 0) explode:Fire("kill", "", 0) local tr = util.QuickTrace(self.Entity:GetPos(), Vector(0,0,-4096), self.Entity) local beamTarg = ents.Create("info_target") beamTarg:SetKeyValue("targetname", "NULL" .. beamTarg) beamTarg:SetPos(self.Entity:GetPos()) beamTarg:Spawn() local entBeam = ents.Create("env_laser") entBeam:SetPos(tr.HitPos) entBeam:SetKeyValue("renderamt", "255") entBeam:SetKeyValue( "rendercolor", "255 100 0") entBeam:SetKeyValue( "texture", "sprites/plasmabeam.spr") entBeam:SetKeyValue( "TextureScroll", "55") entBeam:SetKeyValue( "targetname", "laser" .. entBeam) entBeam:SetKeyValue( "parentname", "") entBeam:SetKeyValue( "damage", "5") entBeam:SetKeyValue( "spawnflags", "1 + 16 + 32") entBeam:SetKeyValue( "width", "15") entBeam:SetKeyValue( "dissolvetype", "1") entBeam:SetKeyValue( "LaserTarget", "NULL" .. beamTarg) entBeam:SetKeyValue( "TouchType", "1") entBeam:Spawn() entBeam:Fire("kill", "", 2) beamTarg:Fire("kill", "", 2) local effect = EffectData() effect:SetOrigin(tr.HitPos) util.Effect("thumperdust", effect) util.Effect("manhacksparks", effect) local phys = ents.Create("env_physexplosion") phys:SetPos(tr.HitPos) phys:SetKeyValue("magnitude", "300") phys:SetKeyValue("radius", "250") phys:SetOwner(self.Entity:GetOwner()) phys:SetPhysicsAttacker(self.Entity:GetOwner()) --phys:SetKeyValue("spawnflags", "2 + 16") phys:Spawn() phys:Fire("explode", "", 0) phys:Fire("kill", "", 0) local pobj = self.Entity:GetPhysicsObject() pobj:EnableMotion(false) timer.Simple(3, function() self:DropIt() end) end function ENT:DropIt() local pobj = self.Entity:GetPhysicsObject() pobj:EnableMotion(true) self.Drop = true end function ENT:SetLaunch( ply ) self.Active = true self.Launcher = ply self:SetAngles(ply:GetAimVector()) end function ENT:Explode() local explode = ents.Create("env_explosion") explode:SetPos(self.Entity:GetPos()) explode:SetOwner(self.Entity:GetOwner()) explode:SetKeyValue("iMagnitude", "200") explode:Spawn() explode:Fire("explode", "", 0) explode:Fire("kill", "", 0) self.Drop = false self.Entity:Fire("kill", "", 0) end /*--------------------------------------------------------- Name: Think ----------------------------------------------------------*/ function ENT:Think( ) self.LastHeight = self.LastHeight or self:GetPos().z if self:GetPos().z < self.LastHeight then self:Detonate() end self.LastHeight = self:GetPos().z if self.Drop then local entC = ents.FindInSphere(self.Entity:GetPos(), 300) for k, v in pairs(entC) do if v and v:IsValid() then if v:IsPlayer() && v:IsNPC() then if self.Entity:IsOnGround() then self:Explode() end end end end end end