actor SSTPistol : Pistol Replaces Pistol
{
  DamageType "NewBullet"
  Weapon.SelectionOrder 1899
  Weapon.AmmoUse 1
  Weapon.AmmoGive 20
  Weapon.AmmoType "Clip"
  Weapon.AmmoUse2 1
  Weapon.AmmoGive2 0
  Weapon.AmmoType2 "Clip"
  Obituary "%o was capped by %k's pistol."
  +WEAPON.WIMPY_WEAPON
  +Noautofire
  +UNDROPPABLE
  Inventory.Pickupmessage "Picked up a pistol."
  Decal "bulletchip"
  attacksound ""
  Weapon.preferredSkin "PistolSkin"
  //Weapon.SwayStyle "DownOnly"
  //Weapon.SwaySpeed 1
  Weapon.ViewPitchStyle Full
  Weapon.ViewPitchOffset 11
  +NOALERT
  +NOEXTREMEDEATH
	+FORCEXYBILLBOARD
  States
  {
  Ready:
    TNT1 A 0 A_JumpIfInventory("InstantSwitch",1, "ActualReady")
    BERT CDE 1
  ActualReady:
    BERT A 1 A_WeaponReady
    Loop
  Deselect:
    BERT E 1
    BERT D 0 ACS_ExecuteAlways(779,0, 4,0,0)
    BERT EDD 1 A_Lower
  DeselectContinued:
    BERT B 1 A_Lower
    BERT B 0 A_Lower
    Loop
  Select:
    TNT1 A 0 A_JumpIfInventory("InstantSwitch",1, "ActualReady")
    BERT K 0 ACS_ExecuteAlways(779,0, 3,0,0)
    BERT K 0
    BERT K 0 A_Raise
    TNT1 A 0 A_JumpIfInventory("InstantSwitch",1, "ActualReady")
    BERT C 1 A_Raise
    Goto Select+3
  Fire:
    BERT B 0 A_GunFlash
    //BERT B 0 A_PlayWeaponSound("weapons/pistol")
    SHT2 A 0 A_PlaySoundEx("weapons/pistol", "SoundSlot5")
    BERF A 1 BRIGHT
	//BERT C 1
	TNT1 A 0 Radius_Quake(1,2,0,1, 0)
	BERT BBCD 1
    BERT B 0 A_GiveInventory("PistolInaccurracy",1)
	//TNT1 A 0 A_FireCustomMissile("GunAlert",0,0,0,0)
    BERT DEFAAAA 1 a_weaponready
	BERT A 0 A_Refire
	BERT AAAAAAAAAAAAA 1 A_weaponready
    BERT B 0 A_TakeInventory("PistolInaccurracy",1)
    Goto ActualReady
  Altfire:
    BERT B 0 A_Jumpifnoammo("actualready")
    //BERT B 0 A_TakeInventory("clip",1)
    BERT B 0 A_GiveInventory("PistolInaccurracy",1)
    BERT B 0 A_GunFlash
	TNT1 A 0 Radius_Quake(1,2,0,1, 0)
    //BERT B 0 A_PlayWeaponSound("weapons/pistol")
    SHT2 A 0 A_PlaySoundEx("weapons/pistol", "SoundSlot5")
    BERF A 1 BRIGHT
    BERT B 1
    BERT C 1
	
    BERT B 0 A_Jumpifnoammo("ready")
    //BERT B 0 A_TakeInventory("clip",1)
    BERT B 0 A_GunFlash
	TNT1 A 0 Radius_Quake(1,2,0,1, 0)
    //BERT B 0 A_PlayWeaponSound("weapons/pistol")
    SHT2 A 0 A_PlaySoundEx("weapons/pistol", "SoundSlot5")
    BERF A 1 BRIGHT
    BERT B 1
    BERT C 1
	
    BERT B 0 A_Jumpifnoammo("ready")
    //BERT B 0 A_TakeInventory("clip",1)
    BERT B 0 A_GunFlash
	TNT1 A 0 Radius_Quake(1,2,0,1, 0)
    //BERT B 0 A_PlayWeaponSound("weapons/pistol")
    SHT2 A 0 A_PlaySoundEx("weapons/pistol", "SoundSlot5")
    BERF A 1 BRIGHT
    BERT BBCCDDDE 1
    BERT EEFFAAAAAAAAA 1 A_weaponready
    BERT B 0 A_TakeInventory("PistolInaccurracy",1)
    Goto ActualReady
    
  Flash:
    NULL A 0 A_SpawnItemEx ("PistolEcho", 0,0,0, 0,0,0, 0, 160)
    BERT B 0 A_JumpIfInventory("PistolInaccurracy",1, "Inaccurate")
	
    BERT B 0 A_FireBullets (2.5, 2.75, -1, random(7,10), "SSTBulletPuff1",1) 
    
	  TNT1 A 0 A_FireCustomMissile ("TracerRound", random(-2.5,2.5)*0.4, 0, 0, 0, 0, random(-2.75,2.75)*0.4)
	Goto EndFlash
  Inaccurate:
    BERT B 0 A_FireBullets (4.0, 6.5, -1, random(7,10), "SSTBulletPuff1",1) 
	  TNT1 A 0 A_FireCustomMissile ("TracerRound", random(-4.0,4.0)*0.4, 0, 0, 0, 0, random(-6.5,6.5)*0.4)
  EndFlash:
    TNT1 A 1 Bright A_Light2
    //TNT1 A 0 ACS_ExecuteAlways(925,0, random(480,640),0,0)
	TNT1 A 0 A_Jump(192, "CutLeft")
  CutRight:
	TNT1 A 0 A_SetAngle(angle+0.2)
    TNT1 A 0 A_SetPitch(pitch-1.5)
    TNT1 A 1 Bright A_Light1
	BERT B 0 A_FireCustomMissile("BulletCasingSpawner",0,0,0,3)
    TNT1 A 1 Bright A_Light0
	TNT1 A 0 A_SetAngle(angle-0.2)
    TNT1 A 1 A_SetPitch(pitch+0.5)
    TNT1 A 1 A_SetPitch(pitch+1)
    RLGG E 0 A_AlertMonsters
    Stop
  CutLeft:
	TNT1 A 0 A_SetAngle(angle-0.3)
    TNT1 A 0 A_SetPitch(pitch-1.2)
    TNT1 A 1 Bright A_Light1
	BERT B 0 A_FireCustomMissile("BulletCasingSpawner",0,0,0,3)
    TNT1 A 1 Bright A_Light0
	TNT1 A 0 A_SetAngle(angle+0.3)
    TNT1 A 1 A_SetPitch(pitch+0.6)
    TNT1 A 1 A_SetPitch(pitch+0.6)
    RLGG E 0 A_AlertMonsters
    Stop
  Spawn:
    P1ST A -1
    Stop
  }
}

actor PistolInaccurracy : Inventory
{
  inventory.amount 1
  inventory.maxamount 1
}