ACTOR PDAR34 : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "AR34"
        Weapon.Ammotype1 "AR34Clip"
  Weapon.Ammotype2 "PDRifleAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 30
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a AR34."
  Obituary  "%o was torn to shreds by %k's AR34."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 J -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK66 A 2 
    TK66 B 2
    TK66 C 2
    TK66 D 2
    TK66 EFGHIJKL 1
    TK66 M -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK66 M 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+7
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("AR34Clip",30,2)
	 KLBG A 0 A_JumpIfInventory("PDRifleAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+13

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/AR34Reload")
     TK67 KLMNOPQRSTUVXYZ 1
	 TK68 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK69 ABCDEFGHIJ 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDRifleAmmo",1)
	 TNT1 A 0 A_GiveInventory("AR34Clip",1)
	 TNT1 A 0 A_JumpIfInventory("AR34Clip",30,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDRifleAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK69 KLMNOPQRSTUVXYZ 1
	 TK70 AB 1
	 Goto Ready+13
	
  Deselect:
    TK67 FGHIJ 2
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  KLBG A 0 A_JumpIfNoAmmo("ReloadCheck")
 	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/AR34")
    TK66 N 2 BRIGHT A_FireBullets(2, 2, 1, 12, "BulletPuff",FBF_USEAMMO)
	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/AR34")
    TK66 M 2 BRIGHT A_FireBullets(2, 2, 1, 12, "BulletPuff",FBF_USEAMMO)
	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/AR34")
	TK66 O 2 BRIGHT A_FireBullets(2, 2, 1, 12, "BulletPuff",FBF_USEAMMO)
	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/AR34")
	TK66 Q 2 BRIGHT A_FireBullets(2, 2, 1, 12, "BulletPuff",FBF_USEAMMO)
	TNT1 A 0 A_PlayWeaponSound ("PerfectDark/Weapons/AR34")
	TK66 R 2 BRIGHT A_FireBullets(2, 2, 1, 12, "BulletPuff",FBF_USEAMMO)
	TK66 S 2
	TK66 TUVXYZ 2 A_REFIRE
	TK67 ABCDE 2 A_REFIRE
    Goto Ready+13
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

ACTOR AR34Clip : Ammo
{
Inventory.MaxAmount 30 // size of the clip
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 30 //MUST be the same as Inventory.MaxAmmount
+INVENTORY.IGNORESKILL
}

ACTOR PDAR34Pickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a AR34."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKA4 J -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDAR34")
	  TNT1 A 0 A_JumpIfInventory("PlayingasPerfectKirby",1,"PickupPerfectKirby")
	  TNT1 A 0 A_JumpIfInventory("PlayingasRED",1,"PickupRED")
	  stop
	  PickupPerfectKirby:
	 	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PerfectKirby/PerfectKirbyWeaponPickup")
		Stop
	  PickupRED:
	 	TNT1 A 0 A_PlaySound ("PerfectDark/Player/RED/REDWeaponPickup")
		Stop
   }
}
