// --------------------------------------------------------------------------
//
//	AA12
//
// --------------------------------------------------------------------------

ACTOR U_AssaultShotgun : BrutalWeapon 
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 20
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "GreenShell"
	Weapon.AmmoType2 "AssaultShotgunAmmo"
	Weapon.SelectionOrder 1200
	-WEAPON.CHEATNOTWEAPON
	Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "You got the Assault Shotgun!"
	AttackSound "None"
	Obituary "%o was shot down by %k's Assault Shotgun."
	Scale 0.8
	tag "Assault Shotgun"
	States
	{
 	Spawn:
		A12P A -1
		Stop

	Select:
		TNT1 A 0 // A_JumpIfInventory("IsPlayingAsPurist",1,"PuristGun")
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1002,1)==0,"PuristGun")
		TNT1 A 0 A_Giveinventory("SSGSelected",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 4
		TNT1 A 0 A_Raise
		Wait








	CheckSprint:
		a13k a 1 A_WeaponReady(WRF_NOFIRE)
		UNHG A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		UNHG A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		a13k a 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)
		a13k a 1 offset(-9,34) A_SetPitch(pitch -0.25) //-0.5
		a13k a 1 offset(-6,36) A_SetPitch(pitch -0.25)
		a13k a 1 offset(-3,38) A_SetPitch(pitch -0.25)
		a13k a 1 offset(0,38) A_SetPitch(pitch -0.25)
		a13k a 1 offset(3,36) A_SetPitch(pitch -0.25)
		a13k a 1 offset(6,34) A_SetPitch(pitch -0.25)
		a13k a 1 offset(9,32) A_SetPitch(pitch -0.25)
		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)
		a13k a 1 offset(9,34) A_SetPitch(pitch +0.5)
		a13k a 1 offset(6,36) A_SetPitch(pitch +0.5)
		a13k a 1 offset(3,38) A_SetPitch(pitch +0.5)
		a13k a 1 offset(0,38) A_SetPitch(pitch +0.5)
		a13k a 1 offset(-3,36) A_SetPitch(pitch +0.5)
		a13k a 1 offset(-6,34) A_SetPitch(pitch +0.5)
		a13k a 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:
		a13k a 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)
		a13k a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		a13k a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		a13k a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		a13k a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		a13k a 5 A_WeaponReady
		Goto Ready3
	StopSprint:
		a13k a 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")
		TNT1 A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,8)
		A13S ABCDEF 1
		TNT1 A 0 A_Jump(256,7)
		A13S GHIJKL 1
		TNT1 A 0 A_Takeinventory("SSGSelected",1)
		TNT1 A 0 A_Lower
		Wait
		
	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		TNT1 A 0 A_PlaySound("CLIPIN")
	Ready1:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,8)
		A13S FEDCBA 1
		TNT1 A 0 A_Jump(256,7)
		A13S LKJIHG 1
		TNT1 A 0
	Ready2:
		TNT1 A 0 A_GunFlash
	Ready3:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"ReadyUnloaded")
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ReadyZoom")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //TauntR
		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("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")
		//TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		A13G A 1 A_WeaponReady
		Loop

	 ReadyUnloaded: //Unloaded weapon
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt") //TauntR
		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("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")		
TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		A13E A 1 A_WeaponReady(WRF_NOSECONDARY)
		Loop

	ReadyZoom:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("Unloading",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"AltFire")
	//	TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1029)==1,2)
		A13A D 1 A_WeaponReady
		Loop


// --------------------------------------------------------------------------
//
//	Fire
//
// --------------------------------------------------------------------------
	
	Fire:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"PutMag")
		TNT1 A 0 A_JumpIfInventory("AssaultShotgunAmmo",1,3)
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1)
		Goto DryFire
		TNT1 A 0
		Goto Reload
		TNT1 A 0 A_FireCustomMissile("GunFireSmoke",0,0,0,0,0,0)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound("A12FIR",1)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundShotgun",random(-1,1),0,0,-12,0,random(-1,1))
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("ShakeYourAss",0,0,0,0)
		TNT1 A 0 A_Takeinventory("AssaultShotgunAmmo",1)
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"FireZoom")
		A13F A 1 BRIGHT A_FireBullets(5,5,6,12,"ShotgunPuff")
		TNT1 AAA 0 A_FireCustomMissile("Tracer",random(-6,6),0,-1,-12,0,random(-6,6))
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",random(-10,10),0,-1,-8,0,random(-10,10))
		TNT1 A 0 A_SetAngle(angle+frandom(-1,1))
		TNT1 A 0 A_ZoomFactor(0.9)
		TNT1 A 0 A_SetPitch(-5.0 + pitch)
		A13F B 1 A_SetPitch(+0.9 + pitch)
		TNT1 A 0 A_ZoomFactor(1.0)
		A13F C 1 A_SetPitch(+0.9 + pitch)
		TNT1 A 0 A_FireCustomMissile("AutoShotCaseSpawn",5,0,6,-14)
		A13F DEF 1 A_SetPitch(+0.9 + pitch)
		A13G A 2
		A13G A 1 A_Refire
		Goto Ready2
		
	 FireZoom:
		A13A E 1 BRIGHT A_FireBullets(4,4,6,12,"ShotgunPuff")
		TNT1 AAA 0 A_FireCustomMissile("Tracer",random(-5,5),0,-1,-12,0,random(-5,5))
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",random(-9,9),0,-1,-8,0,random(-9,9))
		TNT1 A 0 A_SetAngle(angle+frandom(-0.8,0.8))
		TNT1 A 0 A_ZoomFactor(1.2)
		TNT1 A 0 A_SetPitch(-4.1 + pitch)
		A13A F 1 A_SetPitch(+0.8 + pitch)
		TNT1 A 0 A_ZoomFactor(1.3)
		A13A G 1 A_SetPitch(+0.8 + pitch)
		TNT1 A 0 A_FireCustomMissile("AutoShotCaseSpawn",5,0,6,-14)
		A13A DDD 1 A_SetPitch(+0.8 + pitch)
		A13A D 2
		A13A D 1 A_Refire
		Goto ReadyZoom

	AltFire:
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ZoomOut")
		TNT1 A 0 A_Giveinventory("Zoomed",1)
		TNT1 A 0 A_Giveinventory("ADSmode",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_ZoomFactor(1.5)
		A13A ABC 1
		TNT1 A 0 A_SetCrosshair(41)
RIFG A 0 A_JumpIfInventory("FiredSecondary",1,"HoldAim")
		Goto ReadyZoom
		

HoldAim:	
		RIFG A 0 A_GiveInventory("ZoomHold",1)
	    A13A D 1 
		RIFG A 0 A_JumpIfInventory("FiredSecondary",1,"HoldAim")
		Goto ReadyZoom



	ZoomOut:
		TNT1 A 0 A_Takeinventory("Zoomed",1)
RIFG A 0 A_TakeInventory("ZoomHold",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetCrosshair(0)
		A13A CBA 1
RIFG A 0 A_JumpIfInventory("FiredSecondary",1,"HoldnoZoom")
		Goto Ready3

HoldnoZoom:	
		RIFG A 0 A_TakeInventory("ZoomHold",1)
	    A13G A 1
		RIFG A 0 A_JumpIfInventory("FiredSecondary",1,"HoldnoZoom")
		Goto Ready3


// --------------------------------------------------------------------------
//
//	Unload and Reload
//
// --------------------------------------------------------------------------

	Reload:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"PutMag")
		TNT1 A 0 A_JumpIfInventory("AssaultShotgunAmmo",20,"Ready2") //Is weapon full?
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1) //Do we have any spare ammo?
		Goto Ready2

TNT1 A 0 A_JumpIfInventory("NoMagReload",1,"NoMagReloading")
TNT1 A 0 A_Takeinventory("AssaultShotgunAmmo")
NoMagReloading:

		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"ReloadLoop")
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2) //Check if zoomed
		TNT1 A 0 A_Jump(256, 7)
		A13A CBA 1
		TNT1 A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_GiveInventory("Pumping", 1)
		A13R ABCDEFGHIJKLM 1
		TNT1 A 0 A_PlaySound("AACL",1)
		A13R NNNNNNOOPPQQRRRRRRRR 1
		A13R STUVWWWWWW 1

		TNT1 A 0 A_PlaySound("PistolReload5",1)
TNT1 A 0 A_FireCustomMissile("EmptyDrumSpawn",-5,0,8,-4)
		A13R WWWXYZ 1
	PutMag:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,2)
		TNT1 A 0 A_Jump(256,5)
		A13E EDCB 1 
		TNT1 A 0 A_Giveinventory("HasUnloaded_AA12",1)
		A13T AAAAA 5 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_PlaySound("PistolReload5",1)
		A13R ZYXWWWWWWWWW 1 
		A13T BCD 1
		Goto ReloadLoop
		
	ReloadLoop:
		TNT1 A 0 A_JumpIfInventory("AssaultShotgunAmmo",20,"ReloadDone")
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1)
		Goto ReloadDone
		TNT1 A 0 A_Giveinventory("AssaultShotgunAmmo",1)
		TNT1 A 0 A_Takeinventory("GreenShell",1)
		Loop
		
	ReloadDone:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Takeinventory("HasUnloaded_AA12",1)
		TNT1 A 0 A_Refire
		Goto Ready2

	Unload:
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"PutMag")
		TNT1 A 0 A_JumpIfInventory("AssaultShotgunAmmo",1,1)
		Goto Ready2
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2) //Check if zoomed
		TNT1 A 0 A_Jump(256, 7)
		A13A CBA 1
		TNT1 A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_GiveInventory("Pumping", 1)
		A13R ABCDEFGHIJKLM 1
		TNT1 A 0 A_PlaySound("AACL",1)
		A13R NNNNNNOOPPQQRRRRRRRR 1
		A13R STUVWWWWWW 1
		TNT1 A 0 A_PlaySound("PistolReload5",1)
		A13R WWWXYZ 1
		TNT1 A 0 A_Giveinventory("HasUnloaded_AA12",1)
		A13T A 12
		A13E BCDE 1
		TNT1 A 0 A_GiveInventory("Pumping",1)
		TNT1 A 0 A_Takeinventory("Unloading",1)
		
	UnloadLoop:
		TNT1 A 0 A_JumpIfInventory("AssaultShotgunAmmo",1,1)
		Goto FinishUnload
		TNT1 A 0 A_Takeinventory("AssaultShotgunAmmo",1)
		TNT1 A 0 A_Giveinventory("GreenShell",1)
		Loop
	
	FinishUnload:
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_GiveInventory("HasUnloaded_AA12",1)
		Goto ReadyUnloaded

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

	DryFire:
		TNT1 A 0 A_PlaySound("weapons/empty2", 2)
		Goto Ready2

	PuristGun:
		TNT1 A 0 A_TakeInventory("AssaultShotgun",1)
		Goto Deselect

// --------------------------------------------------------------------------
//
//	End stuff
//
// --------------------------------------------------------------------------

	TauntFlash:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"TauntFlashUnloaded")
		A13K ABCDE 1
		A13K F 33
		A13K EDCBA 1
		A13G A 1
		Stop

	TauntFlashUnloaded:
		A13K GHIJK 1
		A13K L 33
		A13K KJIHG 1
		A13E A 1
		Stop

	KickFlash:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"ReloadKickFlash")
		A13K ABCDE 1
		A13K F 6
		A13K EDCBA 1
		A13G A 1
		Stop

	ReloadKickFlash:
		A13K GHIJK 1
		A13K L 6
		A13K KJIHG 1
		A13E A 1
		Stop

	AirKickFlash:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,"ReloadAirKickFlash")
		A13K ABCDE 1
		A13K F 8
		A13K EDCBA 1
		A13G A 1
		Stop

	ReloadAirKickFlash:
		A13K GHIJK 1
		A13K L 8
		A13K KJIHG 1
		A13E A 1
		Stop

	SlideKickStartFlash:
		A13K ABCDE 1
		A13K F 16
		Stop

	SlideKickEndFlash:
		A13K EDCBA 2
		A13G A 1
		Stop

	GrenadeFlash:
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_AA12",1,8)
		A13S ABCDEF 1
		TNT1 A 0 A_Jump(256,7)
		A13S GHIJKL 1
		TNT1 A 0
		Stop
	}
}

ACTOR HasUnloaded_AA12 : Inventory { Inventory.MaxAmount 1 }