Actor StartAmmoRevolver : Inventory
{
Inventory.MaxAmount 1
}

// --------------------------------------------------------------------------
//
//	Revolver
//
// --------------------------------------------------------------------------

ACTOR TE_Revolver : BaseWeapon
{

	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 6
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "RevolverBullets"
	Weapon.AmmoType2 "TE_RevolverAmmo"
	Weapon.SelectionOrder 5000
	Weapon.Kickback 200
	-WEAPON.CHEATNOTWEAPON
	Weapon.SisterWeapon "DualRevolver"
	Inventory.PickupSound "revolver/draw"
	Inventory.Pickupmessage "You got the Revolver!"
	Obituary "%o got shot into pieces by %k's revolver."
	tag "Revolver"
	Scale 0.55 //0.7 
	States
	{
 	Spawn:
		RVIC A -1
		Stop
	
	Select:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist",1,"PuristGun")
//		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1001,2)==0,"PuristGun")
TNT1 A 0 A_JumpIfInventory("StartAmmoRevolver",1,"Selected")
TNT1 A 0 A_GiveInventory("TE_RevolverAmmo",6)
	//Bullets in the revolver
TNT1 A 0 A_GiveInventory("RevolverCylinderSlot1",1)
TNT1 A 0 A_GiveInventory("RevolverCylinderSlot2",1)
TNT1 A 0 A_GiveInventory("RevolverCylinderSlot3",1)
TNT1 A 0 A_GiveInventory("RevolverCylinderSlot4",1)
TNT1 A 0 A_GiveInventory("RevolverCylinderSlot5",1)
TNT1 A 0 A_GiveInventory("RevolverCylinderSlot6",1)
Selected:
TNT1 A 0 A_GiveInventory("StartAmmoRevolver",1)

		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("TossGrenade",1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
		TNT1 A 0 A_Takeinventory("Taunting",1)
//		TNT1 A 0 A_Takeinventory("IdleCounter",200)
		TNT1 A 6
		TNT1 A 0 A_Raise
		Wait
		





	CheckSprint:
		Revf g 1 A_WeaponReady(WRF_NOFIRE)
		UNHG A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		UNHG A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready3
		
	StartSprint:
		revf G 1 A_WeaponReady(WRF_NOFIRE)
		UNHG A 0 A_Takeinventory("Zoomed",1)
		UNHG A 0 A_Takeinventory("ADSmode",1)
		UNHG A 0 A_ZoomFactor(1.0)
		UNHG A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
		
	Sprinting:	
		UNHG A 0 offset(-9,32) 
		UNHG A 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		UNHG A 0 offset(-9,32) A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		UNHG A 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
		UNHG A 0 offset(-9,32) A_GiveInventory("UsedStamina", 12)
		UNHG A 0 offset(-9,32)
		revf g 1 offset(-9,34) A_SetPitch(pitch -0.5) //-0.25
		revf g 1 offset(-6,36) A_SetPitch(pitch -0.5)
		revf g 1 offset(-3,38) A_SetPitch(pitch -0.5)
		revf g 1 offset(0,38) A_SetPitch(pitch -0.5)
		revf g 1 offset(3,36) A_SetPitch(pitch -0.5)
		revf g 1 offset(6,34) A_SetPitch(pitch -0.5)
		revf g 1 offset(9,32) A_SetPitch(pitch -0.5)
		UNHG A 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		UNHG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        UNHG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        UNHG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		UNHG A 0 offset(-9,32) A_GiveInventory("UsedStamina", 12)
		UNHG A 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		revf g 1 offset(9,34) A_SetPitch(pitch +0.5)
		revf g 1 offset(6,36) A_SetPitch(pitch +0.5)
		revf g 1 offset(3,38) A_SetPitch(pitch +0.5)
		revf g 1 offset(0,38) A_SetPitch(pitch +0.5)
		revf g 1 offset(-3,36) A_SetPitch(pitch +0.5)
		revf g 1 offset(-6,34) A_SetPitch(pitch +0.5)
		revf g 1 offset(-9,32) A_SetPitch(pitch +0.5)
		UNHG A 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		UNHG A 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint
		
	StopSprintTired:
		revf g 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		UNHG A 0 A_PlaySound("Tired", 2)
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		revf g 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		revf g 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		revf g 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		revf g 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		revf g 5 A_WeaponReady
		Goto Ready3
	StopSprint:
		revf g 1
		UNHG A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready3

















	Deselect:
		TNT1 A 0 A_PlaySound("weapons/changing")
		REVF A 1
		REVD ABCD 1
		TNT1 A 1
		TNT1 A 0 A_Lower
		Wait
			
	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		TNT1 A 0 A_PlaySound("revolver/draw",5)
	Ready1:
		REVD DCBA 1
	Ready2:
		TNT1 A 0 A_GunFlash
	Ready3:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
	//	TNT1 A 0 A_JumpIfInventory("Taunting",1,"TauntL")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
	RLNG A 0 A_JumpIfInventory("HasUnloadedRL", 1, "ReadyNoAmmo")
RLNG A 0 A_JumpIfInventory("Unloading",1,"Unload")
TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
	//	TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		REVF A 1 A_WeaponReady
		Loop

ReadyNoAmmo:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		REVF A 1 A_WeaponReady
		Loop

		
// --------------------------------------------------------------------------
//
//	Fire
//
//		With each fire the weapon cycles to the next "RevolverCylinderPos"
//		by adding one token to the player. If the player has 7 tokens we go back
//		to 1, since there's only 6 possible positions in the chamber.
//		Then check if the player has the "RevolverCylinderSlot"-token for that slot,
//		and if that's the case - remove the token so that we know in the future that
//		that position has been fired. Then continue to fire as normal.
//
//		When the player spins the cylinder we get a new starting position for
//		"RevolverCylinderPos", wo that we can play russian roulette.
//		When we reload the weapon we gain all tokens back.
//
// --------------------------------------------------------------------------

	FireBullet:
		TNT1 A 0 A_Jump(25,5) //10% chance to do a critical hit.
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff1B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff1B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff1A")
//		TNT1 A 0 A_FireCustomMissile("RWP",0,0,0,0) //RevolverWallPenetrator
		Stop
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff2B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff2B")
		TNT1 A 0 A_FireBullets(0,0,-1,21,"RevolverPuff2A")
//		TNT1 A 0 A_FireCustomMissile("RWP",0,0,0,0) //RevolverWallPenetrator
		Stop

	Fire:
	TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,2)
	TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"DryFire") //Reload
		Goto DryFire
		
		//Bring forth next cylinder slot
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_GiveInventory("RevolverCylinderPos",1)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",7,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_TakeInventory("RevolverCylinderPos",6)
		
		//Check if selected slot has a bullet
		//Slot 1
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",2,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Jump(256,19)
		//Slot 2
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",3,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Jump(256,15)
		//Slot 3
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",4,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Jump(256,11)
		//Slot 4
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",5,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Jump(256,7)
		//Slot 5
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",6,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Jump(256,3)
		//Slot 6
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,1)
		Goto DryFire
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot6",1)
		
		//Slot has a bullet. Fire!
		TNT1 A 0 A_PlaySound("revolver/fire1",1)
		TNT1 A 0 A_PlaySound("revolver/fire2",5,0.7)
		REVF BC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_ZoomFactor(0.80)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_Jump(128,3)
		REVF D 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Jump(256,2)
		REVF E 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",frandom(-10,10),0,-1,-8,0,frandom(-10,10))
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		TNT1 AA 0 A_FireCustomMissile("GunFireSmoke",0,0,0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("Tracer",frandom(-2,2),0,-1,0)
		TNT1 A 0 A_FireCustomMissile("ShakeYourAssDouble",0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
		TNT1 A 0 A_AlertMonsters
		
		TNT1 A 0 A_SetAngle(frandom(0.8,-0.8) + angle)
		TNT1 A 0 A_SetPitch(frandom(0.8,-0.8) + pitch)
		TNT1 A 0 A_GunFlash("FireBullet")
		
		TNT1 A 0 A_Takeinventory("TE_RevolverAmmo",1)
		TNT1 A 0 A_Takeinventory("DualRevolverAmmo",1) //xx
		TNT1 A 0 A_Takeinventory("LeftChamber",1) //xx

		

TNT1 A 0 A_Recoil(0.3)
		TNT1 A 0 A_SetAngle(frandom(2,-2) + angle)
		TNT1 A 0 A_setpitch(pitch - 5.0) //was -8.0
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_ZoomFactor(1.00)
		REVF GGFF 1 A_setpitch(pitch + 1.2)
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 7 A_WeaponReady
		Goto Ready2

	AltFire:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"Reload")
		Goto DryFire
		
		//Bring forth next cylinder slot
		REVF HIJKL 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Jump(256,6)
		
	AltHold:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"Reload")
		Goto DryFire
		REVF VKL 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_GiveInventory("RevolverCylinderPos",1)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",7,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_TakeInventory("RevolverCylinderPos",6)
		
		//Check if selected slot has a bullet
		//Slot 1
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",2,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Jump(256,19)
		//Slot 2
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",3,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Jump(256,15)
		//Slot 3
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",4,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Jump(256,11)
		//Slot 4
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",5,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Jump(256,7)
		//Slot 5
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",6,4)
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Jump(256,3)
		//Slot 6
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,1)
		Goto DryFireAlt
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot6",1)
		
		//Slot has a bullet. Fire!
		TNT1 A 0 A_PlaySound("revolver/fire1",1)
		TNT1 A 0 A_PlaySound("revolver/fire2",5,0.7)
		TNT1 A 0 A_ZoomFactor(0.80)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_Jump(128,3)
		REVF M 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Jump(256,2)
		REVF N 1 BRIGHT A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",frandom(-10,10),0,-1,-8,0,frandom(-10,10))
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		TNT1 AA 0 A_FireCustomMissile("GunFireSmoke",0,0,0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("Tracer",frandom(-2,2),0,-1,0)
		TNT1 A 0 A_FireCustomMissile("ShakeYourAssDouble",0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle2",30,5,27)
		TNT1 A 0 A_AlertMonsters
		
		TNT1 A 0 A_SetAngle(frandom(1.6,-1.6) + angle)
		TNT1 A 0 A_SetPitch(frandom(1.6,-1.6) + pitch)
		TNT1 A 0 A_GunFlash("FireBullet")

		TNT1 A 0 A_Takeinventory("TE_RevolverAmmo",1)
TNT1 A 0 A_Takeinventory("DualRevolverAmmo",1) //xx
		TNT1 A 0 A_Takeinventory("LeftChamber",1) //xx

		TNT1 A 0 A_Recoil(0.3)
		TNT1 A 0 A_SetAngle(frandom(2,-2) + angle)
		TNT1 A 0 A_setpitch(pitch - 5.0) //was -8.0
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_ZoomFactor(1.00)
		REVF OPQ 1 A_SetPitch(pitch + 1.3)
		TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF R 1 A_Refire
		REVF WXYZ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 3 A_WeaponReady
		Goto Ready2


// --------------------------------------------------------------------------
//
//	Reload
//
// --------------------------------------------------------------------------
	
	Reload:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",6,"WeapSpecial")
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,1)
		Goto Ready2
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"ReloadLoop")
		REVF A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVR A 1 //2
		TNT1 A 0 //A_PlaySound ("revolver/reload")
		REVR BC 2 
		REVR DE 1 A_PlaySound ("revolver/open",7) //new sound
TNT1 A 0 A_JumpIfinventory("HasUnloaded",1,"ReloadUnload")

REVR F 1

		REVR GGG 1 //GG 2
		
		REVR HIJKLMNOPQR 2
REVR S 1
		REVR TU 1 //2 


TNT1 A 0 A_JumpIfInventory("RevolverBullets",6,"ReloadNormal")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
goto Reloadsome
ReloadNormal:

//How many cases should we spawn?
TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,"COLD1")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx

Goto Next1
COLD1:
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
Next1:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,"COLD2")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto Next2
COLD2:
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
Next2:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,"COLD3")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto Next3
COLD3:
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
Next3:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,"COLD4")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto Next4
COLD4:
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
Next4:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,"COLD5")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto Next5
COLD5:
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
Next5:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,"COLD6")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto Next6
COLD6:
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
Next6:

//TNT1 A 0 A_JumpIfInventory("RevolverBullets",6,"ReloadNormal")
//goto Reloadsome
//ReloadNormal:


Goto ContReload

ReloadUnload:
TNT1 A 0 A_JumpIfInventory("RevolverBullets",6,"ReloadUnloadNormal")
goto Reloadsome
ReloadUnloadNormal:


TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,"reunCOLD1")
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx

Goto reunNext1
reunCOLD1:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
reunNext1:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,"reunCOLD2")
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto reunNext2
reunCOLD2:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
reunNext2:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,"reunCOLD3")
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto reunNext3
reunCOLD3:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
reunNext3:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,"reunCOLD4")
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto reunNext4
reunCOLD4:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
reunNext4:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,"reunCOLD5")
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto reunNext5
reunCOLD5:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
reunNext5:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,"reunCOLD6")
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto reunNext6
reunCOLD6:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
reunNext6:


		RVVR F 2
		RVVR GGG 1 
		RVVR HI 2 
RVVR J 2
TNT1 A 0 A_Takeinventory("HasUnloaded",1)

ContReload:

 
		R6V1 ABCDE 2
R6V1 F 2 A_PlaySound ("revolver/case",0) //new sound 
		R6V1 GHIJ 2
R6V1 K 2 A_PlaySound ("revolver/close") 
		R6V1 N 1  
		REVR EDCBA 1 //2 changed order
		REVF Z 2
				
	ReloadLoop:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",6,5)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,2)
		TNT1 A 0 A_Jump(256,3)
		TNT1 A 0 A_Giveinventory("TE_RevolverAmmo",6) //6 edit

//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",6) //xx

		TNT1 A 0 A_Takeinventory("RevolverBullets",6) //1 edit
		//Goto ReloadLoop
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot6",1)
		TNT1 A 0 A_Refire
		Goto Ready2
		

Reloadsome:
42v2 IHG 2
ReloadsomePreloop:
TNT1 A 0 A_Takeinventory("TE_RevolverAmmo",1) 
TNT1 A 0 A_Takeinventory("DualRevolverAmmo",1)
TNT1 A 0 A_JumpIfinventory("TE_RevolverAmmo",1,"ReloadsomePreloop")

ReloadsomeLoop:
TNT1 AAA 2
TNT1 AAA 2

TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",6,"Reloadsomedone")
TNT1 A 0 A_JumpIfInventory("RevolverBullets",1,"ReloadsomeLooping")
goto Reloadsomedone
ReloadsomeLooping:
		TNT1 A 0 A_Giveinventory("TE_RevolverAmmo",1) 

TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1)
TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx

		TNT1 A 0 A_Takeinventory("RevolverBullets",1)

TNT1 A 2 A_PlaySound("revolver/case",0)
TNT1 AAA 2
		Goto ReloadsomeLoop
Reloadsomedone:
TNT1 A 0 A_PlaySound ("revolver/close")
42v2 GHI 2
		REVR EDCBA 1 //2 changed order
		REVF Z 2

		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Giveinventory("RevolverCylinderSlot6",1)
		TNT1 A 0 A_Refire

Goto Ready2

Unload:
		TNT1 A 0 A_Takeinventory("Unloading",1)
TNT1 A 0 A_Giveinventory("HasUnloaded",1)
	TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,"unloadgo")
Goto Ready2
unloadgo:
		REVF A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVR A 1 //2
		TNT1 A 0 //A_PlaySound ("revolver/reload")
		REVR BC 2 
		REVR DEF 1 A_PlaySound ("revolver/open") //new sound
		REVR GGG 1 //GG 2
		
		REVR HIJ 2 
		RVVR KLMNOPQR 2
RVVR S 1
		RVVR TU 1 A_PlaySound ("revolver/close") //2 

//How many cases should we spawn?
TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot1",1,"unCOLD1")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
//TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx

Goto unNext1
unCOLD1:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
unNext1:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot2",1,"unCOLD2")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
//TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto unNext2
unCOLD2:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
unNext2:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot3",1,"unCOLD3")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
//TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto unNext3
unCOLD3:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
unNext3:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot4",1,"unCOLD4")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
//TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto unNext4
unCOLD4:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
unNext4:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot5",1,"unCOLD5")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
//TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto unNext5
unCOLD5:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
unNext5:

TNT1 A 0 A_JumpIfInventory("RevolverCylinderSlot6",1,"unCOLD6")
TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawn",-2,0,-8,0)
//TNT1 A 0 A_Giveinventory("DualRevolverAmmo",1) //xx
//TNT1 A 0 A_Giveinventory("LeftChamber",1) //xx
Goto unNext6
unCOLD6:
//TNT1 A 0 A_FireCustomMissile("RevolverCaseSpawncold",-2,0,-8,0)
unNext6:



 
	//	R6V1 ABCDEF 2 A_PlaySound ("revolver/case",0) //new sound 
	//	R6V1 GHIJK 2 A_PlaySound ("revolver/close") 
	//	R6V1 N 1  
		REVR EDCBA 2 
		REVF Z 2
				
	UnloadLoop:
		TNT1 A 0 A_JumpIfInventory("TE_RevolverAmmo",1,"unloadlooping")
goto finishunload
unloadlooping:
		
		TNT1 A 0 A_Takeinventory("TE_RevolverAmmo",1) 
TNT1 A 0 A_Takeinventory("DualRevolverAmmo",1) 
TNT1 A 0 A_Takeinventory("LeftChamber",1) //xx
		TNT1 A 0 A_Giveinventory("RevolverBullets",1) 
		Goto UnloadLoop

finishunload:
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot1",1)
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot2",1)
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot3",1)
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot4",1)
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot5",1)
		TNT1 A 0 A_Takeinventory("RevolverCylinderSlot6",1)
		TNT1 A 0 A_Refire
		Goto Ready2

// --------------------------------------------------------------------------
//
//	Misc.
//
// --------------------------------------------------------------------------

	DualWield:
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
//		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1028)==0,"NoDualWield")
//		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1028)==2,"Ready2")
		TNT1 A 0 A_JumpIfInventory("TE_Revolvers",2,"GetDual")
TNT1 A 0 A_Print("You must have two revolvers to dual wield.")
		Goto Ready2
GetDual:
		REVD ABCD 1
		TNT1 A 6
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_Giveinventory("PowerSphere2",1)
		Goto Ready


	//NoDualWield:
	//	TNT1 A 0 A_Print("Dual wielding is disabled.")
	//	Goto Ready2

	DryFire:
		REVF BC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 1 A_PlaySound("weapons/empty2")
		Goto Ready2

	WeapSpecial:
		REVF A 1
		REVR ABC 1 
		REVR ZE 1 //DE
	SpinMoar:
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
	TNT1 A 0 A_Takeinventory("Taunting",1)
		TNT1 A 0 A_PlaySound("revolver/spin")
		REVR YXWV 2 //REVR UTSR 2
		REVS ABCDEFDE 1
		REVS CD 2
		REVS E 3
		TNT1 A 0 A_JumpIfInventory("WeapSpecial",1,"SpinMoar")
		TNT1 A 0 A_JumpIfInventory("SwitchFlashlight",1,"SpinMoar")
		REVR EZCBA 2 //REVR EDCBA 2
		TNT1 A 0 A_GiveInventory("RevolverCylinderPos",random(1,6))
		TNT1 A 0 A_JumpIfInventory("RevolverCylinderPos",7,2)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_TakeInventory("RevolverCylinderPos",6)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Takeinventory("WeapSpecial",1)
		TNT1 A 0 A_Takeinventory("SwitchFlashlight",1)
		Goto Ready2

	DryFireAlt:
		TNT1 A 0 A_PlaySound("weapons/empty2")
		REVR WXYV 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
//REVR UTSR 2	
TNT1 A 0 A_Refire
		REVF WXYZ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		REVF A 3 A_WeaponReady
		Goto Ready2
	
	PuristGun:
		TNT1 A 0 A_TakeInventory("Revolver",1)
		Goto Deselect
		
// --------------------------------------------------------------------------
//
//	End stuff
//
// --------------------------------------------------------------------------

	TauntFlash:
		REVD ABCD 1
		TNT1 A 35
		REVD DCBA 1
		REVF A 1
		Stop

	KickFlash:
		REVK ABCD 1
		REVK D 8
		REVK DCBA 1
		REVF A 1
		Stop

	AirKickFlash:
		REVK ABCD 1
		REVK D 10
		REVK DCBA 1
		REVF A 1
		Stop

	SlideKickStartFlash:
		REVK ABCD 1
		REVK D 17
		Stop

	SlideKickEndFlash:
		REVK DDCBA 2
		REVF A 1
		Stop

	GrenadeFlash:
		REVD ABCD 1
		Stop
	}
}

ACTOR RevolverCylinderPos : Inventory { Inventory.MaxAmount 12 }
ACTOR RevolverCylinderSlot1 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot2 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot3 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot4 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot5 : Ammo { Inventory.MaxAmount 1 }
ACTOR RevolverCylinderSlot6 : Ammo { Inventory.MaxAmount 1 }

ACTOR TE_RevolverAmmo : Ammo
{
	+INVENTORY.IGNORESKILL
	Inventory.Amount 0
	Inventory.MaxAmount 6
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 6
   	Inventory.Icon "RVICA0"
}

Actor RevolverPuff1A
{
	Renderstyle Translucent
	Alpha 0.4
	Scale 1.5
	Radius 0
	Height 0
	Gravity 0.01
	DamageType Blast
	Decal "RevolverDecal"
	+NOBLOCKMAP
	+NOGRAVITY
	+NOEXTREMEDEATH
	+FORCEXYBILLBOARD
	+DONTSPLASH
	-EXPLODEONWATER
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("RevolverRicoChet",0,0,-5,0,0,0,0,SXF_NOCHECKPOSITION,0)
	Melee:
		TNT1 A 0
		stop
	}
}

Actor RevolverPuff1B : RevolverPuff1A
{
	Decal "None"
	states
	{
	Spawn:
		TNT1 A 0
	Melee:
		TNT1 A 0
		stop
	}
}

Actor RevolverPuff2A : RevolverPuff1A
{
	DamageType SSG
	Decal "RevolverDecal"
}

Actor RevolverPuff2B : RevolverPuff1A
{
	DamageType SSG
	Decal "None"
	states
	{
	Spawn:
		TNT1 A 0
	Melee:
		TNT1 A 0
		stop
	}
}


// --------------------------------------------------------------------------
//
//	Revolver Wall Penetrator
//		Heavily edited original code by Sergeant Mark IV
//
// --------------------------------------------------------------------------





//MISC --------------------------------------------------------------------------



Actor PowerSphere2 : PowerupGiver //Gives to the player when normal dual wielding
{
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	Powerup.Duration -600
	Powerup.Type "WeaponLevel2"
}
