actor SwatMinigun : Weapon
{
   Weapon.AmmoUse 1
   Weapon.AmmoGive 150
   Inventory.PickupMessage "You got the Heavy Minigun!"
   Obituary "%o was turned to a pink mist by %k's heavy minigun."
   Tag "Heavy Minigun"
   Weapon.AmmoType "SwatMinigunAmmo"
   Inventory.RestrictedTo "SwatClass"
   Decal "BulletChip"
   States
   {
   Ready:
     MMIN A 1 A_WeaponReady(WRF_ALLOWZOOM)
     Loop
   Select:
     MMIN A 1 A_Raise
	 TNT1 A 0 A_Raise
	 TNT1 A 0 A_Raise
     Loop
   Deselect:
     MMIN A 1 A_Lower
	 TNT1 A 0 A_Lower
	 TNT1 A 0 A_Lower
     Loop
   Fire:
     TNT1 A 0 A_JumpIfNoAmmo("Spindown")
     TNT1 A 0 A_JumpIfInventory("SwatMiniSpinActive", 1, "Firing")
     TNT1 A 0 A_PlaySound("swat/minigun_spinup", 5)
	 MMIN ABCD 3
     MMIN ABCD 2
	 MMIN ABCD 1
     TNT1 A 0 A_GiveInventory("SwatMiniSpinActive", 1)
     Goto Firing
  Firing:
    TNT1 A 0 A_PlaySound("swat/minigun_spin", CHAN_AUTO,0.3)
    TNT1 A 0 Radius_Quake(1, 2, 0, 1, 0)
    Goto DoFire
  DoFire:
    TNT1 A 0 A_PlaySound("Character/SwatEnforcer/Minigun", CHAN_WEAPON ,1)
	MMIN E 0 A_GunFlash
    MMIN E 1 A_RailAttack(40, 0, 1, "none", "FFEED6", RGF_SILENT , 0, "SwatMinigunPuff", 3.5, 3.5, 8192)
	TNT1 A 0 A_PlaySound("Character/SwatEnforcer/Minigun", CHAN_WEAPON ,1)
	MMIN F 0 A_GunFlash
    MMIN F 1 A_RailAttack(40, 0, 1, "none", "FFEED6", RGF_SILENT , 0, "SwatMinigunPuff", 3.5, 3.5, 8192)
    TNT1 A 0 A_JumpIfNoAmmo("SpinDownEmpty")
    MMIN A 0 A_ReFire("Firing")
    Goto SpinDown
  SpinDownEmpty:
    Goto SpinDown
  SpinDown:
   TNT1 A 0 A_PlaySound("swat/minigun_spindown", 5)
   TNT1 A 0 A_TakeInventory("SwatMiniSpinActive", 1)
   MMIN A 1
   MMIN B 1
   MMIN C 1
   MMIN D 1
   MMIN A 2
   MMIN B 2
   MMIN C 2
   MMIN D 1
   MMIN A 3
   MMIN B 3
   MMIN C 3
   MMIN D 1
   MMIN A 4
   MMIN B 4
   MMIN C 4
   MMIN D 1
	Goto Ready
  Zoom:
    TNT1 A 0 A_JumpIfInventory("HasSwatGrenades", 1, "CheckAmmo")
    Goto DontThrow
  CheckAmmo:
    TNT1 A 0 A_JumpIfInventory("SwatGrenadeAmmo", 1, "DoThrow")
    Goto DontThrow
  DoThrow:
    TNT1 A 0
    Goto ThrowFrag
  ThrowFrag:
	FGGN BCD 2
	TNT1 A 0 A_TakeInventory("SwatGrenadeAmmo", 1) // ONLY grenade ammo removed
	FGGN E 2 A_PlaySound("weapons/grnpullpin")
	FGGN FGHH 2
	FGGN J 0 A_FireCustomMissile("ThrownGrenade30", 0, 0, 0, 0)
	FGGN J 0 A_PlaySound("weapons/grntoss")
	FGGN JKLMNOPQ 2
	FGGN A 0
	NULL A 12 A_CheckReload
		Goto RaiseAfterThrow
	RaiseAfterThrow:
    MMIN A 1 Offset(0, 50)
    MMIN A 1 Offset(0, 40)
    MMIN A 1 Offset(0, 30)
		Goto Ready
	DontThrow:
		MMIN A 1
		Goto Ready
   }
}

Actor SwatMinigunPuff : BulletPuff
{
Decal BulletChip
+FOILINVUL
}

Actor SwatMiniSpinActive : Inventory { Inventory.MaxAmount 1 }

Actor SwatMinigunAmmo : Ammo
{
	Inventory.Amount 100
	Inventory.Maxamount 500
	Ammo.Backpackamount 0
	Ammo.BackpackMaxamount 999
}