ACTOR PDFalcon2Scoped : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "Falcon 2 Scoped"
        Weapon.Ammotype1 "Falcon2ScopedClip"
  Weapon.Ammotype2 "PDPistolAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 8
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a Falcon 2 Scoped."
  Obituary  "%o was f'alcond nice and good by %k."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 H -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK10 A 1 
    TK10 B 1
    TK10 C 1
    TK10 D 1
    TK10 EFGHIJKLMNO 1
    TK10 P -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK10 P 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+9
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("Falcon2ScopedClip",8,2)
	 KLBG A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+9

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/Falcon2Reload")
	 TK11 CDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK12 ABCDEFGH 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDPistolAmmo",1)
	 TNT1 A 0 A_GiveInventory("Falcon2ScopedClip",1)
	 TNT1 A 0 A_JumpIfInventory("Falcon2ScopedClip",8,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK12 IJKLMNOPQRSTUV 1
	 Goto Ready+9
	
  Deselect:
    TK10 XYZ 2
	TK11 AB 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/Falcon2","Weapon")
    TK10 Q 1 BRIGHT A_FireBullets(1, 1, 1, 8, "BulletPuff",FBF_USEAMMO)
	PP7G B 0 BRIGHT A_SpawnItemEx ("PDBulletCasing", 30,cos(pitch)*12,sin(-pitch)*10+30, frandom(0.5,1.2),frandom(0.5,1.2),frandom(1.5,2.5))
    TK10 R 2
	TK10 S 2 
	TK10 TU 2
	TK10 V 2 A_REFIRE
    Goto Ready+9
	Altfire:
	TL57 ABCDEFGHIJK 1
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/PistolWinp","Weapon")
	TL57 L 1
	MK45 T 0 A_CustomPunch(14, false, 0, "PDPunchPuff")
	TL57 MNOPQRSTUVXYZ 1
	TL58 ABC 1
	Goto Ready+9
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR PDFalcon2ScopedPickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a Falcon 2 Scoped."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKA4 H -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDFalcon2Scoped")
	  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
   }
}
