actor PistolAmmo : Ammo replaces Clip 19327
{
  inventory.pickupmessage "$D3D_PISTOLAMMO"
  inventory.amount 12
  inventory.maxamount 200
  inventory.icon "TNT1A0"
  ammo.backpackamount 12
  ammo.backpackmaxamount 400
  scale 0.2
  +INVENTORY.IGNORESKILL
  states
  {
  Spawn:
    PISP B -1
    stop
  }
}

ACTOR PistolClip : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 12
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 12
  +INVENTORY.IGNORESKILL
}

ACTOR DualPistolClip : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 24
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 24
  +INVENTORY.IGNORESKILL
}

actor "Pistol " : DefaultDukeWeapon replaces Pistol 19328
{
  Weapon.SelectionOrder 21
  Weapon.AmmoUse1 0
  Weapon.AmmoGive1 12
  Weapon.AmmoType1 "PistolAmmo"
  Weapon.AmmoUse2 1
  Weapon.AmmoGive2 0
  Weapon.AmmoType2 "PistolClip"
  Obituary "%o was gattered by %k's pistol."
  +WEAPON.WIMPY_WEAPON
  Inventory.Pickupmessage "$D3D_PISTOL"
  Inventory.PickupSound "misc/backpack"
  weapon.upsound "pistol/select"
  scale 0.5
  decal bulletchip
  +NOALERT
  Tag " "
  States
  {
  RReady2:
    TNT1 A 0 A_JumpIfInventory("PistolClip",1,1)
    Goto Reload
    PIST A 0 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
    PIST A 1 A_WeaponReady
    goto RReady
  NoAmmo:
    PIST A 5 A_WeaponReady(WRF_NOFIRE)
    PIST A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
    TNT1 A 0 A_JumpIfInventory("PistolClip",1,"RReady")
    TNT1 A 0 A_JumpIfInventory("PistolAmmo",1,"Reload")
    loop
  Deselect:
    PIST A 0
    goto Super::Deselect
  Select:
    PIST A 0
    goto Super::Select
  Fire:
    TNT1 A 0
    TNT1 A 0 A_JumpIfInventory("PistolClip", 1, 2)
    PIST A 10 A_PlaySound("DRYFIRE", 1)
    Goto Reload
    TNT1 A 0 A_TakeInventory("Waiting",10)
    TNT1 A 0 A_FireCustomMissile("GunFireSmoke", 0, 0, 2, 1, 0, 0)
    PIST A 0 BRIGHT A_FireCustomMissile("MuzzleFlashSmall",0,0,0)
    PIST B 0 A_FireBullets (1.4, 1.4, 1, 6, "DukeBulletPuff")
    TNT1 A 0 A_FireCustomMissile("DecorativeTracer", random[RIDFX](-1,1), 0, 10, -12)
    PIST B 1 BRIGHT A_PlayWeaponSound("pistol/shoot")
    TNT1 A 0 A_ZoomFactorD3D("d3d_rpistol",0.98)
    PIST C 1 BRIGHT A_FireCustomMissile("MonsterAlert",0,0,0)
    TNT1 A 0 A_SetPitchD3D("d3d_rpistol",-1.0)
    TNT1 A 0 A_ZoomFactor(1.0)
    PIST A 1
    TNT1 A 0 A_Firecustommissile("9mmSpawn",0,0,6,-6)
    PIST A 1 A_SetPitchD3D("d3d_rpistol",0.5)
    PIST A 1 A_SetPitchD3D("d3d_rpistol",0.5)
    PIST A 1
    TNT1 A 0 A_TakeInventory("PistolClip", 1)
    TNT1 A 0 A_JumpIfInventory("PistolClip", 1, 1)
    Goto Reload
    PIST A 0 A_Refire
    Goto RReady
  Spawn:
    PISP A -1
    Stop
  Reload:
    PIST A 1
    TNT1 A 0 A_Takeinventory("Reloading",1)
    TNT1 A 0 A_JumpIfInventory("PistolClip",12,32)
    TNT1 A 0 A_JumpIfInventory("PistolAmmo",1,3)
    Goto NoAmmo
    TNT1 AAA 0
    TNT1 A 0 A_Takeinventory("Reloading",1)
    PIST D 3 A_PlaySound("pistol/reload")
    TNT1 A 0
    PIST EF 3
    TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,18,-10)
    PIST GHID 3
  InsertBullets:
    TNT1 AAAA 0
    TNT1 A 0 A_JumpIfInventory("PistolClip",12,15)
    TNT1 A 0 A_JumpIfInventory("PistolAmmo",1,3)
    Goto RReady2+2
    TNT1 AAAAAA 0
    TNT1 A 0 A_Giveinventory("PistolClip",1)
    TNT1 A 0 A_Takeinventory("PistolAmmo",1)
    Goto InsertBullets
    TNT1 AAAAAAAAAA 0
    TNT1 A 0 A_Takeinventory("Reloading",1)
    PIST A 0 A_Refire
    Goto RReady2+2
  }
}

actor "Dual Pistol" : DefaultDukeWeapon 19329
{
  Weapon.SelectionOrder 20
  Weapon.AmmoUse1 0
  Weapon.AmmoGive1 24
  Weapon.AmmoType1 "PistolAmmo"
  Weapon.AmmoUse2 1
  Weapon.AmmoGive2 0
  Weapon.AmmoType2 "DualPistolClip"
  Obituary "%o was gattered by %k's pistol."
  Inventory.Pickupmessage "$D3D_DUALPISTOL"
  Inventory.PickupSound "misc/backpack"
  weapon.upsound "pistol/select"
  scale 0.5
  decal bulletchip
  +NOALERT
  Tag " "
  States
  {
  RReady2:
    TNT1 A 0 A_JumpIfInventory("DualPistolClip",1,1)
    Goto Reload
    PI2T A 0 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
    PI2T A 1 A_WeaponReady
    goto RReady
  NoAmmo:
    PI2T A 5 A_WeaponReady(WRF_NOFIRE)
    PI2T A 5 A_WeaponReady
    TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
    TNT1 A 0 A_JumpIfInventory("DualPistolClip",1,"RReady")
    TNT1 A 0 A_JumpIfInventory("PistolAmmo",1,"Reload")
    loop
  Deselect:
    PI2T A 0
    goto Super::Deselect
  Select:
    PI2T A 0
    goto Super::Select
  Fire:
    TNT1 A 0
    TNT1 A 0 A_JumpIfInventory("DualPistolClip", 1, 2)
    PI2T A 10 A_PlaySound("DRYFIRE", 1)
    Goto Reload
    PI2T A 0 A_JumpIfInventory("DualCheck",1,"FireLeft")
    TNT1 A 0 A_TakeInventory("Waiting",10)
    TNT1 A 0 A_FireCustomMissile("GunFireSmoke", 0, 0, 2, 1, 0, 0)
    PI2T A 0 BRIGHT A_FireCustomMissile("MuzzleFlashSmall",0,0,0)
    PI2T B 0 A_FireBullets (1.4, 1.4, 1, 6, "DukeBulletPuff")
    TNT1 A 0 A_FireCustomMissile("DecorativeTracer", random[RIDFX](-1,1), 0, 10, -12)
    PI2T B 1 BRIGHT A_PlayWeaponSound("pistol/shoot")
    TNT1 A 0 A_ZoomFactorD3D("d3d_rpistol",0.98)
    PI2T C 1 BRIGHT A_FireCustomMissile("MonsterAlert",0,0,0)
    TNT1 A 0 A_SetPitchD3D("d3d_rpistol",-1.0)
    TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_GiveInventory("DualCheck",1)
    PI2T A 1
    TNT1 A 0 A_Firecustommissile("9mmSpawn",0,0,6,-6)
    PI2T A 1 A_SetPitchD3D("d3d_rpistol",0.5)
    PI2T A 1 A_SetPitchD3D("d3d_rpistol",0.5)
    TNT1 A 0 A_TakeInventory("DualPistolClip", 1)
    TNT1 A 0 A_JumpIfInventory("DualPistolClip", 1, 1)
    Goto Reload
    PI2T A 0 A_ReFire
    Goto RReady
  FireLeft:
    TNT1 A 0
    TNT1 A 0 A_JumpIfInventory("DualPistolClip", 1, 2)
    PI2T A 10 A_PlaySound("DRYFIRE", 1)
    Goto Reload
    TNT1 A 0 A_TakeInventory("Waiting",10)
    TNT1 A 0 A_FireCustomMissile("GunFireSmoke", 0, 0, -2, 1, 0, 0)
    PI2T A 0 BRIGHT A_FireCustomMissile("MuzzleFlashSmall",0,0,0)
    PI2T B 0 A_FireBullets (2.6, 2.6, 1, 6, "DukeBulletPuff")
    TNT1 A 0 A_FireCustomMissile("DecorativeTracer", random[RIDFX](-1,1), 0, -10, -12)
    PI2T D 1 BRIGHT A_PlayWeaponSound("pistol/shoot")
    TNT1 A 0 A_ZoomFactorD3D("d3d_rpistol",0.98)
    PI2T E 1 BRIGHT A_FireCustomMissile("MonsterAlert",0,0,0)
    TNT1 A 0 A_SetPitchD3D("d3d_rpistol",-1.0)
    TNT1 A 0 A_ZoomFactor(1.0)
    TNT1 A 0 A_TakeInventory("DualCheck",1)
    PI2T A 1
    TNT1 A 0 A_Firecustommissile("9mmSpawnLeft",0,0,-6,-6)
    PI2T A 1 A_SetPitchD3D("d3d_rpistol",0.5)
    PI2T A 1 A_SetPitchD3D("d3d_rpistol",0.5)
    TNT1 A 0 A_TakeInventory("DualPistolClip", 1)
    TNT1 A 0 A_JumpIfInventory("DualPistolClip", 1, 1)
    Goto Reload
    PI2T A 0 A_ReFire
    Goto RReady
  Reload:
    PI2T A 1
    TNT1 A 0 A_Takeinventory("Reloading",1)
    TNT1 A 0 A_JumpIfInventory("DualPistolClip",24,42)
    TNT1 A 0 A_JumpIfInventory("PistolAmmo",1,3)
    Goto NoAmmo
    TNT1 AAA 0
    TNT1 A 0 A_Takeinventory("Reloading",1)
    PI2T F 3 A_PlaySound("pistol/reload")
    TNT1 A 0
    PI2T G 3
    TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,18,-10)
    PI2T HIJKLM 3
    PI2T N 3 A_PlaySound("pistol/reload")
    PI2T O 3
    PIST F 3
    TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,-18,-10)
    PIST GHI 3
    PI2T ON 3
  InsertBullets:
    TNT1 AAAA 0
    TNT1 A 0 A_JumpIfInventory("DualPistolClip",24,15)
    TNT1 A 0 A_JumpIfInventory("PistolAmmo",1,3)
    Goto RReady2+2
    TNT1 AAAAAA 0
    TNT1 A 0 A_Giveinventory("DualPistolClip",1)
    TNT1 A 0 A_Takeinventory("PistolAmmo",1)
    Goto InsertBullets
    TNT1 AAAAAAAAAA 0
    TNT1 A 0 A_Takeinventory("Reloading",1)
    PIST A 0 A_Refire
    Goto RReady2+2
  Spawn:
    PISP A -1
    Stop
  }
}

actor DualCheck : Inventory
{
  inventory.amount 0
  inventory.maxamount 1
}