Author Topic: Ammo mod.  (Read 1153 times)

I don't know how exactly it would work without re-scripting every weapon, but I'd like to request an ammo mod that gives weapons a certain amount of shots that can be fired before disabling them. A set of events to go with it would be nice, to, such as "SetWeaponAmmo" or "AddWeaponAmmo", if that's even possible.

I'm not going to use the zombie mod's, and I don't know stuff about scripting, so I can't do a damn thing.

Thanks for considering it.
« Last Edit: August 01, 2009, 10:40:23 PM by Regulith »

here + a new zombie mod it comes with a working ammo crate that you will find under "special" in the block menu.
http://returntoblockland.com/forums/download.php?cmd=getFile&id=94

Yes, I'm quite aware of the ammo mod that comes with Rotondo's zombie mod. I'm not using that one. That's why I requested a new one that's independent of zombie mod.

Added that part to the first post.

oh ok u didnt clearify, srry

The main problem is that other mods cannot affect the ammo of 'spread-firing' generic machine guns or shotguns in any way.

The main problem is that other mods cannot affect the ammo of 'spread-firing' generic machine guns or shotguns in any way.

Is it possible to work around? I'm guessing if it is, it wouldn't be an easy thing to do.

well, the script should request all weapon images on the server, and make a variable for every weapon.
then, when a shot is fired, it should request the weapon image of the weapon, find the right variable that belongs to the weapon image, then do -1 to the variable and then check if the variable isn't 0.
If it is 0, it should delete the weapon from your hand (if you want that, otherwise it should make it not fire anymore).

Then you also need a new output event, that should be called setweaponammo/addweaponammo and it should have the output parameters of the different weapons and a box for how much ammo it should have.

Sorry I can't give you a script of the thing above (because I actually suck at scripting), but you can go to coding help and ask there.
also don't know how to do this with automatic weapons (like minigun or such).

Is it possible to work around? I'm guessing if it is, it wouldn't be an easy thing to do.
Yes. You can hard-code a hack for every single weapon in existance.

i.e. no with the number there is now

You'd also either need a second "no ammo" image for every weapon type or hacking the states of each to bits.
« Last Edit: July 30, 2009, 10:10:24 AM by Space Guy »

The reason it doesn't really affect weapons like the shotgun, and generic machine guns is because most have a spread. They don't actually fire the bullet, when you click with the gun, there is usually a function that they coded in the 'Fire' state called OnFire. The OnFire script spawns bullets around the muzzle point to add the factor of spread, they don't actually get fired out of the weapon.

There is one way you may be able to do it, but it's extremely hacky and will probably break a lot of weapons...

Go through every existing shapeBaseImageData. Replace any ones with stateScript[whatever] = "onFire" with "onAmmoFire". Then define WeaponImage::onAmmoFire() to decrement the ammo count by one and then call onFire. It should also mount a "Out of ammo" image (like the Zombies mod) if your ammo count is zero at that point. (Create one image per item, not for each other weaponimage, that way it saves datablocks for e.g. the Portal Gun)
« Last Edit: July 30, 2009, 02:43:00 PM by Space Guy »

To me this seems overly complicated and not even worth it. D:

... Exactly. And 99% probable to break at least one weapon.

So I'm guessing it's hopeless? Is a topic lock in order?

« Last Edit: July 30, 2009, 06:46:25 PM by BobSevenSevens »

No, it's possible, don't lock. Just don't use any broken weapons.

You did not read/ understand what Space was saying. You should not spread your stupidity.