actor SwatGlock : Weapon
{
  Obituary "%o got shot by %k."
  +WEAPON.ALT_USES_BOTH
  Weapon.AmmoType2 "PistolAmmoClip"
  Weapon.AmmoUse2 1
  Weapon.AmmoGive 18
  Weapon.AmmoGive2 18
  AttackSound "weapons/gock"
  Inventory.PickupMessage "Picked up an UAC Standard Pistol."
  Weapon.Kickback 100
  Obituary "%o was taken in by %k."
  Tag "Standard Issue Glock 18"
  Decal "BulletChip"
  Inventory.RestrictedTo "SwatClass"

  States
  {
  Spawn:
    DEPI A -1
    Stop
  Ready:
    DPIG A 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Loop
  ReadyNoReload:
    DPIG A 1 A_WeaponReady
    Goto Ready
  Deselect:
    DPIG A 1 A_Lower
    TNT1 A 0 A_Lower
    TNT1 A 0 A_Lower
    Loop
  Select:
    DPIG A 1 A_Raise
    TNT1 A 0 A_Raise
    TNT1 A 0 A_Raise
    Loop
  Fire:
    TNT1 A 0 A_JumpIfInventory("PistolAmmoClip", 1, "DoFire")
    Goto Reload
  DoFire:
    TNT1 A 0 A_GunFlash
	TNT1 A 0 A_TakeInventory("PistolAmmoClip", 1)
    DPIF A 2 Bright A_FireBullets(1, 1, -1, 10, "BulletPuff", FBF_NORANDOM, 8192)
    DPIG B 1
    DPIG C 3
    Goto Ready
  Reload:
    DPIR A 0 A_JumpIfInventory("PistolAmmoClip", 18, "Ready")
    DPIR A 0 A_CheckReload
    DPIR B 3 A_PlaySound("clipout")
    DPIR C 3
    DPIR D 3
    DPIR E 3
    DPIR F 3 A_PlaySound("clipin")
    DPIR G 3
    DPIR H 3
    DPIR I 3
    DPIR J 3 A_GiveInventory("PistolAmmoClip", 18)
    DPIG A 3 A_ReFire
    Goto Ready
  Fired:
    DPIG A 2 A_ReFire
    Goto Ready
  Flash:
    TNT1 A 2 A_Light2
    TNT1 A 2 A_Light1
    Goto LightDone
  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:
    DPIG A 1 Offset(0, 50)
    DPIG A 1 Offset(0, 40)
    DPIG A 1 Offset(0, 30)
	Goto Ready
  DontThrow:
	DPIG A 1
	Goto Ready
  }
}

actor UpgradedSwatGlock : Weapon
{
  Obituary "%o got shot by %k."
  +WEAPON.ALT_USES_BOTH
  Weapon.AmmoType2 "UpgradedPistolAmmoClip"
  Weapon.AmmoGive 36
  Weapon.AmmoUse2 1
  Weapon.AmmoGive2 36
  AttackSound "weapons/gock"
  Inventory.PickupMessage "Picked up a Modified Glock 18."
  Obituary "%o was rapidly taken in by %k."
  Weapon.Kickback 100
  Tag "Modified Glock 18"
  Decal "BulletChip"
  Inventory.RestrictedTo "SwatClass"

  States
  {
  Spawn:
    DEPI A -1
    Stop
  Ready:
    DPIG A 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Loop
  ReadyNoReload:
    DPIG A 1 A_WeaponReady
    Goto Ready
  Deselect:
    DPIG A 1 A_Lower
    TNT1 A 0 A_Lower
    TNT1 A 0 A_Lower
    Loop
  Select:
    DPIG A 1 A_Raise
    TNT1 A 0 A_Raise
    TNT1 A 0 A_Raise
    Loop
  Fire:
    TNT1 A 0 A_JumpIfInventory("UpgradedPistolAmmoClip", 1, "DoFire")
    Goto Reload
  DoFire:
    TNT1 A 0 A_GunFlash
    TNT1 A 0 A_TakeInventory("UpgradedPistolAmmoClip", 1)
    DPIF A 1 Bright A_FireBullets(0.5, 0.5, -1, 20, "BulletPuff", FBF_NORANDOM, 8192)
    DPIG B 1
    DPIG C 2
    Goto Ready
  Reload:
    DPIR A 0 A_JumpIfInventory("UpgradedPistolAmmoClip", 36, "Ready")
    DPIR A 0 A_CheckReload
    DPIR B 2 A_PlaySound("clipout")
    DPIR C 2
    DPIR D 2
    DPIR E 2
    DPIR F 2 A_PlaySound("clipin")
    DPIR G 2
    DPIR H 2
    DPIR I 2
    DPIR J 2 A_GiveInventory("UpgradedPistolAmmoClip", 36)
    DPIG A 2 A_ReFire
    Goto Ready
  Fired:
    DPIG A 1 A_ReFire
    Goto Ready
  Flash:
    TNT1 A 1 A_Light2
    TNT1 A 1 A_Light1
    Goto LightDone
  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:
    DPIG A 1 Offset(0, 50)
    DPIG A 1 Offset(0, 40)
    DPIG A 1 Offset(0, 30)
	Goto Ready
  DontThrow:
	DPIG A 1
	Goto Ready
  }
}

Actor PistolAmmoClip : Ammo
{
  Inventory.MaxAmount 18
}

Actor UpgradedPistolAmmoClip : Ammo
{
  Inventory.MaxAmount 36
}