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

ACTOR DualUSMG : BaseWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 30
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Magazine9mm"
	Weapon.AmmoType2 "DualSMGAmmo"
	Weapon.SelectionOrder 5500
	-WEAPON.CHEATNOTWEAPON
	+POWERED_UP
	Weapon.SisterWeapon "U_SMG"
	Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "You got the SMG!"
	Obituary "%o was shot down by %k's SMGs."
	tag "Dual Submachine guns"
	Scale 0.9
	States
	{
	Spawn:
		SMGZ A -1
		Stop

	Select:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist", 1, "PuristGun")
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1002,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("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
		
	Deselect:
		TNT1 A 0 A_PlaySound("weapons/changing")
		SM2S ABCDEF 1
		TNT1 A 0 A_Takeinventory("SubMachineGunSelected",1)
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1028)==2, 2)
		TNT1 A 0 A_Takeinventory("PowerWeaponLevel2",1)
		TNT1 A 0 A_Lower
		Wait
		
	Ready:
		TNT1 A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
		TNT1 A 0 A_PlaySound("CLIPIN")
	Ready1:
		SM2S FEDCBA 1
	Ready2:
		TNT1 A 0 //A_GunFlash
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		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("Unloading",1,"Unload")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		TNT1 A 0 A_JumpIfInventory("IdleCounter",200,"PlayerIsIdle")
		SM2G A 1 A_WeaponReady
		Goto Ready2
		
// --------------------------------------------------------------------------
//
//	Fire
//
// --------------------------------------------------------------------------

	Fire:
		TNT1 A 0 A_JumpIfInventory("DualSMGAmmo",2,1)
		Goto Reload
		TNT1 A 0 A_PlaySound("FARSHT")
		TNT1 A 0 A_PlaySound("SMGFIRE",1)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,15,5)
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,15,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
		TNT1 A 0 A_ZoomFactor(0.98)
		SM2F A 1 BRIGHT A_FireBullets(7.2, 7.2, -1, 8, "WeakPuff")
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_FireCustomMissile("Tracer", frandom(-3,3), 0, 15, 0, 0, frandom(-3,3))
		TNT1 A 0 A_Takeinventory("DualSMGAmmo",1)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(-1.1 + pitch)
		
		TNT1 A 0 A_JumpIfInventory("FireSeq",1,2)
		TNT1 A 0 A_Jump(256,3)
		TNT1 A 0 A_SetPitch(+0.4 + pitch)
		TNT1 A 0 A_FireCustomMissile("9mmCaseSpawn",5,0,-9,-7)
		
		TNT1 A 0 A_PlaySound("FARSHT")
		TNT1 A 0 A_PlaySound("SMGFIRE",5)
		TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,-15,5)
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,-15,0)
		TNT1 A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
		TNT1 A 0 A_ZoomFactor(0.98)
		SM2F B 1 BRIGHT A_FireBullets(7.2, 7.2, -1, 8, "WeakPuff")
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_FireCustomMissile("Tracer", frandom(-3,3), 0, -15, 0, 0, frandom(-3,3))
		TNT1 A 0 A_Takeinventory("DualSMGAmmo",1)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(-1.1 + pitch)
		
		TNT1 A 0 A_SetPitch(+0.5 + pitch)
		SM2F C 1
		TNT1 A 0 A_SetPitch(+0.5 + pitch)
		TNT1 A 0 A_SetPitch(+0.4 + pitch)
		TNT1 A 0 A_FireCustomMissile("9mmCaseSpawn",5,0,21,-7)
		TNT1 A 0 A_GiveInventory("FireSeq",1)
		TNT1 A 0 A_ReFire
		
		SM2G A 1
		TNT1 A 0 A_SetPitch(+0.4 + pitch)
		TNT1 A 0 A_FireCustomMissile("9mmCaseSpawn",5,0,-9,-7)
		TNT1 A 0 A_TakeInventory("FireSeq",2)
		SM2G A 1 A_WeaponReady
		Goto Ready2
		

// --------------------------------------------------------------------------
//
//	Reload and unload
//
// --------------------------------------------------------------------------
		
	Reload:
		SM2G A 1
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_JumpIfInventory("DualSMGAmmo",80,"Ready2")
		TNT1 A 0 A_JumpIfInventory("Magazine9mm",1,1)
		Goto DryFire
		TNT1 A 0 A_GiveInventory("Pumping", 1)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		SM2S ABCDEF 1
		TNT1 A 5
		TNT1 A 0 A_PlaySound("reload")
		SMGR VUTSREEFGHIJKKKKKKK 1
		TNT1 A 0 A_JumpIfInventory("DualSMGAmmo",1,3)
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_DualSMG",1,2)
		TNT1 A 0 A_FireCustomMissile("EmptyMag9mm",-5,0,8,-4)
		SMGR LMNOPQQQRSTUV 1
		TNT1 A 5
		
		TNT1 A 0 A_PlaySound("reload")
		SM2R VUTSREEFGHIJKKKKKKK 1
		TNT1 A 0 A_JumpIfInventory("DualSMGAmmo",1,3)
		TNT1 A 0 A_JumpIfInventory("HasUnloaded_DualSMG",1,2)
		TNT1 A 0 A_FireCustomMissile("EmptyMag9mm",-5,0,8,-4)
		SM2R LMNOPQQQRSTUV 1
		TNT1 A 5
				
	TurboReload:
		TNT1 A 0 A_Takeinventory("HasUnloaded_DualSMG",1)
		Goto ReloadLoop
		
	ReloadLoop:
		TNT1 A 0 A_JumpIfInventory("DualSMGAmmo",80,"ReloadDone")
		TNT1 A 0 A_JumpIfInventory("Magazine9mm",1,1)
		Goto ReloadDone
		TNT1 A 0 A_Giveinventory("DualSMGAmmo",1)
		TNT1 A 0 A_Takeinventory("Magazine9mm",1)
		Loop

	ReloadDone:
		TNT1 A 0 A_Takeinventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("HasUnloaded_DualSMG",1)
		TNT1 A 0 A_JumpIfInventory("TurboReload",1,1)
		Goto Ready1
		TNT1 A 0 A_Refire
		Goto Ready2

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

	DualWield:
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(1028)==2, "Ready2")
		TNT1 A 0 A_Takeinventory("PowerSphere2",1)
		Goto Deselect

	DryFire:
		TNT1 A 0 A_PlaySound("weapons/empty")
		Goto Ready2

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

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

	Taunt:
		SM2G A 5
		TNT1 A 0 A_PlaySound("FUCK", 2)
		TNT1 A 0 A_FireCustomMissile("Taunter", 0, 0, -1, 0)
		TNT1 A 0 A_FireCustomMissile("Taunter", -9, 0, -1, 0)
		TNT1 A 0 A_FireCustomMissile("Taunter", 9, 0, -1, 0)
		TNT1 A 0 A_AlertMonsters
		SM2G A 20
		TNT1 A 0 A_Takeinventory("Taunting",1)
		Goto Ready2

	KickFlash:
		SM2S ABCDE 1
		SM2S F 6
		SM2S EDCBA 1
		SM2G A 1
		Stop
		
	AirKickFlash:
		SM2S ABCDE 1
		SM2S F 8
		SM2S EDCBA 1
		SM2G A 1
		Stop
		
	GrenadeFlash:
		SM2S ABCDEF 1
		Stop
	}
}

ACTOR HasUnloaded_DualSMG : Inventory { Inventory.MaxAmount 1 }

ACTOR DualSMGAmmo: Ammo
{
	+INVENTORY.IGNORESKILL
	Inventory.Amount 0
	Inventory.MaxAmount 80
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 80
	Inventory.Icon "SMGZA0"
}