ACTOR PDCC13 : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "CC13"
        Weapon.Ammotype1 "CC13Clip"
  Weapon.Ammotype2 "PDPistolAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 8
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a CC13."
  Obituary  "%k's CC13 delivered a 7.62x25mm to %o's smiling face."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKB4 I -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TL36 A 1 
    TL36 B 1
    TL36 C 1
    TL36 D 1
    TL36 EFGHIJK 1
    TL36 L -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TL36 L 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+7
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("CC13Clip",8,2)
	 KLBG A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+10

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

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDPistolAmmo",1)
	 TNT1 A 0 A_GiveInventory("CC13Clip",1)
	 TNT1 A 0 A_JumpIfInventory("CC13Clip",8,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TL37 LMNOPQ 2
	 Goto Ready+12
	
  Deselect:
    TL37 FGH 1
    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/CC13","Weapon")
    TL36 M 1 BRIGHT A_FireBullets(0, 1, 1, 9, "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))
    TL36 NOPQ 2
	TL36 R 1 
	TL36 S 1 A_REFIRE
	TL36 TUVXYZ 1 A_REFIRE
	TL37 ABCDE 1 A_REFIRE
    Goto Ready+12
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

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