actor "FAMAS" : RGUWeapon
{
  obituary "%k shot %o down with the FAMAS."
  inventory.pickupmessage "FAMAS"  
  //attacksound "g2/fire"
  weapon.selectionorder 5
  weapon.ammotype "FamasClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "FamasAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    FAMA A 0 
    FAMA A 2 //A_PlayWeaponSound("g2/select")
    FAMA BCDEFGHIJKLMN 2 A_WeaponReady(WRF_NOPRIMARY)
    FAMA N 0 A_JumpIfNoAmmo("Reload")
    FAMA N 0 A_JumpIfInventory("Aiming",1,5)
    FAMA N 0 A_JumpIfInventory("Reloading",1,"Reload")
    FAMA N 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    FAMA N 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMA N 0 
    FAMA N 1 A_WeaponReady
    goto Ready+15
    FAMF G 0 A_JumpIfInventory("Reloading",1,"Reload")    
    FAMF G 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    FAMF G 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMF G 1 A_WeaponReady(WRF_NOBOB)
    goto Ready+22
  ReadyM203:
    FAMG J 0 A_TakeInventory("UsingM203",1)
    FAMG J 2 A_PlayWeaponSound("m9/select")
    FAMG IHGFEDCBA 2 A_WeaponReady
    goto Ready+15
  Deselect:
    FAMA N 0 A_TakeInventory("Aiming",1)
    FAMF A 0 ACS_ExecuteAlways(602,0,0,0,0)
    SPSA L 0 A_TakeInventory("Reloading",1)
    INTA L 0 A_ZoomFactor(1.0)
    FAMA N 0 A_Lower
    FAMA N 1 A_Lower
    goto Deselect+2
  Select:
    FAMA A 0 A_Raise
	FAMA A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 F 0 A_GiveInventory("InCombatCrosshair", 35)
    loop
  Spawn:
    WEAP G 15
    TNT1 A 0 A_SpawnItem("FamasPickup")
    stop
  Fire:	
    FAMB A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    FAMA N 1 A_JumpIfNoAmmo("ReloadStart")
    FAMB A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,-3)
    FAMB A 1 BRIGHT A_FireBullets (7.0, 7.0, -1, 16, "RiflePuff", 1, 8000)
    FAMB A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMB A 0 A_JumpIfNoAmmo("FireEmpty")
    FAMB C 1 BRIGHT A_GunFlash
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,-3)
    FAMB B 1 BRIGHT A_FireBullets (7.0, 7.0, -1, 16, "RiflePuff", 1, 8000)
    FAMB A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMB A 0 A_JumpIfNoAmmo("FireEmpty")
    FAMB D 1 BRIGHT A_GunFlash
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,-3)
    FAMB A 1 BRIGHT A_FireBullets (7.0, 7.0, -1, 16, "RiflePuff", 1, 8000)
    FAMB A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMB A 0 A_JumpIfNoAmmo("FireEmpty")
    FAMB C 1 BRIGHT A_GunFlash
    FAMB CDE 1
    FAMB A 0 A_JumpIfInventory("FamasAmmo",1,2)
    FAMB A 0 A_ReFire
    goto Ready+15
    FAMB A 0 A_JumpIfNoAmmo("ReloadStart")
    FAMB A 0 A_ReFire
    goto Ready+15
  FireEmpty:
    FAMB C 1 BRIGHT A_GunFlash
    FAMB D 1 A_GiveInventory("FamasBolt",1)
    FAMB E 1
    FAMB A 0 A_JumpIfInventory("FamasAmmo",1,2)
    FAMB A 0 A_ReFire
    goto Ready+15
    FAMB A 0 A_JumpIfNoAmmo("ReloadStart")
    FAMB A 0 A_ReFire
    goto Ready+15
  Hold:
    FAMA N 3 A_JumpIfInventory("Aiming",1,"HoldAim")
    FAMA N 1 A_ReFire
    goto Ready+15
  HoldAim:
    FAMF G 3
    FAMF G 1 A_ReFire
    goto Ready+22
  FireAim:
    FAMF G 1 A_JumpIfNoAmmo("ReloadStart")
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,-3)
    FAMF H 1 BRIGHT A_FireBullets (1, 1, -1, 16, "RiflePuff", 1, 8000)
    FAMF A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMF A 0 A_JumpIfNoAmmo("FireAimEmpty")
    FAMF J 1 BRIGHT A_GunFlash
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,-3)
    FAMF I 1 BRIGHT A_FireBullets (1, 1, -1, 16, "RiflePuff", 1, 8000)
    FAMF A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMF A 0 A_JumpIfNoAmmo("FireAimEmpty")
    FAMF J 1 BRIGHT A_GunFlash
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,0,-3)
    FAMF H 1 BRIGHT A_FireBullets (1, 1, -1, 16, "RiflePuff", 1, 8000)
    FAMF A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMF A 0 A_JumpIfNoAmmo("FireAimEmpty")
    FAMF I 1 BRIGHT A_GunFlash
    FAMF JGG 1
    FAMF A 0 A_JumpIfInventory("FamasAmmo",1,2)
    FAMF A 0 A_ReFire
    goto Ready+22
    FAMF A 0 A_JumpIfNoAmmo("ReloadStart")
    FAMF A 0 A_ReFire
    goto Ready+22
  FireAimEmpty:
    FAMF I 1 BRIGHT A_GunFlash
    FAMF JGG 1 A_GiveInventory("FamasBolt",1)
    FAMF A 0 A_JumpIfInventory("FamasAmmo",1,2)
    FAMF A 0 A_ReFire
    goto Ready+22
    FAMF A 0 A_JumpIfNoAmmo("ReloadStart")
    FAMF A 0 A_ReFire
    goto Ready+22
  Reload: //AltFire:
    VECC A 0 A_JumpIfInventory("FamasAmmo",1,"ReloadStart")
    VECC A 0 A_TakeInventory("Reloading",1)
    goto Ready+18
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    FAMC A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    FAMC A 3 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    FAMC BCDEFGH 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC I 3 A_PlaySoundEx("g2/clipout","SoundSlot5")
    FAMC JKLMNO 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC PQRSTUV 3 A_WeaponReady(WRF_NOFIRE)
    FAMC W 3 A_TakeInventory("Reloading",1)
    FAMC X 3 A_PlayWeaponSound("g2/clipin")
    goto ReloadAmmo
  ReloadAmmo:
    FAMC I 0 A_GiveInventory("FamasClip",1)
    FAMC I 0 A_TakeInventory("FamasAmmo",1)
    FAMC I 0 A_JumpIfInventory("FamasClip",30,"ReloadEnd")
    FAMC I 0 A_JumpIfInventory("FamasAmmo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    FAMC YZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD A 3 A_JumpIfInventory("FamasBolt",1,"ReloadEndBolt")
    FAMD BCD 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD EFG 3 A_WeaponReady(WRF_NOFIRE)
    FAMD M 0 A_ReFire
    goto Ready+15
  ReloadEndBolt:
    FAMD A 0 A_TakeInventory("FamasBolt",1)
    FAMD ABCHI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD J 0 A_PlaySound("g2/bolt")
    FAMD JKLM 3 A_WeaponReady(WRF_NOFIRE)
    FAMD N 3 
    FAMD OPQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD M 0 A_ReFire
    goto Ready+15
  AltFire:
    FAMF A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    U45F A 0 A_ZoomFactor(1.25)
    FAMF ABCDEF 1
    FAMF G 0 A_GiveInventory("Aiming",1)
    FAMF G 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto Ready+22
  AltFire2:
    U45F A 0 A_ZoomFactor(1.0)
    FAMF FEDCBA 1
    FAMF A 0 A_TakeInventory("Aiming",1)
    FAMF A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto Ready+15
  ReloadStartAim:
    U45F A 0 A_ZoomFactor(1.0)
    FAMF FEDCBA 1
    FAMF A 0 A_TakeInventory("Aiming",1)
    FAMF 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
  Fire_SteadyAim:
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,-3)
    FAMB A 1 BRIGHT A_FireBullets (4.62, 4.62, -1, 16, "RiflePuff", 1, 8000)
    FAMB A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMB A 0 A_JumpIfNoAmmo("FireEmpty")
    FAMB C 1 BRIGHT A_GunFlash
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,-3)
    FAMB B 1 BRIGHT A_FireBullets (4.62, 4.62, -1, 16, "RiflePuff", 1, 8000)
    FAMB A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMB A 0 A_JumpIfNoAmmo("FireEmpty")
    FAMB D 1 BRIGHT A_GunFlash
    FAMF A 0 A_PlayWeaponSound("g2/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMF A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,-3)
    FAMB A 1 BRIGHT A_FireBullets (4.62, 4.62, -1, 16, "RiflePuff", 1, 8000)
    FAMB A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMB A 0 A_JumpIfNoAmmo("FireEmpty")
    FAMB C 1 BRIGHT A_GunFlash
    FAMB CDE 1
    FAMB A 0 A_JumpIfInventory("FamasAmmo",1,2)
    FAMB A 0 A_ReFire
    goto Ready+15
    FAMB A 0 A_JumpIfNoAmmo("ReloadStart")
    FAMB A 0 A_ReFire
    goto Ready+15
  ReloadStart_SOH:
    FAMC A 2
    FAMC BCDEFGH 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC I 2 A_PlaySoundEx("g2/clipout","SoundSlot5")
    FAMC JKLMNO 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC PQRSTUV 2 A_WeaponReady(WRF_NOFIRE)
    FAMC W 2 A_TakeInventory("Reloading",1)
    FAMC X 2 A_PlayWeaponSound("g2/clipin")
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    FAMC I 0 A_GiveInventory("FamasClip",1)
    FAMC I 0 A_TakeInventory("FamasAmmo",1)
    FAMC I 0 A_JumpIfInventory("FamasClip",30,"ReloadEnd_SOH")
    FAMC I 0 A_JumpIfInventory("FamasAmmo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    FAMC YZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD A 2 A_JumpIfInventory("FamasBolt",1,"ReloadEndBolt_SOH")
    FAMD BCD 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD EFG 2 A_WeaponReady(WRF_NOFIRE)
    FAMD M 0 A_ReFire
    goto Ready+15
  ReloadEndBolt_SOH:
    FAMD A 0 A_TakeInventory("FamasBolt",1)
    FAMD ABCHI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD J 0 A_PlaySound("g2/bolt")
    FAMD JKLM 2 A_WeaponReady(WRF_NOFIRE)
    FAMD N 2 
    FAMD OPQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD M 0 A_ReFire
    goto Ready+15
  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 FamasClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 30
    ammo.backpackamount 0
    ammo.backpackmaxamount 30
    +IGNORESKILL
}


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

actor "FAMAS M203" : RGUWeapon
{
  obituary "%k popped %o with the FAMAS M203!"
  inventory.pickupmessage "FAMAS M203"  
  //attacksound "g2/fire"
  weapon.selectionorder 22
  weapon.ammotype "M203Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "M203Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    FAMG A 2 //A_PlayWeaponSound("m9/select")
    FAMG BCDEFGHIJ 2 A_WeaponReady(WRF_NOFIRE)
    FAMG K 0 A_JumpIfNoAmmo("Reload")
    FAMG K 0 A_JumpIfInventory("Reloading",1,"Reload")
    FAMG K 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    FAMG K 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMA N 0 
    FAMG J 1 A_WeaponReady
    goto Ready+10
  Ready2:
    FAMA BDFHJLN 2 
    goto Ready+1
  Deselect:
    FAMG V 0 A_TakeInventory("Aiming",1)
    FAMG V 0 A_TakeInventory("UsingM203",1)
    FAMG V 0 ACS_ExecuteAlways(602,0,0,0,0)
    SPSA L 0 A_TakeInventory("Reloading",1)
    FAMG J 0 A_Lower
    FAMG J 1 A_Lower
    goto Deselect+3
  DeselectFAMAS:
    FAMG V 0 A_TakeInventory("Aiming",1)
    FAMG V 0 ACS_ExecuteAlways(602,0,0,0,0)
    SPSA L 0 A_TakeInventory("Reloading",1)
    FAMG J 0 A_Lower
    FAMG J 0 A_Lower
    goto DeselectFAMAS+2
  Select:
    FAMF A 0
    FAMF A 0 ACS_ExecuteAlways(605,0,0,0,0)
    FAMF A 0 ACS_ExecuteAlways(602,0,0,0,0)
    FAMA A 0 A_Raise
    goto Select+2
  Fire:	
    FAMG J 1 A_JumpIfNoAmmo("ReloadStart")
    FAMG A 0 A_PlayWeaponSound("hk69/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    FAMG A 0 A_FireCustomMissile("WeaponSmokePuffLong",3,0,4,-4)
    FAMG A 0 A_FireCustomMissile("WeaponSmokePuffLong",0,0,8,0)
    FAMG A 0 A_FireCustomMissile("WeaponSmokePuffLong",-3,0,12,-4)
    FAMH A 1 BRIGHT A_FireCustomMissile("M203Shell",0,1,8,8)
    FAMH A 0 ACS_ExecuteAlways(600,0,0,0,0)
    FAMH B 1 BRIGHT A_GunFlash
    FAMH CDEFGHI 1
    FAMH A 0 A_JumpIfInventory("M203Ammo",1,2)
    FAMH A 0 A_ReFire
    goto Ready+10
    FAMH A 0 A_JumpIfNoAmmo("ReloadStart")
    FAMH A 0 A_ReFire
    goto Ready+10
  Hold:
    FAMG J 1 
    FAMG J 1 A_ReFire
    goto Ready+10
  AltFire:
    FAMG J 5 
    goto Ready+10
  Reload: //AltFire:
    FAMI A 0 A_JumpIfInventory("M203Ammo",1,"ReloadStart")
    FAMI A 0 A_TakeInventory("Reloading",1)
    goto Ready+14
  ReloadStart:
  	FAMI A 3 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    FAMI BCDE 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMI F 3 A_PlaySoundEx("hk69/open","SoundSlot5")
    FAMI GHIJKLM 3 A_WeaponReady(WRF_NOFIRE)
    FAMI N 3 A_TakeInventory("Reloading",1)
    FAMI O 3 A_PlayWeaponSound("hk69/in")
    goto ReloadAmmo
  ReloadAmmo:
    FAMC I 0 A_GiveInventory("M203Clip",1)
    FAMC I 0 A_TakeInventory("M203Ammo",1)
    FAMC I 0 A_JumpIfInventory("M203Clip",1,"ReloadEnd")
    FAMC I 0 A_JumpIfInventory("M203Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    FAMI PQRSTUVWX 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMI Y 3 A_PlaySound("hk69/close")
    FAMI Z 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMJ ABCD 3 A_WeaponReady(WRF_NOFIRE)
    FAMJ D 0 A_ReFire
    goto Ready+10
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  Spawn:
    WEAP G 15
    TNT1 A 0 A_SpawnItem("FamasPickup")
    stop
  ReloadStart_SOH:
    FAMI A 2 
    FAMI BCDE 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMI F 2 A_PlaySoundEx("hk69/open","SoundSlot5")
    FAMI GHIJKLM 2 A_WeaponReady(WRF_NOFIRE)
    FAMI N 2 A_TakeInventory("Reloading",1)
    FAMI O 2 A_PlayWeaponSound("hk69/in")
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    FAMC I 0 A_GiveInventory("M203Clip",1)
    FAMC I 0 A_TakeInventory("M203Ammo",1)
    FAMC I 0 A_JumpIfInventory("M203Clip",1,"ReloadEnd_SOH")
    FAMC I 0 A_JumpIfInventory("M203Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    FAMI PQRSTUVWX 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMI Y 2 A_PlaySound("hk69/close")
    FAMI Z 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMJ ABCD 2 A_WeaponReady(WRF_NOFIRE)
    FAMJ D 0 A_ReFire
    goto Ready+10
  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 M203Clip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 1
    ammo.backpackamount 0
    ammo.backpackmaxamount 1
    +IGNORESKILL
}

actor M203Ammo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 3
    ammo.backpackamount 1
    ammo.backpackmaxamount 6
    +IGNORESKILL
}

//Check if using M203
actor UsingM203 : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}

actor M203Shell
{
  obituary "%k popped %o with the M203!"
  radius 5
  height 5
  speed 45
  damage (35)
  deathsound "generic/fleshhit"
  PROJECTILE
  -NOGRAVITY
  +RANDOMIZE
  +NOEXTREMEDEATH
  +FORCERADIUSDMG
  +CANBOUNCEWATER
  -NOTELEPORT
  Scale 0.05
  gravity 0.4
  bouncefactor 0.5
  DamageType "Explosion"
  states
  {
  Spawn:
    G69X AAAAAA 1 A_SpawnItemEx("FlightSmokePuff", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    G69X A 0 A_GiveInventory("M203Armed",1)
    Loop
  XDeath:
    TNT1 A 0 
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
  Death:
    TNT1 A 0 A_JumpIfInventory("M203Armed",1,"DeathArmed")
    TNT1 A 0 A_Explode(220,16,0)
    TNT1 A 20 A_SpawnItemEx("M203ShellUnarmedDrop",0,0,0,-2,0,2,random(-8,8),0,0)
    stop
  DeathArmed:
    TNT1 AAAA 0 A_SpawnItemEx("ExplosionMain",random(-8,8),random(-8,8),0,0,0,0,0,0,0)
    TNT1 AAAAAAAAAA 0 A_SpawnItemEx("ImpactSpark2", random(-32,32), random(-32,32), random(-32,32), random(-5,5), random(-5,5), random(-1,5), 0, 128, 0)
    TNT1 AAAAAAAAAA 0 A_SpawnItemEx("ImpactSpark2", random(-32,32), random(-32,32), random(-32,32), random(-5,5), random(-5,5), random(-1,5), 0, 128, 0)
	TNT1 A 0 A_JumpIfInTargetInventory("Perk2_DangerClose_Pro", 1, "DangerClosePro")
    TNT1 A 0 A_Explode(100,80)
    TNT1 A 0 A_Explode(80,135)
	TNT1 A 20
    stop
  DangerClosePro:
    TNT1 A 0 A_Explode(100,125)
    TNT1 A 0 A_Explode(80,200)
	TNT1 A 20
	stop
  }
}

//Grenades need .2 or so seconds before it arms.
actor M203Armed : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}


ACTOR M203ShellUnarmedDrop
{
  Speed 1
  Height 1
  Radius 0
  Scale 0.03
  gravity 0.5
  bouncefactor 0.5
  bouncecount 3
  +DOOMBOUNCE
  +MISSILE
  SeeSound "misc/shell"
  DeathSound "misc/shell"
  States
  {
  Spawn:
    G69X A 0 
    G69X AAAAA 5 A_SpawnItemEx("FlightSmokePuff", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    G69X A -1
    Loop
  Death:
    G69X A 1050
    Stop
  }
}
actor "FAMAS Ex Mags" : "FAMAS"
{
  obituary "%k shot %o down with the FAMAS."
  inventory.pickupmessage "FAMAS"  
  //attacksound "g2/fire"
  weapon.selectionorder 5
  weapon.ammotype "FamasClip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "FamasAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Reload: //AltFire:
    VECC A 0 A_JumpIfInventory("FamasAmmo",1,"ReloadStart")
    VECC A 0 A_TakeInventory("Reloading",1)
    goto Ready+18
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    FAMC A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    FAMC A 3 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    FAMC BCDEFGH 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC I 3 A_PlaySoundEx("g2/clipout","SoundSlot5")
    FAMC JKLMNO 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC PQRSTUV 3 A_WeaponReady(WRF_NOFIRE)
    FAMC W 3 A_TakeInventory("Reloading",1)
    FAMC X 3 A_PlayWeaponSound("g2/clipin")
    goto ReloadAmmo
  ReloadAmmo:
    FAMC I 0 A_GiveInventory("FamasClip2",1)
    FAMC I 0 A_TakeInventory("FamasAmmo",1)
    FAMC I 0 A_JumpIfInventory("FamasClip2",45,"ReloadEnd")
    FAMC I 0 A_JumpIfInventory("FamasAmmo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    FAMC YZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD A 3 A_JumpIfInventory("FamasBolt",1,"ReloadEndBolt")
    FAMD BCD 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD EFG 3 A_WeaponReady(WRF_NOFIRE)
    FAMD M 0 A_ReFire
    goto Ready+15
  ReloadEndBolt:
    FAMD A 0 A_TakeInventory("FamasBolt",1)
    FAMD ABCHI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD J 0 A_PlaySound("g2/bolt")
    FAMD JKLM 3 A_WeaponReady(WRF_NOFIRE)
    FAMD N 3 
    FAMD OPQRS 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD M 0 A_ReFire
    goto Ready+15
  ReloadStart_SOH:
    FAMC A 2
    FAMC BCDEFGH 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC I 2 A_PlaySoundEx("g2/clipout","SoundSlot5")
    FAMC JKLMNO 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMC PQRSTUV 2 A_WeaponReady(WRF_NOFIRE)
    FAMC W 2 A_TakeInventory("Reloading",1)
    FAMC X 2 A_PlayWeaponSound("g2/clipin")
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    FAMC I 0 A_GiveInventory("FamasClip2",1)
    FAMC I 0 A_TakeInventory("FamasAmmo",1)
    FAMC I 0 A_JumpIfInventory("FamasClip2",45,"ReloadEnd_SOH")
    FAMC I 0 A_JumpIfInventory("FamasAmmo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    FAMC YZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD A 2 A_JumpIfInventory("FamasBolt",1,"ReloadEndBolt_SOH")
    FAMD BCD 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD EFG 2 A_WeaponReady(WRF_NOFIRE)
    FAMD M 0 A_ReFire
    goto Ready+15
  ReloadEndBolt_SOH:
    FAMD A 0 A_TakeInventory("FamasBolt",1)
    FAMD ABCHI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD J 0 A_PlaySound("g2/bolt")
    FAMD JKLM 2 A_WeaponReady(WRF_NOFIRE)
    FAMD N 2 
    FAMD OPQRS 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    FAMD M 0 A_ReFire
    goto Ready+15
  ReloadStartAim:
    U45F A 0 A_ZoomFactor(1.0)
    FAMF FEDCBA 1
    FAMF A 0 A_TakeInventory("Aiming",1)
    FAMF A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  }
}

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

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

