
actor NormalPistol : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1300
  weapon.ammotype "pistolClip"
  weapon.ammouse 1
  weapon.ammogive2 10
  weapon.ammogive1 999
  weapon.ammotype2 "PistolAmmo"
  Obituary "$OB_MPPISTOL" // "%o was tickled by %k's pea shooter."
  +WEAPON.WIMPY_WEAPON
  +AMMO_OPTIONAL
  Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" // "Picked up a pistol."
  States
  {
  Ready: 
	M1GE A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload")	
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")
    PISG A 1 A_WeaponReady
    loop
  Deselect:
    PISG A 0 A_Lower
    PISG A 0 A_Lower
    PISG A 1 A_Lower
    Loop
  Select:
    PISG A 0 A_Raise
    PISG A 0 A_Raise
    PISG A 1 A_Raise
    Loop
  Fire:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 	
    PISG A 0 A_JumpIfNoAmmo("reload") 
    PISF A 0 A_jumpifinventory("doubletap",1,"Fire_doubletap")
    PISG A 4
	PISG B 0 A_Gunflash
	PISG B 0 A_PlaySound("pistol/fire")
    PISG B 0 A_FireBullets(2,2,1,random(38,38),"bulletPuff",0)
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    PISG B 0 A_TakeInventory("pistolClip",1)
    PISG B 6 
    PISG C 4
    PISG C 0 A_JumpIfNoAmmo("reload") 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 	
    PISG B 5 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 	
    PISG B 0 A_JumpIfNoAmmo("reload") 
    Goto Ready
  Fire_Doubletap:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 	
    PISG A 0 A_JumpIfNoAmmo("reload") 
    PISG A 2
	PISG B 0 A_Gunflash
	PISG B 0 A_PlaySound("pistol/fire")
    PISG B 0 A_FireBullets(2,2,1,random(38,38),"bulletPuff",0)
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    PISG B 0 A_TakeInventory("pistolClip",1)
    PISG B 3 
    PISG C 2
    PISG A 0 A_JumpIfNoAmmo("reload") 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 	
    PISG B 3 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 	
    PISG A 0 A_JumpIfNoAmmo("reload") 
    Goto Ready
  Reload:
    PIRE A 0 A_takeinventory("IsReloading",1)
    PIRE A 0 A_jumpifinventory("SpeedCola",1,"Reload_speed")
	PIRE A 0 A_jumpifInventory("pistolClip",6,"Ready")
    PIRE A 0 A_JumpIfInventory("pistolammo", 1, 1)
	goto Ready
    PISF A 0 A_playsound("pistol/out")
    PISF ABCD 2
  Goto Reload2
  Reload2:
	PISF D 0 A_GiveInventory("pistolClip",1)
	PISF D 0 A_TakeInventory("pistolammo",1)
	PISF D 0 A_jumpifInventory("pistolClip",6,"ReloadDone")
    PISF D 0 A_JumpIfInventory("pistolammo", 1, "Reload2")
    Goto Reloaddone
  ReloadDone:
	PISF E 6
	PISF EFGH 2
    PISF H 0 A_playsound("pistol/load")
	PISF IJK 2
    Goto Ready
  Reload_speed:
    PIRE A 0 A_takeinventory("IsReloading",1)
	PIRE A 0 A_jumpifInventory("pistolClip",6,"Ready")
    PIRE A 0 A_JumpIfInventory("pistolammo", 1, 1)
	goto Ready
    PISF A 0 A_playsound("pistol/out")
    PISF ABCD 1
  Goto Reload2_speed
  Reload2_speed:
	PISF D 0 A_GiveInventory("pistolClip",1)
	PISF D 0 A_TakeInventory("pistolammo",1)
	PISF D 0 A_jumpifInventory("pistolClip",6,"ReloadDone_speed")
    PISF D 0 A_JumpIfInventory("pistolammo", 1, "Reload2_speed")
    Goto Reloaddone_speed
  ReloadDone_speed:
	PISF E 3
	PISF EFGH 1
    PISF H 0 A_playsound("pistol/load")
	PISF IJK 1
    Goto Ready
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Flash:
    PISM B 0 A_jumpifinventory("doubletap",1,"Flash_doubletap")
    PISM B 7 Bright A_Light1
    Goto LightDone
    PISM B 7 Bright A_Light0
    Goto LightDone
  Flash_doubletap:
    PISM B 3 Bright A_Light1
    Goto LightDone
    PISM B 3 Bright A_Light0
    Goto LightDone
  Spawn:
    PIST A -1
    Stop
  }
}

actor PAPPistol : Weapon
{
  Game Doom
  Weapon.SelectionOrder 1900
  weapon.ammotype "PAPpistolClip"
  weapon.ammouse 1
  weapon.ammogive2 999
  weapon.ammogive1 999
  weapon.ammotype2 "PistolAmmo"
  Obituary "$OB_MPPISTOL" // "%o was tickled by %k's pea shooter."
  +WEAPON.WIMPY_WEAPON
  Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED" // "Picked up a pistol."
  States
  {
  Ready:
	M1GE A 0 A_JumpIfInventory("thrownade",1,"ThrowGrenade")
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
	AK47 A 0 A_JumpIfInventory("Kinfeammo",1,"UseKnife")	
    PISG A 1 A_WeaponReady
    Loop
  Useknife:
     KNFG A 0 A_jumpifinventory("Machete",1,"UseMachete")
     KNFG ABC 2
	 KNFG C 0 A_CustomPunch (110,1,0,"KnifePuff")
	 KNFG DEF 2
	 KNFG F 0 A_TakeInventory("Kinfeammo")
	 goto ready
  UseMachete:
     MHT4 ABC 2
	 MHT4 C 0 A_CustomPunch (450,1,0,"Machetepuff")
	 MHT4 DEFG 2
	 MHT4 G 0 A_TakeInventory("Kinfeammo")
	 goto ready
  Deselect:
    PISG A 0 A_Lower
    PISG A 0 A_Lower
    PISG A 1 A_Lower
    Loop
  Select:
    PISG A 0 A_Raise
    PISG A 0 A_Raise
    PISG A 1 A_Raise
    Loop
  Fire:
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    PISG A 0 A_JumpIfNoAmmo("reload") 
    PISF A 0 A_jumpifinventory("doubletap",1,"Fire_doubletap")
    PISG A 4
	PISG B 0 A_Gunflash
	PISG B 0 A_PlaySound("pistol/fire")
    PISG B 0 A_FireBullets(0.2,0.2,2,random(76,76),"bulletPuff",0)
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    PISG B 0 A_TakeInventory("PAPpistolClip",1)
    PISG B 6 
    PISG C 4
    PISG C 0 A_JumpIfNoAmmo("reload") 
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    PISG B 5 A_ReFire
    AUG1 A 0 A_JumpIfInventory("IsReloading",1,"Reload") 
    PISG B 0 A_JumpIfNoAmmo("reload") 
    Goto Ready
  Fire_Doubletap:
    PISG A 0 A_JumpIfNoAmmo("reload") 
    PISG A 2
	PISG B 0 A_Gunflash
	PISG B 0 A_PlaySound("pistol/fire")
    PISG B 0 A_FireBullets(0.2,0.2,2,random(76,76),"bulletPuff",0)
	TNTT A 0 A_FireCustomMissile("BulletCasingSpawner",0,0,-6,2)
    PISG B 0 A_TakeInventory("PAPpistolClip",1)
    PISG B 3 
    PISG C 2
    PISG A 0 A_JumpIfNoAmmo("reload") 
    PISG B 3 A_ReFire
    PISG A 0 A_JumpIfNoAmmo("reload") 
    Goto Ready
  Reload:
    PIRE A 0 A_takeinventory("IsReloading",1)
    PIRE A 0 A_jumpifinventory("SpeedCola",1,"Reload_speed")
	PIRE A 0 A_jumpifInventory("PAPpistolClip",12,"Ready")
    PIRE A 0 A_JumpIfInventory("pistolammo", 1, 1)
	goto Ready
    PISF A 0 A_playsound("pistol/out")
    PISF ABCD 2
  Goto Reload2
  Reload2:
	PISF D 0 A_GiveInventory("PAPpistolClip",1)
	PISF D 0 A_TakeInventory("pistolammo",1)
	PISF D 0 A_jumpifInventory("PAPpistolClip",12,"ReloadDone")
    PISF D 0 A_JumpIfInventory("pistolammo", 1, "Reload2")
    Goto Reloaddone
  ReloadDone:
	PISF E 6
	PISF EFGH 2
    PISF H 0 A_playsound("pistol/load")
	PISF IJK 2
    Goto Ready
  Reload_speed:
    PIRE A 0 A_takeinventory("IsReloading",1)
	PIRE A 0 A_jumpifInventory("PAPpistolClip",12,"Ready")
    PIRE A 0 A_JumpIfInventory("pistolammo", 1, 1)
	goto Ready
    PISF A 0 A_playsound("pistol/out")
    PISF ABCD 2
  Goto Reload2_speed
  Reload2_speed:
	PISF D 0 A_GiveInventory("PAPpistolClip",1)
	PISF D 0 A_TakeInventory("pistolammo",1)
	PISF D 0 A_jumpifInventory("PAPpistolClip",12,"ReloadDone_speed")
    PISF D 0 A_JumpIfInventory("pistolammo", 1, "Reload2_speed")
    Goto Reloaddone_speed
  ReloadDone_speed:
	PISF E 3
	PISF EFGH 1
    PISF H 0 A_playsound("pistol/load")
	PISF IJK 1
    Goto Ready
  ThrowGrenade:
     HNDG BCD 1
     HNDG E 1 A_PlaySound("weapons/grenadepin")
     HNDG FGHH 1
     HNDG I 1 A_PlaySound("weapons/grenadethr") 
     HNDG J 0 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
     HNDG J 0 A_PlaySound("weapons/grenadethr")
     HNDG JKLMNOPQ 1
     HNDG Q 0 A_TakeInventory("thrownade")
     Goto Ready
  Flash:
    PISM B 0 A_jumpifinventory("doubletap",1,"Flash_doubletap")
    PISM B 7 Bright A_Light1
    Goto LightDone
    PISM B 7 Bright A_Light0
    Goto LightDone
  Flash_doubletap:
    PISM B 3 Bright A_Light1
    Goto LightDone
    PISM B 3 Bright A_Light0
    Goto LightDone
  Spawn:
    PIST A -1
    Stop
  }
}

actor pistolClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 6
    ammo.backpackamount 0
    ammo.backpackmaxamount 6
    +IGNORESKILL
}

actor PistolAmmo : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 12
    inventory.maxamount 144
    ammo.backpackamount 12
    ammo.backpackmaxamount 144
    +IGNORESKILL
    inventory.pickupmessage "Got Pistol! rounds!"  
    States
    {
    Spawn:
      CLIP A -1
      Stop
    }
}

actor PAPpistolClip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 12
    ammo.backpackamount 0
    ammo.backpackmaxamount 12
    +IGNORESKILL
}