To be specific. If your clips are at zero when the reloading sequence begins, nothing happens. But if they're even one above, it gives you 30 ammo.
I want it to give you only as much ammo as you have clips.
Code: Select all
ACTOR AssaultRifle1 : Weapon 2061
{
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "You got the Assault Rifle!"
  Obituary "%o was turned to swiss cheese by %k."
  AttackSound "weapons/carbine"
  Weapon.AmmoType "AsltClip"
  Weapon.AmmoType2 "GrenadePickup"
  Weapon.AmmoGive 30
  Weapon.AmmoGive2 4
  Weapon.AmmoUse 1
  Weapon.AmmoUse2 1
  +Ammo_optional
  States
   {
  Spawn:
   M16P A -1
   Loop
  Deselect:
   M16A A 1 A_Lower
   Loop
  Select:
   M16A AAAAAAAAAAAAAAA 1 A_Raise
   M16A A 0 A_playweaponsound("weapons/reload")   
   M16A OPQR 6
   Loop
  Ready:
   M16A A 1 A_WeaponReady
   Loop
  Fire:
   M16A A 0 A_JumpIfNoammo(5)
   M16A B 2 BRIGHT A_FireBullets(6,2,1,4,0,1)
   M16A C 2 BRIGHT
   M16A A 2 A_refire
   M16A D 6   
   Goto Ready
   M16A A 0 A_JumpifInventory("Clip",1,1)               //This seems to be where the problem starts
   Goto Ready
   M16A A 0 A_Takeinventory("Clip",1)                    //Unfortunately, it doesn't seem to be checking if there's ammo properly
   M16A A 0 A_Giveinventory("AsltClip",1)               //So it ends up taking 0 clip ammo and giving 30 assault clips
   M16A A 0 A_JumpifInventory("AsltClip",30,1)
   Goto Fire+6                                                      //I think this may be the source of the problem
   M16A DIKLMGHID 4
   Goto Ready
  Altfire:
   M16A A 8 A_GunFlash
   M16A D 5
   M16A A 3
   M16A E 3
   M16A F 6
   M16A E 6
   Goto Ready
  Flash:
   M203 A 3 BRIGHT
   M203 B 5 BRIGHT A_FireCustomMissile("GrenadeThrow",0,1,6,1)
   M203 C 5 BRIGHT
   Stop
   }
}