// New revolver
ACTOR RevolverDummy : Inventory { Inventory.MaxAmount 6 }


ACTOR Revolver : Handcrack
{
  Inventory.RestrictedTo ZyklonB
  Weapon.SelectionOrder 1900
  Obituary "%o was killed by %k's revolver."
  decal MBulletChip
  Weapon.SlotNumber 0
  Weapon.AmmoUse 1
  Weapon.AmmoGive 24
  Weapon.AmmoType "Magazine"
  +WEAPON.NOALERT
  +INVENTORY.UNTOSSABLE
  Inventory.PickupMessage "Picked up the revolver."
  Weapon.BobStyle Smooth
  Weapon.BobSpeed 2.5
  Weapon.BobRangeX 0.5
  Weapon.BobRangeY 0.3
  Tag "Revolver"
  States
  {

  RealReady:
    REVI A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Loop
  Deselect:
    REVS DCBA 1
	TNT1 AAAAAAAAAAAAAAA 0 A_Lower
	TNT1 A 1 A_Lower
    Goto Deselect+4
	
  RealSelect:
  Select:
	TNT1 A 0 A_Raise
	TNT1 A 1 A_WeaponReady
    Goto SelectAnim
  SelectAnim:
	GLKR I 0 A_PlaySoundEx("glock/deploy","SoundSlot5")
	REVS ABCD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Ready
	
  Fire:
	TNT1 A 0 A_JumpIfInventory("MMV_NoReload",1,1)
	Goto ReloadCheck
	TNT1 AAA 0
	TNT1 A 0 A_GiveInventory("RevolverDummy",1)
	TNT1 A 0 A_FireBullets(2.5, 2.4, 1, 10, "MM_NewBulletPuff_Small")
	PPFI AA 0 A_FireCustomMissile("MuzzleSmokeFX",0,0,4,0)
	TNT1 A 0 A_PlaySound("REVLSHT", CHAN_WEAPON)
	TNT1 A 0 ////A_SetPitch(Pitch-6.0)
	TNT1 A 0 A_GunFlash
	TNT1 A 0 A_AlertMonsters
	BM16 A 0 ACS_NamedExecuteAlways("SelectFlash",0,6,0,0)
	BM16 A 0 A_JumpIfInventory("MuzzleFlashes",5,"MF6")
	BM16 A 0 A_JumpIfInventory("MuzzleFlashes",4,"MF5")
	BM16 A 0 A_JumpIfInventory("MuzzleFlashes",3,"MF4")
	BM16 A 0 A_JumpIfInventory("MuzzleFlashes",2,"MF3")
	BM16 A 0 A_JumpIfInventory("MuzzleFlashes",1,"MF2")
	Goto MF1
  ReloadCheck:
	REVL A 0 A_JumpIfInventory("RevolverDummy", 6, "Reloading")
	Goto Fire+3
  MF1:
	REVI B 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireEnd
  MF2:
	REVI C 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireEnd
  MF3:
	REVI D 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireEnd
  MF4:
	REVI E 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireEnd
  MF5:
	REVI F 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireEnd
  MF6:
	REVI G 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireEnd
  FireEnd:
	TNT1 A 0 ////A_SetPitch(Pitch+4.0)
	REVI HIJ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	REVI KL 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	REVI A 2
	REVI A 3 A_Refire
	Goto Ready
	
  Reload:
  AltFire:
    TNT1 A 0 A_JumpIfInventory("MMV_NoReload",1,"Ready")
  Reloading:
	TNT1 A 0 A_JumpIfInventory("RevolverDummy",1,1)
	Goto Ready
	TNT1 A 0 A_TakeInventory("RevolverDummy",20)
	REVR ABCDEF 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 0 A_PlaySoundEx("REVOUT", "SoundSlot6")
	REVR G 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	REVL AAAAAA 0 A_SpawnItemEx("BulletCasing", 15, -6, 24, frandom(1,3), frandom(-4,-2), frandom(1,3))
	REVR H 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TNT1 A 8
	TNT1 A 0 A_PlaySoundEx("REVLOAD", "SoundSlot5")
	TNT1 A 10
	TNT1 A 0 A_PlaySoundEx("REVIN", "SoundSlot6")
	REVR HG 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	REVR E 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	REVR D 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	REVR CBA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Ready

  Flash:
    TNT1 A 1 Bright A_Light1
    Goto LightDone

  Spawn:
    GLOI A -1
    Stop
  }
}
