You must have the Support_AmmoGuns.cs inside the .zip with the weapon.
First, you have to add 2 lines to the item datablock.
maxAmmo = 60;
canReload = 1;
maxAmmo: Sets the maximum amount of ammo for the gun.
canReload: Can you reload? 1:Yes, 0:No.
Next you need to change up the weapon's states. (note this is for automatic weapons)
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.3;
stateWaitForTimeout[0] = true;
stateTransitionOnTimeout[0] = "LoadCheckA";
stateSound[0] = weaponSwitchSound;
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Fire";
stateAllowImageChange[1] = true;
stateTimeoutValue[1] = 0.01;
stateTransitionOnNoAmmo[1] = "Reload";
stateName[2] = "Fire";
stateTransitionOnTimeout[2] = "FireLoadCheckA";
stateTimeoutValue[2] = 0.06;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateSequence[2] = "Fire"; //Fire animation
stateScript[2] = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = (Flash Emitter);
stateEmitterTime[2] = 0.06;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = (Fire Sound);
stateEjectShell[2] = true;
stateName[3] = "LoadCheckA";
stateScript[3] = "onLoadCheck";
stateTimeoutValue[3] = 0.01;
stateTransitionOnTimeout[3] = "LoadCheckB";
stateName[4] = "LoadCheckB";
stateTransitionOnAmmo[4] = "Ready";
stateTransitionOnNoAmmo[4] = "Reload";
stateName[5] = "Reload";
stateTimeoutValue[5] = 1.4;
stateSequence[5] = "beltReplace"; //Reload animation
stateScript[5] = "onReloaded";
stateTransitionOnTimeout[5] = "Wait";
stateWaitForTimeout[5] = true;
stateSound[5] = (reload sound);
//this is kinda useless but should still be in here
stateName[6] = "Wait";
stateTimeoutValue[6] = 0.0;
stateTransitionOnTimeout[6] = "Ready";
stateName[7] = "FireLoadCheckA";
stateScript[7] = "onLoadCheck";
stateTimeoutValue[7] = 0.03;
stateTransitionOnTimeout[7] = "FireLoadCheckB";
stateName[8] = "FireLoadCheckB";
stateTransitionOnAmmo[8] = "Smoke";
stateTransitionOnNoAmmo[8] = "ReloadSmoke";
stateName[9] = "Smoke";
stateEmitter[9] = (Smoke Emitter);
stateEmitterTime[9] = 0.3;
stateEmitterNode[9] = "muzzleNode";
stateTimeoutValue[9] = 0.2;
stateTransitionOnTimeout[9] = "Ready";
stateTransitionOnTriggerDown[9] = "Fire";
stateName[10] = "ReloadSmoke";
stateEmitter[10] = (Smoke Emitter);
stateEmitterTime[10] = 0.3;
stateEmitterNode[10] = "muzzleNode";
stateTimeoutValue[10] = 0.2;
stateTransitionOnTimeout[10] = "Reload";
This should work, I haven't tested it tho. You will need to fill in for the emitters and sounds. don't include the "(" or ")".
Now you need to make some code that subtracts from your ammo.
function (Weapon)Image::onFire(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool]--;
}
Next you need to make a piece of code that sets the amount of ammo after reloading.
function (Weapon)Image::onReloaded(%this,%obj,%slot)
{
%obj.toolAmmo[%obj.currTool] = %this.item.maxAmmo;
%obj.setImageAmmo(%slot,1);
}
Your weapon should now have reloading. If you have any questions feel free to ask.