actor "Beretta M9" : RGUWeapon
{
  obituary "%k capped %o with the M9."
  inventory.pickupmessage "You got the Beretta M9 pistol."
  //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:
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    GRNA L 0 A_TakeInventory("weapondropper",2)
    TNT1 A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    BM9A ABCDEFF 2 A_WeaponReady(WRF_ALLOWZOOM)
    BM9A F 0 A_JumpIfNoAmmo("Reload")
	G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    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(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+12
    BM9C E 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    BM9C E 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9C E 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
    BM9C E 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+18
  Deselect:
    BM9A F 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    BM9A F 0 A_TakeInventory("Firing",1)
    BM9A F 0 A_TakeInventory("Aiming",1)
    BM9A F 0 A_TakeInventory("Reloading",1)
    BM9A F 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    BM9A F 0 A_ZoomFactor(1.0)
    BM9A F 0 A_Lower
    BM9A F 1 A_Lower
    Goto Deselect+6
  Select:
    BM9A A 0
    BM9A A 0 A_TakeInventory("Firing",1)
    BM9A A 0 A_Raise
    Goto Select+2
  Fire:
    BM9A F 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_JumpIfInventory("Firing",1,"FireHold")
    BM9B A 0 A_PlayWeaponSound("m93r/fire")
    BM9B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,7,5)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9B A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-6.00,6.00), 1, 0, 4, 0, frandom(-6.00,6.00))
	BM9B A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9B A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9B C 1 BRIGHT A_GunFlash
	BM9B C 0 A_GiveInventory("Firing",1)
    BM9B DEFG 1 A_WeaponReady
    BM9A FFF 1 A_WeaponReady
	BM9A F 0 A_TakeInventory("Firing",1)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9A F 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FireHold:
    BM9B A 0 A_PlayWeaponSound("m93r/fire")
    BM9B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,7,5)
    BM9B A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-9.00,9.00), 1, 0, 4, 0, frandom(-9.00,9.00))
	BM9B A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9B A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9B C 1 BRIGHT A_GunFlash
	BM9B C 0 A_GiveInventory("Firing",1)
    BM9B DEFG 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9A FFF 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9A F 0 A_TakeInventory("Firing",1)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9A F 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FireEmpty:
    BM9B C 1 BRIGHT A_GunFlash
    BM9B D 1 A_PlaySound("m9/lock")
    BM9B EFG 1
    BM9A F 0 A_TakeInventory("Firing",1)
    BM9A F 1 A_GiveInventory("M9Bolt",1)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9A F 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FireAim:
    BM9C E 1 A_JumpIfNoAmmo("ReloadStart")
    BM9D A 0 A_JumpIfInventory("Firing",1,"FireAimHold")
    BM9D A 0 A_PlayWeaponSound("m93r/fire")
    BM9D A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,8)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9D A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-1.20,1.20), 1, 0, 4, 0, frandom(-1.20,1.20))
	BM9D A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9D A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9D A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9D B 1 BRIGHT A_GunFlash
	BM9D B 0 A_GiveInventory("Firing",1)
    BM9D CDFH 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9C EEE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9D I 0 A_TakeInventory("Firing",1)
    BM9D I 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9D I 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FireAimHold:
    BM9D A 0 A_PlayWeaponSound("m93r/fire")
    BM9D A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,8)
    BM9D A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-3.60,3.60), 1, 0, 4, 0, frandom(-3.60,3.60))
	BM9D A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9D A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9D A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9D B 1 BRIGHT A_GunFlash
	BM9D B 0 A_GiveInventory("Firing",1)
    BM9D CDFH 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9C EEE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9D I 0 A_TakeInventory("Firing",1)
    BM9D I 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9D I 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FireAimEmpty:
    BM9D B 1 BRIGHT A_GunFlash
    BM9D C 1 A_PlaySound("m9/lock")
    BM9D DEFGH 1
    BM9D I 0 A_TakeInventory("Firing",1)
    BM9D I 1 A_GiveInventory("M9Bolt",1)
    BM9D I 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9D I 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  Reload: //AltFire:
    BM9A F 0 A_JumpIfInventory("M9Clip",15,2)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    BM9A F 0 A_TakeInventory("Reloading",1)
    BM9A F 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+15
  ReloadStart:
    BM9E A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    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 A 0 A_JumpIfInventory("M9Token",1,"Reload2")
    BM9E ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload2
  Reload2:
    BM9E GHIJKL 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9E M 3 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E N 3 A_TakeInventory("Reloading",1)
    BM9E O 3
    Goto ReloadAmmo
  ReloadAmmo:
    BM9E Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd
    BM9E Z 0 A_GiveInventory("M9Clip",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo
  ReloadEnd:
    BM9E PQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  ReloadStartBolt:
    BM9F A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
	BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload3")
    BM9F ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload3
  Reload3:
    BM9F GHIJKLM 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9F N 3 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9F Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt
    BM9F Z 0 A_GiveInventory("M9Clip",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt
  ReloadEndBolt:
    BM9F P 0 A_TakeInventory("M9Bolt",1)
    BM9F PQ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F R 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F STUV 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	//M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  Zoom:
  PostReloadAlt:
    G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
    BM9C E 0 A_ZoomFactor(1.15)
	BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    BM9C D 0 A_GiveInventory("Aiming",1)
    BM9C ABCDE 1
    Goto AltHold
  ReloadBreak:
    BM9C E 0 A_ZoomFactor(1.0)
    BM9C ED 1
    BM9C D 0 A_TakeInventory("Aiming",1)
    BM9C CBA 1
    BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    TNT1 A 0 A_ClearReFire
    Goto Reload
  ClearRefire:
    BM9C E 1 A_ClearReFire
	Goto AltHold
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("M9Clip",1,2)
	TNT1 A 0 A_GiveInventory("M9Bolt",1)
	Goto ReloadBreak
    BM9D A 0 A_PlayWeaponSound("m93r/fire")
	GRNA L 0 A_TakeInventory("M9Clip",1)
    BM9D A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,8)
	"####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9D A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-2.60,2.60), 1, 0, 4, 0, frandom(-2.60,2.60))
	BM9D A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9D A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9D A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9D B 1 BRIGHT A_GunFlash
	"####" "#" 0 A_JumpIfInventory("M9Clip",1,2)
	TNT1 A 0 A_GiveInventory("M9Bolt",1)
	Goto ReloadBreak
    A12C A 0 A_ClearReFire
    Goto AltHold
  AltHold:
    A12C C 0 A_JumpIfInventory("FireHeld",1,"ClearRefire")
    BM9C E 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
	A12C C 0 A_JumpIfInventory("FireHeld",1,"FireAimAltHold")
	A12C C 0 A_JumpIfInventory("Reloading",1,"ReloadBreak")
	U45A L 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    U45A L 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
	A12C F 0 A_Refire("AltHold")
	A12C C 0 A_JumpIfInventory("Aiming",1,"AltFire2")
	Goto Ready+18
  AltFire:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"AltHold")
    BM9C A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    BM9C A 0 A_ZoomFactor(1.15)
    BM9C AB 1
    BM9C B 0 A_GiveInventory("Aiming",1)
    BM9C CDE 1
    BM9C E 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	A12C F 0 A_Refire("AltHold")
    Goto Ready+18
  AltFire2:
    BM9C E 0 A_ZoomFactor(1.0)
    BM9C ED 1
    BM9C D 0 A_TakeInventory("Aiming",1)
    BM9C CBA 1
    BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	//M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  AltFire3:
    BM9C E 0 A_ZoomFactor(1.0)
    BM9C ED 1
    BM9C D 0 A_TakeInventory("Aiming",1)
    BM9C CBA 1
    BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	goto DropWeapon
  ReloadStartAim:
    BM9C E 0 A_ZoomFactor(1.0)
    BM9C ED 1
    BM9C D 0 A_TakeInventory("Aiming",1)
    BM9C CBA 1
    BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  Spawn:
    WEP2 E 0
    WEP2 E 0 A_SpawnItem("M9Drop")
    stop
  ReloadStart_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload4")
    BM9E ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload4
  Reload4:
    BM9E GHIJKL 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9E M 2 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E N 2 A_TakeInventory("Reloading",1)
    BM9E O 2
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9E Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd_SOH
    BM9E Z 0 A_GiveInventory("M9Clip",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    BM9E PQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  ReloadStartBolt_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload5")
    BM9F ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload5
  Reload5:
    BM9F GHIJKLM 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9F N 2 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9F Z 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt_SOH
    BM9F Z 0 A_GiveInventory("M9Clip",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt_SOH
  ReloadEndBolt_SOH:
    BM9F P 0 A_TakeInventory("M9Bolt",1)
    BM9F PQ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F R 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F STUV 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	//M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  Fire_SteadyAim:
    BM9B A 0 A_JumpIfInventory("Firing",1,"FireHold_SteadyAim")
    BM9B A 0 A_PlayWeaponSound("m93r/fire")
    BM9B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,7,5)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9B A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-4.00,4.00), 1, 0, 4, 0, frandom(-4.00,4.00))
	BM9B A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9B A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9B C 1 BRIGHT A_GunFlash
	BM9B C 0 A_GiveInventory("Firing",1)
    BM9B DEFG 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9A FFF 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9A F 0 A_TakeInventory("Firing",1)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9A F 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FireHold_SteadyAim:
    BM9B A 0 A_PlayWeaponSound("m93r/fire")
    BM9B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,7,5)
    BM9B A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	BM9B A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9B A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9B C 1 BRIGHT A_GunFlash
	BM9B C 0 A_GiveInventory("Firing",1)
    BM9B DEFG 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9A FFF 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9A F 0 A_TakeInventory("Firing",1)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+12
    BM9A F 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+12
  FragGrenade:
    U45F A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    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_NamedExecuteAlways("RefSpeed",0,0,0,0)
	M4CA J 0 A_JumpIfInventory("ThrowingStun",1,"StunGrenade")
	M4CA J 0 A_JumpIfInventory("ThrowingIncd",1,"IncGrenade")
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"FragGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("GrenadeAmmo",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",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  FragGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("GrenadeAmmo",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",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    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_NamedExecuteAlways("RefSpeed",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_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    KNFA DEFGHIJKL 1
    TNT1 A 20
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack_Commando:
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    KNFA DEFGHIJKL 1
    TNT1 A 20
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack_SOH:
    U45C A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_SOH_Commando")
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    KNFA DEFGHIJKL 1
    TNT1 A 10
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack_SOH_Commando:
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    KNFA DEFGHIJKL 1
    TNT1 A 10
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  StunGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"StunGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  IncGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"IncGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  StunGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  IncGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  DropWeapon:
    BM9A EDCBA 2 A_WeaponReady(WRF_NOPRIMARY)
    BM9A A 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CC F 0 A_JumpIfInventory("weapondropper",2,"ThrowWeapon")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",1)
	M4CB A 0 A_FireCustomMissile("M9Dropped",0,0,7,2)
	stop
  ThrowWeapon:
    GRNA IKMN 1
	KNFA B 0 A_PlaySound("knife/swing")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",2)
	M4CB A 0 A_FireCustomMissile("M9Thrown",0,0,7,2)
	stop
  }
}

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 "Beretta M9 Ex Mags" : "Beretta M9"
{
  obituary "%k capped %o with the M9."
  inventory.pickupmessage "You got the Beretta M9 pistol."
  //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
  {
  Ready:
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    GRNA L 0 A_TakeInventory("weapondropper",2)
    TNT1 A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    BM9A ABCDEFF 2 A_WeaponReady(WRF_ALLOWZOOM)
	G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
    BM9A F 0 A_JumpIfNoAmmo("Reload")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    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(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+12
    BM9C E 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    BM9C E 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9C E 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
    BM9C E 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+18
  Reload: //AltFire:
    BM9A F 0 A_JumpIfInventory("M9Clip2",23,2)
    BM9A F 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    BM9A F 0 A_TakeInventory("Reloading",1)
    BM9A F 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+15
  ReloadStart:
    BM9E A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    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 A 0 A_JumpIfInventory("M9Token",1,"Reload2")
    BM9E ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolExtEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload2
  Reload2:
    BM9E GHIJKL 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9E M 3 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E N 3 A_TakeInventory("Reloading",1)
    BM9E O 3
    Goto ReloadAmmo
  ReloadAmmo:
    BM9E Z 0 A_JumpIfInventory("M9Clip2",23,"ReloadEnd")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd
    BM9E Z 0 A_GiveInventory("M9Clip2",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo
  ReloadEnd:
    BM9E PQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  ReloadStartBolt:
    BM9F A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
	BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload3")
    BM9F ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolExtEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload3
  Reload3:
    BM9F GHIJKLM 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9F N 3 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9F Z 0 A_JumpIfInventory("M9Clip2",23,"ReloadEndBolt")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt
    BM9F Z 0 A_GiveInventory("M9Clip2",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt
  ReloadEndBolt:
    BM9F P 0 A_TakeInventory("M9Bolt",1)
    BM9F PQ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F R 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F STUV 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+12
  ReloadStartAim:
    BM9C E 0 A_ZoomFactor(1.0)
    BM9C ED 1
    BM9C D 0 A_TakeInventory("Aiming",1)
    BM9C CBA 1
    BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  ReloadStart_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload4")
    BM9E ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9E F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolExtEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload4
  Reload4:
    BM9E GHIJKL 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9E M 2 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9E N 2 A_TakeInventory("Reloading",1)
    BM9E O 2
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9E Z 0 A_JumpIfInventory("M9Clip2",23,"ReloadEnd_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9E Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd_SOH
    BM9E Z 0 A_GiveInventory("M9Clip2",1)
    BM9E Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    BM9E PQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+12
  ReloadStartBolt_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload5")
    BM9F ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolExtEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload5
  Reload5:
    BM9F GHIJKLM 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9F N 2 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9F O 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9F Z 0 A_JumpIfInventory("M9Clip2",23,"ReloadEndBolt_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9F Z 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt_SOH
    BM9F Z 0 A_GiveInventory("M9Clip2",1)
    BM9F Z 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt_SOH
  ReloadEndBolt_SOH:
    BM9F P 0 A_TakeInventory("M9Bolt",1)
    BM9F PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9F S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9F TUV 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+12
  ReloadBreak:
    BM9C E 0 A_ZoomFactor(1.0)
    BM9C ED 1
    BM9C D 0 A_TakeInventory("Aiming",1)
    BM9C CBA 1
    BM9C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    TNT1 A 0 A_ClearReFire
    Goto Reload
  ClearRefire:
    BM9C E 1 A_ClearReFire
	Goto AltHold
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("M9Clip2",1,2)
	TNT1 A 0 A_GiveInventory("M9Bolt",1)
	Goto ReloadBreak
    BM9D A 0 A_PlayWeaponSound("m93r/fire")
	GRNA L 0 A_TakeInventory("M9Clip2",1)
    BM9D A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,8)
	"####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9D A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-2.60,2.60), 1, 0, 4, 0, frandom(-2.60,2.60))
	BM9D A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9D A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9D A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9D B 1 BRIGHT A_GunFlash
	"####" "#" 0 A_JumpIfInventory("M9Clip2",1,2)
	TNT1 A 0 A_GiveInventory("M9Bolt",1)
	Goto ReloadBreak
    A12C A 0 A_ClearReFire
    Goto AltHold
  }
}

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


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

actor "Beretta M9 Akimbo" : "Beretta M9"
{
  obituary "%k capped %o with a couple M9s."
  weapon.ammotype "M9Clip3"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M9Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    TNT1 A 2 A_PlaySoundEx("weapon/draw","SoundSlot5")
	TNT1 AA 2
    BM9G ABCDEFGHI 1 A_WeaponReady(WRF_NOFIRE)
	G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
    BM9G I 0 A_JumpIfNoAmmo("Reload")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    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(WRF_ALLOWRELOAD)
    Goto Ready+14
  Deselect:
    BM9G I 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    BM9G I 0 A_TakeInventory("Aiming",1)
    BM9G I 0 A_TakeInventory("Reloading",1)
    BM9G I 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    BM9G I 0 A_ZoomFactor(1.0)
    BM9G I 0 A_Lower
    BM9G I 1 A_Lower
    Goto Deselect+5
  Select:
    BM9G A 0 A_Raise
    Loop
  Fire: //Right
    BM9G I 0 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")
    BM9I A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,20,4)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9I A 1 BRIGHT A_FireCustomMissile("HHCBM9A", frandom(-9.00,9.00), 1, 0, 4, 0, frandom(-9.00,9.00))
	BM9I A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,19,32-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9I B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9I A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9I B 1 BRIGHT A_GunFlash
    BM9I B 0 A_GiveInventory("FireSwitch",1)
    BM9I B 0 A_JumpIfInventory("M9Clip3",2,2)
    BM9I B 0 BRIGHT A_PlaySound("m9/lock")
    BM9I CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9G A 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+14
    BM9G A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+14
  FireLeft:
    BM9H A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"FireLeft_SteadyAim")
    BM9H A 0 A_PlaySoundEx("m93r/fire","SoundSlot6")
    BM9H A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,-25,3)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9H A 1 BRIGHT A_FireCustomMissile("HHCBM9A", frandom(-9.00,9.00), 1, 0, 4, 0, frandom(-9.00,9.00))
	BM9H A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,-19,32-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9H B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9H A 0 A_JumpIfNoAmmo("FireEmptyLeft")
    BM9H B 1 BRIGHT A_GunFlash
    BM9H B 0 A_TakeInventory("FireSwitch",1)
    BM9H B 0 A_JumpIfInventory("M9Clip3",2,2)
    BM9H B 0 BRIGHT A_PlaySound("m9/lock")
    BM9H CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9H A 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+14
    BM9H A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+14
  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,1)
    Goto Ready+14
    BM9I A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+14
  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,1)
    Goto Ready+14
    BM9H A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+14
  AltFire: //Does nothing
    BM9G I 1 A_WeaponReady(WRF_NOSECONDARY|WRF_ALLOWRELOAD)
    Goto Ready+14
  Reload: //AltFire:
    BM9G A 0 A_JumpIfInventory("M9Clip3",30,2)
    BM9G A 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    BM9G A 0 A_TakeInventory("Reloading",1)
    Goto Ready+17
  ReloadStart:
	BM9J A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
	BM9J A 0 A_TakeInventory("FireSwitch",1)
    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")
	BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload2")
    BM9J ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9J F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
    BM9J G 3 A_PlaySoundEx("m93r/clipout","SoundSlot7")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload2
  Reload2:
    BM9J HIJKLMN 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9J O 9 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9J O 0 A_PlayWeaponSound("m93r/clipin")
    BM9J O 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo
  ReloadAmmo:
    BM9J O 0 A_JumpIfInventory("M9Clip3",30,"ReloadEnd")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9J O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd
    BM9J O 0 A_GiveInventory("M9Clip3",1)
    BM9J O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo
  ReloadEnd:
    BM9G ABCDEFGH 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    Goto Ready+14
  ReloadStartBolt:
    BM9K A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
	BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload3")
    BM9K ABCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K F 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
    BM9K G 3 A_PlaySoundEx("m93r/clipout","SoundSlot7")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload3
  Reload3:
    BM9K HIJKLMN 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9K O 9 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9K O 0 A_PlayWeaponSound("m93r/clipin")
    BM9K O 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9K O 0 A_JumpIfInventory("M9Clip3",30,"ReloadEndBolt")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9K O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt
    BM9K O 0 A_GiveInventory("M9Clip3",1)
    BM9K O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt
  ReloadEndBolt:
    BM9K P 0 A_TakeInventory("M9Bolt",1)
    BM9K PQR 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K S 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9K T 3 A_PlayWeaponSound("m93r/bolt")
    BM9K UVWX 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+14
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  ReloadStart_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload4")
    BM9J ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9J F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
    BM9J G 2 A_PlaySoundEx("m93r/clipout","SoundSlot7")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload4
  Reload4:
    BM9J HIJKLMN 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9J O 8 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9J O 0 A_PlayWeaponSound("m93r/clipin")
    BM9J O 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9J O 0 A_JumpIfInventory("M9Clip3",30,"ReloadEnd_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9J O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd_SOH
    BM9J O 0 A_GiveInventory("M9Clip3",1)
    BM9J O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    BM9G ABCDEFGH 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    Goto Ready+14
  ReloadStartBolt_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload5")
    BM9K ABCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K F 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
    BM9K G 2 A_PlaySoundEx("m93r/clipout","SoundSlot7")
	BM9J F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload5
  Reload5:
    BM9K HIJKLMN 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9K O 8 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9K O 0 A_PlayWeaponSound("m93r/clipin")
    BM9K O 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9K O 0 A_JumpIfInventory("M9Clip3",30,"ReloadEndBolt_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9K O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt_SOH
    BM9K O 0 A_GiveInventory("M9Clip3",1)
    BM9K O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt_SOH
  ReloadEndBolt_SOH:
    BM9F P 0 A_TakeInventory("M9Bolt",1)
    BM9K PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9K S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9K T 2 A_PlayWeaponSound("m93r/bolt")
    BM9K UVWX 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+14
  Fire_SteadyAim: //Right
    BM9I A 0 A_PlayWeaponSound("m93r/fire")
    BM9I A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,20,4)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9I A 1 BRIGHT A_FireCustomMissile("HHCBM9A", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	BM9I A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,19,32-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9I B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9I A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9I B 1 BRIGHT A_GunFlash
    BM9I B 0 A_GiveInventory("FireSwitch",1)
    BM9I B 0 A_JumpIfInventory("M9Clip3",2,2)
    BM9I B 0 BRIGHT A_PlaySound("m9/lock")
    BM9I CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9G A 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+14
    BM9G A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+14
  FireLeft_SteadyAim:
    BM9H A 0 A_PlaySoundEx("m93r/fire","SoundSlot6")
    BM9H A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,-25,3)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9H A 1 BRIGHT A_FireCustomMissile("HHCBM9A", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	BM9H A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,-19,32-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9H B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9H A 0 A_JumpIfNoAmmo("FireEmptyLeft")
    BM9H B 1 BRIGHT A_GunFlash
    BM9H B 0 A_TakeInventory("FireSwitch",1)
    BM9H B 0 A_JumpIfInventory("M9Clip3",2,2)
    BM9H B 0 BRIGHT A_PlaySound("m9/lock")
    BM9H CDE 1 A_WeaponReady
    BM9G II 1 A_WeaponReady
    BM9H A 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+14
    BM9H A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+14
  FragGrenade:
    U45F A 0 ACS_NamedExecuteAlways("RefSpeak",0,1,0,0)
    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_NamedExecuteAlways("RefSpeed",0,0,0,0)
	M4CA J 0 A_JumpIfInventory("ThrowingStun",1,"StunGrenade")
	M4CA J 0 A_JumpIfInventory("ThrowingIncd",1,"IncGrenade")
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"FragGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("GrenadeAmmo",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",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
    Goto Ready+2
  FragGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("GrenadeAmmo",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",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
    Goto Ready+2
  KnifeAttack:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    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_NamedExecuteAlways("RefSpeed",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_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    KNFA DEFGHIJKL 1
    TNT1 A 20
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    Goto Ready+2
  KnifeAttack_Commando:
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    KNFA DEFGHIJKL 1
    TNT1 A 20
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    Goto Ready+2
  KnifeAttack_SOH:
    U45C A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_SOH_Commando")
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    KNFA DEFGHIJKL 1
    TNT1 A 10
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    Goto Ready+2
  KnifeAttack_SOH_Commando:
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    KNFA DEFGHIJKL 1
    TNT1 A 10
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    Goto Ready+2
  StunGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"StunGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
    Goto Ready+2
  IncGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"IncGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
    Goto Ready+2
  StunGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
    Goto Ready+2
  IncGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
    Goto Ready+2
  DropWeapon:
    BM9G HGFEDCBA 2 A_WeaponReady(WRF_NOPRIMARY)
    BM9G A 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CC F 0 A_JumpIfInventory("weapondropper",2,"ThrowWeapon")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",1)
	M4CB A 0 A_FireCustomMissile("M9Dropped",0,0,7,2)
	stop
  ThrowWeapon:
    GRNA IKMN 1
	KNFA B 0 A_PlaySound("knife/swing")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",2)
	M4CB A 0 A_FireCustomMissile("M9Thrown",0,0,7,2)
  }
}

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 "Beretta M9 Tac Knife" : "Beretta M9"
{
  obituary "%k capped %o with the M9."
  inventory.pickupmessage "You got the Beretta M9 pistol."
  //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:
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    GRNA L 0 A_TakeInventory("weapondropper",2)
    BM9L A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    BM9L BCDEGHIJ 1 A_WeaponReady(WRF_ALLOWZOOM)
	G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
    BM9L K 0 A_JumpIfNoAmmo("Reload")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    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(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+13
    BM9N E 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    BM9N E 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    BM9N E 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
    BM9N E 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+19
  Deselect:
    BM9L K 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    BM9L K 0 A_TakeInventory("Firing",1)
    BM9L K 0 A_TakeInventory("Aiming",1)
    BM9L K 0 A_TakeInventory("Reloading",1)
    BM9L K 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    BM9L K 0 A_ZoomFactor(1.0)
    BM9L K 0 A_Lower
    BM9L K 1 A_Lower
    Goto Deselect+6
  Select:
    BM9L A 0
    BM9L A 0 A_TakeInventory("Firing",1)
    BM9L A 0 A_Raise
    Goto Select+2
  Fire:
    BM9L K 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_JumpIfInventory("Firing",1,"FireHold")
    BM9M A 0 A_PlayWeaponSound("m93r/fire")
    BM9M A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,5,9)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9M A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	BM9M A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9M A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9M A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9M B 1 BRIGHT A_GunFlash
    BM9M B 0 A_GiveInventory("Firing",1)
    BM9M CDE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9L KKKK 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9L K 0 A_TakeInventory("Firing",1)
    BM9L K 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9L K 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  FireHold:
    BM9M A 0 A_PlayWeaponSound("m93r/fire")
    BM9M A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,5,9)
    BM9M A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-10.00,10.00), 1, 0, 4, 0, frandom(-10.00,10.00))
	BM9M A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9M A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9M A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9M B 1 BRIGHT A_GunFlash
    BM9M CDE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9L KKKK 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9L K 0 A_TakeInventory("Firing",1)
    BM9L K 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9L K 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  FireEmpty:
    BM9M B 1 BRIGHT A_GunFlash
    BM9M C 1 A_PlaySound("m9/lock")
    BM9M DE 1
    BM9L K 0 A_TakeInventory("Firing",1)
    BM9L K 1 A_GiveInventory("M9Bolt",1)
    BM9L K 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9L K 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  FireAim:
    BM9N E 1 A_JumpIfNoAmmo("ReloadStart")
	BM9O A 0 A_JumpIfInventory("Firing",1,"FireAimHold")
    BM9O A 0 A_PlayWeaponSound("m93r/fire")
    BM9O A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,9)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9O A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-1.40,1.40), 1, 0, 4, 0, frandom(-1.40,1.40))
	BM9O A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9O A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9O A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9O B 1 BRIGHT A_GunFlash
    BM9O B 0 A_GiveInventory("Firing",1)
    BM9O CDE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9N EEEE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9N E 0 A_TakeInventory("Firing",1)
    BM9N E 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9N E 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  FireAimHold:
    BM9O A 0 A_PlayWeaponSound("m93r/fire")
    BM9O A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,9)
    BM9O A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-4.20,4.20), 1, 0, 4, 0, frandom(-4.20,4.20))
	BM9O A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9O A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9O A 0 A_JumpIfNoAmmo("FireAimEmpty")
    BM9O B 1 BRIGHT A_GunFlash
    BM9O B 0 A_GiveInventory("Firing",1)
    BM9O CDE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9N EEEE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9N E 0 A_TakeInventory("Firing",1)
    BM9N E 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9N E 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  FireAimEmpty:
    BM9O B 1 BRIGHT A_GunFlash
    BM9O C 1 A_PlaySound("m9/lock")
    BM9O DE 1
    BM9N E 0 A_TakeInventory("Firing",1)
    BM9N E 1 A_GiveInventory("M9Bolt",1)
    BM9N E 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9N E 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  Reload: //AltFire:
    BM9L K 0 A_JumpIfInventory("M9Clip",15,2)
    BM9L K 0 A_JumpIfInventory("M9Ammo",1,"ReloadStart")
    BM9L K 0 A_TakeInventory("Reloading",1)
    BM9L K 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+16
  ReloadStart:
    BM9P A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    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")
	BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload2")
    BM9P ABC 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9P D 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9P G 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload2
  Reload2:
    BM9P EFGHIJKL 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9P M 3 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9P N 3 A_TakeInventory("Reloading",1)
    BM9P O 3
    Goto ReloadAmmo
  ReloadAmmo:
    BM9P O 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9P O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd
    BM9P O 0 A_GiveInventory("M9Clip",1)
    BM9P O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo
  ReloadEnd:
    BM9P PQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+13
  ReloadStartBolt:
    BM9Q A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStartBolt_SOH")
	BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload3")
    BM9Q ABCD 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q E 3 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9Q E 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload3
  Reload3:
    BM9Q FGHIJKLM 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9Q N 3 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9Q O 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt
  ReloadAmmoBolt:
    BM9Q O 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9Q O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt
    BM9Q O 0 A_GiveInventory("M9Clip",1)
    BM9Q O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt
  ReloadEndBolt:
    BM9Q P 0 A_TakeInventory("M9Bolt",1)
    BM9Q PQR 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q S 3 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9Q TUVW 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+13
  Zoom:
  PostReloadAlt:
    G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
    BM9N D 0 A_GiveInventory("Aiming",1)
    BM9N E 0 A_ZoomFactor(1.15)
    BM9N A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    BM9N ABCDE 1
    Goto AltHold
  ReloadBreak:
    BM9N E 0 A_ZoomFactor(1.0)
    BM9N ED 1
    BM9N D 0 A_TakeInventory("Aiming",1)
    BM9N CBA 1
    BM9N A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    TNT1 A 0 A_ClearReFire
    Goto Reload
  ClearRefire:
    BM9N E 1 A_ClearReFire
	Goto AltHold
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("M9Clip",1,2)
	TNT1 A 0 A_GiveInventory("M9Bolt",1)
	Goto ReloadBreak
    BM9O A 0 A_PlayWeaponSound("m93r/fire")
	GRNA L 0 A_TakeInventory("M9Clip",1)
    BM9O A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,9)
	"####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9O A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-4.20,4.20), 1, 0, 4, 0, frandom(-4.20,4.20))
	BM9O A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,0,42-(Sin(Pitch)*28),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9O A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9O B 1 BRIGHT A_GunFlash
	"####" "#" 0 A_JumpIfInventory("M9Clip",1,2)
	TNT1 A 0 A_GiveInventory("M9Bolt",1)
	Goto ReloadBreak
	A12C A 0 A_ClearReFire
	Goto AltHold
  AltHold:
    A12C C 0 A_JumpIfInventory("FireHeld",1,"ClearRefire")
    BM9N E 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
	A12C C 0 A_JumpIfInventory("FireHeld",1,"FireAimAltHold")
	A12C C 0 A_JumpIfInventory("Reloading",1,"ReloadBreak")
	U45A L 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    U45A L 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
	A12C F 0 A_Refire("AltHold")
	A12C C 0 A_JumpIfInventory("Aiming",1,"AltFire2")
	Goto Ready+24
  AltFire:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    G18A I 0 A_JumpIfInventory("M9Token",1,"Reload")
    BM9N A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    BM9N A 0 A_ZoomFactor(1.15)
    BM9N AB 1
    BM9N B 0 A_GiveInventory("Aiming",1)
    BM9N CDE 1
    BM9N E 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	A12C A 0 A_ReFire
    Goto Ready+19
  AltFire2:
    BM9N E 0 A_ZoomFactor(1.0)
    BM9N ED 1
    BM9N D 0 A_TakeInventory("Aiming",1)
    BM9N CBA 1
    BM9N A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	//M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+13
  AltFire3:
    BM9N E 0 A_ZoomFactor(1.0)
    BM9N ED 1
    BM9N D 0 A_TakeInventory("Aiming",1)
    BM9N CBA 1
    BM9N A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	goto DropWeapon
  ReloadStartAim:
    BM9N E 0 A_ZoomFactor(1.0)
    BM9N ED 1
    BM9N D 0 A_TakeInventory("Aiming",1)
    BM9N CBA 1
    BM9N A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  Spawn:
    WEP2 E 0
    WEP2 E 0 A_SpawnItem("M9Drop")
    stop
  Fire_SteadyAim:
    BM9M A 0 A_JumpIfInventory("Firing",1,"FireHold_SteadyAim")
    BM9M A 0 A_PlayWeaponSound("m93r/fire")
    BM9M A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,5,9)
    "####" # 0 A_FireBullets(0.0, 0.0, 0, 0, "HHTag", FBF_NOFLASH, 4096)
    BM9M A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-5.00,5.00), 1, 0, 4, 0, frandom(-5.00,5.00))
	BM9M A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9M A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9M A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9M B 1 BRIGHT A_GunFlash
	BM9M B 0 A_GiveInventory("Firing",1)
    BM9M CDE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9L KKKK 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9L K 0 A_TakeInventory("Firing",1)
    BM9L K 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9L K 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  FireHold_SteadyAim:
    BM9M A 0 A_PlayWeaponSound("m93r/fire")
    BM9M A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,5,9)
    BM9M A 1 BRIGHT A_FireCustomMissile("HHCBM9", frandom(-8.00,8.00), 1, 0, 4, 0, frandom(-8.00,8.00))
	BM9M A 0 A_SpawnItemEx("BulletCasing",Cos(Pitch)*30,11,39-(Sin(Pitch)*40),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    BM9M A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    BM9M A 0 A_JumpIfNoAmmo("FireEmpty")
    BM9M B 1 BRIGHT A_GunFlash
	BM9M B 0 A_GiveInventory("Firing",1)
    BM9M CDE 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
    BM9L KKKK 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	BM9L K 0 A_TakeInventory("Firing",1)
    BM9L K 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto Ready+13
    BM9L K 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+13
  ReloadStart_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload4")
    BM9P ABC 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9P D 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9P D 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload4
  Reload4:
    BM9P EFGHIJKL 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9P M 2 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9P N 2 A_TakeInventory("Reloading",1)
    BM9P O 2
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    BM9P O 0 A_JumpIfInventory("M9Clip",15,"ReloadEnd_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9P O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEnd_SOH
    BM9P O 0 A_GiveInventory("M9Clip",1)
    BM9P O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    BM9P PQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+13
  ReloadStartBolt_SOH:
    BM9E A 0 A_JumpIfInventory("M9Token",1,"Reload5")
    BM9Q ABCD 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q E 2 A_PlaySoundEx("m93r/clipout","SoundSlot5")
	BM9E F 0 A_FireCustomMissile("PistolEmptyMagSpawner",0,0,0,1)
	BM9E F 0 A_GiveInventory("M9Token",1)
	goto Reload5
  Reload5:
    BM9Q FGHIJKLM 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    BM9Q N 2 A_PlaySoundEx("m93r/clipin","SoundSlot5")
    BM9Q O 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmoBolt_SOH
  ReloadAmmoBolt_SOH:
    BM9Q O 0 A_JumpIfInventory("M9Clip",15,"ReloadEndBolt_SOH")
	BM9E Z 0 A_TakeInventory("M9Token",1)
    BM9Q O 0 A_JumpIfInventory("M9Ammo",1,1)
    Goto ReloadEndBolt_SOH
    BM9Q O 0 A_GiveInventory("M9Clip",1)
    BM9Q O 0 A_TakeInventory("M9Ammo",1)
    Goto ReloadAmmoBolt_SOH
  ReloadEndBolt_SOH:
    BM9Q P 0 A_TakeInventory("M9Bolt",1)
    BM9Q PQR 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    BM9Q S 2 A_PlaySoundEx("m93r/bolt","SoundSlot5")
    BM9Q TUVW 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+13
  FragGrenade:
    U45F A 0 ACS_NamedExecuteAlways("RefSpeak",0,1,0,0)
    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_NamedExecuteAlways("RefSpeed",0,0,0,0)
	M4CA J 0 A_JumpIfInventory("ThrowingStun",1,"StunGrenade")
	M4CA J 0 A_JumpIfInventory("ThrowingIncd",1,"IncGrenade")
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"FragGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("GrenadeAmmo",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",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  FragGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("GrenadeAmmo",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",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    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_NamedExecuteAlways("RefSpeed",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_NamedExecuteAlways("RefSlash",0,0,0,0)
    BM9R AB 1
    BM9R C 1 A_PlaySound("knife/swing")
    BM9R D 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    BM9R EF 1
    TNT1 AAA 5
    BM9R L 0 A_TakeInventory("ThrowingGrenade",1)
    BM9R L 0 A_TakeInventory("KnifeAttack",1)
    BM9L A 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack_Commando:
    BM9R A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    BM9R AB 1
    BM9R C 1 A_PlaySound("knife/swing")
    BM9R D 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    BM9R EF 1
    TNT1 AAA 5
    BM9R L 0 A_TakeInventory("ThrowingGrenade",1)
    MB9R L 0 A_TakeInventory("KnifeAttack",1)
    BM9L A 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack_SOH:
    BM9R A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_SOH_Commando")
    BM9R A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    BM9R AB 1
    BM9R C 1 A_PlaySound("knife/swing")
    BM9R D 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    BM9R EF 1
    TNT1 A 5
    BM9R L 0 A_TakeInventory("ThrowingGrenade",1)
    BM9R L 0 A_TakeInventory("KnifeAttack",1)
    BM9L A 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack_SOH_Commando:
    BM9R A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    BM9R AB 1
    BM9R C 1 A_PlaySound("knife/swing")
    BM9R D 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    BM9R EF 1
    TNT1 A 5
    BM9R L 0 A_TakeInventory("ThrowingGrenade",1)
    BM9R L 0 A_TakeInventory("KnifeAttack",1)
    BM9L A 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  StunGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"StunGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  IncGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"IncGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  StunGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  IncGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 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("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  DropWeapon:
    BM9L JIHGFEDCBA 2 A_WeaponReady(WRF_NOPRIMARY)
    BM9L A 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CC F 0 A_JumpIfInventory("weapondropper",2,"ThrowWeapon")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",1)
	M4CB A 0 A_FireCustomMissile("M9Dropped",0,0,7,2)
	stop
  ThrowWeapon:
    GRNA IKMN 1
	KNFA B 0 A_PlaySound("knife/swing")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",2)
	M4CB A 0 A_FireCustomMissile("M9Thrown",0,0,7,2)
	stop
  }
}

actor M9Knife : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor M9Pickup : CustomInventory
{
  inventory.pickupmessage "You got the Beretta M9 pistol."
  inventory.pickupsound "deagle/bolt"
  +INVENTORY.AUTOACTIVATE
  //inventory.respawntics 70
  scale 0.1
  States
  {
  Spawn:
    WEP2 E -1
    stop
  Pickup:
    WEP2 E 0
    WEP2 E 0 A_JumpIf((ACS_NamedExecuteWithResult("RefCheckVar",0,0,0)) == 1, "PickupStay")
    WEP2 E 0 A_JumpIfInventory("Beretta M9",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Akimbo",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Tac Knife",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Ex Mags",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEP2 E 0 A_JumpIfInventory("MaxWeaponsFilled",96,"FailPickup2")
	WEP2 E 0 A_GiveInventory("MaxWeaponsFilled",5)
    WEP2 E 0 ACS_NamedExecuteWithResult("RefPickU",31,0,0)
    stop
  PickupStay:
    WEP2 E 0
    WEP2 E 0 A_JumpIfInventory("Beretta M9",1,"FailPickup") // If the player already has this weapon, they get more ammo for it
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Akimbo",1,"FailPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Tac Knife",1,"FailPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Ex Mags",1,"FailPickup")
    WEP2 E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEP2 E 0 A_JumpIfInventory("MaxWeaponsFilled",96,"FailPickup2")
	WEP2 E 0 A_GiveInventory("MaxWeaponsFilled",5)
    WEP2 E 0 ACS_NamedExecuteWithResult("RefPickU",31,0,0)
    WEP2 E 0 ACS_NamedExecuteWithResult("RefPickC",31,0,0)
    WEP2 E 0 A_PlaySound("deagle/bolt")
    fail
  AmmoPickup:
    WEP2 E 0
    WEP2 E 0 A_JumpIfInventory("M9Ammo",0,"FailPickup")
    WEP2 E 0 A_GiveInventory("M9Ammo",15)
    stop
  OneManArmy:
    WEP2 E 0
	WEP2 E 0 A_JumpIfInventory("MaxWeaponsFilled",133,"FailPickup2")
	WEP2 E 0 A_GiveInventory("MaxWeaponsFilled",5)
	WEP2 E 0 ACS_NamedExecuteWithResult("RefPickU",31,0,0)
	stop
  FailPickup:
    WEP2 E 1
    fail
  FailPickup2:
    WEP2 E 1
    WEP2 E 0 ACS_NamedExecuteAlways("RefSlots",0,1,0,0)
    fail
  }
}

actor M9Drop : M9Pickup
{
  States
  {
  Spawn:
    WEP2 E -1
    stop
  Pickup:
    WEP2 E 0
    WEP2 E 0 A_JumpIfInventory("Beretta M9",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Akimbo",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Tac Knife",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Ex Mags",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEP2 E 0 A_JumpIfInventory("MaxWeaponsFilled",96,"FailPickup2")
	WEP2 E 0 A_GiveInventory("MaxWeaponsFilled",5)
    WEP2 E 0 ACS_NamedExecuteWithResult("RefPickU",31,0,0)
    stop
  }
}

actor M9Drop2 : M9Drop
{
  States
  {
  Spawn:
    WEP2 E -1
    stop
  Pickup:
    WEP2 E 0
    WEP2 E 0 A_JumpIfInventory("Beretta M9",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Akimbo",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Tac Knife",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Beretta M9 Ex Mags",1,"AmmoPickup")
    WEP2 E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEP2 E 0 A_JumpIfInventory("MaxWeaponsFilled",96,"FailPickup2")
	WEP2 E 0 A_GiveInventory("MaxWeaponsFilled",5)
    WEP2 E 0 ACS_NamedExecuteWithResult("RefPickU",31,0,0)
    stop
  AmmoPickup:
    WEP2 E 0
    stop
  }
}

actor HHCBM9 : HHBullet
{
  damage (random(13,19))
  Speed 300
  States
  {
  Spawn:
    TNT1 A 10
    TNT1 A 5 A_ScaleVelocity(0.667)
    stop
  Death:
    TNT1 A 0 A_SpawnItemEx("ImpactSmokePuff", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    TNT1 A 5 A_PlaySound("generic/ricochet")
    stop
  XDeath:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
    TNT1 A 5 A_PlaySound("generic/ricochets")
    stop
  Crash:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
    TNT1 A 0 A_SpawnItemEx("ImpactSmokePuff_2", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    TNT1 A 5 A_PlaySound("generic/ricochet")
    stop
  }
}

actor HHCBM9A : HHCBM9
{
  damage (random(13,19))
}