ACTOR BrutalPistol : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Clip1"
	Weapon.AmmoType2 "BDPistolAmmo"
	weapon.selectionorder 3800
	Obituary "%o was shot down by %k's pistol."
    AttackSound "None"
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "$GOTPISTOL"
    +WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+WEAPON.NOALERT
	+WEAPON.NO_AUTO_SWITCH
	+WEAPON.WIMPY_WEAPON
    +FORCEXYBILLBOARD
	Scale 0.9
	Tag "Pistol"
	States
	{
	
	Ready3:
	Ready:
        PIST F 0 A_JumpIfInventory("Kicking",1,"DoKick")
        PIST F 0 A_JumpIfInventory("Taunting",1,"Taunt")
		PIST F 0 A_JumpIfInventory("Salute1", 1, "Salute")
		PIST F 0 A_JumpIfInventory("Salute2", 1, "Salute")
        PIST F 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST F 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		PIST F 0 A_JumpIfInventory("Unloading",1,"Unload")
		PIST F 1 A_WeaponReady(WRF_ALLOWRELOAD)
		PIST F 0 A_Takeinventory("PistolFireAnimation1",1)
		PIST F 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		PIST F 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		
		Loop
		
	CheckSprint:
		PIST F 1 A_WeaponReady(WRF_NOFIRE)
		PIST F 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		PIST F 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		PIST F 1 A_WeaponReady(WRF_NOFIRE)
		PIST F 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
		
	Sprinting:	
		PISP A 0 offset(-9,32) 
		PIST F 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		PIST F 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.
		PIST F 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
		PIST F 0 offset(-9,32) A_GiveInventory("UsedStamina", 2)
		PIST F 0 offset(-9,32)
		PISP F 1 offset(-9,34) A_SetPitch(pitch -0.5)
		PISP F 1 offset(-6,36) A_SetPitch(pitch -0.5)
		PISP F 1 offset(-3,38) A_SetPitch(pitch -0.5)
		PISP F 1 offset(0,38) A_SetPitch(pitch -0.5)
		PISP F 1 offset(3,36) A_SetPitch(pitch -0.5)
		PISP F 1 offset(6,34) A_SetPitch(pitch -0.5)
		PISP F 1 offset(9,32) A_SetPitch(pitch -0.5)
		PIST F 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		PIST F 0 A_JumpIfInventory("Kicking",1,"DoKick")
        PIST F 0 A_JumpIfInventory("Taunting",1,"Taunt")
        PIST F 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST F 0 offset(-9,32) A_GiveInventory("UsedStamina", 3)
		PIST F 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		PISP F 1 offset(9,34) A_SetPitch(pitch +0.5)
		PISP F 1 offset(6,36) A_SetPitch(pitch +0.5)
		PISP F 1 offset(3,38) A_SetPitch(pitch +0.5)
		PISP F 1 offset(0,38) A_SetPitch(pitch +0.5)
		PISP F 1 offset(-3,36) A_SetPitch(pitch +0.5)
		PISP F 1 offset(-6,34) A_SetPitch(pitch +0.5)
		PISP F 1 offset(-9,32) A_SetPitch(pitch +0.5)
		PIST F 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		PIST F 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		
		Goto StopSprint
	StopSprintTired:
		PIST F 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		PIST F 0 A_PlaySound("Tired", 2)
		PIST F 0 A_TakeInventory("UsedStamina", 2)
		PIST F 5 A_WeaponReady
		PIST F 0 A_TakeInventory("UsedStamina", 2)
		PIST F 5 A_WeaponReady
		PIST F 0 A_TakeInventory("UsedStamina", 2)
		PIST F 5 A_WeaponReady
		PIST F 0 A_TakeInventory("UsedStamina", 2)
		PIST F 5 A_WeaponReady
		PIST F 0 A_TakeInventory("UsedStamina", 2)
		PIST F 5 A_WeaponReady
		Goto Ready
	StopSprint:
		PISP A 1
		PIST F 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready	
		
	Deselect:
        PISS BA 1
		TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
		PIST F 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 1 A_Lower
		Wait
		
	Select:
		PIST F 0 A_Takeinventory("StartDualWield",1)
		PIST F 0 A_Giveinventory("GoSpecial",1)
		PIST F 0 A_Takeinventory("FistsSelected",1)
		PIST F 0 A_Takeinventory("SawSelected",1)
		PIST F 0 A_Takeinventory("ShotgunSelected",1)
		PIST F 0 A_Takeinventory("SSGSelected",1)
		PIST F 0 A_Takeinventory("MinigunSelected",1)
		PIST F 0 A_Takeinventory("PlasmaGunSelected",1)
		PIST F 0 A_Takeinventory("RocketLauncherSelected",1)
		PIST F 0 A_Takeinventory("GrenadeLauncherSelected",1)
		PIST F 0 A_Takeinventory("BFGSelected",1)
		PIST F 0 A_Takeinventory("BFG10kSelected",1)
		PIST F 0 A_Takeinventory("RailGunSelected",1)
		PIST F 0 A_Takeinventory("SubMachineGunSelected",1)
		PIST F 0 A_Takeinventory("RevenantLauncherSelected",1)
		PIST F 0 A_Takeinventory("LostSoulSelected",1)
		PIST F 0 A_Takeinventory("FlameCannonSelected",1)
		PIST F 0 A_Takeinventory("HasBarrel",1)
		TNT1 A 1
		TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAA 0 A_Raise
		Goto SelectAnimation
		
		
	SelectAnimation:
		TNT1 A 1
	    PIST F 0 A_JumpIfInventory("GoFatality", 1, "Steady")
        PIST F 0 A_PlaySound("CLIPIN")
        PISS AB 1
		PIST F 0 A_Takeinventory("StartDualWield",1)
        PIST F 0 A_GunFlash
		Goto Ready

	
    Fire:
        PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,2)
        Goto NoAmmo
        TNT1 AAAA 0
		PIST F 0 A_AlertMonsters
		
		TNT1 A 0 A_JumpIFInventory("PistolBurstFire", 1, "Fire2")
		//RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
		PIST F 0 A_PlaySound("FARSHT", 6)
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_ZoomFactor(0.98)
		PIST A 1 BRIGHT A_FireBullets (1, 1, -1, 14, "WeakPuff", FBF_NORANDOM)
		PIST F 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, 0)
		PIST F 0 A_Takeinventory("BDPistolAmmo",1)
		PIST F 0 A_Takeinventory("BDDualPistolAmmo",1)
        PIST B 1
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST C 1 
		PIST F 0 A_JumpIfInventory("IsTacticalClass", 1, "FireEndTactical")
		PIST D 1
		PIST F 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST F 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		PIST F 3 A_WeaponReady(WRF_NOBOB | WRF_ALLOWRELOAD)
		PIST F 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST F 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		PIST F 3 A_WeaponReady(WRF_NOBOB | WRF_ALLOWRELOAD)
		PIST F 0 A_REfire
		Goto Ready
		
	Fire2:
        TNT1 A 0
		PIST F 0 A_PlaySound("FARSHT", 6)
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_ZoomFactor(0.98)
		PIST A 1 BRIGHT A_FireBullets (1, 1, -1, 14, "WeakPuff", FBF_NORANDOM)
		PIST F 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, 0)
		PIST F 0 A_Takeinventory("BDPistolAmmo",1)
		PIST F 0 A_Takeinventory("BDDualPistolAmmo",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,2)
		Goto NoAmmo
        PIST B 0
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST F 0 A_PlaySound("FARSHT", 6)
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_ZoomFactor(0.98)
		PIST A 0 BRIGHT A_FireBullets (1, 1, -1, 14, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_SetPitch(pitch-1)
		PIST F 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, 0)
		PIST F 0 A_Takeinventory("BDPistolAmmo",1)
		PIST F 0 A_Takeinventory("BDDualPistolAmmo",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,2)
		Goto NoAmmo
        PIST B 0
        PIST B 1
		TNT1 A 0 A_SetPitch(pitch-1)
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST F 0 A_PlaySound("FARSHT", 6)
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_ZoomFactor(0.98)
		PIST A 1 BRIGHT A_FireBullets (2, 2, -1, 14, "WeakPuff", FBF_NORANDOM)
		PIST F 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, 0)
		PIST F 0 A_Takeinventory("BDPistolAmmo",1)
		PIST F 0 A_Takeinventory("BDDualPistolAmmo",1)
		TNT1 A 0 A_SetPitch(pitch-1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,2)
		Goto NoAmmo
        PIST B 0
        PIST B 1
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST C 1 
		PIST DE 1
		PIST F 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST F 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		PIST F 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST F 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		PIST F 2 A_WeaponReady(WRF_NOBOB | WRF_ALLOWRELOAD)
		Goto Ready	
		
	FireEndTactical:
		PIST F 0
		PIST F 0 A_JumpIfInventory("IsRunning", 1, "FireEndTactical2")
		PIST E 1 A_WeaponReady(1)
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		PIST F 7 A_WeaponReady(1)
		Goto Ready
		
	FireEndTactical2:
		PIST F 0
		PLAY A 0 ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		PIST F 0 A_GiveInventory("UsedStamina", 4)
		PIST E 1 A_WeaponReady(1)
		PIST F 5 A_WeaponReady(1)
		Goto Sprinting
		
	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("IsRunning",1,"CheckSprint")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PIST F 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "Ready3")
		RIFG A 0 A_JumpIfInventory("Clip1",1,"Reload")
		RIFG A 0 A_JumpIfInventory("FiredPrimary",1,"NoAmmo2")
		Goto Ready3
	
    Reload:
		PIST F 1 A_WeaponReady
		PIST F 0 A_Takeinventory("Reloading",1)
		PIST F 0 A_Takeinventory("ADSmode",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",16,"Ready")

        PIST F 0 A_JumpIfInventory("Clip1",1,3)
        Goto NoAmmo
        TNT1 AAA 0
		PIST F 0 A_Takeinventory("Zoomed",1)
        PIST F 0 A_ZoomFactor(1.0)
		PIST F 0 A_GiveInventory ("Pumping", 1)
		PIST F 0 A_Takeinventory("Reloading",1)
		PIST F 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		PIST F 0 A_JumpIfInventory("HasUnloaded", 1, 3)
		RIFR C 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		PIST F 0 A_PlaySound("reload")
		TNT1 AA 0
        PISR ABCDEFFFFF 1 
		PIST F 0 A_PlaySound("prel")
        PISR GHIIJKLMNNNOPQR 1
		PIST F 0 A_Takeinventory("HasUnloaded",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,"InsertBullets2")//15+1 effect
		
	TurboReload:
		PIST F 0 A_Takeinventory("HasUnloaded",1)
        PISS BA 0
        Goto InsertBullets
		
	InsertBullets:
		TNT1 AAAA 0
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",15,15)
		PIST F 0 A_JumpIfInventory("Clip1",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PIST F 0 A_Giveinventory("BDPistolAmmo",1)
		PIST F 0 A_Giveinventory("BDDualPistolAmmo",1)
		PIST F 0 A_Takeinventory("Clip1",1)
		Goto InsertBullets
		
		TNT1 AAAAAAAAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)
		
		PIST F 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)
		
		PIST F 0 A_Refire
        Goto Ready
		
	InsertBullets2:
		TNT1 AAAA 0
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",16,15)
		PIST F 0 A_JumpIfInventory("Clip1",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PIST F 0 A_Giveinventory("BDPistolAmmo",1)
		PIST F 0 A_Giveinventory("BDDualPistolAmmo",1)
		PIST F 0 A_Takeinventory("Clip1",1)
		Goto InsertBullets2
		
		TNT1 AAAAAAAAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)
		PIST F 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)
		
		PIST F 0 A_Refire
        Goto Ready	
 	Spawn:
		PIST A 0
		PIST G -1
		Stop
		
		
	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIFInventory("PistolBurstFire", 1, "StopAlt")
		TNT1 A 0 A_GiveInventory("PistolBurstFire", 1)
		TNT1 A 0 A_Print("Burst fire")
		Goto Ready3
		
	StopAlt:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("PistolBurstFire", 1)
		TNT1 A 0 A_Print("Single shot")
		Goto Ready3
		
	AltFire2:	
		PIST F 0
		PIST F 0 A_JumpIfInventory("PistolFireAnimation1", 1, 5)
		PISA ABC 1
        TNT1 A 4
		PIST F 0
		PIST F 0 A_PlaySound("skeleton/swing")
		PIST F 0 A_Giveinventory("Punching",1)
		PIST F 0 A_Giveinventory("PistolFireAnimation1",1)
		PISA DE 1 
		PONG A 0 A_FireCustomMissile("MeleeStrikeNormal", 0, 0, 0, 2)
		PISA FFFG 1
		PISA H 1 A_Weaponready(1)
		PIST F 0 A_JumpIfInventory("Kicking",1,"KickLeft")
		PISA IJ 1 A_Weaponready(1)
		PIST F 0 A_JumpIfInventory("Kicking",1,"KickLeft")
		PISA CBA 1 A_Weaponready(1)
		PIST F 0 A_Takeinventory("PistolFireAnimation1",1)
		Goto Ready	
		
	KickLeft:
		KIK1 ABC 1
        PIST F 0 A_PlaySound("KICK")
		PIST F 0 A_Giveinventory("Punching",1)
		PIST F 0 A_SetPitch(-6 + pitch)
		KIK1 D 1
		PUN2 A 0 A_Custompunch(35,0,1,"MeleePuff", 100)
		KIK1 DD 1
		KIK1 ECBA 1
		TNT1 A 5 A_TakeInventory("Kicking",1)
		Goto Ready	
		
	Steady:
		TNT1 A 1
		Goto Ready	
		
		
	Unload:
		PIST F 1 A_WeaponReady
		PIST F 0 A_Takeinventory("Unloading",1)
		PIST F 0 A_Takeinventory("ADSmode",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,3)
        Goto NoAmmo
        TNT1 AAA 0
		PIST F 0 A_Takeinventory("Zoomed",1)
        PIST F 0 A_ZoomFactor(1.0)
		PIST F 0 A_GiveInventory ("Pumping", 1)
		PIST F 0 A_Takeinventory("Reloading",1)
        PISR RQPONNNMLKJIIHG 1
		PIST F 0 A_PlaySound("prel")
		PISR FFFEDCBA 1
		PIST F 0 A_Giveinventory("HasUnloaded",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,"RemoveBullets")

	RemoveBullets:
		TNT1 AAAA 0
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PIST F 0 A_Takeinventory("BDPistolAmmo",1)
		PIST F 0 A_Takeinventory("BDDualPistolAmmo",1)
		PIST F 0 A_Giveinventory("Clip1",1)
		Goto RemoveBullets
		
		TNT1 AAAAAAAAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)
		
		PIST F 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)
		
		PIST F 0 A_Refire
        Goto Ready
		
		
	DualWield:
		TNT1 A 1
		PIST F 0 A_Takeinventory("StartDualWield",1)
		PIST F 0 A_JumpIfInventory("DualPistols", 1, "GetDual")
		PIST F 0 A_Print("You must have two identical weapons to dual wield.")
		Goto Ready
		
	 GetDual:	
		PIST F 0
		PIST F 0 A_Takeinventory("Zoomed",1)
		PIST F 0 A_Takeinventory("ADSmode",1)
		PIST F 0 A_TakeInventory("TossGrenade", 1)
		PIST F 0 A_TakeInventory("Kicking",1)
        PIST F 0 A_TakeInventory("Taunting",1)
        PIST F 0 A_TakeInventory("Reloading",1)
		PIST F 0 A_TakeInventory("Unloading",1)
		PIST F 0 A_TakeInventory("Salute1", 1)
		PIST F 0 A_TakeInventory("Salute2", 1)
        PIST F 0 A_ZoomFactor(1.0)
		PIST F 0 A_SelectWEapon("DualPistols")
		Goto Ready	
	}
}