
/*
	//***Che: remade this weapon twice:
	First changing it to separate ammo type, 7.92 UAC aka 7.92 Mauser,
	shared with the machinegun and the sniper rifle
	(max 150, backpack max 300).
	
	Second, by turning it from the same thing as the minigun
		into assault rifle's big brother:
	1. drum-fed, requires reload after 50 shots
	2. alt-fire now zooms through iron sights -- you can *aim*
	3. near-zero spread for the first 7 shots, then increases rapidly 
		coupled with unholy muzzle climb (Berserk negates)
		
	This makes it into what the weapon *should* be:
		a precision tool of sniping designed to dish out
		very high burst damage but mediocre at sustained fire.
		
	Also, is now using sprites, uh, borrowed from Project Brutality.	

*/


ACTOR FBD_Hbus_Drum : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 50
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 50
   Inventory.Icon "HBUSD0"
}

Actor HbusSpread : fbd_Token
{
	inventory.maxamount 20
}

ACTOR HitlersBuzzsaw : BrutalWeapon
{
	Game Doom
	
//***Che place it at the *end* of the list, below everything else. Because its ammo is rare and it RUNS OUT	
//	Weapon.SelectionOrder 1
	Weapon.SelectionOrder 3600

	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0 // the weapon spawner takes care of that (see WeaponSpawners.txt)
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "792UAC"
	Weapon.AmmoType2 "FBD_Hbus_Drum"
	
	//Weapon.AmmoUse 1
	//Weapon.AmmoGive 75 //200 //600 //***Che: changing rare ammo management
	//Weapon.AmmoType "792UAC" //"BuzzsawAmmo"
	
	Inventory.PickupMessage "$GOTMG42" // "Ты взял пилу Гитлера, MG-42! (слот 8)" / "You got the Hitler's Buzzsaw, MG42! (Slot 8)"
	Obituary "%o was cut in half by %k's MG42"
	+WEAPON.CHEATNOTWEAPON // is excluded from the "give weapons" console command
	+WEAPON.NOAUTOAIM
	VisibleToPlayerClass FBDoomer, FBDoomer2, TacticalFBDoomer, Purist, FBD_Doomgal, FBD_Doomgal2, FBD_TacticalDoomgal, FBD_Nostalgia, FBD_NostalgiaFem, FBD_Mortal, FBD_MortalFem // in short to ALL of them
	Inventory.ForbiddenTo ""
	Scale 0.4 // using PB's sprite which is 2x bigger //0.8
	Tag "MG-42"
	States
	{
		//***Che disabling player weapons for cutscenes and for the evacuation center
		HoldFire:
			HBUS U 0 offset(-40,32) A_JumpIfInventory("Taunting",1,"Taunt")
			HBUS U 0 A_JumpIfInventory("Salute1", 1, "Salute")
			HBUS U 0 A_JumpIfInventory("Salute2", 1, "Salute")
			HBUS U 0 A_JumpIfInventory("Unloading",1,"Unload")
			HBUS U 0 A_JumpIfInventory("Reloading",1,"Reload")
			HBUS U 0 A_JumpIfInventory("TurboReload",1,"Reload")				
			HBUS U 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			HBUS U 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")

			HBUS U 1 offset(-40,32) A_WeaponReady(WRF_NOBOB | WRF_NOFIRE | WRF_ALLOWRELOAD)
			HBUS U 0 A_TakeInventory("HbusSpread", 1)
			HBUS U 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire")
			Goto Ready		
			
		Ready:
		Ready3:
			TNT1 A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			TNT1 A 0 A_JumpIfInventory("Zoomed",1,"Ready2")
			HBUS F 1 A_WeaponReady(WRF_ALLOWRELOAD)
			
			"----" A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
			"----" A 0 A_JumpIfInventory("Unloading",1,"Unload")
			"----" A 0 A_JumpIfInventory("Reloading",1,"Reload")
			"----" A 0 A_JumpIfInventory("TurboReload",1,"Reload")
			"----" A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			"----" A 0 A_JumpIfInventory("Taunting",1,"Taunt")
			"----" A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			"----" A 0 A_JumpIfInventory("Salute2", 1, "Salute")
			"----" A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			"----" A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			"----" A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
			Loop
			
		Ready2:
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD)
			"----" A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
			"----" A 0 A_JumpIfInventory("Unloading",1,"Unload")
			"----" A 0 A_JumpIfInventory("Reloading",1,"Reload")
			"----" A 0 A_JumpIfInventory("TurboReload",1,"Reload")
			"----" A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			"----" A 0 A_JumpIfInventory("Taunting",1,"Taunt")
			"----" A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			"----" A 0 A_JumpIfInventory("Salute2", 1, "Salute")
			"----" A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			"----" A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			"----" A 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			Loop
			
		Deselect:
			"----" A 0 A_JumpIfinventory("Zoomed",1,"DeselectUnzoom")
		DeselectContinue:
			HBUS UUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 1 A_Lower
			Loop
			
		Select:
		
			TNT1 A 0 A_Takeinventory("StartDualWield",1)
			TNT1 A 0 A_Giveinventory("GoSpecial",1)
			TNT1 A 0 A_Takeinventory("FistsSelected",1)
			TNT1 A 0 A_Takeinventory("sawSelected",1)
			TNT1 A 0 A_Takeinventory("ShotgunSelected",1)
			TNT1 A 0 A_Takeinventory("SSGSelected",1)
			TNT1 A 0 A_Takeinventory("MinigunSelected",1)
			TNT1 A 0 A_Takeinventory("PlasmaGunSelected",1)
			TNT1 A 0 A_Takeinventory("RocketLauncherSelected",1)
			TNT1 A 0 A_Takeinventory("GrenadeLauncherSelected",1)
			TNT1 A 0 A_Takeinventory("BFGSelected",1)
			TNT1 A 0 A_Takeinventory("BFG10kSelected",1)
			"----" A 0 A_Takeinventory("UnmakerSelected",1) //***Che
			"----" A 0 A_Giveinventory("MG42Selected",1) //***Che
			"----" A 0 A_Takeinventory("AxeSelected",1) //***Che
				
				"----" A 0 A_Takeinventory("DragonslayerSelected",1) //***Che
				"----" A 0 A_Takeinventory("SniperRifleSelected",1)
				"----" A 0 A_Takeinventory("ShotolverSelected",1)
				"----" A 0 A_Takeinventory("Shotolver2Selected",1)
			TNT1 A 0 A_Takeinventory("RailGunSelected",1)
			TNT1 A 0 A_Takeinventory("SubMachineGunSelected",1)
			TNT1 A 0 A_Takeinventory("RevenantLauncherSelected",1)
			TNT1 A 0 A_Takeinventory("LostSoulSelected",1)
			TNT1 A 0 A_Takeinventory("FlameCannonSelected",1)
			TNT1 A 0 A_Takeinventory("HasBarrel",1)	
		
			HBUS TU 1 A_Raise
			TNT1 AAAAAAAAAAAA 0 A_Raise
			GOto SelectAnimation
			
		SelectAnimation:
			HBUS U 0
			HBUS U 0 A_GunFlash
			HBUS UUUU 1 A_Raise
			Goto Ready
		Fire:
			"----" A 0 A_JumpIfInventory("Zoomed",1,"Fire2")
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",1,1)
			Goto NoAmmo
			
				"----" A 0 A_JumpIfInventory("QPowerQuadDamage", 1, 2)
				"----" A 0 A_JumpIf(true, 2)
				"----" A 0 A_PlaySound("quaddamage/echo", CHAN_7)
				
			"----" A 0
			"----" A 0 A_JumpIfInventory("HbusSpread", 20, "FirstBullet16")
			"----" A 0 A_JumpIfInventory("HbusSpread", 16, "FirstBullet12")
			"----" A 0 A_JumpIfInventory("HbusSpread", 12, "FirstBullet8")
			"----" A 0 A_JumpIfInventory("HbusSpread", 8, "FirstBullet4")	

			//damage type "Bullet792"
			"----" A 0 BRIGHT A_FireBullets (2, 2, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 6, -12, 0, random(-1,1))
			Goto AfterFirstBullet
			
		FirstBullet4:	
			"----" A 0 BRIGHT A_FireBullets (4, 4, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-2,2), 0, 6, -12, 0, random(-2,2))
			"----" A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
			Goto AfterFirstBullet
		FirstBullet8:	
			"----" A 0 BRIGHT A_FireBullets (8, 8, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-4,4), 0, 6, -12, 0, random(-4,4))
			"----" A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
			Goto AfterFirstBullet
		FirstBullet12:	
			"----" A 0 BRIGHT A_FireBullets (12, 12, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-6,6), 0, 6, -12, 0, random(-6,6))
			"----" A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
			Goto AfterFirstBullet
		FirstBullet16:	
			"----" A 0 BRIGHT A_FireBullets (16, 16, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-8,8), 0, 6, -12, 0, random(-8,8))
			"----" A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
			Goto AfterFirstBullet			
			
		AfterFirstBullet:
			"----" A 0 A_TakeInventory("FBD_Hbus_Drum", 1)
			"----" A 0 A_GiveInventory("HbusSpread", 1)
			
			"----" A 0 A_PlaySound("m14FIRE", CHAN_WEAPON)
			"----" A 0 A_PlaySound("FARM14", CHAN_6)
			
			"----" A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
			"----" A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,0,0)
			"----" A 0 A_FireCustomMissile("50CaseSpawn2",5,0,12,-6)
			"----" A 0 A_SetPitch(-0.6 + pitch)
			HBUS G 1 
			"----" A 0 A_SetPitch(0.6 + pitch)
			//"----" A 0 A_SetAngle(random(2, -2) + angle)
			HBUS H 1 A_SpawnItemEx("PlayerMuzzle1",45,6,36)
			
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",1,1)
			Goto NoAmmo
			
			"----" A 0
			"----" A 0 A_JumpIfInventory("HbusSpread", 20, "SecondBullet16")
			"----" A 0 A_JumpIfInventory("HbusSpread", 16, "SecondBullet12")
			"----" A 0 A_JumpIfInventory("HbusSpread", 12, "SecondBullet8")
			"----" A 0 A_JumpIfInventory("HbusSpread", 8, "SecondBullet4")
			
		// the 0th tier, *minimal* spread		
			//damage type "Saw"
			"----" A 0 A_FireBullets (2, 2, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 6, -12, 0, random(-1,1))
			Goto AfterSecondBullet
		SecondBullet4:	
			"----" A 0 A_FireBullets (4, 4, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-2,2), 0, 6, -12, 0, random(-2,2))
			Goto AfterSecondBullet
		SecondBullet8:	
			"----" A 0 A_FireBullets (8, 8, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-4,4), 0, 6, -12, 0, random(-4,4))
			Goto AfterSecondBullet
		SecondBullet12:	
			"----" A 0 A_FireBullets (12, 12, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-6,6), 0, 6, -12, 0, random(-6,6))
			"----" A 0 A_SetPitch(0.1 * Random (-10,10) + pitch)
			"----" A 0 A_SetAngle(0.1 * Random (-10,10) + angle)
			Goto AfterSecondBullet
		SecondBullet16:	
			"----" A 0 A_FireBullets (16, 16, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-8,8), 0, 6, -12, 0, random(-8,8))
			"----" A 0 A_SetPitch(0.15 * Random (-10,10) + pitch)
			"----" A 0 A_SetAngle(0.15 * Random (-10,10) + angle)
			Goto AfterSecondBullet	
			
		AfterSecondBullet:	
			"----" A 0 A_TakeInventory("FBD_Hbus_Drum", 1)
			"----" A 0 A_GiveInventory("HbusSpread", 1)
			
			"----" A 0 A_PlaySound("m14FIRE", CHAN_5)
			"----" A 0 A_PlaySound("FARM14", CHAN_BODY) // 7 reserved for quad
			
			"----" A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
			"----" A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,0,0)
			"----" A 0 A_FireCustomMissile("50CaseSpawn2",5,0,12,-6)
			"----" A 0 A_SetPitch(-0.6 + pitch)
			HBUS I 1
			"----" A 0 A_SetPitch(0.6 + pitch)
			//"----" A 0 A_SetAngle(random(2, -2) + angle)
			HBUS H 1 A_SpawnItemEx("PlayerMuzzle1",45,6,36)
			//"----" A 0 A_Refire
			"----" A 0 A_JumpIfInventory("PressedPrimary", 1, "Fire") //***Che ChebMaster's addition to BD tokens, auto-removed by the same ACS script when the button is released
			Goto Ready
			
			
			
			
		Fire2:
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			
			
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",1,1)
			Goto NoAmmoUnzoom
			
				"----" A 0 A_JumpIfInventory("QPowerQuadDamage", 1, 2)
				"----" A 0 A_JumpIf(true, 2)
				"----" A 0 A_PlaySound("quaddamage/echo", CHAN_7)
				
			"----" A 0
			"----" A 0 A_JumpIfInventory("HbusSpread", 20, "First2Bullet16")
			"----" A 0 A_JumpIfInventory("HbusSpread", 16, "First2Bullet12")
			"----" A 0 A_JumpIfInventory("HbusSpread", 12, "First2Bullet8")
			"----" A 0 A_JumpIfInventory("HbusSpread", 8, "First2Bullet4")	

			//damage type "Bullet792"
			"----" A 0 BRIGHT A_FireBullets (0, 0, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", 0, 0, 2, -12, 0, 0)
			Goto AfterFirst2Bullet
			
		First2Bullet4:	
			"----" A 0 BRIGHT A_FireBullets (2, 2, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 2, -12, 0, random(-1,1))
			Goto AfterFirst2Bullet
		First2Bullet8:	
			"----" A 0 BRIGHT A_FireBullets (4, 4, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-2,2), 0, 2, -12, 0, random(-2,2))
			Goto AfterFirst2Bullet
		First2Bullet12:	
			"----" A 0 BRIGHT A_FireBullets (8, 8, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-4,4), 0, 2, -12, 0, random(-4,4))
			"----" A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
			Goto AfterFirst2Bullet
		First2Bullet16:	
			"----" A 0 BRIGHT A_FireBullets (12, 12, 1, 55, "M14Puff", FBF_NORANDOM)
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-6,6), 0, 2, -12, 0, random(-6,6))
			"----" A 0 A_FireCustomMissile("ShakeYourAss", 0, 0, 0, 0)
			Goto AfterFirst2Bullet			
			
		AfterFirst2Bullet:
			"----" A 0 A_TakeInventory("FBD_Hbus_Drum", 1)
			"----" A 0 A_GiveInventory("HbusSpread", 1)
			
			"----" A 0 A_PlaySound("m14FIRE", CHAN_WEAPON)
			"----" A 0 A_PlaySound("FARM14", CHAN_6)
			
			"----" A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
			"----" A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,0,0)
			"----" A 0 A_FireCustomMissile("50CaseSpawn2",5,0,6,-6)
			"----" A 0 A_SetPitch(-0.6 + pitch)
			HBUS P 1 
			"----" A 0 A_SetPitch(0.6 + pitch)
			//"----" A 0 A_SetAngle(random(2, -2) + angle)
			HBUS O 1 A_SpawnItemEx("PlayerMuzzle1",45,6,36)
			
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",1,1)
			Goto NoAmmoUnzoom
			
			"----" A 0
			"----" A 0 A_JumpIfInventory("HbusSpread", 20, "Second2Bullet16")
			"----" A 0 A_JumpIfInventory("HbusSpread", 16, "Second2Bullet12")
			"----" A 0 A_JumpIfInventory("HbusSpread", 12, "Second2Bullet8")
			"----" A 0 A_JumpIfInventory("HbusSpread", 8, "Second2Bullet4")
			
		// the 0th tier, *no* spread		
			//damage type "Saw"
			"----" A 0 A_FireBullets (0, 0, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", 0, 0, 2, -12, 0, 0)
			Goto AfterSecond2Bullet
		Second2Bullet4:	
			"----" A 0 A_FireBullets (2, 2, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 2, -12, 0, random(-1,1))
			Goto AfterSecond2Bullet
		Second2Bullet8:	
			"----" A 0 A_FireBullets (4, 4, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-2,2), 0, 2, -12, 0, random(-2,2))
			Goto AfterSecond2Bullet
		Second2Bullet12:	
			"----" A 0 A_FireBullets (8, 8, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-4,4), 0, 2, -12, 0, random(-4,4))
			"----" A 0 A_SetPitch(0.05 * Random (-10,10) + pitch)
			"----" A 0 A_SetAngle(0.05 * Random (-10,10) + angle)
			Goto AfterSecond2Bullet
		Second2Bullet16:	
			"----" A 0 A_FireBullets (12, 12, 1, 55, "ExtremeBulletPuff", FBF_NORANDOM) 
			"----" A 0 A_FireCustomMissile("DecorativeTracer", random(-6,6), 0, 2, -12, 0, random(-6,6))
			"----" A 0 A_SetPitch(0.08 * Random (-10,10) + pitch)
			"----" A 0 A_SetAngle(0.08 * Random (-10,10) + angle)
			Goto AfterSecond2Bullet	
			
		AfterSecond2Bullet:	
			"----" A 0 A_TakeInventory("FBD_Hbus_Drum", 1)
			"----" A 0 A_GiveInventory("HbusSpread", 1)
			
			"----" A 0 A_PlaySound("m14FIRE", CHAN_5)
			"----" A 0 A_PlaySound("FARM14", CHAN_BODY) // 7 reserved for quad
			
			"----" A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
			"----" A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,0,0)
			"----" A 0 A_FireCustomMissile("50CaseSpawn2",5,0,6,-6)
			"----" A 0 A_SetPitch(-0.6 + pitch)
			HBUS P 1
			"----" A 0 A_SetPitch(0.6 + pitch)
			//"----" A 0 A_SetAngle(random(2, -2) + angle)
			HBUS O 1 A_SpawnItemEx("PlayerMuzzle1",45,6,36)
			//"----" A 0 A_Refire
			"----" A 0 A_JumpIfInventory("PressedPrimary", 1, "Fire2") //***Che ChebMaster's addition to BD tokens, auto-removed by the same ACS script when the button is released
			Goto HoldAim			
			
			
		AltFire:
			"----" A 0
			"----" A 0 A_JumpIfInventory("Zoomed",1,"Unzoom")
			"----" A 0 A_Giveinventory("Zoomed",1)
			"----" A 0 
			"----" A 0 A_Giveinventory("ADSmode",1)
			HBUS M 1 A_ZoomFactor(1.1)
			HBUS M 1 A_ZoomFactor(1.4)
			HBUS N 1 A_ZoomFactor(2.0)
			HBUS N 1 A_ZoomFactor(2.5)
			HBUS N 1 A_ZoomFactor(3.0)
			"----" A 0 A_TakeInventory ("FiredSecondary", 1)
			
			// for 7 tics a brief press does not result in zoom catching -- just like all other weapons act
			
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1) //***Che ChebMaster's addition to BD tokens, auto-removed by the same ACS script when the button is released
			Goto Unzoom
			// here WRF_NOSECONDARY prevents the game engine switching back to AltFire's beginning which leads to immediate unzoom
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1)
			Goto Unzoom
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1)
			Goto Unzoom
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1)
			Goto Unzoom
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1)
			Goto Unzoom
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1)
			Goto Unzoom
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			HBUS O 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_JumpIfInventory("PressedAlt", 1, 1)
			Goto Unzoom
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			"----" A 0 A_JumpIfInventory("PressedAlt",1,"HoldAim")
			Goto Unzoom
		
		HoldAim:
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			"----" A 0 A_GiveInventory("ZoomHold",1)
			"----" A 0 A_GiveInventory ("PlayerIsFighting", 20) //***Che encourages the follower NPCs to get da fug out of your line of fire
			"----" A 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			"----" A 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			"----" A 0 A_JumpIfInventory("FiredPrimary",1,"Fire2")
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			HBUS O 1 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOSECONDARY)
			"----" A 0 A_JumpIfInventory("PressedAlt",1,"HoldAim")
			"----" A 0 A_TakeInventory("HbusSpread", 1)
			Goto Ready2
			
		Unzoom:
			"----" A 0
			"----" A 0 A_Takeinventory("Zoomed",1)
			"----" A 0 A_Takeinventory("ADSmode",1)
			HBUS N 1 A_ZoomFactor(2.0)
			HBUS M 1 A_ZoomFactor(1.4)
			HBUS M 1 A_ZoomFactor(1.1)
			"----" A 0 A_TakeInventory ("FiredSecondary", 1)
			Goto Ready
			
		NoAmmoUnzoom:	
			"----" A 0 A_Takeinventory("Zoomed",1)
			"----" A 0 A_Takeinventory("ADSmode",1)
			HBUS N 1 A_ZoomFactor(2.0)
			HBUS M 1 A_ZoomFactor(1.4)
			HBUS M 1 A_ZoomFactor(1.1)
			"----" A 0 A_TakeInventory ("FiredSecondary", 1)
			Goto NoAmmo	

		ReloadUnzoom:
			"----" A 0 A_Takeinventory("Zoomed",1)
			"----" A 0 A_Takeinventory("ADSmode",1)
			HBUS N 1 A_ZoomFactor(2.0)
			HBUS M 1 A_ZoomFactor(1.4)
			HBUS M 1 A_ZoomFactor(1.1)
			"----" A 0 A_TakeInventory ("FiredSecondary", 1)
			Goto ContinueReload	

		DeselectUnzoom:
			"----" A 0 A_Takeinventory("Zoomed",1)
			"----" A 0 A_Takeinventory("ADSmode",1)
			HBUS N 1 A_ZoomFactor(2.0)
			HBUS M 1 A_ZoomFactor(1.4)
			HBUS M 1 A_ZoomFactor(1.1)
			Goto DeselectContinue
			
		CheckSprint:
			"----" A 1 A_WeaponReady(WRF_NOFIRE)
			"----" A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
			"----" A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
			Goto Ready
			
		StartSprintUnzoom:	
			"----" A 0 A_Takeinventory("Zoomed",1)
			"----" A 0 A_Takeinventory("ADSmode",1)
			"----" A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
			HBUS NM 1
			HBUS M 1 offset(0, 38)
			HBUS T 1
			Goto Sprinting
			
		StartSprint:
			"----" A 1 A_WeaponReady(WRF_NOFIRE)
			"----" A 0 A_JumpIfinventory("Zoomed",1,"StartSprintUnzoom")
			"----" A 0 A_Takeinventory("ADSmode",1)
			"----" A 0 A_ZoomFactor(1.0)
			"----" A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
			HBUS UT 1
			
		Sprinting:	
			"----" A 0 A_GiveInventory("HbusSpread", 1)
			HBUS T 0 offset(-9,32) 
			HBUS T 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
			HBUS T 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.
			HBUS T 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
			HBUS T 0 offset(-9,32) A_GiveInventory("UsedStamina", 15)
			HBUS T 0 offset(-9,32)
			HBUS T 1 offset(-9,34) A_SetPitch(pitch -0.5)
			HBUS T 1 offset(-6,36) A_SetPitch(pitch -0.5)
			HBUS T 1 offset(-3,38) A_SetPitch(pitch -0.5)
			HBUS T 1 offset(0,38) A_SetPitch(pitch -0.5)
			HBUS T 1 offset(3,36) A_SetPitch(pitch -0.5)
			HBUS T 1 offset(6,34) A_SetPitch(pitch -0.5)
			HBUS T 1 offset(9,32) A_SetPitch(pitch -0.5)
			TNT1 C 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
			HBUS T 0 A_JumpIfInventory("Kicking",1,"DoKick")
			HBUS T 0 A_JumpIfInventory("Taunting",1,"Taunt")
			HBUS T 0 A_JumpIfInventory("Reloading",1,"Reload")
			HBUS T 0 offset(-9,32) A_GiveInventory("UsedStamina", 8)
			HBUS T 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
			HBUS T 1 offset(9,34) A_SetPitch(pitch +0.5)
			HBUS T 1 offset(6,36) A_SetPitch(pitch +0.5)
			HBUS T 1 offset(3,38) A_SetPitch(pitch +0.5)
			HBUS T 1 offset(0,38) A_SetPitch(pitch +0.5)
			HBUS T 1 offset(-3,36) A_SetPitch(pitch +0.5)
			HBUS T 1 offset(-6,34) A_SetPitch(pitch +0.5)
			HBUS T 1 offset(-9,32) A_SetPitch(pitch +0.5)
			HBUS T 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
			HBUS T 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
			Goto StopSprint
			
		StopSprintTired:
			HBUS U 1
			"----" A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
			HBUS F 0 A_PlaySound("Tired", 2)
			HBUS F 0 A_TakeInventory("UsedStamina", 2)
			HBUS FFFFF 1 A_WeaponReady
			HBUS A 0 A_TakeInventory("UsedStamina", 2)
			HBUS FFFFF 1 A_WeaponReady
			HBUS A 0 A_TakeInventory("UsedStamina", 2)
			HBUS FFFFF 1 A_WeaponReady
			HBUS A 0 A_TakeInventory("UsedStamina", 2)
			HBUS FFFFF 1 A_WeaponReady
			HBUS A 0 A_TakeInventory("UsedStamina", 2)
			HBUS FFFFF 1 A_WeaponReady
			Goto Ready
		StopSprint:
			HBUS A 1
			HBUS A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
			PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
			Goto Ready		
			
		NoAmmo:
			HBUS F 0
			HBUS F 0 A_ZoomFactor(1.0)
			HBUS F 0 A_Takeinventory("Zoomed",1)
			HBUS F 0 A_Takeinventory("ADSmode",1)
			HBUS F 0 A_JumpIfInventory("TurboReload",1,"Reload")
			TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
			HBUS F 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			HBUS F 0 A_JumpIfInventory("Taunting",1,"Taunt")
			HBUS F 0 A_JumpIfInventory("Salute1", 1, "Salute")
			HBUS F 0 A_JumpIfInventory("Salute2", 1, "Salute")
			HBUS F 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			HBUS F 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
			HBUS F 0 A_JumpIfInventory("Kicking",1,"DoKick")
			HBUS F 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
			HBUS F 0 A_JumpIfInventory("Reloading",1,"Reload")
			HBUS F 0 A_JumpIfInventory("TurboReload",1,"Reload")
			TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 1)
			HBUS F 0 A_JumpIfInventory("792UAC",1,"Reload")
			Goto Ready			
			
			
			
		Spawn:
			HBUS Y -1 // irrelevant because always given by the weapon spawner 
			Stop
		

		Reload:
			"----" A 0 A_Takeinventory("Reloading",1)
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",50,"Ready")
			"----" A 0 A_JumpIfInventory("Zoomed", 1, "ReloadUnzoom")
		
		ContinueReload:
			"----" A 0
			"----" A 0 A_JumpIfInventory("792UAC",1,1)
			Goto NoAmmo
			"----" A 0  A_ZoomFactor(1.0)
			"----" A 0 A_JumpIfInventory("TurboReload",1,"InsertBullets")
			
			"----" A 0 A_PlaySound("mg42/reload1", 5)
			
			HBUS RS 2
			
			TNT1 AAAAAAAAAA 1 A_SetPitch(-1.0 + pitch)
			
			TNT1 A 20
			
			"----" A 0 A_PlaySound("mg42/reload2", 6)
			
			Goto InsertBullets
			
		InsertBullets:
			"----" A 0 
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",50,"FinishReloading")
			"----" A 0 A_JumpIfInventory("792UAC",1,1)
			Goto FinishReloading
			"----" A 0 A_Giveinventory("FBD_Hbus_Drum",1)
			"----" A 0 A_Takeinventory("792UAC",1)
			Loop
			
		FinishReloading:
			"----" A 0 A_TakeInventory("HbusSpread", 20)
			"----" A 0 A_JumpIfInventory("TurboReload",1,"Ready")
			
			TNT1 AAAAAAAAAA 1 A_SetPitch(1.0 + pitch)
			
			TNT1 A 20
			
			"----" A 0 A_PlaySound("mg42/reload3", 6)
			
			TNT1 AAAAA 1
			HBUS TU 3
			Goto Ready
			
			
		Unload:
			"----" A 0 
			"----" A 0 A_Takeinventory("Unloading",1)
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",1,1)
			Goto Ready
			"----" A 0 A_ZoomFactor(1.0)
			"----" A 0 A_Takeinventory("Zoomed",1)
			
			"----" A 0 A_JumpIfInventory("TurboReload",1,"ExtractBullets")
			
			"----" A 0 A_PlaySound("mg42/reload1", 5)
			
			HBUS RS 2
			
			TNT1 AAAAAAAAAA 1 A_SetPitch(-1.0 + pitch)
			
			"----" A 0 A_PlaySound("mg42/reload2", 6)
		
			Goto ExtractBullets
			
		ExtractBullets:
			"----" A 0 A_JumpIfInventory("792UAC",150,"FinishReloading") // you cannot unload if your ammo is at the backpackless max or higher
			"----" A 0 A_JumpIfInventory("FBD_Hbus_Drum",1,1)
			Goto FinishReloading
			"----" A 0 A_Takeinventory("FBD_Hbus_Drum",1)
			"----" A 0 A_Giveinventory("792UAC",1)
			Loop
		
		
		
	}
}
