ACTOR PDMauler : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "Mauler"
        Weapon.Ammotype1 "MaulerClip"
  Weapon.Ammotype2 "PDPistolAmmo"
    Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 20
  +WEAPON.AMMO_OPTIONAL
  Inventory.PickupMessage "Picked up a Mauler."
  Obituary  "Hahaha %o got absolutely mauled by %k's absurdly overpowered Mauler."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKA4 C -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TK17 A 2 
    TK17 B 2
    TK17 C 2
    TK17 D 2
    TK17 E 2
    TK17 F -1 A_WeaponReady(WRF_ALLOWRELOAD)
	goto ReloadCheck
	TK17 F 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Goto Ready+7
	
	  ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("MaulerClip",20,2)
	 KLBG A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadStart")
	 KLBG A 0
	 Goto Ready+7

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("PerfectDark/Weapons/MaulerReload")
     TK20 HIJKLMNO 1
	 TK20 PQRSTUVXYZ 1
	 TK21 ABCDEF 1
	 TK21 GHIJ 2
	 TK21 KLMNOP 1
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("PDPistolAmmo",1)
	 TNT1 A 0 A_GiveInventory("MaulerClip",1)
	 TNT1 A 0 A_JumpIfInventory("MaulerClip",20,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("PDPistolAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TK21 QRSTUVXYZ 1
	 TK22 ABC 1
	 Goto Ready+7
	
  Deselect:
    TK17 LMN 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/Mauler","Weapon")
    TK17 G 1 BRIGHT A_FireBullets(1, 1, 1, 10, "PDGreenPuff",FBF_USEAMMO)
    TK17 HI 2
	TK17 J 2 
	TK17 K 2
    Goto Ready+7
	AltFire: 
	NULL A 0 A_JumpIfInventory("MaulerClip",10,1)
  goto Ready+7
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/MaulerChange","Weapon")
    TK17 OPQRSTUVXYZ 1
	TK18 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	TK19 ABCDEFGHIJKLMNOPQRSTUVXYZ 1
	TK20 ABCDE 1
	TK20 F 2 A_Refire
	Goto AltRelease
   AltHold:
   TK20 F 1
    TK20 F 1 A_Refire
	Goto AltRelease
	AltRelease:
	  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/MaulerChangeFire","Weapon")
	  TNT1 A 0 A_TakeInventory("MaulerClip",10,TIF_NOTAKEINFINITE)
	  TK20 G 1 BRIGHT A_FireBullets(1, 1, 1, 60, "PDRedPuff")
    TK17 HI 2
	TK17 J 2 
	TK17 K 2
    Goto Ready+7
		Reload:
		TK04 A 0
		goto ReloadCheck
  }
}

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

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