Non-Entity Bullet Interaction

I remember a couple years ago it was impossible to detect and interact with non-entity bullets with lua is this still the case?

Basically I want to detect if a bullet has entered a specific spherical area and if so remove it.

I know hammer has a tool texture BLOCK BULLETS, would I be able to create an entity with no model, setup custom spherical collision physics and somehow apply this texture?

You can’t really remove those bullets since they basically don’t even exist. Source has hit scan bullets, which means its a trace that applies damage instantly ( Basically ). And then it creates visible bullet effect and so on.

I figured as much since that’s what I do in my own c++ projects…
No good on my second theory about BLOCK BULLETS tool texture?

Not sure, you can try create a mesh or a model with Entity:SetNoDraw set to true, surely that will block bullets, but I am not sure what about effects.

JetBoom/necrosin can modify bullet particles, no?

Isnt it possible to make bullet entities?

Sure it’s possible to make bullet entities but that defeats the purpose here.

My entity already blocks everything except non-entity bullets and it doesn’t use a model. I create a custom physics sphere and during the touch function repel everything away, obviously bullets don’t trigger the touch function which was why I was wondering if there was any way possible to block the bullets short of creating a custom model the size of my sphere.

I could check every entity inside the sphere to see if it was shot by someone outside the sphere and negate the damage, which will work but I don’t want to see the bullets pass through the sphere not to mention it wouldn’t trigger the effect when something bounces off the sphere…

So you’re trying to make a non-solid shield of some sort? You could make another sphere and set it’s collision group to something that will block boolet traces but not things like players

Thank you amkoc that’s beautiful, exactly what I was looking for! Your gorgeous, and I’m tired x.x

EDIT: Now is there some sort of function that will fire when it’s hit? ^.^

EDIT: EDIT: Still blocks the player and not the bullets until I uncomment self:SetNotSolid( true ), then it doesn’t block anything :frowning:

function ENT:Initialize()
	self:SetMoveType( MOVETYPE_NONE )
	self:SetSolid( SOLID_NONE )
	self:DrawShadow( false )
	self:GetPhysicsObject():EnableCollisions( true )

	self:SetTrigger( true )
	--self:SetNotSolid( true )
	self:SetCollisionBounds( Vector( -self.DX_Base.DX_Radius, -self.DX_Base.DX_Radius, -self.DX_Base.DX_Radius), Vector( self.DX_Base.DX_Radius, self.DX_Base.DX_Radius, self.DX_Base.DX_Radius ) )

Any ideas what I might be doing wrong? I tried using different solid types with no luck.

If you’re using it as a shield for one player, you could try self:SetOwner( ply )
I think that should stop it colliding with that player.

Valve uses hitscan bullets, there isn’t any travel time, so you can’t detect it once it’s “entered an area”
Best you can do is either create and use your own (maybe physical) bullets and mess with those, or do a whole bunch of work in the gamemode damage hooks. You could just draw a big collision model around the player and set it to the debris group though.

[editline]10th July 2013[/editline]

i tried this with a helicopter bomb and it seemed to do the trick.

COLLISION_GROUP_DEBRIS blocks most things, but not projectiles, I only want to block projectiles, why wouldn’t COLLISION_GROUP_PROJECTILES work? Is there a bug?

Effectively I have 2 spheres setup.

An entity creates the first sphere and that entity controls the shield strength, recharge, etc.
The 1st sphere controls blocking out players, vehicles, etc during the Touch event function it controls shield drain.
The 1st sphere creates a 2nd sphere which is this one I’m trying to work with to block only projectiles since I can’t do both with the 1st sphere.

how about you block damage on all entities inside the sphere?
Could be a solution

Of course I can block damage done to entities inside the sphere if damaged by something from outside the sphere but its the visual aspect of that which is a little icky.

I’m just wondering why SetCollisionGroup( COLLISION_GROUP_PROJECTILES ) does not work

Have you tried COLLISION_GROUP_WEAPON supposedly only doesn’t collide with players

COLLISION_GROUP_WEAPON does not stop bullets either.

I think I need a little Garry input on this one if he’s listening…


Pretty sure bullet collision depends on CONTENTS_ enum masks. It’s possible to recreate the bullet code and apply the damage yourself. However, there is currently no available functions to set an entities’ CONTENTS_ mask.

I’m at a loss as to what I should do at this point, I guess remove damage from anything inside the sphere caused by anything outside the sphere…

:[ fail.