Author Topic: Making guns unable to fire?  (Read 736 times)

I have a gamemode where I want bots to be able to carry around guns that DO work, and players to have fake ones so they can blend in with the bots without being able to fight. How would I go about making a gun utterly useless? Assuming it has no secondary fire or anything, just fires when you press the activate key.

EDIT: It'd be a better idea to just make the bullets do no damage so the illusion of the gun being dangerous is better, I bet I can figure that out myself.
EDIT EDIT: Nope, I'm clueless. This seems needlessly complex. How would I go about making a second version of the gun that does no damage? What parts of server.cs do I need to remove or change to not make it overwrite the default gun?
« Last Edit: May 09, 2016, 02:47:52 PM by SuperSuit12 »

Prevent guns from shooting
function yourGunDatablockHere::onFire(%image, %obj, %slot){}

No need to package it

Ammo doing no damage, look for directDamage and set it to 0

Prevent guns from shooting
function yourGunDatablockHere::onFire(%image, %obj, %slot){}

No need to package it

Ammo doing no damage, look for directDamage and set it to 0
Err... What all do I need to remove from a file to not overwrite stuff? If I change all the datablock names (bullet and weapon?) will it not overwrite anything? I'm making a copy of the default gun that isn't supposed to replace it. I'm going to test just changing the names and stuff.

It should be fine then as long as the name is different like FakeGunImage

Prevent guns from shooting
function yourGunDatablockHere::onFire(%image, %obj, %slot){}

No need to package it

Ammo doing no damage, look for directDamage and set it to 0
that will not prevent the gun from firing that will prevent the gun from shooting projectiles but it will still play the firing animation and sounds
you need to do state ammo checks


that will not prevent the gun from firing that will prevent the gun from shooting projectiles but it will still play the firing animation and sounds
you need to do state ammo checks


It'd still work for my purposes, if it could affect only certain guns of the same datablock. But it can't. I've got it figured out... I think...

Can I use assets from another addon? I'd rather not package it with duplicate assets. (Weapon_Gun requirement but everyone has it.) Instead of ./filename do I just put /Weapon_Gun/filename? How would I put the file path? I've forgotten how to do file paths like that... Is it ../Weapon_Gun/filename? .. is up a folder, right?

Also, particles and such are included. Can I just delete those? Will it know how to use them from the other files? If not, how do I reference them?

EDIT: It seems to be working with all the un-modified stuff referenced in the other addon folder (I used a different filepath from elsewhere in the file, for some damage image or something), but it still does damage. Apparently I missed a gun->fakeGun modification. Or something else stupid.

EDIT EDIT: Yep, it was just that I was still using the original projectile.
« Last Edit: May 09, 2016, 03:52:21 PM by SuperSuit12 »

Solved! Basically just edited some file paths, cut out duplicate files and chunks of code, and did a bunch of find and replace gun->fakeGun and such. It still has knockback, but that's awesome. I'm currently being shot across the world by crazed bots with knockback guns. I might actually publish it if I can get around to making a knockback-less version too. (I'd put them both in, one as "Knockback Gun" and the other as "Useless Gun")

I don't want to ruin your fun but someone made a bunch of gun edits: https://forum.blockland.us/index.php?topic=294580.0
You can still edit and release it if you want, it's good practice

You should post your code so we know that you did everything right and can give you pointers.

I don't see Knockback Gun or Useless gun in the edits. Plus, they need to be the same color for Hunter/Hunted (or Guess Who if you prefer the GMod name for it) or else it's "LOOK! 'E HAS A RED GUN! KILL'IM DEAD!" I'm not that interested in learning how to make guns for Blockland, this was just me making something I needed for my server, but I'll be happy to release the code once I've gotten the no-knockback one done.

EDIT: Oh, there is a Harmless Gun. But it's green so it doesn't work for my purposes.
« Last Edit: May 10, 2016, 02:08:33 PM by SuperSuit12 »