actor "M4A1" : RGUWeapon
{
  obituary "%k gunned %o down with the M4A1."
  inventory.pickupmessage "M4A1"  
  //attacksound "ump45/fire6"
  weapon.selectionorder 3
  weapon.ammotype "M4A1Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M4A1Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Ready:
    M4CA A 2 //A_PlayWeaponSound("m9/select")
    M4CA BCDEFGHIJJ 2 A_WeaponReady(WRF_NOPRIMARY)
    M4CA K 0 A_JumpIfNoAmmo("Reload")
    M4CA K 0 A_JumpIfInventory("Aiming",1,5)
    M4CA K 0 A_JumpIfInventory("Reloading",1,"Reload")
    M4CA K 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    M4CA K 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CA J 1 A_WeaponReady
    goto Ready+11
    M4CC F 0 A_JumpIfInventory("Reloading",1,"Reload")    
    M4CC F 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    M4CC F 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CC F 1 A_WeaponReady(WRF_NOBOB)
    goto Ready+17
  Deselect: 
    M4CA K 0 A_TakeInventory("Aiming",1)
    M4CA K 0 ACS_ExecuteAlways(602,0,0,0,0)
    M4CA L 0 A_TakeInventory("Reloading",1)
    M4CA L 0 A_ZoomFactor(1.0)
    M4CA K 0 A_Lower
    M4CA J 1 A_Lower
    goto Deselect+2
  Select:
    M4CC A 0 A_Raise
	M4CC A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 A 0 A_GiveInventory("InCombatCrosshair",35)
    loop
  Fire:
    M4CB B 0 A_JumpIfInventory("Aiming",1,"FireAim")
    M4CB B 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    M4CB A 0 A_PlayWeaponSound("m4a1/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    M4CB A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,3)
    M4CB A 1 BRIGHT A_FireBullets (7.0, 7.0, -1, 11, "RiflePuff", 1, 6000)
    M4CB B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    M4CB A 0 A_JumpIfNoAmmo("FireEmpty")
    M4CB B 1 BRIGHT A_GunFlash
    M4CB C 1
    M4CB A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CB A 0 A_ReFire
    goto Ready+11
    M4CB A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_ReFire
    goto Ready+11
  Hold:  	
    M4CB A 0 A_JumpIfInventory("Aiming",1,"HoldAim")
    M4CB K 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Hold_SteadyAim")
    M4CB A 0 A_PlayWeaponSound("m4a1/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    M4CB A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,3)
    M4CB A 1 BRIGHT A_FireBullets (10.5, 10.5, -1, 11, "RiflePuff", 1, 6000)
    M4CB B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    M4CB A 0 A_JumpIfNoAmmo("FireEmpty")
    M4CB B 1 BRIGHT A_GunFlash
    M4CB C 1
    M4CB A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CB A 0 A_ReFire
    goto Ready+11
    M4CB A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_ReFire
    goto Ready+11
  FireEmpty:
    M4CB B 1 BRIGHT A_GunFlash
    M4CB C 1 A_GiveInventory("M4A1Bolt",1)
    M4CB A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CB A 0 A_ReFire
    goto Ready+11
    M4CB A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_ReFire
    goto Ready+11
  FireAim:
    M4CC G 0 A_PlayWeaponSound("m4a1/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    M4CC G 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,3)
    M4CC G 1 BRIGHT A_FireBullets (1.0, 1.0, -1, 11, "RiflePuff", 1, 6000)
    M4CC G 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    M4CC G 0 A_JumpIfNoAmmo("FireAimEmpty")
    M4CC H 1 BRIGHT A_GunFlash
    M4CC I 1
    M4CC A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CC A 0 A_ReFire
    goto Ready+17
    M4CC A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CC A 0 A_ReFire
    goto Ready+17
  HoldAim:
    M4CC A 0 A_PlayWeaponSound("m4a1/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    M4CC A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,3)
    M4CC G 1 BRIGHT A_FireBullets (4.0, 4.0, -1, 11, "RiflePuff", 1, 6000)
    M4CC G 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    M4CC G 0 A_JumpIfNoAmmo("FireAimEmpty")
    M4CC H 1 BRIGHT A_GunFlash
    M4CC I 1
    M4CC A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CC A 0 A_ReFire
    goto Ready+17
    M4CC A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CC A 0 A_ReFire
    goto Ready+17
  FireAimEmpty:
    M4CC H 1 BRIGHT A_GunFlash
    M4CC I 1 A_GiveInventory("M4A1Bolt",1)
    M4CC A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CC A 0 A_ReFire
    goto Ready+17
    M4CC A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CC A 0 A_ReFire
    goto Ready+17
  Reload: //AltFire:
    M4CD A 0 A_JumpIfInventory("M4A1Ammo",1,"ReloadStart")
    M4CD A 0 A_TakeInventory("Reloading",1)
    goto Ready+14
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 	
    M4CD A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    M4CD A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    M4CD A 3 A_PlaySoundEx("m4a1/clipout","SoundSlot5")
    M4CD BCDEFGH 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD IJKLMNO 3 A_WeaponReady(WRF_NOFIRE)
    M4CD P 3 A_PlaySoundEx("m4a1/clipin","SoundSlot5")
    M4CD Q 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    M4CD Z 0 A_GiveInventory("M4A1Clip",1)
    M4CD Z 0 A_TakeInventory("M4A1Ammo",1)
    M4CD Z 0 A_JumpIfInventory("M4A1Clip",30,"ReloadEnd")
    M4CD Z 0 A_JumpIfInventory("M4A1Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    M4CD R 0 A_JumpIfInventory("M4A1Bolt",1,"ReloadEndBolt") 
    M4CD RST 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD UVW 3 A_WeaponReady(WRF_NOFIRE)
    M4CD G 0 A_ReFire
    goto Ready+11 
  ReloadEndBolt:
    M4CD Z 0 A_TakeInventory("M4A1Bolt",1)
    M4CD XYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE A 3 A_PlaySoundEx("m4a1/bolt","SoundSlot5")
    M4CE BCD 3 A_WeaponReady(WRF_NOFIRE)
    M4CE EFG 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE V 0 A_ReFire
    goto Ready+11 
  AltFire:
    M4CC A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    M4CC A 0 A_ZoomFactor(1.2)
    M4CC ABCDEF 1
    M4CC G 0 A_GiveInventory("Aiming",1)
    M4CC G 0 ACS_ExecuteAlways(602,0,0,0,0)
    M4CC G 0 A_Refire
    goto Ready+17
  AltFire2:
    M4CC A 0 A_ZoomFactor(1.0)
    M4CC FEDCBA 1
    M4CC A 0 A_TakeInventory("Aiming",1)
    M4CC A 0 ACS_ExecuteAlways(602,0,0,0,0)
    M4CC G 0 A_Refire
    goto Ready+11
  AltHold:
    M4CA J 1 A_JumpIfInventory("Aiming",1,"AltHoldAim")
    M4CA J 1 A_ReFire
    goto Ready+11
  AltHoldAim:
    M4CC F 1
    M4CC F 1 A_ReFire
    goto Ready+17
  ReloadStartAim:
    M4CC A 0 A_ZoomFactor(1.0)
    M4CC FEDCBA 1
    M4CC A 0 A_TakeInventory("Aiming",1)
    M4CC A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  Spawn:
    WEAP T 15
    WEAP T 0 A_SpawnItemEx("M4A1Pickup")
    stop
  ReloadStart_SOH:
    M4CD A 2 A_PlaySoundEx("m4a1/clipout","SoundSlot5")
    M4CD BCDEFGH 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD IJKLMNO 2 A_WeaponReady(WRF_NOFIRE)
    M4CD P 2 A_PlaySoundEx("m4a1/clipin","SoundSlot5")
    M4CD Q 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    M4CD Z 0 A_GiveInventory("M4A1Clip",1)
    M4CD Z 0 A_TakeInventory("M4A1Ammo",1)
    M4CD Z 0 A_JumpIfInventory("M4A1Clip",30,"ReloadEnd_SOH")
    M4CD Z 0 A_JumpIfInventory("M4A1Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    M4CD R 0 A_JumpIfInventory("M4A1Bolt",1,"ReloadEndBolt_SOH") 
    M4CD RST 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD UVW 2 A_WeaponReady(WRF_NOFIRE)
    M4CD G 0 A_ReFire
    goto Ready+11 
  ReloadEndBolt_SOH:
    M4CD Z 0 A_TakeInventory("M4A1Bolt",1)
    M4CD XYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE A 2 A_PlaySoundEx("m4a1/bolt","SoundSlot5")
    M4CE BCD 2 A_WeaponReady(WRF_NOFIRE)
    M4CE EFG 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE V 0 A_ReFire
    goto Ready+11 
  Fire_SteadyAim:
    M4CB A 0 A_PlayWeaponSound("m4a1/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    M4CB A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,3)
    M4CB A 1 BRIGHT A_FireBullets (4.62, 4.62, -1, 11, "RiflePuff", 1, 6000)
    M4CB B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    M4CB A 0 A_JumpIfNoAmmo("FireEmpty")
    M4CB B 1 BRIGHT A_GunFlash
    M4CB C 1
    M4CB A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CB A 0 A_ReFire
    goto Ready+11
    M4CB A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_ReFire
    goto Ready+11
  Hold_SteadyAim:
    M4CB A 0 A_PlayWeaponSound("m4a1/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    M4CB A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,3)
    M4CB A 1 BRIGHT A_FireBullets (6.93, 6.93, -1, 11, "RiflePuff", 1, 6000)
    M4CB B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    M4CB A 0 A_JumpIfNoAmmo("FireEmpty")
    M4CB B 1 BRIGHT A_GunFlash
    M4CB C 1
    M4CB A 0 A_JumpIfInventory("M4A1Ammo",1,2)
    M4CB A 0 A_ReFire
    goto Ready+11
    M4CB A 0 A_JumpIfNoAmmo("ReloadStart")
    M4CB A 0 A_ReFire
    goto Ready+11
  FragGrenade:
    U45F A 0 A_ZoomFactor(1.0)
    U45A L 0 A_TakeInventory("Aiming",1)
    U45A L 0 A_TakeInventory("Reloading",1)
    U45F A 0 ACS_ExecuteAlways(602,0,0,0,0)
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"FragGrenade_SOH")
    GRNA A 2 A_PlaySound("grenade/pinpull")
    GRNA BCDEFGH 2
    TNT1 A 15 
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 2
    GRNA L 0 A_TakeInventory("FragGrenadeAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("FragGrenade",0,0,0,16)
    GRNA MN 2 
    goto Ready+1
  FragGrenade_SOH:
    GRNA A 1 A_PlaySound("grenade/pinpull")
    GRNA BCDEFGH 1
    TNT1 A 10
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 1
    GRNA L 0 A_TakeInventory("FragGrenadeAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("FragGrenade",0,0,0,16)
    GRNA MN 1 
    goto Ready+1
  KnifeAttack:
    U45F A 0 A_ZoomFactor(1.0)
    U45A L 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    U45A L 0 A_TakeInventory("Aiming",1)
    U45A L 0 A_TakeInventory("Reloading",1)
    U45F A 0 ACS_ExecuteAlways(602,0,0,0,0)
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"KnifeAttack_SOH")
    U45C A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_Commando")
    KNFA A 0 ACS_ExecuteAlways(599,0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA CDE 1 A_CustomPunch(34,1,0,"KnifePuff",96)
    KNFA FGHIJKL 1 
    TNT1 A 20
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready+1
  KnifeAttack_Commando:
    KNFA A 0 ACS_ExecuteAlways(599,0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA CDE 1 A_CustomPunch(34,1,0,"KnifePuff",160)
    KNFA FGHIJKL 1 
    TNT1 A 20
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready+1
  KnifeAttack_SOH:
    U45C A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_SOH_Commando")
    KNFA A 0 ACS_ExecuteAlways(599,0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA CDE 1 A_CustomPunch(34,1,0,"KnifePuff",96)
    KNFA FGHIJKL 1 
    TNT1 A 10
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready+1
  KnifeAttack_SOH_Commando:
    KNFA A 0 ACS_ExecuteAlways(599,0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA CDE 1 A_CustomPunch(34,1,0,"KnifePuff",160)
    KNFA FGHIJKL 1 
    TNT1 A 10
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready+1
  }
}

actor M4A1Clip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 30
    ammo.backpackamount 0
    ammo.backpackmaxamount 30
    +IGNORESKILL
}

actor M4A1Bolt : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}

actor "M4A1 Ex Mags" : "M4A1"
{
  obituary "%k gunned %o down with the M4A1."
  inventory.pickupmessage "M4A1"  
  //attacksound "ump45/fire6"
  weapon.selectionorder 3
  weapon.ammotype "M4A1Clip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M4A1Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Reload: //AltFire:
    M4CD A 0 A_JumpIfInventory("M4A1Ammo",1,"ReloadStart")
    M4CD A 0 A_TakeInventory("Reloading",1)
    goto Ready+14
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    M4CD A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    M4CD A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    M4CD A 3 A_PlaySoundEx("m4a1/clipout","SoundSlot5")
    M4CD BCDEFGH 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD IJKLMNO 3 A_WeaponReady(WRF_NOFIRE)
    M4CD P 3 A_PlaySoundEx("m4a1/clipin","SoundSlot5")
    M4CD Q 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    M4CD Z 0 A_GiveInventory("M4A1Clip2",1)
    M4CD Z 0 A_TakeInventory("M4A1Ammo",1)
    M4CD Z 0 A_JumpIfInventory("M4A1Clip2",45,"ReloadEnd")
    M4CD Z 0 A_JumpIfInventory("M4A1Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    M4CD R 0 A_JumpIfInventory("M4A1Bolt",1,"ReloadEndBolt") 
    M4CD RST 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD UVW 3 A_WeaponReady(WRF_NOFIRE)
    M4CD G 0 A_ReFire
    goto Ready+11 
  ReloadEndBolt:
    M4CD Z 0 A_TakeInventory("M4A1Bolt",1)
    M4CD XYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE A 3 A_PlaySoundEx("m4a1/bolt","SoundSlot5")
    M4CE BCD 3 A_WeaponReady(WRF_NOFIRE)
    M4CE EFG 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE V 0 A_ReFire
    goto Ready+11 
  ReloadStartAim:
    M4CC A 0 A_ZoomFactor(1.0)
    M4CC FEDCBA 1
    M4CC A 0 A_TakeInventory("Aiming",1)
    M4CC A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  ReloadStart_SOH:
    M4CD A 2 A_PlaySoundEx("m4a1/clipout","SoundSlot5")
    M4CD BCDEFGH 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD IJKLMNO 2 A_WeaponReady(WRF_NOFIRE)
    M4CD P 2 A_PlaySoundEx("m4a1/clipin","SoundSlot5")
    M4CD Q 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    M4CD Z 0 A_GiveInventory("M4A1Clip2",1)
    M4CD Z 0 A_TakeInventory("M4A1Ammo",1)
    M4CD Z 0 A_JumpIfInventory("M4A1Clip2",45,"ReloadEnd_SOH")
    M4CD Z 0 A_JumpIfInventory("M4A1Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    M4CD R 0 A_JumpIfInventory("M4A1Bolt",1,"ReloadEndBolt_SOH") 
    M4CD RST 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CD UVW 2 A_WeaponReady(WRF_NOFIRE)
    M4CD G 0 A_ReFire
    goto Ready+11 
  ReloadEndBolt_SOH:
    M4CD Z 0 A_TakeInventory("M4A1Bolt",1)
    M4CD XYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE A 2 A_PlaySoundEx("m4a1/bolt","SoundSlot5")
    M4CE BCD 2 A_WeaponReady(WRF_NOFIRE)
    M4CE EFG 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    M4CE V 0 A_ReFire
    goto Ready+11 
  }
}

actor M4A1Clip2 : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 45
    ammo.backpackamount 0
    ammo.backpackmaxamount 45
    +IGNORESKILL
}

actor M4A1ExMags : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}

actor M4A1Pickup : CustomInventory
{
  inventory.pickupmessage "M4A1"  
  inventory.pickupsound "misc/w_pkup"
  +INVENTORY.AUTOACTIVATE
  inventory.respawntics 35
  scale 0.15
  States
  {
  Spawn:
    WEAP T -1
    stop
  Pickup:
    JDGP A 0
    JDGP A 0 A_JumpIfInventory("M4A1",1,"FailPickup") // If the player already has this weapon, they get more ammo for it
    JDGP A 0 A_JumpIfInventory("M4A1 Ex Mags",1,"FailPickup")
    JDGP A 0 A_JumpIfInventory("MaxWeaponsFilled",0,"FailPickup2")
    BKPK A 0 ACS_ExecuteWithResult(618,18,0,0)
    stop
  AmmoPickup:
    JDGP A 0
    JDGP A 0 A_JumpIfInventory("M4A1Ammo",0,"FailPickup")
    JDGP A 0 A_GiveInventory("M4A1Ammo",30)
    stop
  FailPickup:
    WEAP T 1
    fail
  FailPickup2:
    WEAP T 1 
    BKPK A 0 ACS_ExecuteAlways(620,0,0,0,0)
    fail
  }
}

