Detecting bullet's travel line

This might be super difficult I’m not sure, but would it be possible to detect where bullets hit or their “line” that they would go through? I just want to detect if a bullet grazes a player but it seems since bullets aren’t entities it might be hard. By line, I mean the straight line from their starting point to destination. I googled and googled but again bullets aren’t entities… Help? I felt it would maybe need it’s own thread because I don’t even know where to start.

[editline]ok[/editline]
I wanted to use physical bullets anyway, it would make this easier maybe? A good addon for it that would make this easier?

Worshipper’s Mad cow base does this for near miss sounds, I would advise looking at that.

I’m assuming he doesn’t use physical bullets and uses the default way that bullets shoot…?

Yes

So I downloaded the Mad Cow’s Weapons reborn for GMod 13 (I couldn’t find any Mad Cows Weapons things by the so-called “Worshipper”) and I was checking the entities… “ent_mad_bullet” it does use entities, remember I want this to be compatible with all types of weapons (well not all, but at least FA:S 2)
[editline]ok[/editline]
Found the old version you are talking about, luckily no bullet entities… Looking through the shared file for the base I found this
[lua]function SWEP:RicochetCallback(bouncenum, attacker, tr, dmginfo)

if (CLIENT) then return end

local DoDefaultEffect = true
if (tr.HitSky) then return end

// Can we go through whatever we hit?
if (self.Penetration) and (self:BulletPenetrate(bouncenum, attacker, tr, dmginfo)) then
	return {damage = true, effects = DoDefaultEffect}
end

if (tr.MatType != MAT_METAL) then
	if (SERVER) then
		util.ScreenShake(tr.HitPos, 5, 0.1, 0.5, 64)
		WorldSound("Bullets.DefaultNearmiss", tr.HitPos, 250, math.random(110, 180)) // this is what i want, right?
	end

	return 
end

if (self.Ricochet == false) then return {damage = true, effects = DoDefaultEffect} end

if (bouncenum > self.MaxRicochet) then return end

// Bounce vector
local trace = {}
trace.start = tr.HitPos
trace.endpos = trace.start + (tr.HitNormal * 16384) // this looks like it would be just what I want for detecting the lines but it says "bounce" vector

local trace = util.TraceLine(trace) // or is it this

local DotProduct = tr.HitNormal:Dot(tr.Normal * -1) 

local bullet = 
{	
	Num 		= 1,
	Src 		= tr.HitPos + (tr.HitNormal * 5),
	Dir 		= ((2 * tr.HitNormal * DotProduct) + tr.Normal) + (VectorRand() * 0.05),
	Spread 	= Vector(0, 0, 0),
	Tracer	= 1,
	TracerName 	= "effect_mad_ricochet_trace",
	Force		= dmginfo:GetDamage() * 0.25,
	Damage	= dmginfo:GetDamage() * 0.5,
	HullSize	= 2
}
	
// Added conditional to stop errors when bullets ricochet after weapon switch
bullet.Callback  	= function(a, b, c) if (self.Ricochet) then return self:RicochetCallback(bouncenum + 1, a, b, c) end end

timer.Simple(0.05, attacker.FireBullets, attacker, bullet, true)

return {damage = true, effects = DoDefaultEffect}

end[/lua]
of course I only see things about bouncing I don’t see anything about actually detecting their lines. Even if I did find the code though, I don’t think editing the FA:S 2 files in server would work

The “line” you want is just the vector normal or “direction” times the distance.

You would have to do some kind of line - point distance calculation to test for grazing.

Mad Cow weapons reborn by siminov is the one you’re looking for, sorry. Most of the code is still Worshippers. However there was never any physical bullets in mad cow…

[editline]18th October 2014[/editline]

Just checked again; my mistake, looks like mad cow doesn’t do it.

One thing you could do is make a tracehull just slightly larger than a bullet hull that uses the bullet callback to see if it “grazed” anything.

I’m going to try both of your suggestions… Please tell me I don’t have to mess with the actual code of the SWEP to do this?

If that’s a problem you won’t be able to do what you’re trying to do.

No, there’s a way.