ACTOR Riotgun : Weapon replaces Shotgun
{
	Weapon.SelectionOrder 1400
	Weapon.SlotNumber 3
	Weapon.AmmoType "Shell"
	Weapon.AmmoGive 8
	Weapon.AmmoUse 1
	Weapon.AmmoType2 "LoadedShell"
	Weapon.AmmoUse2 1
	Inventory.PickupMessage "You got the Riot Gun!"
	Inventory.PickupSound "weapons/fist/swing"
	Obituary "%o stopped resisting %k's riot gun"
	+WEAPON.NOALERT
	+WEAPON.AMMO_CHECKBOTH
	Tag "Riot Gun"
	Weapon.BobStyle "Smooth"
	Weapon.BobSpeed 2.0
	Weapon.BobRangeX 0.30
	Weapon.BobRangeY 0.40
	States
	{
	Ready:
		RGSW F 1 Offset(-100,40)
		RGSW F 1 Offset(-80,38)
		RGSW E 1 Offset(-40,38)
		RGSW D 1 Offset(-20,40) A_PlaySound("weapons/riotgun/draw")
		RGSW C 1 Offset(-12,38) A_GiveInventory("SynthFireActive",1)
		RGSW B 1 Offset(-7,36)
		RGSW A 1 Offset(-1,34)
		RIOT A 1 Offset(0,36)
		RIOT A 1 Offset(0,33)
		TNT1 A 0 A_Refire
	ReadyII:
		TNT1 A 0 ACS_NamedExecuteAlways("SynthLeft",0,0,0,0) //act.synth-fire LEFT(pri)
		TNT1 A 0 ACS_NamedExecuteAlways("SynthRight",0,0,0,0) //act.synth-fire RIGHT(sec)
		TNT1 A 0 A_JumpIfInventory("SynthFireRight",1,"ZoomIn")
		RIOT A 0 Offset(0,32) A_JumpIfInventory("LoadedShell",0,2)
		RIOT A 0 A_JumpIfInventory("Shell",1,2)
		RIOT A 1 A_WeaponReady
		Loop
		RIOT A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Ready2:
		TNT1 A 0 A_JumpIfInventory("Aiming",1,2)
		TNT1 A 0 A_Giveinventory("Aiming",1)
		TNT1 A 0 A_JumpIfInventory("LoadedShell",0,2)
		TNT1 A 0 A_JumpIfInventory("Shell",1,3)
		SHZM C 1 A_WeaponReady
		TNT1 A 0 A_Refire ("Ready2")
		Goto ZoomOut
		SHZM C 1 A_WeaponReady(WRF_ALLOWRELOAD)
		TNT1 A 0 A_JumpIfInventory("SynthFireLeft",1,"AimedFire")
		TNT1 A 0 A_Refire ("Ready2")
		Goto ZoomOut
	Ready3:
		TNT1 A 0 A_JumpIfInventory("Aiming",1,2)
		TNT1 A 0 A_Giveinventory("Aiming",1)
		TNT1 A 0 A_JumpIfInventory("LoadedShell",0,2)
		TNT1 A 0 A_JumpIfInventory("Shell",1,3)
		SHZM C 1 A_WeaponReady
		Loop
		SHZM C 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Deselect:
		TNT1 A 0 A_TakeInventory("SynthFireActive",1)
		TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
		TNT1 A 0 A_TakeInventory("SynthFireRight",1)
		TNT1 A 0 A_TakeInventory("ShotgunReloading",1)
		TNT1 A 0 A_Takeinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("Aiming",1)
		RIOT A 1 Offset(-3,35)
		RIOT A 1 Offset(-7,39)
		RIOT A 1 Offset(-12,45)
		RIOT A 1 Offset(-20,52)
		RIOT A 1 Offset(-40,60)
		RIOT A 1 Offset(-70,69)
		RIOT A 1 Offset(-120,79)
		TNT1 A 5
		TNT1 A 0 A_Lower
		Wait
	Select:
		TNT1 A 0 A_Raise
		Loop
	Fire:
		TNT1 A 0 A_JumpIfInventory("ShotgunReloading",1,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("LoadedShell",1,1)
		Goto ReloadCheck
		TNT1 AAAA 0
		TNT1 A 0 A_JumpIfInventory("ZoomIn",1,"AimedFire")
		RIOT A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound("weapons/riotgun/fire", 7)
		TNT1 A 0 A_GunFlash
		RIOT D 1 A_FireBullets(5,5,7,5,"AltPuff",0)
		TNT1 A 0 A_TakeInventory("LoadedShell",1,TIF_NOTAKEINFINITE)
		RIOT D 1 Bright Offset (0,33)
		TNT1 A 0 A_SetPitch(pitch+0.2)
		TNT1 A 0 A_ZoomFactor(0.985)
		RIOT D 1
		TNT1 A 0 A_SetPitch(pitch-0.2)
		TNT1 A 0 A_ZoomFactor(0.99)
		RIOT BC 1 Offset (0,32)
		TNT1 A 0 A_ZoomFactor(0.996)
		TNT1 AAAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,0)
		TNT1 A 0 A_ZoomFactor(1.0)
		RIOT D 5
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ClassicPump")==1, "ClassicPump")
		Goto QuickPump
	QuickPump:
		RIOT D 5
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/pumpback")
		RIOT D 1
		TNT1 A 0 A_ZoomFactor(1.005)
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/pumpforth")
		RIOT E 1
		TNT1 A 0 A_ZoomFactor(1.0)
		RIOT EF 1
		TNT1 AAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,8,0)
		RIOT F 2 Offset(0,34) A_FireCustomMissile("ShotgunCasingSpawner",0,0,8,-20)
		RIOT F 2 Offset(0,36)
		RIOT F 2 Offset(0,33)
		RIOT A 5 Offset(0,32) A_WeaponReady
		Goto ReadyII
	ClassicPump:
	//	RIOT D 4
		RGSW ABC 1 Offset(0,34)
		RGSW D 1 Offset(-2,35)
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/pumpback")
		RGSW D 1 Offset(-4,36)
		TNT1 AAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,-2,0)
		RGSW E 2 Offset(-6,38)
		RGSW G 1 Offset(-8,39)
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/pumpforth")
		TNT1 A 0 A_FireCustomMissile("ShotgunCasingSpawner",0,0,-2,-15)
		RGSW H 2 Offset(-10,40)
		RGSW IJ 1
		RGSW E 2 Offset(-12,39)
		RGSW D 2 Offset(-10,38)
		RGSW D 2 Offset(-6,36)
		RGSW C 1 Offset(-3,35)
		RGSW B 1 Offset(-1,34)
		RGSW A 1 Offset(0,38) A_PlayWeaponSound("weapons/riotgun/raise")
		RIOT A 2 Offset(0,33)
		Goto ReadyII
	AimedFire:
		TNT1 A 0 A_JumpIfInventory("ShotgunReloading",1,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("LoadedShell",1,1)
		Goto ReloadCheck
		TNT1 A 0 A_TakeInventory("LoadedShell",1,TIF_NOTAKEINFINITE)
		SHZM C 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound("weapons/riotgun/fire", 7)
		ZMFI C 0 A_Light2
		ZMFI A 1 Bright A_FireBullets(2,2,8,5,"AltPuff",0)
		TNT1 A 0 A_ZoomFactor(1.285)
		ZMFI A 1 A_Light1
		TNT1 A 0 A_SetPitch(pitch-0.2)
		TNT1 A 0 A_ZoomFactor(1.29)
		ZMFI B 2 A_Light0
		TNT1 A 0 A_SetPitch(pitch+0.2)
		TNT1 AAAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,0)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,0)
		TNT1 A 0 A_ZoomFactor(1.3)
		ZMFI C 13
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/pumpback")
		ZMCK A 1
		ZMCK B 2
		TNT1 AAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,8,0)
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/pumpforth")
		ZMCK C 1 Offset(0,34) A_FireCustomMissile("ShotgunCasingSpawner",0,0,8,-10)
		ZMCK C 4 Offset(0,36)
		ZMCK DE 2 Offset(0,34)
		SHZM C 3 Offset(0,32)
		SHZM C 1 A_JumpIfInventory("SynthFireRight",1,"Ready2")
		Goto ZoomOut
	Altfire:
		TNT1 A 0 A_JumpIfInventory("ShotgunReloading",1,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("Aiming",1,"Ready2")
		TNT1 A 0 A_Giveinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.3)
		TNT1 A 0 A_Giveinventory("Aiming",1)
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/raise")
		SHZM ABC 1
		Goto Ready2	
	ZoomOut:
		TNT1 AAAAAA 0
		SHZM BA 2
		TNT1 A 0 A_Takeinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("Aiming",1)
		Goto ReadyII
	Flash:
		BOOF A 1 Bright A_Light1
		BOOF B 1 Bright A_Light2
		Goto LightDone
	AltFlash:
		ZMFL A 1 Bright A_Light1
		TNT1 A 1 Bright A_Light2
		Goto LightDone
	ReloadCheck:
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RiotgunReload")==0, "NoReload")
		Goto Reload
	Reload:
		TNT1 A 0 A_Takeinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_GiveInventory("ShotgunReloading",1)
		RGSW ABC 1
		RGSW DEF 1
		Goto ReloadWork1
	ReloadWork1:
		TNT1 A 0 A_JumpIfInventory("LoadedShell",1,"ReloadWork2")
		TNT1 A 0 A_GiveInventory ("ChamberLoading",1)
		TNT1 A 0 A_JumpIfInventory("ChamberLoading",1,"FirstLoad")
	FirstLoad:
		TNT1 A 0 A_PlaySound("weapons/riotgun/load",5)
		TNT1 A 0 A_TakeInventory("Shell",1)
		TNT1 A 0 A_GiveInventory("LoadedShell",1)
		RGLS ABCD 1
		RGLS EFGH 1
		Goto ReloadPump
	ReloadWork2:
		TNT1 A 0 A_PlaySound("weapons/riotgun/load",5)
		TNT1 A 0 A_TakeInventory("Shell",1)
		TNT1 A 0 A_GiveInventory("LoadedShell",1)
		RGLS ABCD 1 A_WeaponReady
		RGLS EFGH 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("ChamberLoading",1,"ReloadPump")
		RGLS II 1 A_WeaponReady(1)
		TNT1 A 0 A_JumpIfInventory("LoadedShell",9,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("Shell",1,"ReloadWork2")
		CSHT A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		Goto ReloadEnd
	ReloadPump:
		RGSW FE 1 A_PlayWeaponSound("weapons/riotgun/pumpback")
		RGSW G 2
		RGSW H 2 offset(1,36)
		RGSW H 2 offset(2,38) A_PlayWeaponSound("weapons/riotgun/pumpforth")
		RGSW I 1 offset(2,40)
		RGSW J 3 offset(5,36)
		RGSW D 2 offset(0,32)
		RGSW EF 2
		TNT1 A 0 A_TakeInventory("ChamberLoading", 1)
		TNT1 A 0 A_JumpIfInventory("Shell",1,"ReloadWork2")
		Goto ReloadEnd
	ReloadEnd:
		TNT1 A 0 A_Takeinventory("Aiming",1)
		RGSW F 1 offset(0,38) A_PlayWeaponSound("weapons/riotgun/raise")
		RGSW E 1 offset(-10,38)
		RGSW D 1 offset(-8,40)
		RGSW C 1 offset(-4,38)
		RGSW B 1 offset(-2,36)
		RGSW A 1 offset(-1,32) A_TakeInventory("ShotgunReloading",1)
		RIOT A 1 offset(0,33) A_WeaponReady(1)
		TNT1 A 0 A_ReFire
		Goto ReadyII
		
	NoReload:
		TNT1 A 0 A_GiveInventory("ShotgunReloading",1)
		Goto NoReloadWork1
	NoReloadWork1:
		TNT1 A 0 A_JumpIfInventory("LoadedShell",1,"NoReloadWork2")
		TNT1 A 0 A_GiveInventory ("ChamberLoading",1)
		TNT1 A 0 A_JumpIfInventory("ChamberLoading",1,"NoFirstLoad")
	NoFirstLoad:
		TNT1 A 0 A_TakeInventory("Shell",1)
		TNT1 A 0 A_GiveInventory("LoadedShell",1)
		Goto NoReloadPump
	NoReloadWork2:
		TNT1 A 0 A_TakeInventory("Shell",1)
		TNT1 A 0 A_GiveInventory("LoadedShell",1)
		TNT1 A 0 A_JumpIfInventory("ChamberLoading",1,"NoReloadPump")
		TNT1 A 0 A_JumpIfInventory("LoadedShell",9,"NoReloadEnd")
		TNT1 A 0 A_JumpIfInventory("Shell",1,"NoReloadWork2")
		Goto NoReloadEnd
	NoReloadPump:
		TNT1 A 0 A_TakeInventory("ChamberLoading", 1)
		TNT1 A 0 A_JumpIfInventory("Shell",1,"NoReloadWork2")
		Goto NoReloadEnd
	NoReloadEnd:
		TNT1 A 0 A_Takeinventory("Aiming",1)
		RGSW A 0 A_TakeInventory("ShotgunReloading",1)
		TNT1 A 0 A_ReFire
		Goto ReadyII

	Spawn:
		SHAT A -1
		Stop
	}
}

ACTOR LoadedShell : Ammo
{
	+IGNORESKILL
	Inventory.MaxAmount 9
}

ACTOR ShotgunReloading : Inventory
{
	Inventory.Maxamount 1
}

ACTOR ChamberLoading : Inventory
{
	Inventory.Maxamount 1
}