ACTOR PDDY357Magnum : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "DY357 Magnum"
        Weapon.Ammotype1 "DY357MagnumClip"
  Weapon.Ammotype2 "PDMagnumAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 6
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a DY357 Magnum."
  Obituary  "%k dropped %o with his six shooter."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 D -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK27 A 2 
    TK27 B 2
    TK27 C 2
    TK27 D 2
    TK27 EFGHIJK 1
    TK27 L -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK27 L 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+13
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("DY357MagnumClip",6,2)
	 KLBG A 0 A_JumpIfInventory("PDMagnumAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+13

  ReloadStart:
	 TK28 OPQRSTUVXYZ 1
	 TK29 ABCDEFGHIJKLM 1
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/DY357MagnumReload")
	 TK29 NOPQRSTUVXYZ 1
	 TK30 ABC 2
	 TK30 DEFGHIJKLMNOPQRSTUVX 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDMagnumAmmo",1)
	 TNT1 A 0 A_GiveInventory("DY357MagnumClip",1)
	 TNT1 A 0 A_JumpIfInventory("DY357MagnumClip",6,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDMagnumAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK30 YZ 2
	 TK31 ABCDEFGHI 1
	 TK31 JK 2
	 TK31 LMNOPQRSTU 1
	 Goto Ready+13
	
  Deselect:
    TK28 LMN 1
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  KLBG A 0 A_JumpIfNoAmmo("ReloadCheck")
    TK27 MNOPQRSTUVX 1
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/DY357Magnum","Weapon")
    TK27 X 1 BRIGHT A_FireBullets(0, 0, 1, 30, "BulletPuff",FBF_USEAMMO)
    TK27 YZ 2
	TK28 ABCDEFGHIJK 1
    Goto Ready+13
		Altfire:
	TL59 ABCDEFGH 1
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/PistolWinp","Weapon")
	TL59 IJ 1
	TL59 K 1
	MK45 T 0 A_CustomPunch(14, false, 0, "PDPunchPuff")
	TL59 LMNOPQRSTUVXYZ 1
	Goto Ready+13
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

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