Stargate bullets

Well apparently before I installed stargate, I always had fun using the bullettime mod with custom SWEPS.
Now, right after I installed stargate, I get this lua error spammed at me whenever a bullet hits a surface.
It works properly with stargate weapons and normal half life 2 weapons.



stargate/shared/bullets.lua:49: attempt to index local 'spread' (a number value)


Can anyone tell me a line of code to edit or something? Or is this unfixable?

[editline]08:44PM[/editline]

Anyone?

I noticed the same thing (literally, the exact same situation, I’m probably using the same bullet-time mod). I’m not entirely sure how to fix this but it would be great if someone could help.

No more executing Kliener with kermite’s pistols

Anyone???

Rageia;nfoainsapihdaf

Agggh comeon someone!
This is so annoying!

Its probebly a veriable name wich they both share, and are overiding eachother.

i know this is soom anyoning

Bump. Any real help? Someone have a solution to this?

Bump again. I’m getting frustrated.

:frowning:

Try using a different bullet-time mod.

http://www.garrysmod.org/img/?t=dll&id=44260
http://www.garrysmod.org/img/?t=dll&id=57929
http://www.garrysmod.org/img/?t=dll&id=64139
http://www.garrysmod.org/img/?t=dll&id=60322

you must choose, choose wisely now.

Try deleting bullets.lua in the stargate directory, I don’t see why stargate needs it.

Try putting the following code into garrysmod/addons/stargate/lua/stargate/shared/bullets.lua

[lua]
/*
Stargate Bullet Lib for GarrysMod10
Copyright © 2007 aVoN

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

–################# Instead of overwriting the FireBullets function twice (shield/eventhorizon) to recognize bullets, we create a customhook here @aVoN
StarGate.Bullets = StarGate.Bullets or {};
local meta = FindMetaTable(“Entity”);
if(not meta) then return end;
if(not StarGate.Bullets.__FireBullets) then StarGate.Bullets.__FireBullets = meta.FireBullets end;

–################# Redefine Entity:FireBullets @aVoN
function meta:FireBullets(bullet)
if(not bullet) then return end;
local original_bullet = table.Copy(bullet);
local qued = {}; – We qued bullets which have not been overwritten - Fire then “normally”
local override = false; – If set to true, we will shoot the bullets instead of letting the engine decide
– The modified part now, to determine if we hit a shield!
local num = bullet.Num or 1; bullet.Num = 1; – Just ONE bullet drawn by FireBullets. The others are getting shot by the loop
local spread1 = bullet.Spread; bullet.Spread = Vector(0,0,0);
local direction = (bullet.Dir or Vector(0,0,0));
local pos = bullet.Src or self:GetPos();
local rnd = {};
– Calculate the spread. Must be in a separate for loop. Doing this in the loop below seems to always result the same random numer (Don’t ask me why…)
for i=1,num do
rnd* = {math.Rand(-1,1),math.Rand(-1,1)};
end
–################# If we hit anything, run the hook
for i=1,num do
local dir = Vector(direction.x,direction.y,direction.z); – We need a “new fresh” vector
–Calculate Bullet-Spread!
if(spread1 and spread1 ~= Vector(0,0,0)) then
– Two perpendicular vectors to the direction vector (to calculate the spread-cone)
local v1 = (dir:Cross(Vector(1,1,1))):Normalize();
local v2 = (dir:Cross(v1)):Normalize();
dir = dir + v1spread1.xrnd*[1] + v2spread1.yrnd*[2];
– Instead letting the engine decide to add randomness, we are doing it (Just for the trace)
bullet.Dir = dir;
end
local trace = StarGate.Trace:New(pos,dir161024,{self,self:GetParent()});
if(hook.Call(“StarGate.Bullet”,GAMEMODE,self,bullet,trace)) then
override = true;
else
table.insert(qued,table.Copy(bullet));
end
end
–################# Fire old bullets
if(override) then
– Remaining shots - Engine has nothinh to say now!
for _,v in pairs(qued) do
StarGate.Bullets.__FireBullets(self,v);
end
else
– No override: Shoot like the engine would (keeps the shots in sync with client/serverside animations)
StarGate.Bullets.__FireBullets(self,original_bullet);
end
end
[/lua]
Untested, but shouldn’t screw anything up.

If that doesn’t work, then use the code below this.


TRY THE ABOVE CODE FIRST!

[lua]
/*
Stargate Bullet Lib for GarrysMod10
Copyright © 2007 aVoN

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

–################# Instead of overwriting the FireBullets function twice (shield/eventhorizon) to recognize bullets, we create a customhook here @aVoN
StarGate.Bullets = StarGate.Bullets or {};
local meta = FindMetaTable(“Entity”);
if(not meta) then return end;
if(not StarGate.Bullets.__FireBullets) then StarGate.Bullets.__FireBullets = meta.FireBullets end;

–################# Redefine Entity:FireBullets @aVoN
function meta:FireBullets(bullet)
if(not bullet) then return end;
local original_bullet = table.Copy(bullet);
local qued = {}; – We qued bullets which have not been overwritten - Fire then “normally”
local override = false; – If set to true, we will shoot the bullets instead of letting the engine decide
– The modified part now, to determine if we hit a shield!
local num = bullet.Num or 1; bullet.Num = 1; – Just ONE bullet drawn by FireBullets. The others are getting shot by the loop
local spread1 = bullet.Spread1; bullet.Spread1 = Vector(0,0,0);
local direction = (bullet.Dir or Vector(0,0,0));
local pos = bullet.Src or self:GetPos();
local rnd = {};
– Calculate the spread. Must be in a separate for loop. Doing this in the loop below seems to always result the same random numer (Don’t ask me why…)
for i=1,num do
rnd* = {math.Rand(-1,1),math.Rand(-1,1)};
end
–################# If we hit anything, run the hook
for i=1,num do
local dir = Vector(direction.x,direction.y,direction.z); – We need a “new fresh” vector
–Calculate Bullet-Spread!
if(spread1 and spread1 ~= Vector(0,0,0)) then
– Two perpendicular vectors to the direction vector (to calculate the spread-cone)
local v1 = (dir:Cross(Vector(1,1,1))):Normalize();
local v2 = (dir:Cross(v1)):Normalize();
dir = dir + v1spread1.xrnd*[1] + v2spread1.yrnd*[2];
– Instead letting the engine decide to add randomness, we are doing it (Just for the trace)
bullet.Dir = dir;
end
local trace = StarGate.Trace:New(pos,dir161024,{self,self:GetParent()});
if(hook.Call(“StarGate.Bullet”,GAMEMODE,self,bullet,trace)) then
override = true;
else
table.insert(qued,table.Copy(bullet));
end
end
–################# Fire old bullets
if(override) then
– Remaining shots - Engine has nothinh to say now!
for _,v in pairs(qued) do
StarGate.Bullets.__FireBullets(self,v);
end
else
– No override: Shoot like the engine would (keeps the shots in sync with client/serverside animations)
StarGate.Bullets.__FireBullets(self,original_bullet);
end
end
[/lua]

the stargate bullets.lua controls the impact with the shield, and other items, meaning that bullets from sweps can be deflected by the shield. this is not possible without this lua file as the source bullets don’t travel if that makes sense. I define bullets as primary ammo from the pistol/smg/rifle. they have nt physics object.