actor "M9" : RGUWeapon
{
  obituary "%k capped %o with the M9."
  inventory.pickupmessage "M9"  
  //attacksound "u45/fire6"
  weapon.selectionorder 19
  weapon.ammotype "M9Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M9Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    BM9A A 2 //A_PlayWeaponSound("m9/select")
    BM9A BCDEFFF 2 A_WeaponReady(WRF_NOPRIMARY)
    BM9A F 0 A_JumpIfNoAmmo("Reload")
    BM9A F 0 A_JumpIfInventory("Aiming",1,5)
    BM9A F 0 A_JumpIfInventory("Reloading",1,"Reload")
    BM9A F 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9A F 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9A F 1 A_WeaponReady
    goto Ready+8
    BM9C E 0 A_JumpIfInventory("Reloading",1,"Reload")    
    BM9C E 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9C E 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9C E 1 A_WeaponReady(WRF_NOBOB)
    goto Ready+14
  Deselect:
    BM9A H 0 A_TakeInventory("Aiming",1)
    BM9A H 0 ACS_ExecuteAlways(602,0,0,0,0)
    BM9A H 0 A_TakeInventory("Reloading",1)
    BM9A H 0 A_ZoomFactor(1.0)
    BM9A H 0 A_Lower
    BM9A F 1 A_Lower
    goto Deselect+2
  Select:
    BM9A A 0 A_Raise
	BM9A A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 F 0 A_GiveInventory("InCombatCrosshair", 35)
    loop
  Fire:	
    BM9A A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    BM9A F 1 A_JumpIfNoAmmo("ReloadStart")
    BM9B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    BM9B A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,3)
    BM9B A 1 BRIGHT A_FireBullets (10.0, 10.0, -1, 8, "HHBulletPuff", 1, 4000)
    BM9B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9B A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9B B 1 BRIGHT A_GunFlash
    BM9B CDEFG 1 A_WeaponReady
    BM9B A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9B A 0 A_ReFire
    goto Ready+8
    BM9B A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9B A 0 A_ReFire
    goto Ready+8
  FireEmpty:
    BM9B B 1 BRIGHT A_GunFlash
    BM9B C 1 BRIGHT A_PlaySound("m9/lock")
    BM9B DEFG 1
    BM9B G 1 A_GiveInventory("M9Bolt",1)
    BM9B A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9B A 0 A_ReFire
    goto Ready+8
    BM9B A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9B A 0 A_ReFire
    goto Ready+8
  Hold:
    BM9A F 3 A_JumpIfInventory("Aiming",1,"HoldAim")
    BM9A F 1 A_ReFire
    goto Ready+8
  HoldAim:
    BM9C E 3
    BM9C E 1 A_ReFire
    goto Ready+14
  FireAim:
    BM9C E 1 A_JumpIfNoAmmo("ReloadStart")
    BM9D A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9D A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,8)
    BM9D A 1 BRIGHT A_FireBullets (2, 2, -1, 8, "HHBulletPuff", 1, 4000)
    BM9D B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9D A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9D B 1 BRIGHT A_GunFlash
    BM9D CDEFGHI 1 A_WeaponReady
    BM9D A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9D A 0 A_ReFire
    goto Ready+8
    BM9D A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9D A 0 A_ReFire
    goto Ready+8
  FireAimEmpty:
    BM9D B 1 BRIGHT A_GunFlash
    BM9D C 1 BRIGHT A_PlaySound("m9/lock")
    BM9D DE 1
    BM9D FGH 1
    BM9D I 1 A_GiveInventory("M9Bolt",1)
    BM9D A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9D A 0 A_ReFire
    goto Ready+8
    BM9D A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9D A 0 A_ReFire
    goto Ready+8
  Reload: //AltFire:
    VECC A 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    VECC A 0 A_TakeInventory("Reloading",1)
    goto Ready+11
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    BM9E A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    BM9E A 0 A_JumpIfInventory("M9Bolt",1,"ReloadStartBolt") 
    BM9E A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    BM9E ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9E GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9E O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    BM9E Z 0 A_GiveInventory("M9Clip",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    BM9E Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd")
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    BM9E PQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E G 0 A_ReFire
    goto Ready+8  
  ReloadStartBolt:
    BM9F A 0 A_TakeInventory("M9Bolt",1) 
    BM9F A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
    BM9F ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9F GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9F O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9F Z 0 A_GiveInventory("M9Clip",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    BM9F Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt")
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt")
    goto ReloadEndBolt
  ReloadEndBolt:
    BM9F PQR 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F S 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F TUV 3 A_WeaponReady(WRF_NOFIRE)
    BM9F G 0 A_ReFire
    goto Ready+8  
  AltFire:
    BM9C A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    BM9C A 0 A_ZoomFactor(1.2)
    BM9C ABCDE 1
    BM9C G 0 A_GiveInventory("Aiming",1)
    BM9C G 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto Ready+14
  AltFire2:
    BM9C E 1 A_ZoomFactor(1.0)
    BM9C EDCBA 1
    BM9C A 0 A_TakeInventory("Aiming",1)
    BM9C A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto Ready+8
  ReloadStartAim:
    BM9C E 1 A_ZoomFactor(1.0)
    BM9C EDCBA 1
    BM9C A 0 A_TakeInventory("Aiming",1)
    BM9C 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:
    WEP2 E 15 
    WEP2 E 0 A_SpawnItem("M9Pickup")
    stop
  ReloadStart_SOH:
    BM9E ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9E GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9E O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9E Z 0 A_GiveInventory("M9Clip",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    BM9E Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd_SOH")
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    BM9E PQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E G 0 A_ReFire
    goto Ready+8  
  ReloadStartBolt_SOH:
    BM9F ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9F GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9F O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9F Z 0 A_GiveInventory("M9Clip",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    BM9F Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt_SOH")
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt_SOH")
    goto ReloadEndBolt_SOH
  ReloadEndBolt_SOH:
    BM9F PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F TUV 2 A_WeaponReady(WRF_NOFIRE)
    BM9F G 0 A_ReFire
    goto Ready+8  
  Fire_SteadyAim:
    BM9B A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,3)
    BM9B A 1 BRIGHT A_FireBullets (6.6, 6.6, -1, 8, "HHBulletPuff", 1, 4000)
    BM9B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9B A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9B B 1 BRIGHT A_GunFlash
    BM9B CDEFG 1 A_WeaponReady
    BM9B A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9B A 0 A_ReFire
    goto Ready+8
    BM9B A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9B A 0 A_ReFire
    goto Ready+8
  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 M9Bolt : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor M9Clip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 15
    ammo.backpackamount 0
    ammo.backpackmaxamount 15
    +IGNORESKILL
}
actor "M9 Ex Mags" : "M9"
{
  obituary "%k capped %o with the M9."
  inventory.pickupmessage "M9"  
  //attacksound "u45/fire6"
  weapon.selectionorder 19
  weapon.ammotype "M9Clip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M9Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Reload: //AltFire:
    VECC A 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    VECC A 0 A_TakeInventory("Reloading",1)
    goto Ready+11
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    BM9E A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    BM9E A 0 A_JumpIfInventory("M9Bolt",1,"ReloadStartBolt") 
    BM9E A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    BM9E ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9E GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9E O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    BM9E Z 0 A_GiveInventory("M9Clip2",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    BM9E Z 0 A_JumpIfInventory("M9Clip2",25,"ReloadEnd")
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    BM9E PQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E G 0 A_ReFire
    goto Ready+8  
  ReloadStartBolt:
    BM9F A 0 A_TakeInventory("M9Bolt",1) 
    BM9F A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
    BM9F ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9F GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9F O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9F Z 0 A_GiveInventory("M9Clip2",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    BM9F Z 0 A_JumpIfInventory("M9Clip2",25,"ReloadEndBolt")
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt")
    goto ReloadEndBolt
  ReloadEndBolt:
    BM9F PQR 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F S 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F TUV 3 A_WeaponReady(WRF_NOFIRE)
    BM9F G 0 A_ReFire
    goto Ready+8  
  ReloadStartAim:
    BM9C E 1 A_ZoomFactor(1.0)
    BM9C EDCBA 1
    BM9C A 0 A_TakeInventory("Aiming",1)
    BM9C A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  ReloadStart_SOH:
    BM9E ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9E GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9E O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9E Z 0 A_GiveInventory("M9Clip2",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    BM9E Z 0 A_JumpIfInventory("M9Clip2",25,"ReloadEnd_SOH")
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    BM9E PQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E G 0 A_ReFire
    goto Ready+8  
  ReloadStartBolt_SOH:
    BM9F ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9F GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9F O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9F Z 0 A_GiveInventory("M9Clip2",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    BM9F Z 0 A_JumpIfInventory("M9Clip2",25,"ReloadEndBolt_SOH")
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt_SOH")
    goto ReloadEndBolt_SOH
  ReloadEndBolt_SOH:
    BM9F PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F TUV 2 A_WeaponReady(WRF_NOFIRE)
    BM9F G 0 A_ReFire
    goto Ready+8  
  }
}

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


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

actor "M9 Akimbo" : "M9"
{
  weapon.ammotype "M9Clip3"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M9Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    TNT1 AAA 2 //A_PlayWeaponSound("m9/select")
    BM9G ABCDEFGHI 1 A_WeaponReady(WRF_NOFIRE)
    BM9G I 0 A_JumpIfNoAmmo("Reload")
    BM9G I 0 A_JumpIfInventory("Reloading",1,"Reload")
    BM9G I 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9G I 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9G I 1 A_WeaponReady
    goto Ready+12
  Deselect:
    BM9G L 0 A_TakeInventory("Aiming",1)
    BM9G A 0 ACS_ExecuteAlways(602,0,0,0,0)
    BM9G L 0 A_TakeInventory("Reloading",1)
    BM9G L 0 A_ZoomFactor(1.0)
    BM9G L 0 A_Lower
    BM9G I 1 A_Lower
    goto Deselect+2
  Select:
    BM9G A 0 A_Raise
	BM9G A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 F 0 A_GiveInventory("InCombatCrosshair", 35)
    loop
  Fire: //Right	
    BM9G I 1 A_JumpIfNoAmmo("ReloadStart")
    BM9I A 0 A_JumpIfInventory("FireSwitch",1,"FireLeft")
    BM9I A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    BM9I A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9I A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,20,0)
    BM9I A 1 BRIGHT A_FireBullets (10.0, 10.0, -1, 8, "HHBulletPuff", 1, 4000)
    BM9I B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9I A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9I B 1 BRIGHT A_GunFlash
    BM9I B 0 A_GiveInventory("FireSwitch",1)
    BM9I CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9G A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9G A 0 A_ReFire
    goto Ready+12
    BM9G A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9G A 0 A_ReFire
    goto Ready+12
  FireLeft:
    BM9H A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"FireLeft_SteadyAim")
    BM9H A 0 A_PlaySoundEx("m93r/fire","SoundSlot6")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9H A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,-26,0)
    BM9H A 1 BRIGHT A_FireBullets (10.0, 10.0, -1, 8, "HHBulletPuff", 1, 4000)
    BM9H B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9H A 0 A_JumpIfNoAmmo("FireEmptyLeft")
    BM9H B 1 BRIGHT A_GunFlash
    BM9H B 0 A_TakeInventory("FireSwitch",1)
    BM9H CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9H A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9H A 0 A_ReFire
    goto Ready+12
    BM9H A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9H A 0 A_ReFire
    goto Ready+12
  FireEmpty:
    BM9I B 1 BRIGHT A_GunFlash
    BM9I C 1 BRIGHT A_PlaySound("m9/lock")
    BM9I D 1
    BM9I E 1 A_GiveInventory("M9Bolt",1)
    BM9I A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9I A 0 A_ReFire
    goto Ready+12
    BM9I A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9I A 0 A_ReFire
    goto Ready+12
  FireEmptyLeft:
    BM9H B 1 BRIGHT A_GunFlash
    BM9H C 1 BRIGHT A_PlaySound("m9/lock")
    BM9H D 1
    BM9H E 1 A_GiveInventory("M9Bolt",1)
    BM9H A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9H A 0 A_ReFire
    goto Ready+12
    BM9H A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9H A 0 A_ReFire
    goto Ready+12
  AltFire: //Does nothing
    BM9G I 5
    goto Ready+12
  Hold:
    BM9G I 3 
    BM9G I 1 A_ReFire
    goto Ready+12
  Reload: //AltFire:
    BM9G A 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    BM9G A 0 A_TakeInventory("Reloading",1)
    goto Ready+15
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    BM9J A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    BM9J A 0 A_JumpIfInventory("M9Bolt",1,"ReloadStartBolt") 
    BM9J A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    BM9J ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9J F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9J GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9J O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9J O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    BM9J Z 0 A_GiveInventory("M9Clip3",1)
    BM9J Z 0 A_TakeInventory("M9Ammo",1)
    BM9J Z 0 A_JumpIfInventory("M9Clip3",30,"ReloadEnd")
    BM9J Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    BM9G ABCDEFGH 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9G G 0 A_ReFire
    goto Ready+12  
  ReloadStartBolt:
    BM9K A 0 A_TakeInventory("M9Bolt",1) 
    BM9K A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
    BM9K ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9K GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9K O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9K O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9K Z 0 A_GiveInventory("M9Clip3",1)
    BM9K Z 0 A_TakeInventory("M9Ammo",1)
    BM9K Z 0 A_JumpIfInventory("M9Clip3",30,"ReloadEndBolt")
    BM9K Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt")
    goto ReloadEndBolt
  ReloadEndBolt:
    BM9K PQR 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K S 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9K TUVWX 3 A_WeaponReady(WRF_NOFIRE)
    BM9K G 0 A_ReFire
    goto Ready+12 
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  ReloadStart_SOH:
    BM9J ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9J F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9J GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9J O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9J O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9J Z 0 A_GiveInventory("M9Clip3",1)
    BM9J Z 0 A_TakeInventory("M9Ammo",1)
    BM9J Z 0 A_JumpIfInventory("M9Clip3",30,"ReloadEnd_SOH")
    BM9J Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    BM9G ABCDEFGH 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9G G 0 A_ReFire
    goto Ready+12  
  ReloadStartBolt_SOH:
    BM9K ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9K GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9K O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9K O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9K Z 0 A_GiveInventory("M9Clip3",1)
    BM9K Z 0 A_TakeInventory("M9Ammo",1)
    BM9K Z 0 A_JumpIfInventory("M9Clip3",30,"ReloadEndBolt_SOH")
    BM9K Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt_SOH")
    goto ReloadEndBolt_SOH
  ReloadEndBolt_SOH:
    BM9K PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9K TUVWX 2 A_WeaponReady(WRF_NOFIRE)
    BM9K G 0 A_ReFire
    goto Ready+12 
  Fire_SteadyAim: //Right
    BM9I A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9I A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,20,0)
    BM9I A 1 BRIGHT A_FireBullets (6.6, 6.6, -1, 8, "HHBulletPuff", 1, 4000)
    BM9I B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9I A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9I B 1 BRIGHT A_GunFlash
    BM9I B 0 A_GiveInventory("FireSwitch",1)
    BM9I CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9G A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9G A 0 A_ReFire
    goto Ready+12
    BM9G A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9G A 0 A_ReFire
    goto Ready+12
  FireLeft_SteadyAim:
    BM9H A 0 A_PlaySoundEx("m93r/fire","SoundSlot6")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9H A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,-26,0)
    BM9H A 1 BRIGHT A_FireBullets (6.6, 6.6, -1, 8, "HHBulletPuff", 1, 4000)
    BM9H B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9H A 0 A_JumpIfNoAmmo("FireEmptyLeft")
    BM9H B 1 BRIGHT A_GunFlash
    BM9H B 0 A_TakeInventory("FireSwitch",1)
    BM9H CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9H A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9H A 0 A_ReFire
    goto Ready+12
    BM9H A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9H A 0 A_ReFire
    goto Ready+12
  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 M9Clip3 : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 30
    ammo.backpackamount 0
    ammo.backpackmaxamount 30
    +IGNORESKILL
}


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

actor "M9 Tac Knife" : "M9"
{
  obituary "%k capped %o with the M9."
  inventory.pickupmessage "M9"  
  //attacksound "u45/fire6"
  weapon.selectionorder 19
  weapon.ammotype "M9Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M9Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    BM9L A 1 //A_PlayWeaponSound("m9/select")
    BM9L BCDEGHIJ 1 A_WeaponReady(WRF_NOPRIMARY)
    BM9L K 0 A_JumpIfNoAmmo("Reload")
    BM9L K 0 A_JumpIfInventory("Aiming",1,5)
    BM9L K 0 A_JumpIfInventory("Reloading",1,"Reload")
    BM9L K 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9L K 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9L K 1 A_WeaponReady
    goto Ready+9
    BM9N E 0 A_JumpIfInventory("Reloading",1,"Reload")    
    BM9N E 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9N E 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9N E 1 A_WeaponReady(WRF_NOBOB)
    goto Ready+15
  Deselect:
    BM9L H 0 A_TakeInventory("Aiming",1)
    BM9L H 0 ACS_ExecuteAlways(602,0,0,0,0)
    BM9L H 0 A_TakeInventory("Reloading",1)
    BM9L H 0 A_ZoomFactor(1.0)
    BM9L H 0 A_Lower
    BM9L K 1 A_Lower
    goto Deselect+2
  Select:
    BM9L A 0 A_Raise
	BM9L A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 F 0 A_GiveInventory("InCombatCrosshair", 35)
    loop
  Fire:	
    BM9L A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    BM9L K 1 A_JumpIfNoAmmo("ReloadStart")
    BM9M A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    BM9M A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9M A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,8)
    BM9M A 1 BRIGHT A_FireBullets (10.0, 10.0, -1, 8, "HHBulletPuff", 1, 4000)
    BM9M B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9M A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9M B 1 BRIGHT A_GunFlash
    BM9M CDE 1 A_WeaponReady
    BM9L KK 1 A_WeaponReady
    BM9M A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9M A 0 A_ReFire
    goto Ready+9
    BM9M A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9M A 0 A_ReFire
    goto Ready+9
  FireEmpty:
    BM9M B 1 BRIGHT A_GunFlash
    BM9M C 1 BRIGHT A_PlaySound("m9/lock")
    BM9M DE 1
    BM9L K 1 A_GiveInventory("M9Bolt",1)
    BM9M A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9M A 0 A_ReFire
    goto Ready+9
    BM9M A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9M A 0 A_ReFire
    goto Ready+9
  Hold:
    BM9L K 3 A_JumpIfInventory("Aiming",1,"HoldAim")
    BM9L K 1 A_ReFire
    goto Ready+9
  HoldAim:
    BM9N E 3
    BM9N E 1 A_ReFire
    goto Ready+15
  FireAim:
    BM9N E 1 A_JumpIfNoAmmo("ReloadStart")
    BM9O A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9O A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,8)
    BM9O A 1 BRIGHT A_FireBullets (2, 2, -1, 8, "HHBulletPuff", 1, 4000)
    BM9O B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9O A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9O B 1 BRIGHT A_GunFlash
    BM9O CDE 1 A_WeaponReady
    BM9N EEE 1 A_WeaponReady
    BM9O A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9O A 0 A_ReFire
    goto Ready+9
    BM9O A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9O A 0 A_ReFire
    goto Ready+9
  FireAimEmpty:
    BM9O B 1 BRIGHT A_GunFlash
    BM9O C 1 BRIGHT A_PlaySound("m9/lock")
    BM9O DE 1
    BM9N E 1 A_GiveInventory("M9Bolt",1)
    BM9O A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9O A 0 A_ReFire
    goto Ready+9
    BM9O A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9O A 0 A_ReFire
    goto Ready+9
  Reload: //AltFire:
    VECC A 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    VECC A 0 A_TakeInventory("Reloading",1)
    goto Ready+12
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    BM9P A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    BM9P A 0 A_JumpIfInventory("M9Bolt",1,"ReloadStartBolt") 
    BM9P A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    BM9P ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9P F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9P GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9P O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9P O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    BM9P Z 0 A_GiveInventory("M9Clip",1)
    BM9P Z 0 A_TakeInventory("M9Ammo",1)
    BM9P Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd")
    BM9P Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    BM9P PQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9P G 0 A_ReFire
    goto Ready+9  
  ReloadStartBolt:
    BM9Q A 0 A_TakeInventory("M9Bolt",1) 
    BM9Q A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
    BM9Q ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9Q GHIJKLMN 3 A_WeaponReady(WRF_NOFIRE)
    BM9Q O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9Q O 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9F Z 0 A_GiveInventory("M9Clip",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    BM9F Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt")
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt")
    goto ReloadEndBolt
  ReloadEndBolt:
    BM9Q PQR 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q S 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9Q TUVW 3 A_WeaponReady(WRF_NOFIRE)
    BM9Q G 0 A_ReFire
    goto Ready+9  
  AltFire:
    BM9N A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    BM9N A 0 A_ZoomFactor(1.2)
    BM9N ABCDE 1
    BM9N G 0 A_GiveInventory("Aiming",1)
    BM9N G 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto Ready+15
  AltFire2:
    BM9N E 1 A_ZoomFactor(1.0)
    BM9N EDCBA 1
    BM9N A 0 A_TakeInventory("Aiming",1)
    BM9N A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto Ready+9
  ReloadStartAim:
    BM9N E 1 A_ZoomFactor(1.0)
    BM9N EDCBA 1
    BM9N A 0 A_TakeInventory("Aiming",1)
    BM9N 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:
    WEP2 E 15 
    WEP2 E 0 A_SpawnItem("M9Pickup")
    stop
  Fire_SteadyAim:
    BM9M A 0 A_PlayWeaponSound("m93r/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair",35)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    BM9M A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,8)
    BM9M A 1 BRIGHT A_FireBullets (6.6, 6.6, -1, 8, "HHBulletPuff", 1, 4000)
    BM9M B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    BM9M A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9M B 1 BRIGHT A_GunFlash
    BM9M CDE 1 A_WeaponReady
    BM9L KK 1 A_WeaponReady
    BM9M A 0 A_JumpIfInventory("M9Ammo",1,2)
    BM9M A 0 A_ReFire
    goto Ready+9
    BM9M A 0 A_JumpIfNoAmmo("ReloadStart")
    BM9M A 0 A_ReFire
    goto Ready+9
  ReloadStart_SOH:
    BM9P ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9P F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9P GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9P O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9P O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo_SOH:
    BM9P Z 0 A_GiveInventory("M9Clip",1)
    BM9P Z 0 A_TakeInventory("M9Ammo",1)
    BM9P Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd_SOH")
    BM9P Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    BM9P PQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9P G 0 A_ReFire
    goto Ready+9  
  ReloadStartBolt_SOH:
    BM9Q ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
    BM9Q GHIJKLMN 2 A_WeaponReady(WRF_NOFIRE)
    BM9Q O 0 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9Q O 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9F Z 0 A_GiveInventory("M9Clip",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    BM9F Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt_SOH")
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,"ReloadAmmoBolt_SOH")
    goto ReloadEndBolt_SOH
  ReloadEndBolt_SOH:
    BM9Q PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9Q TUVW 2 A_WeaponReady(WRF_NOFIRE)
    BM9Q G 0 A_ReFire
    goto Ready+9  
  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:
    BM9R A 0 A_ZoomFactor(1.0)
    BM9R A 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9R A 0 A_TakeInventory("Aiming",1)
    BM9R A 0 A_TakeInventory("Reloading",1)
    BM9R A 0 ACS_ExecuteAlways(602,0,0,0,0)
    BM9R A 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"KnifeAttack_SOH")
    BM9R A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_Commando")
    BM9R A 0 ACS_ExecuteAlways(599,0,0,0,0)
    BM9R AB 2
    BM9R C 2 A_PlaySound("knife/swing")
    BM9R DD 0 A_CustomPunch(34,1,0,"KnifePuff",96)
    BM9R D 2 A_CustomPunch(34,1,0,"KnifePuff",96)
    BM9R EF 2
    TNT1 A 10
    BM9R L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready
  KnifeAttack_Commando:
    BM9R A 0 ACS_ExecuteAlways(599,0,0,0,0)
    BM9R AB 2
    BM9R C 2 A_PlaySound("knife/swing")
    BM9R DD 0 A_CustomPunch(34,1,0,"KnifePuff",160)
    BM9R D 2 A_CustomPunch(34,1,0,"KnifePuff",160)
    BM9R EF 2
    TNT1 A 10
    DEGQ L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready
  KnifeAttack_SOH:
    BM9R A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_SOH_Commando")
    BM9R A 0 ACS_ExecuteAlways(599,0,0,0,0)
    BM9R AB 1
    BM9R C 1 A_PlaySound("knife/swing")
    BM9R DD 0 A_CustomPunch(28,1,0,"KnifePuff",96)
    BM9R D 1 A_CustomPunch(28,1,0,"KnifePuff",96)
    BM9R EF 1
    TNT1 A 5
    BM9R L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready
  KnifeAttack_SOH_Commando:
    BM9R A 0 ACS_ExecuteAlways(599,0,0,0,0)
    BM9R AB 1
    BM9R C 1 A_PlaySound("knife/swing")
    BM9R DD 0 A_CustomPunch(28,1,0,"KnifePuff",160)
    BM9R D 1 A_CustomPunch(28,1,0,"KnifePuff",160)
    BM9R EF 1
    TNT1 A 5
    BM9R L 0 A_TakeInventory("KnifeAttack",1)
    goto Ready
  }
}

actor M9Knife : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor M9Pickup : CustomInventory
{
  inventory.pickupmessage "M9"  
  inventory.pickupsound "misc/w_pkup"
  +INVENTORY.AUTOACTIVATE
  inventory.respawntics 35
  scale 0.15
  States
  {
  Spawn:
    WEP2 E -1
    stop
  Pickup:
    JDGP A 0
    JDGP A 0 A_JumpIfInventory("M9",1,"FailPickup") // If the player already has this weapon, they get more ammo for it
    JDGP A 0 A_JumpIfInventory("M9 Akimbo",1,"FailPickup")
    JDGP A 0 A_JumpIfInventory("M9 Tac Knife",1,"FailPickup")
    JDGP A 0 A_JumpIfInventory("M9 Ex Mags",1,"FailPickup")
    JDGP A 0 A_JumpIfInventory("MaxWeaponsFilled",0,"FailPickup2")
    BKPK A 0 ACS_ExecuteWithResult(618,31,0,0)
    stop
  AmmoPickup:
    JDGP A 0
    JDGP A 0 A_JumpIfInventory("M9Ammo",0,"FailPickup")
    JDGP A 0 A_GiveInventory("M9Ammo",15)
    stop
  FailPickup:
    WEP2 E 1
    fail
  FailPickup2:
    WEP2 E 1 
    BKPK A 0 ACS_ExecuteAlways(620,0,2,0,0)
    fail
  }
}
