ACTOR PDDY357LX : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "DY357-LX"
        Weapon.Ammotype1 "DY357LXClip"
  Weapon.Ammotype2 "PDMagnumAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 6
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a DY357-LX."
  Obituary  "%k's DY357-LX tore %o's head right off."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 E -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK32 A 2 
    TK32 B 2
    TK32 C 2
    TK32 D 2
    TK32 EF 1
    TK32 G -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK32 G 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+6
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("DY357LXClip",6,2)
	 KLBG A 0 A_JumpIfInventory("PDMagnumAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+6

  ReloadStart:
	 TK33 DEFGHIJKLOPQRSTUVXYZ 1
	 TK34 A 1
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/DY357MagnumReload")
	 TK34 BCDEFGHIJKLOPQRSTUVXYZ 1
	 TK35 ABCDEFGHIJKLOPQRSTUVXYZ 1
	 TK36 AB 2
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDMagnumAmmo",1)
	 TNT1 A 0 A_GiveInventory("DY357LXClip",1)
	 TNT1 A 0 A_JumpIfInventory("DY357LXClip",6,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDMagnumAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK36 CDEFGHIJK 1
	 Goto Ready+6
	
  Deselect:
    TK33 ABC 1
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  KLBG A 0 A_JumpIfNoAmmo("ReloadCheck")
    TL60 ABCDEFG 1
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/DY357LX","Weapon")
    TL60 H 1 BRIGHT A_FireBullets(0, 0, 1, 200, "BulletPuff",FBF_USEAMMO)
    TL60 IJKLMNOPQRSTUV 2
    Goto Ready+7
	Altfire:
	TL79 ABCDEFGH 1
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/PistolWinp","Weapon")
	TL79 IJK 1
	TL79 L 1
	MK45 T 0 A_CustomPunch(14, false, 0, "PDPunchPuff")
	TL79 MNOPQRSTUVXYZ 1
	Goto Ready+7
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

ACTOR PDDY357LXPickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a DY357-LX."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKA4 E -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDDY357LX")
	  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
   }
}
