ACTOR PerkPistol : Pistol replaces Pistol
{
	decal bulletchip
	States
	{
	Spawn:
		PSTO a -1
		stop
	Ready:
		TNT1 A 0 a_jumpif(callacs("skintoggler")==1, "64ready")
		TNT1 A 0 a_jumpif(callacs("skintoggler")==2, "blready")		
		PKPI A 1 A_WeaponReady
		Loop
		
	Deselect:
		TNT1 A 0 a_jumpif(callacs("skintoggler")==1, "64deselect")
		TNT1 A 0 a_jumpif(callacs("skintoggler")==2, "bldeselect")
		PKPI A 1 A_Lower
		Loop
		
	Select:
		TNT1 A 0 a_jumpif(callacs("skintoggler")==1, "64select")
		TNT1 A 0 a_jumpif(callacs("skintoggler")==2, "blselect")
		PKPI A 1 A_Raise
		Loop
		
	Fire:
				//skin & bob check
					TNT1 A 0 a_jumpif(callacs("BobToggle")==1, "bobfire")
					TNT1 A 0 a_jumpif(callacs("skintoggler")==1, "64fire")
					TNT1 A 0 a_jumpif(callacs("skintoggler")==2, "blfire")
			
		PKPI AB 2
		PKPI C 2 A_FirePistol
						//casing check
					tnt1 a 0 A_JumpIf(CallACS("CasingToggle")==0, +2)
					TNT1 A 0 A_spawnitemex ("bulletcasing", 40, 0, 25, random(0,2), random(4,6), random(3,5), 0)
		PKPI D 1
		PKPI EF 1
		PKPI G 3
		PKPI F 2
		PKPI B 2 A_ReFire
		PKPI BAA 1 A_refire
		Goto Ready
		
	Flash:
		TNT1 A 0 a_jumpif(callacs("skintoggler")==1, "64flash")
		TNT1 A 0 A_JumpIf(CallACS("RecoilToggle")==1, "Kickflash")
		PKPF B 2 Bright A_Light2
		PKPF A 1 Bright A_Light1
		Goto LightDone
		
	KickFlash:
		PKPF B 2 Bright A_Light2
		PKPF A 1 Bright A_Light1
		TNT1 a 1 a_setpitch(pitch+0.3)
		TNT1 a 1 a_setpitch(pitch-0.1)
		TNT1 a 2 a_setpitch(pitch-0.1)
		TNT1 a 2 a_setpitch(pitch-0.05)
		TNT1 a 2 a_setpitch(pitch-0.05)
		Goto LightDone
		

	////////////////
	//BLACK GLOVES//
	////////////////
	
	BLReady:
		BLPI A 1 A_WeaponReady
		Loop
		
	BLDeselect:
		BLPI A 1 A_Lower
		Loop
		
	BLSelect:
		BLPI A 1 A_Raise
		Loop
		
	BLFire:
				//skin & bob check
					TNT1 A 0 a_jumpif(callacs("BobToggle")==1, "bobblfire")

		BLPI AB 2
		BLPI C 0 A_FirePistol
				//casing check
					tnt1 a 0 A_JumpIf(CallACS("CasingToggle")==0, +2)
					TNT1 A 0 A_spawnitemex ("bulletcasing", 40, 0, 25, random(0,2), random(4,6), random(3,5), 0)

		BLPI C 2
		BLPI D 1
		BLPI EF 1
		BLPI G 3
		BLPI F 2
		BLPI F 2 A_ReFire
		BLPI BAA 1 A_refire
		Goto Ready

		
	/////////////
	//64 STATES//
	/////////////

	64Ready:
		PISG A 1 A_WeaponReady
		Loop
	64Deselect:
		PISG A 1 A_Lower
		Loop
	64Select:
		PISG A 1 A_Raise
		Loop
	64Fire:
		TNT1 A 0 a_jumpif(callacs("BobToggle")==1, "bob64fire")
		
		PISG AB 2
		PISG C 2 A_FirePistol
					//casing check
			tnt1 a 0 A_JumpIf(CallACS("CasingToggle")==0, +2)
			TNT1 A 0 A_spawnitemex ("bulletcasing", 40, 0, 25, random(0,2), random(4,6), random(3,5), 0)

		PISG D 1
		PISG EF 2
		PISG G 1 
		PISG HI 1
		PISG IJ 2 A_refire
		PISG A 3 A_refire
		Goto Ready

	64Flash:
		TNT1 B 2 Bright A_Light2
		TNT1 A 1 Bright A_Light1
		TNT1 a 1 a_setpitch(pitch+0.3)
		TNT1 a 1 a_setpitch(pitch-0.1)
		TNT1 a 2 a_setpitch(pitch-0.1)
		TNT1 a 2 a_setpitch(pitch-0.05)
		TNT1 a 2 a_setpitch(pitch-0.05)
		Goto LightDone
	

		
	///////////////////////////
	//////////BOB STATES///////
	///////////////////////////
	
	bobFire:
		TNT1 A 0 a_jumpif(callacs("skintoggler")==1, "64bobfire")
		TNT1 A 0 A_JumpIf(CallACS("skintoggler")==2, "bobBLFire")

		PKPI A 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI B 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI C 0 A_FirePistol 
			//casing check
			tnt1 a 0 A_JumpIf(CallACS("CasingToggle")==0, +2)
			TNT1 A 0 A_spawnitemex ("bulletcasing", 40, 0, 25, random(0,2), random(4,6), random(3,5), 0)
			//

		PKPI C 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI D 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI E 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI F 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI G 3 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI F 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI B 2 A_refire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI B 1 A_refire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI A 1 A_refire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PKPI A 1 A_refire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		Goto Ready

	bobBLFire:
		TNT1 A 0 A_JumpIf(CallACS("RecoilToggle")==1, "bobblRecoilFire")	
		BLPI A 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI B 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI C 2 A_FirePistol
					//casing check
			tnt1 a 0 A_JumpIf(CallACS("CasingToggle")==0, +2)
			TNT1 A 0 A_spawnitemex ("bulletcasing", 40, 0, 25, random(0,2), random(4,6), random(3,5), 0)
					//
		
		BLPI D 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI E 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI F 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI G 3 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI F 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI B 2 A_ReFire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI B 1 A_refire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI A 1 A_refire
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		BLPI A 1 A_refire
		Goto Ready
		
	64bobFire:
		TNT1 A 0 A_JumpIf(CallACS("RecoilToggle")==1, "bob64RecoilFire")
		TNT1 a 0 A_FirePistol
		TNT1 a 0 a_gunflash
			//recoil check
			TNT1 A 0 A_JumpIf(CallACS("RecoilToggle")==0, +2)
			TNT1 a 0 a_quake(1,4,0,50)
			//casing check
			tnt1 a 0 A_JumpIf(CallACS("CasingToggle")==0, +2)
			TNT1 A 0 A_spawnitemex ("bulletcasing", 40, 0, 25, random(0,2), random(4,6), random(3,5), 0)
			//
		PISG B 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG C 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG D 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG E 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG F 2 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG G 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG H 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG I 1 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG I 2 a_refire
			TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG J 2 A_refire
			TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		PISG A 3 A_refire
		Goto Ready
		}
}