actor "FN P90" : RGUWeapon
{
  obituary "%k filled %o with hot P90 lead."
  inventory.pickupmessage "FN P90"  
  //attacksound "p90/fire"
  weapon.selectionorder 12
  weapon.ammotype "P90Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "P90Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Ready:
    P90A A 2 //A_PlayWeaponSound("fal/select")
    P90A BCDEFGHIJKL 2 A_WeaponReady(WRF_NOPRIMARY)
    P90A L 0 A_JumpIfNoAmmo("Reload")
    P90A L 0 A_JumpIfInventory("Aiming",1,5)
    P90A L 0 A_JumpIfInventory("Reloading",1,"Reload")
    P90A L 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    P90A L 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90A L 1 A_WeaponReady
    goto Ready+12
    P90F F 0 A_JumpIfInventory("Reloading",1,"Reload")    
    P90F F 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    P90F F 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90F F 1 A_WeaponReady(WRF_NOBOB)
    goto Ready+18
  Deselect:
    P90A K 0 A_TakeInventory("Aiming",1)
    P90A K 0 ACS_ExecuteAlways(602,0,0,0,0)
    SPSA L 0 A_TakeInventory("Reloading",1)
    INTA L 0 A_ZoomFactor(1.0)
    P90A K 0 A_Lower
    P90A K 1 A_Lower
    goto Deselect+2
  Select:
    P90A A 0 A_Raise
	P90A A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 F 0 A_GiveInventory("InCombatCrosshair", 35)
    loop
  Fire:	
    P90A A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    P90A K 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (8.0, 8.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B C 1
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  Hold:
    P90B A 0 A_JumpIfInventory("Aiming",1,"HoldAim")
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Hold_SteadyAim")
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (12.0, 12.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B C 1
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  FireEmpty:
    P90B B 1 BRIGHT A_GunFlash
    P90B C 1 A_GiveInventory("P90Bolt",1)
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  FireAim:
    P90F A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90F A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,0)
    P90F G 1 BRIGHT A_FireBullets (1.5, 1.5, -1, 8, "HHBulletPuff", 1, 6000)
    P90F G 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90F G 0 A_JumpIfNoAmmo("FireAimEmpty")
    P90F H 1 BRIGHT A_GunFlash
    P90F I 1
    P90F A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90F A 0 A_ReFire
    goto Ready+18
    P90F A 0 A_JumpIfNoAmmo("ReloadStart")
    P90F A 0 A_ReFire
    goto Ready+18
  HoldAim:
    P90F A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90F A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,0)
    P90F G 1 BRIGHT A_FireBullets (5, 5, -1, 8, "HHBulletPuff", 1, 6000)
    P90F G 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90F G 0 A_JumpIfNoAmmo("FireAimEmpty")
    P90F H 1 BRIGHT A_GunFlash
    P90F I 1
    P90F A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90F A 0 A_ReFire
    goto Ready+18
    P90F A 0 A_JumpIfNoAmmo("ReloadStart")
    P90F A 0 A_ReFire
    goto Ready+18
  FireAimEmpty:
    P90F H 1 BRIGHT A_GunFlash
    P90F I 1 A_GiveInventory("P90Bolt",1)
    P90F A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90F A 0 A_ReFire
    goto Ready+18
    P90F A 0 A_JumpIfNoAmmo("ReloadStart")
    P90F A 0 A_ReFire
    goto Ready+18
  Reload: //AltFire:
    P90C A 0 A_JumpIfInventory("P90Ammo",1,"ReloadStart")
    P90C A 0 A_TakeInventory("Reloading",1)
    goto Ready+15
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    P90C A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    P90C A 2 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    P90C BCDEF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C G 3 A_PlaySoundEx("p90/clipout","SoundSlot5")
    P90C HIJKLMN 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C OPQRST 3 A_WeaponReady(WRF_NOFIRE)
    P90C U 3 A_TakeInventory("Reloading",1)
    P90C V 3 A_PlayWeaponSound("p90/clipin")
    goto ReloadAmmo
  ReloadAmmo:
    P90C P 0 A_GiveInventory("P90Clip",1)
    P90C P 0 A_TakeInventory("P90Ammo",1)
    P90C P 0 A_JumpIfInventory("P90Clip",50,"ReloadEnd")
    P90C P 0 A_JumpIfInventory("P90Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    P90C WXYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D A 3 A_PlaySound("p90/hit")
    P90D BCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D F 3 A_JumpIfInventory("P90Bolt",1,"ReloadEndBolt")
    P90A FGHIJKL 3 A_WeaponReady(WRF_NOFIRE)
    P90A B 0 A_ReFire
    goto Ready+12
  ReloadEndBolt:
    P90D F 3 A_TakeInventory("P90Bolt",1)
    P90D GHI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D J 3 A_PlayWeaponSound("p90/bolt")
    P90D KLMNO 3 A_WeaponReady(WRF_NOFIRE)
    P90D B 0 A_ReFire
    goto Ready+12
  AltFire:
    U45F A 0 A_ZoomFactor(1.2)
    P90F A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    P90F ABCDEF 1
    P90F G 0 A_GiveInventory("Aiming",1)
    P90F G 0 ACS_ExecuteAlways(602,0,0,0,0)
    P90F G 0 A_Refire
    goto Ready+18
  AltFire2:
    U45F A 0 A_ZoomFactor(1.0)
    P90F FEDCBA 1
    P90F A 0 A_TakeInventory("Aiming",1)
    P90F A 0 ACS_ExecuteAlways(602,0,0,0,0)
    P90F G 0 A_Refire
    goto Ready+12
  AltHold:
    P90A L 1 A_JumpIfInventory("Aiming",1,"AltHoldAim")
    P90A L 1 A_ReFire
    goto Ready+12
  AltHoldAim:
    P90F F 1
    P90F F 1 A_ReFire
    goto Ready+18
  ReloadStartAim:
    U45F A 0 A_ZoomFactor(1.0)
    P90F FEDCBA 1
    P90F A 0 A_TakeInventory("Aiming",1)
    P90F A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  Spawn:
    WEAP L 15
    WEAP L 0 A_SpawnItemEx("P90Pickup")
    stop
  Fire_SteadyAim:
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (3.0, 3.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B C 1
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  Hold_SteadyAim:
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (6.0, 6.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B C 1
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  ReloadStart_SOH:
    P90C A 2 
    P90C BCDEF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C G 2 A_PlaySoundEx("p90/clipout","SoundSlot5")
    P90C HIJKLMNOPQRST 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C U 2 A_TakeInventory("Reloading",1)
    P90C V 2 A_PlayWeaponSound("p90/clipin")
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    P90C P 0 A_GiveInventory("P90Clip",1)
    P90C P 0 A_TakeInventory("P90Ammo",1)
    P90C P 0 A_JumpIfInventory("P90Clip",50,"ReloadEnd_SOH")
    P90C P 0 A_JumpIfInventory("P90Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    P90C WXYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D A 2 A_PlaySound("p90/hit")
    P90D BCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D F 2 A_JumpIfInventory("P90Bolt",1,"ReloadEndBolt_SOH")
    P90A FGHIJKL 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90A B 0 A_ReFire
    goto Ready+12
  ReloadEndBolt_SOH:
    P90D F 2 A_TakeInventory("P90Bolt",1)
    P90D GHI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D J 2 A_PlayWeaponSound("p90/bolt")
    P90D KLMNO 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D B 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 P90Clip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 50
    ammo.backpackamount 0
    ammo.backpackmaxamount 50
    +IGNORESKILL
}

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

actor "FN P90 Ex Mags" : "FN P90"
{
  obituary "%k filled %o with hot P90 lead."
  inventory.pickupmessage "FN P90"  
  //attacksound "p90/fire"
  weapon.selectionorder 12
  weapon.ammotype "P90Clip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "P90Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Reload: //AltFire:
    P90C A 0 A_JumpIfInventory("P90Ammo",1,"ReloadStart")
    P90C A 0 A_TakeInventory("Reloading",1)
    goto Ready+15
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    P90C A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    P90C A 2 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    P90C BCDEF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C G 3 A_PlaySoundEx("p90/clipout","SoundSlot5")
    P90C HIJKLMN 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C OPQRST 3 A_WeaponReady(WRF_NOFIRE)
    P90C U 3 A_TakeInventory("Reloading",1)
    P90C V 3 A_PlayWeaponSound("p90/clipin")
    goto ReloadAmmo
  ReloadAmmo:
    P90C P 0 A_GiveInventory("P90Clip2",1)
    P90C P 0 A_TakeInventory("P90Ammo",1)
    P90C P 0 A_JumpIfInventory("P90Clip2",75,"ReloadEnd")
    P90C P 0 A_JumpIfInventory("P90Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    P90C WXYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D A 3 A_PlaySound("p90/hit")
    P90D BCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D F 3 A_JumpIfInventory("P90Bolt",1,"ReloadEndBolt")
    P90A FGHIJKL 3 A_WeaponReady(WRF_NOFIRE)
    P90A B 0 A_ReFire
    goto Ready+12
  ReloadEndBolt:
    P90D F 3 A_TakeInventory("P90Bolt",1)
    P90D GHI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D J 3 A_PlayWeaponSound("p90/bolt")
    P90D KLMNO 3 A_WeaponReady(WRF_NOFIRE)
    P90D B 0 A_ReFire
    goto Ready+12
  ReloadStart_SOH:
    P90C A 2 
    P90C BCDEF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C G 2 A_PlaySoundEx("p90/clipout","SoundSlot5")
    P90C HIJKLMNOPQRST 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90C U 2 A_TakeInventory("Reloading",1)
    P90C V 2 A_PlayWeaponSound("p90/clipin")
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    P90C P 0 A_GiveInventory("P90Clip2",1)
    P90C P 0 A_TakeInventory("P90Ammo",1)
    P90C P 0 A_JumpIfInventory("P90Clip2",75,"ReloadEnd_SOH")
    P90C P 0 A_JumpIfInventory("P90Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    P90C WXYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D A 2 A_PlaySound("p90/hit")
    P90D BCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D F 2 A_JumpIfInventory("P90Bolt",1,"ReloadEndBolt_SOH")
    P90A FGHIJKL 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90A B 0 A_ReFire
    goto Ready+12
  ReloadEndBolt_SOH:
    P90D F 2 A_TakeInventory("P90Bolt",1)
    P90D GHI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D J 2 A_PlayWeaponSound("p90/bolt")
    P90D KLMNO 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    P90D B 0 A_ReFire
    goto Ready+12
  ReloadStartAim:
    U45F A 0 A_ZoomFactor(1.0)
    P90F FEDCBA 1
    P90F A 0 A_TakeInventory("Aiming",1)
    P90F A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  }
}

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

actor P90ExMags : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor "FN P90 Rapid Fire" : "FN P90"
{
  obituary "%k filled %o with hot P90 lead."
  inventory.pickupmessage "FN P90"  
  //attacksound "p90/fire"
  weapon.selectionorder 12
  weapon.ammotype "P90Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "P90Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Fire:	
    P90A A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    P90A K 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (8.0, 8.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  Hold:
    P90B A 0 A_JumpIfInventory("Aiming",1,"HoldAim")
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Hold_SteadyAim")
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (12.0, 12.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  FireAim:
    P90F A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90F A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,0)
    P90F G 1 BRIGHT A_FireBullets (1.5, 1.5, -1, 8, "HHBulletPuff", 1, 6000)
    P90F G 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90F G 0 A_JumpIfNoAmmo("FireAimEmpty")
    P90F H 1 BRIGHT A_GunFlash
    P90F A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90F A 0 A_ReFire
    goto Ready+18
    P90F A 0 A_JumpIfNoAmmo("ReloadStart")
    P90F A 0 A_ReFire
    goto Ready+18
  HoldAim:
    P90F A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90F A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,0)
    P90F G 1 BRIGHT A_FireBullets (5.0, 5.0, -1, 8, "HHBulletPuff", 1, 6000)
    P90F G 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90F G 0 A_JumpIfNoAmmo("FireAimEmpty")
    P90F H 1 BRIGHT A_GunFlash
    P90F A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90F A 0 A_ReFire
    goto Ready+18
    P90F A 0 A_JumpIfNoAmmo("ReloadStart")
    P90F A 0 A_ReFire
    goto Ready+18
  Fire_SteadyAim:
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (5.28, 5.28, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  Hold_SteadyAim:
    P90B A 0 A_PlayWeaponSound("p90/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    P90B A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,-2)
    P90B A 1 BRIGHT A_FireBullets (7.92, 7.92, -1, 8, "HHBulletPuff", 1, 6000)
    P90B B 0 BRIGHT ACS_ExecuteAlways(600,0,120,0,0)
    P90B A 0 A_JumpIfNoAmmo("FireEmpty")
    P90B B 1 BRIGHT A_GunFlash
    P90B A 0 A_JumpIfInventory("P90Ammo",1,2)
    P90B A 0 A_ReFire
    goto Ready+12
    P90B A 0 A_JumpIfNoAmmo("ReloadStart")
    P90B A 0 A_ReFire
    goto Ready+12
  }
}

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

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