BulletLib (Non physical non instahit bullets)

Why useing this=

Tired of instahit bullets like nearly every weapon has?
Hate physical bullets, cause they tend to eat up much server cpu with a automatic weapon and also spaz around from time to time?

What this lib does:
It adds one global function to create a new bullet, with all needed settings

CreateBullet(startpos,movevector,effectfull,timetofly,dmg,force,owner)

Startpos is quite selfexplaining,
movevector is in case of a Swep self.Owner:GetAimVector()*speed of bullet (Note this is the speed per tick, garrysmod servers normally run at tickrate 33)
effectfull is the effect used to visualize the bullet, a example is added called “tazer”
timetofly is the time the bullet should fly in seconds
dmg is also self explaining
force is the force that the bullet inflicts when it hits something
owner is the Entity/Player that shoot the bullet.
If the owner is not present anymore worldspawn will be used (Aka Player fires and disconnects before bullet hits something)

Known bugs:
When shooting through glass the bullet skips a litte distance, this will be fixed soon.

V1 DL:
http://empirephoenix.de/BulletLib.rar

What in the world is this disgusting code? Needs SUPER OPTIMIZATION. :eng101: Seriously, a tick hook?

CptFuzzies: What the fuck are you talking about?

If you would learn what a ‘tick’ in context of the Source engine really is, you would understand that it is probably the best hook to use for the purpose.

The Think hook is run as fast as possible (capped by the server’s FPS limit convar). Between most think hooks, nothing is changed. No physics are simulated. No network data is parsed. Pretty much nothing at all.
It’s at the Tick that everything is done. Physics is simulated. Network data is parsed and sent on it’s way. All the stuff is done. The Tick rate for most servers is 66. If their FPS is 132, then you are calculating things 2 times too many.

Don’t quote me on the network part, however. I’m not sure if networking is tied into it. It may only be physics.

But still, learn what the hell you are talking about.

And what else is wrong with this code? I see nothing besides some minor inconveniences. Such as that CreateBullet creates the table itself, and does not accept one. This means a new table is allocated every time (bad).
Also that custom bullet callbacks cannot be done.

Good job, Empire Phoen!

Hm Custom bullet Callbacks… will be in the next version.

awesome,extremely usefull.

This is the best code I’ve downloaded in a long time.

EDIT: oh and If you could add a bulletspeed variable that would be great :slight_smile:

You’re not scaling by deltatime (and using tick for some reason) so this is useless on a server under load.

Well it will fly a little bit slower, yes, however if its under extreme load so that you can actually see them flying slower, the bullets are probably the least of your problems. (Cause you will lag like hell anyway)

You can set the speed by simply multiplying the vector it should move with a scalar.

x = 5
movevector*x
will make if fly 5 times faster.

That’s pointless.

Then explain please why, cause I can’t see your point

lol, the tick runs everything? No, I’m not trollin’, but the point your trying to make is like broken computer science.

What you mean to say is that calculations are ran through ticks, but even that’s not true, because servers wouldn’t survive on such a method of passing data.

Have you studied this field at all? Writing lines in notepad++ doesn’t mean you’re a programmer.

There are even slap-in-the-face predictable errors here based on tick calls.

By the way, you shouldn’t use worldspawn for this sort of thing, just run a protected call and pass the true attacker.

The tickrate of a server determines how often the physics are updated.

Well If anyone trollinga bout why this is shit can make any constructive critic I’m happy, but saying OMFG LAWLS TICK does not help. Tell me why this is not a good idea , OR GTFO).

Remember however that this si emant to be another method instead of real physical bullets. Using tick was the logical idea, since normal physic is calculated there as well.

I can see tihs point:
By the way, you shouldn’t use worldspawn for this sort of thing, just run a protected call and pass the true attacker.

However this lib can also be used by entitys, and as we all know they can easyly be destroyed.
So imagine two constraptions + a damagesystem fighting each other. Wher is the fun if you are unable to kill the other wiith the last flying bullet when your constraption is already killed?

Multiply the speed with the time since the last tick.

This just seems like something that looked better in theory but when you put it into practice you got lost in translation.

How do you enable it. I downloaded and placed in addons

vphysics isn’t updated the same time as everything else (faster). This doesn’t even use vphysics so it’s irrelevant.

BulletLib automatically runs at startup. You should see “Loading BulletLib” in the console.

dont see it and nothing happens

Just take JetBoom’s and Deco’s word to be true and read it a few more times