ACTOR BrutalPistol : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Clip1"
	Weapon.AmmoType2 "BDPistolAmmo"
	weapon.selectionorder 1900
	Obituary "%o was shot down by %k's pistol."
    AttackSound "None"
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "$GOTPISTOL"
    +WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+WEAPON.WIMPY_WEAPON
    +FORCEXYBILLBOARD
	+WEAPON.NOALERT
	+WEAPON.NO_AUTO_SWITCH
	Scale 0.9
	Tag "Pistol"
	DropItem "PistolSpawner"
	States
	{
	Ready3:
	Ready:
		PIST F 0
		PIST F 1 A_WeaponReady(WRF_ALLOWRELOAD)
        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")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		PIST F 0 A_JumpIfInventory("Unloading",1,"Unload")
		PIST F 0 A_Takeinventory("PistolFireAnimation1",1)
		PIST F 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		PIST F 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Loop

	StartSprint:
		PIST F 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.

	Sprinting:
		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)
		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")

		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)
		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:
		PISP F 0 A_JumpIfInventory("PowerStrength", 1, 2)
		PIST F 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		PISP F 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto Ready

	StopSprintTired:
		PISP F 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		PIST F 0 A_PlaySound("Tired", 2)
		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)
		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)
		PIST F 0 A_Takeinventory("HasBarrel",1)
		PIST F 0 A_Takeinventory("DualPistols",1)
        PIST F 0 A_GunFlash
		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)
		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")
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_SpawnItemEx("PlayerMuzzle1",32,0,28)
		PIST A 1 BRIGHT A_FireBullets (0.8, 0.9, -1, 14, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-1,1),0,0,0,0,random(-1,1))
		PIST F 0 A_Takeinventory("BDPistolAmmo",1)
		PIST F 0 A_Takeinventory("BDDualPistolAmmo",1)
        PIST B 1
		TNT1 A 0 A_ZoomFactor(1.0)
		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 2 A_WeaponReady(WRF_NOBOB | WRF_ALLOWRELOAD)
		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready

	Fire2:
        TNT1 A 0
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_SpawnItemEx("PlayerMuzzle1",32,0,28)
		PIST A 1 BRIGHT A_FireBullets (0.8, 0.9, -1, 14, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_SetPitch(pitch-0.2)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-1,1),0,0,0,0,random(-1,1))
		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 C 1
		TNT1 A 0 A_ZoomFactor(1.0)
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST F 1
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_SpawnItemEx("PlayerMuzzle1",32,0,28)
		PIST A 1 BRIGHT A_FireBullets (1.0, 1.1, -1, 14, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_SetPitch(pitch-0.2)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-1,1),0,0,0,0,random(-1,1))
		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 C 1
		TNT1 A 0 A_ZoomFactor(1.0)
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST F 1
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PIST F 0 A_PlaySound("PFIRE", 1)
		PIST F 0 A_SpawnItemEx("PlayerMuzzle1",32,0,28)
		PIST A 1 BRIGHT A_FireBullets (1.3, 1.4, -1, 14, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
		TNT1 A 0 A_SetPitch(pitch-0.2)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-1,1),0,0,0,0,random(-1,1))
		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 C 1
		TNT1 A 0 A_ZoomFactor(1.0)
		PIST F 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		PIST F 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 D 1
		PLAY A 0 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		PIST F 2 A_WeaponReady(1)
		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready

	FireEndTactical2:
		PIST F 0
		PLAY A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		PIST D 1
		PIST F 0 A_GiveInventory("UsedStamina", 1)
		PIST F 2 A_WeaponReady(1)
		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		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("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PIST F 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("Clip1",1,"Reload")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		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_Takeinventory("Zoomed",1)
        PIST F 0 A_ZoomFactor(1.0)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",16,"Ready")

        PIST F 0 A_JumpIfInventory("Clip1",1,3)
        Goto Ready
        TNT1 AAA 0
		PIST F 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		PIST F 0 A_JumpIfInventory("PistolUnloaded", 1, "PutMag")
		PIST F 0 A_PlaySound("RELO1")
        PISR ABCDE 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PISR F 4 A_FireCustomMissile("EmptyPistolClipSpawn",0,0,0,-20)
	PutMag:
		PISR F 4
		PISR GH 1
		PISR A 0 A_PlaySound("prel")
		PISR IJKLMN 2
		PISR OPQR 1
		PIST F 0 A_Takeinventory("PistolUnloaded",1)
		PIST F 0 A_JumpIfInventory("BDPistolAmmo",1,"InsertBullets2")//15+1 effect
		Goto InsertBullets

	TurboReload:
		PIST F 0 A_Takeinventory("PistolUnloaded",1)
        PISS BA 0
        Goto InsertBullets2

	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 1 A_Takeinventory("Reloading",1)

		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready
		TNT1 AAAA 0
		PIST F 1 A_Takeinventory("Reloading",1)

		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        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 1 A_Takeinventory("Reloading",1)
		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready
		TNT1 AAAA 0
		PIST F 1 A_Takeinventory("Reloading",1)

		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready
 	Spawn:
		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("MeleeStrike1", 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 Ready
        TNT1 AAA 0
		PIST F 0 A_Takeinventory("Zoomed",1)
        PIST F 0 A_ZoomFactor(1.0)
		SMGG A 0 A_Giveinventory("PistolUnloaded",1)
		PIST F 0 A_Takeinventory("Reloading",1)
        PISR RQPO 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PISR A 0 A_PlaySound("prel")
		PISR NMLKJI 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PISR HG 1
		PISR F 4

	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_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready
		TNT1 AAAA 0
		PIST F 0 A_Takeinventory("Reloading",1)

		PIST F 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready


	DualWield:
		PIST F 1
		PIST F 0 A_Takeinventory("StartDualWield",1)
		//PIST F 0 A_JumpIfInventory("IsTacticalClass", 1, "NoDual")//Tactical mode cant dual
		PIST F 0 A_JumpIfInventory("HasDualPistol", 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_GiveInventory("DualPistols",1)
        PIST F 0 A_ZoomFactor(1.0)
		PIST F 0 A_SelectWEapon("DualPistols")
		Goto Ready

	NoDual:
		PIST F 1
		PIST F 0 A_Print("You can't dual wield pistols when playing in Tactical Mode.",1)
		Goto Ready
	}
}

ACTOR BDPistolAmmo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 16
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 16
   Inventory.Icon PISTG0
}