GMod 13 Projectile Weapons

[sp]I really hate how these updates don’t have backwards compatibility![/sp]

Do you know anything about MODERN “ProjectileSweps”?
Things have gotten to a point where in order to do what I want to do I need a projectile SWep, which is to say:

A Lua Scripted Weapon that shoots Lua Scripted Entities out, such as Grenades.

I mean, I would try to script it myself, but I don’t know how I would keep them synchronized Client to Server… I have but one idea, using networked variables for position… to keep the client updated since doing it the other way would allow easy hacks… perhaps you can help?

[editline]18th September 2013[/editline]

I’m saying this with the idea of pre-calculated projectile paths, or the kind of thing you would need to make a lag-free PHYSICALLY ACCURATE reproduction Halo Plasma Rifle, COD Ballist. Knife, etc…

[editline]18th September 2013[/editline]

Something like the baby shooting gun wouldn’t work, that just throws a prop_physics out…

APPEND

When I get the gamemode to a point where all of the basic functions are complete I’ll likely make a thread specifically for the gamemode.

I’m working on this right now, and the sync issues are pretty aweful.
To add to faitly intensive scripting, it be leaps in the wrong direction to start using NetVars.
I’ve tried.

I started picking through GDCW. It’s got some big flaws, but it’s essetially all there.
While it uses the scripts shooting scripts method, it’s written so you could pretty easily integrate it all into single files per weapon, though not sure why you would.

Alright then… succeed and when I, or whatever team I may put together, finish this project you will get credit.

In your weapon’s shared.lua, create the entity and set its velocity (for both client and server) to something. That’s it.

As for the hit detection, either use traces or HullTraces.

unfortunately there is no way to do a mathematically accurate-to-the-line CURVED trace, is there?
by this I mean the line doesn’t just rotate periodically, but rather it’s a true curve, never straight always round…

Now what if the maximum velocity possible in Garry’s Mod, even without restrictions, isn’t fast enough for me? (I think noclip will allow even faster speeds, and with trace hit detection that would work, but it would also make it hard to place the decals)

uhm… as far as I know, in order to break the speed limit I have to get rid of the physics box, but does phys update still get called if I do? If not, what function can I use besides think?

[editline]20th September 2013[/editline]

Shit, sorry for the triple post!!!

Uhm, is there a way to do it without a physics box? Also, can the objects go faster outside of vphysics?
I’m using the physics update function as of right now…
I do need it to still be synch’d with client to server.

I need a velocity length of 16 thou for a pistol bullet, but I can only get 10 thou

Just remember, if I get this fixed, you’ll have to credit Generic Default as well, since I’m editing his code.

Alright, so the biggest problems I’ve found are both deal with the bullet entities themselves.

First, they don’t react with breakable entities. Sometimes a create or pallet might break, but glass never does, regardless of what brush is used. (I’m tweaking the MASK and physics currently to experiment.)

Second, in single player, everything shoots fine, but on servers, the bullets spawn about 50 meters in front of you. I have a feeling this is due to the bullet entities velocity being too fast for MP tick rate, so I’m fiddling around for a good number combination to get it to work better.
This is some code for 5.56x45 ball ammo(keep in mind, this is snipped, only showing velocity and flight):
[lua]
function ENT.Initialize()
self.Flightvector = self.Entity:GetUp()((85052.5)/66) // Velocity in m/s, FIRST NUMMER is SPEED (FrameTime)
end

function ENT:Think()
self.Flightvector = self.Flightvector - self.Flightvector/self.BallisticDrag + (VectorRand():GetNormalized()*self.Drift) + Vector(0,0,-0.111)
self.Entity:SetAngles(self.Flightvector:Angle() + Angle(90,0,0))
self.Entity:NextThink( CurTime() )
end
[/lua]

So this is what I’m working with. Like I said the base is really great, just needs to be tweaked.

I already see one problem… telling it to think on CurTime() won’t be consistent, as if the frame rate changes the bullets will act differently. This can cause dis-synchronization between client and server, as well.

In theory, that can be fixed by using differences in CurTime() as a multiplier to any changes.
I personally don’t like using the think function to do anything… except on very rare occasions when there is no other function that will do what you need.

[editline]21st September 2013[/editline]

for instance, I’m using ENT:PhysicsUpdate() for the bullet I made. That seems to be called fairly regularly. I’m doing traces for hit detection, measuring about the same distance as the entity will travel each time this function gets called.

My bullets ARE SLOWER than a real bullet (Aprox. 60% Speed), but they seem to work!

[editline]21st September 2013[/editline]

Now you are trying to simulate real-speed bullets, and I love that! I don’t think you can do that if you have a physics box, though, but I’m sure there is a way!

Try making it think based on specific time intervals?

Using the bullet’s creation time, make it think on EXACT multiples of 0.1 seconds, or something…

I MAY have to remove gravity, though, since I can’t get it to scale! I do self:SetGravity( 0.001 ) and it still falls at the same rate