AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:KeyValue( key, value ) if ( key == "size" ) then self.Radius=tonumber(value) end if ( key == "do" ) then self.Do=tonumber(value) end if ( key == "los" ) then self.LOS=tonumber(value) end end function ENT:Initialize() self.Entity:SetMoveType( MOVETYPE_NONE ) self.Entity:SetSolid( SOLID_NONE ) self.Entity:DrawShadow( false ) self.Entity:PhysicsInitSphere(self.Radius) local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:EnableCollisions( false ) end self.Entity:SetTrigger( true ) self.Entity:SetNotSolid( true ) self.Entity:SetCollisionBounds( Vector( -self.Radius, -self.Radius, -self.Radius), Vector( self.Radius, self.Radius, self.Radius ) ) end function ENT:StartTouch(entity) end function ENT:Think() self:NextThink(CurTime()) end function ENT:Touch( entity ) if entity:IsPlayer() then local ent=entity:GetActiveWeapon() if ValidEntity(ent) then -- build a table of all weapons for ignoring, no better way :( local es={} for _,entx in pairs(ents.GetAll()) do if entx:IsWeapon() then table.insert(es,entx) end end table.insert(es,entity) local trace={} trace.start=entity:GetPos() trace.endpos=self.Entity:GetPos() trace.filter = es traceRes=util.TraceLine(trace) if ValidEntity(traceRes.Entity) and traceRes.Entity:GetClass()=="ws_stripent" or self.LOS==0 then entity:DropWeapon(ent) ent:SetPos(entity:GetPos()+(self.Entity:GetPos()-entity:GetPos()):Normalize()*100 ) ent:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE) ent:SetSolid(SOLID_VPHYSICS) ent:SetNotSolid(false) ent:SetTrigger(false) if self.Do==1 then ent:Remove() end end end end if entity:IsWeapon() then local phys=entity:GetPhysicsObject() if phys:IsValid() then phys:SetVelocity( (self.Entity:GetPos()-entity:GetPos()):Normalize()*100 ) end if math.random(1,30)==5 then local effectdata = EffectData() effectdata:SetEntity(entity) effectdata:SetOrigin(entity:GetPos()) effectdata:SetStart(entity:GetPos()) effectdata:SetMagnitude(10) util.Effect( "TeslaHitBoxes", effectdata ) end end end local function ReturnWeaponProperties(ply,ent) ent:SetCollisionGroup(COLLISION_GROUP_WEAPON) ent:SetSolid(2) ent:SetNotSolid(true) ent:SetTrigger(true) end hook.Add("PlayerCanPickupWeapon","ReturnWeaponProperties",ReturnWeaponProperties)