Blockland Forums > Suggestions & Requests
Ammo mod.
Regulith:
--- Quote from: Space Guy on July 30, 2009, 02:07:14 AM ---The main problem is that other mods cannot affect the ammo of 'spread-firing' generic machine guns or shotguns in any way.
--- End quote ---
Is it possible to work around? I'm guessing if it is, it wouldn't be an easy thing to do.
chilmans:
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).
Space Guy:
--- Quote from: Regulith on July 30, 2009, 03:13:32 AM ---Is it possible to work around? I'm guessing if it is, it wouldn't be an easy thing to do.
--- End quote ---
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.
AGlass0fMilk:
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.
Space Guy:
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)