actor "AK-47" : RGUWeapon
{
  obituary "%k terrorized %o with the AK-47."
  inventory.pickupmessage "AK-47"  
  //attacksound "acr/fire"
  weapon.selectionorder 4
  weapon.ammotype "AK47Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "AK47Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Ready:
    AKMA A 2 //A_PlayWeaponSound("m9/select")
    AKMA BCDEFGHIJKLM 2 A_WeaponReady(WRF_NOPRIMARY)
    AKMA M 0 A_JumpIfNoAmmo("Reload")
    AKMA M 0 A_JumpIfInventory("Aiming",1,5)
    AKMA M 0 A_JumpIfInventory("Reloading",1,"Reload")
    AKMA M 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    AKMA M 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMA N 1 A_WeaponReady
    goto Ready+13
    AKMC E 0 A_JumpIfInventory("Reloading",1,"Reload")    
    AKMC E 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    AKMC E 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMC E 1 A_WeaponReady(WRF_NOBOB)
    goto Ready+19
  Deselect:
    AKMA K 0 A_TakeInventory("Aiming",1)
    AKMA K 0 ACS_ExecuteAlways(602,0,0,0,0)
    AKMA K 0 A_TakeInventory("Reloading",1)
    AKMA L 0 A_ZoomFactor(1.0)
    AKMA K 0 A_Lower
    AKMA K 1 A_Lower
    goto Deselect+2
  Select:
    AKMA A 0 A_Raise
	AKMA A 0 ACS_ExecuteAlways(602,0,0,0,0)
	TNT1 F 0 A_GiveInventory("InCombatCrosshair", 35)
    loop
  Fire:	
    AKMB A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    AKMB A 0 A_PlayWeaponSound("ak47/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    AKMB A 0 A_FireCustomMissile("WeaponSmokePuff_BigMuzzle",0,0,7,4)
    AKMB A 1 BRIGHT A_FireBullets (8.0, 8.0, -1, 26, "RiflePuff", 1, 6000)
    AKMB B 0 BRIGHT ACS_ExecuteAlways(600,0,0,0,0)
    AKMB A 0 A_JumpIfNoAmmo("FireEmpty")
    AKMB BCD 1 BRIGHT A_GunFlash
    AKMB A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMB E 1 A_ReFire
    goto Ready+13
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB CDE 1 A_ReFire
    goto Ready+13
  Hold:
    AKMB A 0 A_JumpIfInventory("Aiming",1,"HoldAim")
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Hold_SteadyAim")
    AKMB A 0 A_PlayWeaponSound("ak47/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    AKMB A 0 A_FireCustomMissile("WeaponSmokePuff_BigMuzzle",0,0,7,4)
    AKMB A 1 BRIGHT A_FireBullets (12.0, 12.0, -1, 26, "RiflePuff", 1, 6000)
    AKMB B 0 BRIGHT ACS_ExecuteAlways(600,0,0,0,0)
    AKMB A 0 A_JumpIfNoAmmo("FireEmpty")
    AKMB BCD 1 BRIGHT A_GunFlash
    AKMB A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMB E 1 A_ReFire
    goto Ready+13
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB CDE 1 A_ReFire
    goto Ready+13
  FireEmpty:
    AKMB B 1 BRIGHT A_GunFlash
    AKMB CDE 1 A_GiveInventory("AK47Bolt",1)
    AKMB A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMB E 1 A_ReFire
    goto Ready+13
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB E 1 A_ReFire
    goto Ready+13
  FireAim:
    AKMD A 0 A_PlayWeaponSound("ak47/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    AKMD A 0 A_FireCustomMissile("WeaponSmokePuff_BigMuzzle",0,0,0,6)
    AKMD A 1 BRIGHT A_FireBullets (1.5, 1.5, -1, 26, "RiflePuff", 1, 6000)
    AKMD B 0 BRIGHT ACS_ExecuteAlways(600,0,0,0,0)
    AKMD A 0 A_JumpIfNoAmmo("FireAimEmpty")
    AKMD BCD 1 BRIGHT A_GunFlash
    AKMD A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMD E 1 A_ReFire
    goto Ready+13
    AKMD A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMD CDE 1 A_ReFire
    goto Ready+13
  HoldAim:
    AKMD A 0 A_PlayWeaponSound("ak47/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    AKMD A 0 A_FireCustomMissile("WeaponSmokePuff_BigMuzzle",0,0,0,6)
    AKMD A 1 BRIGHT A_FireBullets (5, 5, -1, 26, "RiflePuff", 1, 6000)
    AKMD B 0 BRIGHT ACS_ExecuteAlways(600,0,0,0,0)
    AKMD A 0 A_JumpIfNoAmmo("FireAimEmpty")
    AKMD BCD 1 BRIGHT A_GunFlash
    AKMD A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMD E 1 A_ReFire
    goto Ready+13
    AKMD A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMD CDE 1 A_ReFire
    goto Ready+13
  FireAimEmpty:
    AKMD B 1 BRIGHT A_GunFlash
    AKMD CDE 1 A_GiveInventory("AK47Bolt",1)
    AKMD A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMD E 1 A_ReFire
    goto Ready+13
    AKMD A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMD E 1 A_ReFire
    goto Ready+13
  Reload: //AltFire:
    AKME A 0 A_JumpIfInventory("AK47Ammo",1,"ReloadStart")
    AKME A 0 A_TakeInventory("Reloading",1)
    goto Ready+16
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    AKME A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    AKME A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    AKME A 3 A_PlaySoundEx("ak47/clipout","SoundSlot5")
    AKME BCDEFG 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME HIJKL 3 A_WeaponReady(WRF_NOFIRE)
    AKME MNOPQ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME RSTU 3 A_WeaponReady(WRF_NOFIRE)
    AKME V 3 A_PlaySoundEx("ak47/clipin","SoundSlot5")
    AKME W 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    AKME Z 0 A_GiveInventory("AK47Clip",1)
    AKME Z 0 A_TakeInventory("AK47Ammo",1)
    AKME Z 0 A_JumpIfInventory("AK47Clip",30,"ReloadEnd")
    AKME Z 0 A_JumpIfInventory("AK47Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    AKME Z 0 A_JumpIfInventory("AK47Bolt",1,"ReloadEndBolt") 
    AKME XYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF AB 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF CDEFG 3 A_WeaponReady(WRF_NOFIRE)
    AKMF G 0 A_ReFire
    goto Ready+13 
  ReloadEndBolt:
    AKMD Z 0 A_TakeInventory("AK47Bolt",1)
    AKMG ABCDEF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG G 3 A_PlaySoundEx("ak47/bolt","SoundSlot5")
    AKMG HIJKL 3 A_WeaponReady(WRF_NOFIRE)
    AKMG MNOP 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG V 0 A_ReFire
    goto Ready+13 
  AltFire:
    AKMC A 0 A_ZoomFactor(1.25)
    AKMC A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    AKMC ABCDE 1
    AKMC G 0 A_GiveInventory("Aiming",1)
    AKMC G 0 ACS_ExecuteAlways(602,0,0,0,0)
    AKMC G 0 A_Refire
    goto Ready+19
  AltFire2:
    AKMC A 0 A_ZoomFactor(1.0)
    AKMC EDCBA 1
    AKMC A 0 A_TakeInventory("Aiming",1)
    AKMC A 0 ACS_ExecuteAlways(602,0,0,0,0)
    AKMC G 0 A_Refire
    goto Ready+13
  AltHold:
    AKMA N 1 A_JumpIfInventory("Aiming",1,"AltHoldAim")
    AKMA N 1 A_ReFire
    goto Ready+13
  AltHoldAim:
    AKMC E 1
    AKMC E 1 A_ReFire
    goto Ready+19
  ReloadStartAim:
    AKMC A 0 A_ZoomFactor(1.0)
    AKMC EDCBA 1
    AKMC A 0 A_TakeInventory("Aiming",1)
    AKMC 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 Z 15
    WEAP Z 0 A_SpawnItemEx("AK47Pickup")
    stop
  Fire_SteadyAim:
    AKMB A 0 A_PlayWeaponSound("ak47/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    AKMB A 0 A_FireCustomMissile("WeaponSmokePuff_BigMuzzle",0,0,7,4)
    AKMB A 1 BRIGHT A_FireBullets (5.28, 5.28, -1, 26, "RiflePuff", 1, 6000)
    AKMB B 0 BRIGHT ACS_ExecuteAlways(600,0,0,0,0)
    AKMB A 0 A_JumpIfNoAmmo("FireEmpty")
    AKMB BCD 1 BRIGHT A_GunFlash
    AKMB A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMB E 1 A_ReFire
    goto Ready+13
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB CDE 1 A_ReFire
    goto Ready+13
  Hold_SteadyAim:
    AKMB A 0 A_PlayWeaponSound("ak47/fire")
    TNT1 F 0 A_GiveInventory("InCombatCrosshair", 17)
    TNT1 F 0 A_GiveInventory("InCombat", 5)
    AKMB A 0 A_FireCustomMissile("WeaponSmokePuff_BigMuzzle",0,0,7,4)
    AKMB A 1 BRIGHT A_FireBullets (7.92, 7.92, -1, 26, "RiflePuff", 1, 6000)
    AKMB B 0 BRIGHT ACS_ExecuteAlways(600,0,0,0,0)
    AKMB A 0 A_JumpIfNoAmmo("FireEmpty")
    AKMB BCD 1 BRIGHT A_GunFlash
    AKMB A 0 A_JumpIfInventory("AK47Ammo",1,2)
    AKMB E 1 A_ReFire
    goto Ready+13
    AKMB A 0 A_JumpIfNoAmmo("ReloadStart")
    AKMB CDE 1 A_ReFire
    goto Ready+13
  ReloadStart_SOH:
    AKME A 2 A_PlaySoundEx("ak47/clipout","SoundSlot5")
    AKME BCDEFG 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME HIJKL 2 A_WeaponReady(WRF_NOFIRE)
    AKME MNOPQ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME RSTU 2 A_WeaponReady(WRF_NOFIRE)
    AKME V 2 A_PlaySoundEx("ak47/clipin","SoundSlot5")
    AKME W 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    AKME Z 0 A_GiveInventory("AK47Clip",1)
    AKME Z 0 A_TakeInventory("AK47Ammo",1)
    AKME Z 0 A_JumpIfInventory("AK47Clip",30,"ReloadEnd_SOH")
    AKME Z 0 A_JumpIfInventory("AK47Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    AKME Z 0 A_JumpIfInventory("AK47Bolt",1,"ReloadEndBolt_SOH") 
    AKME XYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF AB 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF CDEFG 2 A_WeaponReady(WRF_NOFIRE)
    AKMF G 0 A_ReFire
    goto Ready+13 
  ReloadEndBolt_SOH:
    AKMD Z 0 A_TakeInventory("AK47Bolt",1)
    AKMG ABCDEF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG G 2 A_PlaySoundEx("ak47/bolt","SoundSlot5")
    AKMG HIJKL 2 A_WeaponReady(WRF_NOFIRE)
    AKMG MNOP 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG V 0 A_ReFire
    goto Ready+13 
  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 AK47Clip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 30
    ammo.backpackamount 0
    ammo.backpackmaxamount 30
    +IGNORESKILL
}

actor AK47Bolt : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor "AK-47 Ex Mags" : "AK-47"
{
  obituary "%k terrorized %o with the AK-47."
  inventory.pickupmessage "AK-47"  
  //attacksound "acr/fire"
  weapon.selectionorder 4
  weapon.ammotype "AK47Clip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "AK47Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Reload: //AltFire:
    AKME A 0 A_JumpIfInventory("AK47Ammo",1,"ReloadStart")
    AKME A 0 A_TakeInventory("Reloading",1)
    goto Ready+16
  ReloadStart:
  	TNT1 A 0 ACS_ExecuteAlways(652,0,0,0,0) // Shout "Reloading" 
    AKME A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    AKME A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
    AKME A 3 A_PlaySoundEx("ak47/clipout","SoundSlot5")
    AKME BCDEFG 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME HIJKL 3 A_WeaponReady(WRF_NOFIRE)
    AKME MNOPQ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME RSTU 3 A_WeaponReady(WRF_NOFIRE)
    AKME V 3 A_PlaySoundEx("ak47/clipin","SoundSlot5")
    AKME W 3 A_TakeInventory("Reloading",1)
    goto ReloadAmmo
  ReloadAmmo:
    AKME Z 0 A_GiveInventory("AK47Clip2",1)
    AKME Z 0 A_TakeInventory("AK47Ammo",1)
    AKME Z 0 A_JumpIfInventory("AK47Clip2",45,"ReloadEnd")
    AKME Z 0 A_JumpIfInventory("AK47Ammo",1,"ReloadAmmo")
    goto ReloadEnd
  ReloadEnd:
    AKME Z 0 A_JumpIfInventory("AK47Bolt",1,"ReloadEndBolt") 
    AKME XYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF AB 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF CDEFG 3 A_WeaponReady(WRF_NOFIRE)
    AKMF G 0 A_ReFire
    goto Ready+13 
  ReloadEndBolt:
    AKMD Z 0 A_TakeInventory("AK47Bolt",1)
    AKMG ABCDEF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG G 3 A_PlaySoundEx("ak47/bolt","SoundSlot5")
    AKMG HIJKL 3 A_WeaponReady(WRF_NOFIRE)
    AKMG MNOP 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG V 0 A_ReFire
    goto Ready+13 
  ReloadStartAim:
    AKMC A 0 A_ZoomFactor(1.0)
    AKMC EDCBA 1
    AKMC A 0 A_TakeInventory("Aiming",1)
    AKMC A 0 ACS_ExecuteAlways(602,0,0,0,0)
    goto ReloadStart+1
  ReloadStart_SOH:
    AKME A 2 A_PlaySoundEx("ak47/clipout","SoundSlot5")
    AKME BCDEFG 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME HIJKL 2 A_WeaponReady(WRF_NOFIRE)
    AKME MNOPQ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKME RSTU 2 A_WeaponReady(WRF_NOFIRE)
    AKME V 2 A_PlaySoundEx("ak47/clipin","SoundSlot5")
    AKME W 2 A_TakeInventory("Reloading",1)
    goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    AKME Z 0 A_GiveInventory("AK47Clip2",1)
    AKME Z 0 A_TakeInventory("AK47Ammo",1)
    AKME Z 0 A_JumpIfInventory("AK47Clip2",45,"ReloadEnd_SOH")
    AKME Z 0 A_JumpIfInventory("AK47Ammo",1,"ReloadAmmo_SOH")
    goto ReloadEnd_SOH
  ReloadEnd_SOH:
    AKME Z 0 A_JumpIfInventory("AK47Bolt",1,"ReloadEndBolt_SOH") 
    AKME XYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF AB 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMF CDEFG 2 A_WeaponReady(WRF_NOFIRE)
    AKMF G 0 A_ReFire
    goto Ready+13 
  ReloadEndBolt_SOH:
    AKMD Z 0 A_TakeInventory("AK47Bolt",1)
    AKMG ABCDEF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG G 2 A_PlaySoundEx("ak47/bolt","SoundSlot5")
    AKMG HIJKL 2 A_WeaponReady(WRF_NOFIRE)
    AKMG MNOP 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    AKMG V 0 A_ReFire
    goto Ready+13 
  }
}


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

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

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