Ballistics - Physical bullets.

Sorry to say that, but the method you are creating “randomness” to the bullets (bullet spread) is inefficient.
The spread vector defines the two radius’s of an ellipsis and has nothing todo with a real direction vector.
So your current method destroys e.g. the old behaviour of the shotgun. E.g. when you shoot directly into the air (z-axis) you nearly have no offset, but when doing the same into the x axis, you have massive offset.

Here is my method which is (mathematical) correct - It adds a random offset according to the bullet’s original direction vector and their both elliptic radius’s for the bulletspread cone.

That’s an excerpt of my stargate pack (shield/init.lua)

[lua]if(not StarGate.Entity_FireBullets) then
local meta = FindMetaTable(“Entity”);
if(meta) then
StarGate.Entity_FireBullets = meta.FireBullets;
– My thing here now stops bullets :slight_smile:
meta.FireBullets = function(self,t)
if(t) then
local num = t.Num or 1; t.Num = 1; – Just ONE bullet drawn by FireBullets. The others are getting shot by the loop
local spread = t.Spread; t.Spread = Vector(0,0,0);
local direction = (t.Dir or Vector(0,0,0));
local pos = t.Src or self.Entity:GetPos();
local rnd = {};
– Must be in a separate for loop because calling StarGate.Entity_FireBullets(self,t); seems to reset the random generator
for i=1,num do
rnd* = {math.Rand(-1,1),math.Rand(-1,1)};
local return_false = false; – This is for one of my own scripts, so I know when to draw inpact smoke or not
–################# FIRE ZEH MISSLES!
for i=1,num do
local dir = Vector(direction.x,direction.y,direction.z); – We need a “new fresh” vector
–################# Add Bullet-Spread!
if(spread and spread ~= Vector(0,0,0)) then
– Two perpendicular vectors to the direction vector
local v1 = (dir:Cross(Vector(1,1,1))):Normalize();
local v2 = (dir:Cross(v1)):Normalize();
dir = dir + v1spread.xrnd*[1] + v2spread.yrnd*[2];
– Instead letting the engine decide to add randomness, we are doing it!
t.Dir = dir;
local trace = StarGate.Trace:New(pos,dir161024,{self.Entity,self.Entity:GetParent()});
if(trace.Entity:IsValid() and trace.Entity:GetClass() == “shield”) then
trace.Entity:Hit(self.Entity,trace.HitPos,(t.Damage or 50)/50,-1*trace.Normal);
return_false = true;
StarGate.Entity_FireBullets(self,t); – Normal bullet!
if(return_false) then return false end;

Have fun :slight_smile:

What are you bitching about? the guy he was talking to said

He said “All scripted weapons”

Holy shit, you can do so much with this! I’m thinking invisible wall neo bullet stopping powers.

Well, with this, you can grab the bullets with the gravity gun and even turn them around and send them back at whoever shot it. :v:

I’ll give that a shot.

Could you make your code any messier? :uhoh:

Why do you need a menu for one command?

You should make all kinds of weird settings like bouncy bullets, spread bullets, and hilariously slow bullets.

Does it do this to all sweps? Hmmm… I should try this :3

It overrides the FireBullets function so any script that calls it will work.

Are you using the SMOD bullets?

So… All SWeps… Does that include lasers?

If you mean the model, no.

You should, they’re an actual bullet projectile as a model.

Except that model doesn’t have a physics model.

No… only SWEPs that fire regular bullets.

Yes it does, I’ve used them with the prop cannon.

Could I implement this into my Swep?
Ill be sure to give credit

And If so

Is there any way to just add it to One Swep Instead of all the Sweps able to shoot bullets?


I have 3 Sweps installed
A Pistol
A Machine Gun
And A Chaingun

I want Only the Chaingun to fire physical bullets, and None of the others

You can always use the old function that’s set in the script:

Ugh, my host_timescale won’t work. It says it’s set to .1, but it’s still normal.

For me, that’s not really messy. I’m not liking long variable names :slight_smile:

I would love to see a video.

You need to enable cheats first.