ACTOR PDKF7Special : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "KF7 Special"
        Weapon.Ammotype1 "KF7SpecialClip"
  Weapon.Ammotype2 "PDRifleAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 30
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a KF7 Special."
  Obituary  "%o got all ground up nastily with %k's KF7 Special."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKB4 K -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TL39 A 2 
    TL39 B 2
    TL39 C 2
    TL39 D 2
    TL39 E -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TL39 E 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+5
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("KF7SpecialClip",30,2)
	 KLBG A 0 A_JumpIfInventory("PDRifleAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+5

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/GoldenEyeReload")
     TL40 BCD 2
	 TNT1 A 10
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDRifleAmmo",1)
	 TNT1 A 0 A_GiveInventory("KF7SpecialClip",1)
	 TNT1 A 0 A_JumpIfInventory("KF7SpecialClip",30,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDRifleAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TL40 EFGHIJ 2
	 Goto Ready+5
	
  Deselect:
    TL39 YZ 2
	TL40 A 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_PlaySound ("PerfectDark/Weapons/KF7Special","Weapon")
    TL39 F 2 BRIGHT A_FireBullets(2, 2, 1, 11, "BulletPuff",FBF_USEAMMO)
	PP7G B 0 BRIGHT A_SpawnItemEx ("PDPointedBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
	TL39 G 1
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/KF7Special","Weapon")
    TL39 H 2 BRIGHT A_FireBullets(2, 2, 1, 11, "BulletPuff",FBF_USEAMMO)
	PP7G B 0 BRIGHT A_SpawnItemEx ("PDPointedBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
	TL39 I 1
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/KF7Special","Weapon")
    TL39 J 2 BRIGHT A_FireBullets(2, 2, 1, 11, "BulletPuff",FBF_USEAMMO)
	PP7G B 0 BRIGHT A_SpawnItemEx ("PDPointedBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
    TL39 O 1 
	TL39 P 2 A_REFIRE
	TL39 QRSTUVX 2 
    Goto Ready+5
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR PDKF7SpecialPickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a KF7 Special."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKB4 K -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDKF7Special")
	  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
   }
}
