// --------------------------------------------------------------------------
//
//	SMG
//
// --------------------------------------------------------------------------

ACTOR U_SMG : BaseWeapon replaces BrutalSMG
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 30
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "9mmMagazine"
	Weapon.AmmoType2 "BDSMGAmmo"
	Weapon.SelectionOrder 5500
	Obituary "%o was shot down by %k's SMG."
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "You got the Sub Machinegun!"
	-WEAPON.CHEATNOTWEAPON
	Scale 0.9
	tag "Sub Machinegun"
	States
	{
 	Spawn:
		SMGZ A -1
		Stop

	Select:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist",1,"PuristGun")
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1010,0)==0, "PuristGun")
		TNT1 A 0 A_Giveinventory("SubMachineGunSelected",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("Taunting",1)
		TNT1 A 0 A_Takeinventory("IdleCounter",200)
		TNT1 A 5
		TNT1 A 0 A_Raise
		Wait
		
	Deselect:
		TNT1 A 0 A_PlaySound("weapons/changing")
		TNT1 A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetCrosshair(0)
		SMGS CBA 1
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 4 A_Takeinventory("SubMachineGunSelected",1)
		TNT1 A 0 A_Lower
		Wait
		
	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality",1,"Steady")
		TNT1 A 0 A_PlaySound("CLIPIN")
	Ready1:
		SMGS ABC 1
	Ready2:
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"ReadyZoom")
        TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        TNT1 A 0 A_JumpIfInventory("Taunting",1,"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("IdleCounter",200,"PlayerIsIdle")
		SMGG A 1 A_WeaponReady
		Loop

	ReadyZoom:
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("Salute1",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Salute2",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"AltFire")
		TNT1 A 0 A_JumpIfInventory("Unloading",1,"AltFire")
		SMGA A 1 A_WeaponReady
		Loop

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

    Fire:
        TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",1,1)
        Goto Reload
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_JumpIfInventory("Zoomed",1,"FireZoom")
		TNT1 A 0 A_PlaySound("FARSHT",6)
        TNT1 A 0 A_PlaySound("SMGFIRE")
		TNT1 A 0 A_ZoomFactor(0.98)
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		SMGF A 1 BRIGHT A_FireBullets(3.6, 3.6, 1, 8, "WeakPuff")
		TNT1 A 0 A_ZoomFactor(1.0)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer", frandom(-1,1), 0, 0, 0)
		TNT1 A 0 A_Takeinventory("BDSMGAmmo",1)
        SMGF B 1
		TNT1 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		SMGF C 1 
		TNT1 A 0 A_ReFire
		SMGG A 1 A_WeaponReady
		Goto Ready2
		
	 FireZoom:
		TNT1 A 0 A_PlaySound("FARSHT", 6)
        TNT1 A 0 A_PlaySound("SMGFIRE")
		TNT1 A 0 A_ZoomFactor(1.45)
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		SMGA B 1 BRIGHT A_FireBullets(1.8, 1.8, 1, 8, "WeakPuff")
		TNT1 A 0 A_ZoomFactor(1.5)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer", frandom(-1,1), 0, 0, 0)
		TNT1 A 0 A_Takeinventory("BDSMGAmmo",1)
		TNT1 A 0 A_Takeinventory("BDDualSMGAmmo",1)
        SMGA C 1
		TNT1 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,0,-9)
		SMGA D 1 
		TNT1 A 0 A_ReFire
		SMGA A 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)
		RIFZ ABC 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)
		RIFZ CBA 1
		Goto Ready2

	DryFire:
		TNT1 A 0 A_PlaySound("weapons/empty")
		Goto Ready2
	
    Reload:
		SMGG A 1
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",41,"Ready2")
        TNT1 A 0 A_JumpIfInventory("9mmMagazine",1,3)
        Goto DryFire
        TNT1 AAA 0
		TNT1 A 0 A_Takeinventory("Zoomed",1)
        TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_GiveInventory("Pumping", 1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("HasUnloaded",1,2)
		RIFR C 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		TNT1 A 0 A_PlaySound("reload")
        SMGR ABCDEEEFGHIJKKKKKKKKKK 1
        SMGR LMNOPQEEEDCBA 1
		TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",1,"ReloadLoop2")//40+1 effect
		
	TurboReload:
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
        SMGS BA 0
        Goto ReloadLoop
		
	ReloadLoop:
		TNT1 AAAA 0
		TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",40,15)
		TNT1 A 0 A_JumpIfInventory("9mmMagazine",1,3)
		Goto Ready2
        TNT1 AAAAAA 0
		TNT1 A 0 A_Giveinventory("BDSMGAmmo",1)
		TNT1 A 0 A_Giveinventory("BDDualSMGAmmo",1)
		TNT1 A 0 A_Takeinventory("9mmMagazine",1)
		Goto ReloadLoop
		TNT1 AAAAAAAAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Refire
        Goto Ready2
		TNT1 AAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Refire
        Goto Ready2
		
	ReloadLoop2:
		TNT1 AAAA 0
		TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",41,15)
		TNT1 A 0 A_JumpIfInventory("9mmMagazine",1,3)
		Goto Ready2
        TNT1 AAAAAA 0
		TNT1 A 0 A_Giveinventory("BDSMGAmmo",1)
		TNT1 A 0 A_Giveinventory("BDDualSMGAmmo",1)
		TNT1 A 0 A_Takeinventory("9mmMagazine",1)
		Goto ReloadLoop2
		TNT1 AAAAAAAAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Refire
        Goto Ready2
		TNT1 AAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Refire
        Goto Ready2
		
	 Unload:
		SMGG A 1
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_Takeinventory("Unloading",1)
		TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",1,3)
		Goto DryFire
        TNT1 AAA 0
		TNT1 A 0 A_Takeinventory("Zoomed",1)
        TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_GiveInventory ("Pumping", 1)
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_PlaySound("reload")
		TNT1 A 0 A_Giveinventory("HasUnloaded",1)
        SMGR ABCDEEEFGHIJKKKKKKKKKK 1
		
	RemoveBullets:
		TNT1 AAAA 0
		TNT1 A 0 A_JumpIfInventory("BDSMGAmmo",1,3)
		Goto Ready2
        TNT1 AAAAAA 0
		TNT1 A 0 A_Takeinventory("BDSMGAmmo",1)
		TNT1 A 0 A_Takeinventory("BDDualSMGAmmo",1)
		TNT1 A 0 A_Giveinventory("9mmMagazine",1)
		Goto RemoveBullets
		TNT1 AAAAAAAAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Refire
        Goto Ready2
		TNT1 AAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_Refire
        Goto Ready2
		
// --------------------------------------------------------------------------
//
//	End Stuff
//
// --------------------------------------------------------------------------

	KickFlash:
		SMGG A 17
		Stop

	AirKickFlash:
		SMGG A 19
		Stop

	TauntFlash:
		SMGS CBA 1
		TNT1 A 37
		SMGS ABC 1
		SMGG A 1
		Stop

	GrenadeFlash:
		SMGS CBA 1
		Stop
	}
}