Actor StartAmmoAutoSG : Inventory
{
Inventory.MaxAmount 1
}


// --------------------------------------------------------------------------
//
//	AutoShotgun
//
// --------------------------------------------------------------------------

ACTOR AutoShotgun : baseweapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 12
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "GreenShell"
	Weapon.AmmoType2 "M1014Ammo"
	Weapon.SelectionOrder 300
	-WEAPON.CHEATNOTWEAPON
	Inventory.PickupSound "M1014RE"
	Inventory.Pickupmessage "You got the Automatic Shotgun!"
	Obituary "%o got shot into pieces by %k's M1014."
	AttackSound "None"
	Tag "Automatic Shotgun"
	Scale 0.9
	States
	{
	Spawn:
		M4SH A -1
		Stop

	Select:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist",1,"PuristGun")
//		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1001,3)==0,"PuristGun")
TNT1 A 0 A_JumpIfInventory("StartAmmoAutoSG",1,"Selected")
TNT1 A 0 A_GiveInventory("M1014Ammo",7)
Selected:
TNT1 A 0 A_GiveInventory("StartAmmoAutoSG",1)

		TNT1 A 0 A_Giveinventory("ShotgunSelected",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 5
		TNT1 A 0 A_Raise
		Wait








	CheckSprint:
		m4hr 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:
		m4hr 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)
		m4hr a 1 offset(-9,34) A_SetPitch(pitch -0.25) //-0.5
		m4hr a 1 offset(-6,36) A_SetPitch(pitch -0.25)
		m4hr a 1 offset(-3,38) A_SetPitch(pitch -0.25)
		m4hr a 1 offset(0,38) A_SetPitch(pitch -0.25)
		m4hr a 1 offset(3,36) A_SetPitch(pitch -0.25)
		m4hr a 1 offset(6,34) A_SetPitch(pitch -0.25)
		m4hr 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)
		m4hr a 1 offset(9,34) A_SetPitch(pitch +0.5)
		m4hr a 1 offset(6,36) A_SetPitch(pitch +0.5)
		m4hr a 1 offset(3,38) A_SetPitch(pitch +0.5)
		m4hr a 1 offset(0,38) A_SetPitch(pitch +0.5)
		m4hr a 1 offset(-3,36) A_SetPitch(pitch +0.5)
		m4hr a 1 offset(-6,34) A_SetPitch(pitch +0.5)
		m4hr 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:
		m4hr 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)
		m4hr a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		m4hr a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		m4hr a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		m4hr a 5 A_WeaponReady
		UNHG A 0 A_TakeInventory("UsedStamina", 2)
		m4hr a 5 A_WeaponReady
		Goto Ready3
	StopSprint:
		m4hr 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)
		M4SR EDCBA 1
		TNT1 A 1 A_Takeinventory("ShotgunSelected",1)
		TNT1 A 0 A_Lower
		Wait

	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		TNT1 A 0 A_PlaySound("M1014RE",5)
	Ready1:
		M4SR ABCDE 1
	Ready2:
		TNT1 A 0 A_GunFlash
	Ready3:
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ReadyZoom")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt")//R
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"Salute")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")	
TNT1 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		//TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		M4SI A 1 A_WeaponReady
		Loop

	ReadyZoom:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"ZoomOut")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"ZoomOut")
TNT1 A 0 A_JumpIfInventory("IsRunning",1,"Checksprint")
		TNT1 A 0 A_JumpIfInventory("Unloading",1,"ZoomOut")
//		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1029)==1,2)
		M4SZ E 1 A_WeaponReady
		Loop
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",1,4)
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,3)
		M4SZ E 1 A_WeaponReady(WRF_NOSECONDARY)
		TNT1 A 0 A_JumpIfInventory("FiredSecondary",1,"ReadyZoom")
		Goto ZoomOut
		TNT1 A 0 A_WeaponReady(WRF_NOSECONDARY)
		M4SZ E 1 A_JumpIfInventory("FiredPrimary",1,"Fire")
		TNT1 A 0 A_JumpIfInventory("FiredSecondary",1,"ReadyZoom")
		Goto ZoomOut


// --------------------------------------------------------------------------
//
//	Fire
//
// --------------------------------------------------------------------------

	Fire:
		TNT1 A 0 A_JumpIfInventory("ReloadingAutoShotty",2,"ReloadDone2")
		TNT1 A 0 A_JumpIfInventory("ReloadingAutoShotty",1,"ReloadDone1")
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",1,3)
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1)
		Goto DryFire
		TNT1 A 0
		Goto Reload
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound("M1014FI",1)
		TNT1 A 0 A_FireCustomMissile("DistantFireSoundShotgun",random(-1,1),0,0,-12,0,random(-1,1))
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
		TNT1 A 0 A_FireCustomMissile("ShakeYourAss",0,0,0,0)
		TNT1 A 0 A_Takeinventory("M1014Ammo",1)	
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"FireZoom")
		TNT1 AAA 0 A_FireCustomMissile("Tracer",frandom(-5,5),0,-1,-12,0,frandom(-5,5))
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",frandom(-8,8),0,-1,-8,0,frandom(-8,8))	
		M4SF A 1 BRIGHT A_FireBullets(3.5,3.5,5,12,"ShotgunPuff") //was 6,12,
		TNT1 A 0 A_SetPitch(-7.0 + pitch)
		M4SF B 1 BRIGHT A_SetPitch(1.65 + pitch)
		M4SF CDE 1 A_SetPitch(1.65 + pitch)
		TNT1 A 0 A_FireCustomMissile("AutoShotCaseSpawn",5,0,6,-14)
		M4SI A 4
		M4SI A 1 A_ReFire
		Goto Ready2

	FireZoom:
		TNT1 AAA 0 A_FireCustomMissile("Tracer",frandom(-3.3,3.3),0,-1,-12,0,frandom(-3.3,3.3))
		TNT1 AAAA 0 A_FireCustomMissile("ShotgunParticles",frandom(-5.3,5.3),0,-1,-8,0,frandom(-5.3,5.3))
		TNT1 A 0 A_ZoomFactor(1.4)
		M4SF F 1 BRIGHT A_FireBullets(2.3,2.3,5,12,"ShotgunPuff") //was 6,12
		TNT1 A 0 A_SetPitch(-6.2 + pitch)
		M4SF G 1 BRIGHT A_SetPitch(1.5 + pitch)
		TNT1 A 0 A_ZoomFactor(1.5)
		M4SF HIJ 1 A_SetPitch(1.5 + pitch)
		TNT1 A 0 A_FireCustomMissile("AutoShotCaseSpawn",5,0,4,-4)
		M4SZ E 4
		TNT1 A 0 A_ReFire
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner11",0,0,0,0)
		M4SZ E 1 A_WeaponReady
		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)
		M4SZ ABCD 1
		TNT1 A 0 A_SetCrosshair(41)
		Goto ReadyZoom

	ZoomOut:
		TNT1 A 0 A_Takeinventory("Zoomed",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)
		M4SZ DCBA 1
		Goto Ready2


// --------------------------------------------------------------------------
//
//	Reload
//
// --------------------------------------------------------------------------

	Reload:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",7,"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("TurboReload",1,"TurboReloadLoop")
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,2)
		TNT1 A 0 A_Jump(256,9)
		M4SZ DCBA 1
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_GiveInventory("Pumping",1)
		M4SI A 1
		M4SG CDEFGH 1
		TNT1 A 0 A_GiveInventory("ReloadingAutoShotty",1) //Reloading and weapon contains ammo
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",1,"ReloadLoop1")
		TNT1 A 0 A_GiveInventory("ReloadingAutoShotty",1) //Reloading and weapon was empty
		Goto ReloadLoop2
		
	TurboReloadLoop:
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",7,"TurboReloadDone")
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1)
		Goto TurboReloadDone
		TNT1 A 0 A_Takeinventory("GreenShell",1)
		TNT1 A 0 A_Giveinventory("M1014Ammo",1)
		Loop
		
	TurboReloadDone:
		TNT1 A 0 A_Refire
		Goto Ready2

	ReloadLoop1: //Weapon contains ammo when starting reload
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1)
		Goto ReloadDone1
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",7,"ReloadDone1")
		TNT1 A 0 A_GiveInventory("Pumping",1)
		M4HR ABC 1
		M4HR D 1 A_PlaySound("Insertshell")
		TNT1 A 0 A_Takeinventory("GreenShell",1)
		TNT1 A 0 A_Giveinventory("M1014Ammo",1)
		M4HR EFGHI 1
		M4HR A 1 A_Refire
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"ReloadKick")
		Loop

	ReloadLoop2: //Weapon was empty when starting reload
		TNT1 A 0 A_JumpIfInventory("GreenShell",1,1)
		Goto ReloadDone2
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",7,"ReloadDone2")
		TNT1 A 0 A_GiveInventory("Pumping",1)
		M4HR ABC 1
		M4HR D 1 A_PlaySound("Insertshell")
		TNT1 A 0 A_Takeinventory("GreenShell",1)
		TNT1 A 0 A_Giveinventory("M1014Ammo",1)
		M4HR EFGHI 1
		M4HR A 1 A_Refire
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"ReloadKick")
		Loop

	ReloadDone1: //Weapon contains ammo when starting reload
		M4SG HGFEDC 1
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("ReloadingAutoShotty",2)
		TNT1 A 0 A_Refire
		Goto Ready2

	ReloadDone2: //Weapon was empty when starting reload
		TNT1 A 0 A_GiveInventory("Pumping",1)
		M4ZR ABCD 2
		TNT1 A 0 A_PlaySound("M1014RE",5)
		//TNT1 A 0 A_Takeinventory("GreenShell",1)
		//TNT1 A 0 A_Giveinventory("M1014Ammo",1)
		M4ZR EEFA 2
		M4SG HGFEDC 1
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("ReloadingAutoShotty",2)
		TNT1 A 0 A_Refire
		Goto Ready2

	ReloadKick:
		TNT1 A 0 A_JumpIfInventory("ReloadingAutoShotty",2,1)
		Goto ReloadKickAlt
		TNT1 A 0 A_GiveInventory("Pumping",1)
		M4ZR ABCD 1
		TNT1 A 0 A_PlaySound("M1014RE",5)
		TNT1 A 0 A_Takeinventory("GreenShell",1)
		TNT1 A 0 A_Giveinventory("M1014Ammo",1)
		M4ZR EEFA 1
	ReloadKickAlt:
		M4HR A 2
		TNT1 A 0 A_GunFlash("ReloadKickFlash")
		TNT1 A 0 A_PlaySound("KICK")
		TNT1 A 0 SetPlayerProperty(0,1,0)
		KICK BCD 1
		TNT1 A 0 A_Jumpifinventory("PowerStrength",1,3)
		TNT1 A 0 A_FireCustomMissile("KickAttack",0,0,0,-7)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_FireCustomMissile("SuperKickAttack",0,0,0,-7)
		KICK H 5
		KICK IGFEDCBA 1 
		TNT1 A 0 SetPlayerProperty(0,0,0)
		TNT1 A 0 A_Takeinventory("Kicking",1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("ReloadingAutoShotty",2)
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		Goto Ready2


// --------------------------------------------------------------------------
//
//	Unload
//
// --------------------------------------------------------------------------

	Unload:
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",1,1) //We have any ammo to unload?
		Goto Ready2
		TNT1 A 0 A_GiveInventory("Pumping",1)
		M4SI A 1
		M4SG CDEFGH 1
		//M4ZR AFEE 2
		//TNT1 A 0 A_PlaySound("M1014RE",5)
		//TNT1 A 0 A_GiveInventory("GreenShell",1)
		//TNT1 A 0 A_Takeinventory("M1014Ammo",1)
		//M4ZR DCBA 2
		Goto UnloadLoop
		
	UnloadLoop:
		TNT1 A 0 A_JumpIfInventory("M1014Ammo",1,1)
		Goto UnloadDone
		TNT1 A 0 A_GiveInventory("Pumping",1)
		//M4HR ABC 1
		//M4HR D 1 A_PlaySound("Insertshell")
		M4HR IHGFE 1
		TNT1 A 0 A_PlaySound("Insertshell")
		TNT1 A 0 A_GiveInventory("GreenShell",1)
		TNT1 A 0 A_Takeinventory("M1014Ammo",1)
		//M4HR EFGHI 1
		M4HR DCBA 1
		M4HR A 1
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"ReloadKick")
		Loop
		
	UnloadDone:
		M4SG HGFEDC 1
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_Refire
		Goto Ready2


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

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

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


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

	TauntFlash:
		M4SG CDE 1
		M4SG F 37
		M4SG EDC 1
		M4SI A 1
		Stop

	KickFlash:
		M4SG CDE 1
		M4SG F 10
		M4SG EDC 1
		M4SI A 1
		Stop

	AirKickFlash:
		M4SG CDEF 1
		M4SG G 10
		M4SG FEDC 1
		M4SI A 1
		Stop

	SlideKickStartFlash:
		M4SG CDEF 1
		M4SG G 17
		Stop
	
	SlideKickEndFlash:
		M4SG GFEDC 2
		M4SI A 1
		Stop

	ReloadKickFlash:
		M4SG HG 2
		M4SG F 9
		M4SG EDC 1
		M4SI A 1
		Stop

	GrenadeFlash:
		M4SR EDCBA 1	
		Stop
	}
}

ACTOR M1014Ammo: Ammo
{
	+INVENTORY.IGNORESKILL
	Inventory.Amount 0
	Inventory.MaxAmount 7
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 7
   	Inventory.Icon "M4SHA0"
}

Actor ReloadingAutoShotty : Inventory { Inventory.MaxAmount 2 }