Ballistics - Physical bullets.

http://www.garrysmod.org/img/?t=dll&id=26557

A script that adds physical bullets to SWEPs, there is no known method of hooking when a regular weapon fires.

Features:
[ul]
[li]Physical bullets, duh.
[/li][li]Responds to phys_timescale for slow motion awesomeness.
[/li][li]phys_physicalbullets cvar for toggeling between regular and physical bullets.
[/li][li]v2:
[/li][list]
[li]Model scale .25 thanks to Robbis_1.
[/li][li]Improved spray calculation.
[/li][/ul]
[/list]

Bugs:
[ul]
[li]Sometimes the bullet that is fired to cause damage when the physical bullet hits clips through the world.
[/li][li]The bullets have a tendancy to spin in circles if they bounce off of something.
[/li][/ul]

Incredible. Good job on this.

They work on all weapons with bullets?

All SWEPs. :eng101:

Would adding a few screens kill you Xera? :v:

Not too hard, but very cool

Nice!

But hasn’t Kogitsune done this before, just with trails on the bullets?
It’s called SMOD Bullettime or something like this.

They weren’t physical, i don’t think. You could just slow down time and look at them, but you couldn’t pick them up with the gravgun and fire them back. I like this script, it’s actually brilliant.

I’ll make a video.

Bleh… no I won’t.

I haven’t gotten round to installing Fraps after I reinstalled Windows and I can’t find the installer.

Good job! I noticed the “Needs a better model…”, how about scaling the current model to like 0.25 of the current size?
And I noticed you used tracers too, isn’t it better to use PhysicsCollide? The would probably fix your bug too.

Noticed something else, on line 26, only this is needed
[lua] if self.Start < CurTime( ) - 10 then[/lua]
Because CurTime is synced with phys_timescale.

Thanks!

How? :v:

I was initially using PhysicsCollide but had some problems, I’ll try again.

The main problem is bullets colliding with each other and sometimes the actual entity would kill things(Kill registers as #physical_bullet).

To get around that I use SOLID_NONE.

Thanks, didn’t know that. :slight_smile:

Oh sweet, When i read “responds to phys_timescale” I instantly clicked download, :v:

Don’t you mean host_timescale? Or is it linked with phys_timescale as well. Which I don’t think it is :tinfoil:

I would install this… Except for the fact that all the weapons on my server do not damage players, but will still kill them if they’re at 0 or less health.
So I wrote this piece of code:
[lua]
local meta = FindMetaTable( “Entity” )

meta.OldBullet = meta.FireBullets --Save the old bullet function

function meta.FireBullets( self, bullet )
bullet = bullet or {}
bullet.Num = bullet.Num or 1
bullet.Src = bullet.Src or Vector( 0, 0, 0 )
bullet.Dir = bullet.Dir or Vector( 0, 0, 0 )
bullet.Spread = bullet.Spread or Vector( 0, 0, 0 )
bullet.Tracer = bullet.Tracer or 1
bullet.Force = bullet.Force or 1
bullet.Damage = bullet.Damage or 1

	local lulzspread = bullet.Spread
	local lulznumber = bullet.Num
	
	for i=1, lulznumber do
	
		bullet.Dir = bullet.Dir + lulzspread
		bullet.Spread = Vector( 0, 0, 0 )
		bullet.Num	= 1
		
		local tracedatabullet = {} 
		tracedatabullet.filter = userid
		tracedatabullet.mask = MASK_SHOT --fuck, lol
		tracedatabullet.start = bullet.Src+(bullet.Dir*35)
		tracedatabullet.endpos = bullet.Src+(bullet.Dir*50000) 
		local tracebullet = util.TraceLine(tracedatabullet)
	
		if tracebullet.Entity:IsValid() then
			if tracebullet.Entity:IsPlayer() then
				if tracebullet.Entity:Armor() &lt;= 0 then
					local health = tracebullet.Entity:Health() - bullet.Damage
					tracebullet.Entity:SetHealth( health )
				else
					local armor = tracebullet.Entity:Armor()
					local armorfactor = tracebullet.Entity:Armor()/5
					if armorfactor &lt;= 1.125 then
						armorprotection = 1.125
					else
						armorprotection = armorfactor
					end
					local damage = bullet.Damage / armorprotection
					local health = tracebullet.Entity:Health() - damage
					tracebullet.Entity:SetHealth( health )
					local armor = tracebullet.Entity:Armor() - 8
					if armor &lt;= 0 then
						tracebullet.Entity:SetArmor( 0 )
					else
						tracebullet.Entity:SetArmor( armor )
					end
				end
			end
		end
				

		meta.OldBullet( self, bullet )
		
	end

end
[/lua]

One Lua King! One!

Well… that code seems utterly pointless.

My code simply fires a bullet(From the same thing that initially called the FireBullets function), if it isn’t killing stuff then it’s a problem your end… tried sbox_plpldamage 0?

Oh yeah… You’re right…
Xera, keep the code you have there :ninja:. My bad.

To scale something, just add this in the draw function
[lua]self.Entity:SetModelScale(Vector(0.25, 0.25, 0.25))[/lua]

New version.

You should make a menu under utilities so you can turn this script on and off.

No one cares if it’s sweps or SWEPs…

For starters, I’d like to see anyone grab a bullet with the gravity gun.

I had done the prop bit for a while, but got tired to looking at props spinning and spazzing out, then went to traces that performed better.

That doesn’t apply here.

@Xera:

Nice work, but I have to agree with Rambo - add some media so we can tell what it looks like, because I can’t tell from your posts if it’s just an invisible entity hurtling along with an effect behind it, or whatever it is.

Good job, though.