ACTOR Revolver : BrutalWeapon
{
	Weapon.SelectionOrder 1600
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "AmmoMagnum"
	Weapon.AmmoType2 "RevolverAmmo"
	Inventory.PickupMessage "$GOTREVOLVER"
    Inventory.PickupSound "REVOHAM"
	Obituary "%o was hollowed out by %k's revolver."
    AttackSound "None"
	+WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+NOALERT
	Scale 0.6
	Tag "Revolver"
	DropItem "RevolverSpawner"
	States
	{
    Spawn:
		REVP A -1
		Stop

	Ready3:
	Ready:
		REVO A 0 A_JumpIfInventory("PistolBurstFire", 1, "Ready2")
		REVO A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        REVO A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        REVO A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        REVO A 0 A_JumpIfInventory("Reloading",1,"Reload")
		REVO A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		REVO A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		REVO A 0 A_JumpIfInventory("Unloading",1,"Unload")
		REVO A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		REVO A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		REVO A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		REVO A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
        Loop

	Ready2://Fan The Hammer Ready State
		REVA A 1 A_WeaponReady(WRF_ALLOWRELOAD)
        REVO A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        REVO A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        REVO A 0 A_JumpIfInventory("Reloading",1,"Reload")
		REVO A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		REVO A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		REVO A 0 A_JumpIfInventory("Unloading",1,"Unload")
		REVO A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		REVO A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		REVO A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		REVO A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
        Loop

	Deselect:
		REVO A 0
		REVO A 0 A_Takeinventory("Zoomed",1)
		REVO A 0 A_TakeInventory("TossGrenade", 1)
		REVO A 0 A_Takeinventory("ADSmode",1)
		REVO A 0 A_TakeInventory("PistolBurstFire",1)
        REVO A 0 A_ZoomFactor(1.0)
		TNT1 AAAAAAAAAAAA 0 A_Lower
		REVO KKKK 1 A_Lower
		Wait

	Select:
		REVO A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_TakeInventory("FistsSelected", 1)
		TNT1 A 0 A_TakeInventory("ShotgunSelected", 1)
		TNT1 A 0 A_TakeInventory("MinigunSelected", 1)
		TNT1 A 0 A_TakeInventory("SSGSelected", 1)
		TNT1 A 0 A_TakeInventory("RocketLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("GrenadeLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("PlasmaGunSelected", 1)
		TNT1 A 0 A_TakeInventory("RailGunSelected", 1)
		TNT1 A 0 A_TakeInventory("RevenantLauncherSelected", 1)
		TNT1 A 0 A_GiveInventory("SubMachineGunSelected", 1)
		TNT1 A 0 A_TakeInventory("BFG10KSelected", 1)
		TNT1 A 0 A_TakeInventory("BFGSelected", 1)
		TNT1 A 0 A_TakeInventory("FlameCannonSelected", 1)
		TNT1 A 0 A_TakeInventory("SawSelected", 1)
		REVO A 0 A_Takeinventory("HasBarrel",1)
		REVO A 0 A_TakeInventory("TossGrenade", 1)
		REVO A 0 A_TakeInventory("Revolver2", 1)
		REVO A 0 A_Takeinventory("StartDualWield",1)
		REVO A 0 A_TakeInventory("PistolBurstFire",1)
		A12G A 0 A_GunFlash
		TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAAAA 0 A_Raise
		Goto SelectAnimation

	SelectAnimation:
		TNT1 A 0
		REVO A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
		TNT1 A 0 A_JumpIfInventory("RevolverChangeAmmo", 1, "Reload")
		REVO KLMN 2 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_PlaySound("REVOHAM", 4)
		REVO OPQR 2
		Goto Ready

    Fire:
        REVO A 0 A_Takeinventory("Reloading",1)
        REVO A 0 A_JumpIfInventory("RevolverAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
		REVO A 0 A_JumpIfInventory("PistolBurstFire",1,"Fire2")
		REVO B 1
        REVO A 0 A_AlertMonsters
		REVO A 0 A_PlaySound("REVOFIR", 1)
		REVO A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        REVO A 0 A_SpawnItemEx("PlayerMuzzle1",32,0,28)
		TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-1,1),0,0,0,0,random(-1,1))
		REVO A 0 A_Takeinventory("RevolverAmmo",1)
		REVO A 0 A_GiveInventory("SpentRound",1)
		REVO A 0 A_FireBullets (1.4, 1.5, -1, 100, "RevoPuff", FBF_NORANDOM)
		REVO A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		REVO A 0 A_SetPitch(pitch-2.0)
		REVO A 0 A_SetPitch(pitch-2.0)
		REVO C 1 BRIGHT
		TNT1 A 0 A_ZoomFactor(0.98)
		REVO D 1 BRIGHT A_SetPitch(pitch+0.4)
		TNT1 A 0 A_ZoomFactor(1.0)
		REVO E 1 A_SetPitch(pitch+0.4)
		REVO FG 1 A_SetPitch(pitch+0.4)
		REVO F 1 A_SetPitch(pitch+0.4)
		REVO E 1
		REVO K 4
		REVO LMN 1
		TNT1 A 0 A_PlaySound("REVOHAM", 4)
		REVO OPQR 1
		REVO A 1 A_JumpIfInventory("FiredPrimary",1,"Fire")
		REVO A 0 A_Refire
		Goto Ready3

	Fire2:
		REVA B 1
        REVO A 0 A_AlertMonsters
		REVO A 0 A_PlaySound("REVOFIR", 1)
		REVO A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        REVO A 0 A_SpawnItemEx("PlayerMuzzle1",32,0,28)
		TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-2,2),0,0,0,0,random(-2,2))
		REVO A 0 A_Takeinventory("RevolverAmmo",1)
		REVO A 0 A_GiveInventory("SpentRound",1)
		REVO A 0 A_FireBullets (1.9, 2.0, -1, 100, "RevoPuff", FBF_NORANDOM)
		REVO A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		REVO A 0 A_SetPitch(pitch-1.0)
		REVO A 0 A_SetPitch(pitch-1.0)
		REVA C 1 BRIGHT
		TNT1 A 0 A_ZoomFactor(0.99)
		REVA D 1 BRIGHT A_SetPitch(pitch+0.2)
		TNT1 A 0 A_ZoomFactor(1.0)
		REVA E 1 A_SetPitch(pitch+0.2)
		REVA FG 1 A_SetPitch(pitch+0.2)
		REVA F 1 A_SetPitch(pitch+0.2)
		REVA E 1
		REVA A 1 A_PlaySound("REVOHAM", 4)
		REVA A 1 A_JumpIfInventory("FiredPrimary",1,"Fire")
		REVA A 0 A_Refire
		Goto Ready2

	AltFire://Fan The Hammer
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("PistolBurstFire", 1, "StopAlt")
		TNT1 A 0 A_GiveInventory("PistolBurstFire", 1)
		TNT1 A 0 A_Print("Fan The Hammer")
		//Lower weapon
		REVO A 2 Offset(0, 45)//(+:Right | -:Left, +:Down | -:Up )
		REVO A 2 Offset(0, 55)
		REVO A 2 Offset(0, 65)
		REVO A 2 Offset(0, 75)
		Goto Ready2

	StopAlt:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("PistolBurstFire", 1)
		TNT1 A 0 A_Print("Single Action")
		//Raise weapon
		REVA A 2 Offset(0, 35)
		REVA A 2 Offset(0, 25)
		REVA A 2 Offset(0, 15)
		REVA A 2 Offset(0, 5)
		Goto Ready3

	StartSprint:
		REVO A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",1)
        SHTN A 0 A_ZoomFactor(1.0)
		SHTN A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_SetCrosshair(0)
		SHTN A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		Goto Sprinting

	Sprinting:
		REVP B 1 offset(-9,34) A_SetPitch(pitch -0.5)
		REVP B 1 offset(-6,36) A_SetPitch(pitch -0.5)
		REVP B 1 offset(-3,38) A_SetPitch(pitch -0.5)
		REVP B 1 offset(0,38) A_SetPitch(pitch -0.5)
		REVP B 1 offset(3,36) A_SetPitch(pitch -0.5)
		REVP B 1 offset(6,34) A_SetPitch(pitch -0.5)
		REVP B 1 offset(9,32) A_SetPitch(pitch -0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 1)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		REVP B 1 offset(9,34) A_SetPitch(pitch +0.5)
		REVP B 1 offset(6,36) A_SetPitch(pitch +0.5)
		REVP B 1 offset(3,38) A_SetPitch(pitch +0.5)
		REVP B 1 offset(0,38) A_SetPitch(pitch +0.5)
		REVP B 1 offset(-3,36) A_SetPitch(pitch +0.5)
		REVP B 1 offset(-6,34) A_SetPitch(pitch +0.5)
		REVP B 1 offset(-9,32) A_SetPitch(pitch +0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 1)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		PLAY A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		SMGG A 0 A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint

	StopSprint:
		REVP B 0 A_JumpIfInventory("PowerStrength", 1, 2)
		REVO A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		REVP B 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto Ready

	StopSprintTired:
		REVP B 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		REVO A 0 A_PlaySound("Tired", 2)
		Goto Ready

    Reload:
	    REVO A 0
		REVO A 0 A_TakeInventory("Reloading", 1)
		REVO A 0 A_JumpIfInventory("AmmoMagnum", 1, 2)
		Goto Ready
		REVO A 0
	    REVO A 0 A_Takeinventory("Zoomed",1)
        REVO A 0 A_ZoomFactor(1.0)
		REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"Ready3")

	OpenCylinder:
        REVO A 0 A_JumpIfInventory("AmmoMagnum",1,1)//If there is no reserve ammo, don't reload, go back to Ready
        Goto Ready
		REVO A 0 A_JumpIfInventory("TurboReload", 1, "TurboReload")//Check if reloads are disabled.
		REVO A 0 A_JumpIfInventory("RevolverUnloaded",1,"OpenEmptyCylinder")
		REVR ABCDE 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR F 1 A_PLaySound("RELO1")
        REVR GH 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR I 4 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVO A 0 A_JumpIfInventory("RevolverChangeAmmo", 1, "InsertBulletAnimation")

		REVR JK 1
		REVR K 8 Offset(0,64)
		Goto Dump

	OpenEmptyCylinder:
        REVO A 0
		REVR ABCDE 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR P 1 A_PLaySound("RELO1")
        REVR ON 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR M 4 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		Goto InsertBulletAnimation

	Dump:
		REVO A 0
		REVO A 0 A_JumpIfInventory("SpentRound",1,1)
        Goto PutMag
		TNT1 A 0 A_FireCustomMissile("MagnumCasing",random(-90,-120),0,0,-16)
        REVO A 0 A_TakeInventory("SpentRound",1)
		Loop

	PutMag:
		REVO A 0
		REVR K 8
		REVR LM 1
		REVR M 4

	InsertBulletAnimation:
		REVO A 0
		REVO A 0 A_JumpIfInventory("AmmoMagnum",1,1)//if there are no more reserve rounds, finish reload.
        Goto FinishedInsertingBullets
		REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishedInsertingBullets")
        REVO A 0 A_Giveinventory("RevolverAmmo",1)
		REVO A 0 A_Takeinventory("AmmoMagnum",1)
        TNT1 A 0 A_PlaySound("insertshell")
		REVR M 4 Offset(0, 64)
		REVR M 4 Offset(0, 66)
        Loop

	FinishedInsertingBullets:
		REVO A 0
		TNT1 A 0 A_PLaySound("RELO2")
		REVR IHGFEDCBA 1
		TNT1 A 0 A_PlaySound("REVOHAM", 4)
		REVO OPQR 1
		TNT1 A 0 A_TakeInventory("RevolverChangeAmmo",1)
		TNT1 A 0 A_TakeInventory("RevolverUnloaded",1)
		Goto Ready

	 TurboReload:
		SHSS BC 0
	TurboBullets:
		REVO A 0
		REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishTurboReload")
        REVO A 0 A_JumpIfInventory("AmmoMagnum",1,3)
        Goto Ready3
        TNT1 AAAA 0
        REVO A 0 A_Giveinventory("RevolverAmmo",1)
		REVO A 0 A_Takeinventory("AmmoMagnum",1)
		Goto TurboBullets
	FinishTurboReload:
		TNT1 A 0 A_TakeInventory("RevolverUnloaded",1)
		REVO A 0 A_Refire
		Goto Ready3

	DualWield:
		TNT1 A 0
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_GiveInventory("RevolverChangeAmmo", 1)
		REVO A 2 A_JumpIfInventory("AmmoShell",1,"Unload")
		Goto NoShells

	NoShells:
		TNT1 A 0 A_Print("You are out of shotgun shells.", 2)
		TNT1 A 0 A_TakeInventory("RevolverChangeAmmo",1)
		REVO A 5
		Goto Ready3

	Unload:
		REVO A 1
		REVO A 0 A_ZoomFactor(1.0)
		REVO A 0 A_Takeinventory("Unloading",1)
		REVO A 0 A_Takeinventory("ADSmode",1)
		REVO A 0 A_Takeinventory("Zoomed",1)
        REVO A 0 A_JumpIfInventory("RevolverAmmo",1,2)
		REVO A 0 A_JumpIfInventory("RevolverChangeAmmo",1,"FinishUnload")
        Goto Ready3
        TNT1 AAA 0
		REVR ABCDE 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR F 1 A_PLaySound("RELO1")
        REVR GH 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR I 4 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVR JK 1
		REVR K 8 Offset(0,64)

	RemoveBullets:
		TNT1 AAAA 0
		REVO A 0 A_JumpIfInventory("RevolverAmmo",1,3)
		Goto FinishUnload
        TNT1 AAAAAA 0
		REVO A 0 A_Takeinventory("RevolverAmmo",1)
		REVO A 0 A_Giveinventory("AmmoMagnum",1)
		Loop

	FInishUnload:
		TNT1 A 0
		REVR K 8
		REVR LM 1
		REVR M 4
		TNT1 A 0 A_PLaySound("RELO2")
		REVR NOPEDCBA 1
		REVO A 0 A_TakeInventory("SpentRound", 6)
		REVO A 0 A_Takeinventory("Unloading",1)
		REVO A 0 A_GiveInventory("RevolverUnloaded",1)
		TNT1 A 0 A_JumpIfInventory("RevolverChangeAmmo", 1, "ChangeAmmo")
		Goto Ready3

	ChangeAmmo:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("Revolver2")
		TNT1 A 0 A_GiveInventory("Reloading",1)
		TNT1 A 0 A_SelectWeapon("Revolver2")
		Goto Ready3

	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
	NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		REVO A 0 A_JumpIfInventory("PistolBurstFire",1,"NoAmmo3")
		REVO A 5 A_WeaponReady(WRF_ALLOWRELOAD)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("AmmoMagnum",1,"Reload")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Goto Ready3
	NoAmmo3:
		REVA A 5 A_WeaponReady(WRF_ALLOWRELOAD)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("AmmoMagnum",1,"Reload")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Goto Ready2
	}
}

ACTOR RevolverAmmo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 6
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 6
   Inventory.Icon "REVPA0"
}

ACTOR SpentRound : Inventory
{
	Inventory.MaxAmount 6
}