ACTOR SwatShotgun : Weapon
{
    Weapon.SelectionOrder 1300
    Weapon.AmmoUse 0                          // don't auto-use reserve
    Weapon.AmmoGive 16
    Weapon.AmmoType "RemingtonSlugs"          // reserve (bottom)
    Weapon.AmmoUse2 0
    Weapon.AmmoGive2 8
    Weapon.AmmoType2 "RemingtonShell"         // tube (top)
    +WEAPON.AMMO_OPTIONAL
    AttackSound "DukeShotgun/Fire"
    Decal BulletChip
    Tag "Remington Model 870"
    Inventory.PickupMessage "You got the Shotgun! Lock and load!"
    Obituary "%o was given extreme prejudice by %k's Shotgun."
    Inventory.RestrictedTo "SwatClass"

    States
    {
    Ready:
        DNSG A 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
        Loop
    Deselect:
        DNSG A 1 A_Lower
        TNT1 A 0 A_Lower
        TNT1 A 0 A_Lower
        Loop
    Select:
        DNSG A 1 A_Raise
        TNT1 A 0 A_Raise
        TNT1 A 0 A_Raise
        Loop
    Fire:
        TNT1 A 0 A_TakeInventory("ShotgunReloading",1337)       // cancel reload
        TNT1 A 0 A_JumpIfInventory("RemingtonShell",1,2)        // must have a shell in tube
        Goto ReloadCheck
        DNSG A 3
        TNT1 A 0 A_ZoomFactor(0.98, ZOOM_NOSCALETURNING)
        TNT1 A 0 A_GunFlash
        DNSG B 1 A_FireBullets(0, 0, 1, 250, "RemingtonSlugPuff", FBF_NORANDOM, 8192)
        TNT1 A 0 A_TakeInventory("RemingtonShell",1)            // manually use tube ammo ONLY
        DNSG C 1 Bright A_ZoomFactor(1.0)
        DNSG DE 1 Bright
        DNSG MNO 1
        DNSG A 3 A_CheckReload
        DNSG FGH 2
        DNSG I 3 A_PlaySound("DukeShotgun/Pump")
        DNSG JKLKJI 3
        DNSG HGF 1
        DNSG A 7 A_ReFire
        Goto Ready
    Reload:
    ReloadCheck:
        TNT1 A 0 A_JumpIfInventory("ShotgunReloading",1,"Ready") // already reloading
        TNT1 A 0 A_JumpIfInventory("RemingtonShell",8,"Ready")   // tube full
        TNT1 A 0 A_JumpIfInventory("RemingtonSlugs",1,"ReloadStart") // reserve check
        Goto Ready
    ReloadStart:
        TNT1 A 0 A_GiveInventory("ShotgunReloading",1)
        DNSG F 4
        DNSG G 4
        Goto ShellInsert
    ShellInsert:
        DNSG I 5
        DNSG J 5 A_PlaySound("Character/SwatEnforcer/ShotgunReload")
        TNT1 A 0 A_GiveInventory("RemingtonShell",1)
        TNT1 A 0 A_TakeInventory("RemingtonSlugs",1)
        TNT1 A 0 A_JumpIfInventory("RemingtonShell",8,"ReloadEndCock")
        TNT1 A 0 A_JumpIfInventory("RemingtonSlugs",1,"ShellInsert")
        Goto ReloadEndCock
    ReloadEndCock:
        DNSG K 4 A_PlaySound("DukeShotgun/Pump")
        DNSG L 4
        DNSG K 4
        DNSG J 4
        DNSG IHGF 1
        TNT1 A 0 A_TakeInventory("ShotgunReloading",1337)
        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:
    DNSG A 1 Offset(0, 50)
    DNSG A 1 Offset(0, 40)
    DNSG A 1 Offset(0, 30)
		Goto Ready
	DontThrow:
		DNSG A 1
		Goto Ready
    }
}

ACTOR ShotgunReloading : Inventory
{
    Inventory.MaxAmount 1
}

ACTOR RemingtonSlugPuff : Bulletpuff
{
    +FoilInvul
}

ACTOR RemingtonShell : Ammo
{
    Inventory.MaxAmount 8
    Ammo.BackpackMaxAmount 8
    +IGNORESKILL
}

ACTOR RemingtonSlugs : Ammo
{
    Inventory.MaxAmount 40
    Ammo.BackpackMaxAmount 80
    +IGNORESKILL
}