ACTOR PDRCP120 : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "RC-P120"
        Weapon.Ammotype1 "RCP120Clip"
  Weapon.Ammotype2 "PDSMGAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 120
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a RC-P120."
  Obituary  "%k tactically deleted %o with his RC-P120."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 P -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK50 A 2 
    TK50 B 2
    TK50 C 2
    TK50 D 2
    TK50 EFG 2
    TK50 H -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK50 H 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+9
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("RCP120Clip",120,2)
	 KLBG A 0 A_JumpIfInventory("PDSMGAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+9

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/RCP120Reload")
     TL49 BCDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK51 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	 TK52 ABCDEFGHIJKLM 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDSMGAmmo",1)
	 TNT1 A 0 A_GiveInventory("RCP120Clip",1)
	 TNT1 A 0 A_JumpIfInventory("RCP120Clip",120,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDSMGAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK52 NOPQRSTUVXYZ 1
	 TL50 AB 1
	 Goto Ready+9
	
  Deselect:
    TK50 XYZ 2
	TL49 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_PlayWeaponSound ("PerfectDark/Weapons/RCP120")
    TK50 I 1 BRIGHT A_FireBullets(2, 1, 1, 10, "BulletPuff",FBF_USEAMMO)
	PP7G B 0 BRIGHT A_SpawnItemEx ("PDBulletCasing", 25,cos(pitch)*4,sin(-pitch)*0+30, frandom(0.5,1.2),frandom(-2.5,1.2),frandom(1.5,2.5))
    TK50 J 2
	TK50 K 2 A_REFIRE
	TK50 LMNOPQRSTUV 2
    Goto Ready+9
	 AltFire: 
    TK50 H 1 A_CheckReload
    NULL A 0 A_JumpIfInventory ("RCP120Clip",1,2)
    TK50 H 1 A_SetTranslucent (1.0,0) 
    goto Ready
    NULL A 0 A_TakeInventory ("RCP120Clip",1)
    NULL A 0 A_PlaySound ("PerfectDark/Weapons/CLOACKON")
    TK50 H 1 A_SetTranslucent (0.1,0)
    NULL A 0 A_ReFire
	NULL A 0 A_PlaySound ("PerfectDark/Weapons/CLOAKOOF")
    TK50 H 1 A_SetTranslucent (1.0,0)
    Goto Ready+9
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR PDRCP120Pickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a RC-P120."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKA4 P -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDRCP120")
	  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
   }
}
