Trying to create a shotgun that fires exploding rounds

This is the first LUA weapon I’m making from scratch, so I’m obviously pretty new to scripting. I wanted to make something that fires like a normal shotgun, but the ammo explode if it touches anything. I was wondering if I would have to make the exploding rounds a separate entity, or if there was a way to do it in the weapon’s script.

SWEP.OnPrimaryFire -> ents.Create(‘exploding_round’) -> ent:GetPhysicsObject():ApplyForceCenter -> ent.StartTouch -> util.Effect -> util.BlastDamage -> ??? -> Profit

Well the simplest way to do it would probably be to use traces and create a very small (low in special effects) env_explosion wherever the trace hits. That would effectively make explosive rounds.

Or maybe simpler, placing the explosion script in a bullet’s callback. That way you still have all the hardcoded tracer and spread stuff.

I was thinking of the bullet callback as well.

But I can’t tell if he’s talking about a real-life type of exploding round or a silly weapon that shoots explosions.

I suggest creating your own “explosion entity”. Look at:

That all you should need, it’s better to be given the tools. Then someone doing it for you. :wink: