ACTOR DualMP40 : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Mauser9mm"
	Weapon.AmmoType2 "DualMP40Ammo"
	Obituary "%o was shot down by %k's SMG."
    AttackSound "None"
	Weapon.SelectionOrder 1700
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "You got dual MP40's! (Slot 2)"
    +WEAPON.NOAUTOAIM
	+WEAPON.NO_AUTO_SWITCH
	Tag "Dual MP40's"
	DropItem "MP40Spawner"
	States
	{
	Ready3:
	Ready:
        MP42 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP42 A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		MP42 A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		MP42 A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        MP42 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		MP42 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		MP42 A 0 A_JumpIfInventory("Unloading",1,"Unload")
		MP42 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		MP42 A 0 A_JumpIfInventory("Reloading",1,"Reload")
		MP42 A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		MP42 A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Loop

	DualWield:
		MP42 F 1
		MP42 F 0 A_GiveInventory("MP40",1)
		MP42 A 0 A_Takeinventory("StartDualWield",1)
		MP42 A 0 A_SelectWEapon("MP40")
		Goto Ready

	StartSprint:
		MP42 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		SHTN A 0 A_Takeinventory("Zoomed",1)
        SHTN A 0 A_ZoomFactor(1.0)
		SHTN A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_SetCrosshair(0)
		SHTN A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.

	Sprinting:
		MP42 A 1 offset(-9,34) A_SetPitch(pitch -0.5)
		MP42 A 1 offset(-6,36) A_SetPitch(pitch -0.5)
		MP42 A 1 offset(-3,38) A_SetPitch(pitch -0.5)
		MP42 A 1 offset(0,38) A_SetPitch(pitch -0.5)
		MP42 A 1 offset(3,36) A_SetPitch(pitch -0.5)
		MP42 A 1 offset(6,34) A_SetPitch(pitch -0.5)
		MP42 A 1 offset(9,32) A_SetPitch(pitch -0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 1)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		MP42 A 1 offset(9,34) A_SetPitch(pitch +0.5)
		MP42 A 1 offset(6,36) A_SetPitch(pitch +0.5)
		MP42 A 1 offset(3,38) A_SetPitch(pitch +0.5)
		MP42 A 1 offset(0,38) A_SetPitch(pitch +0.5)
		MP42 A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		MP42 A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		MP42 A 1 offset(-9,32) A_SetPitch(pitch +0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 1)
		SMGG A 0 A_WeaponReady(WRF_NOBOB)
		SMGG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        SMGG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
        SMGG A 0 A_JumpIfInventory("Reloading",1,"Reload")

		PLAY A 0 ACS_NamedExecuteAlways("BDSprint", 0, 0, 0, 0)//Makes player faster.
		SMGG A 0 A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint

	StopSprint:
		MP42 A 0 A_JumpIfInventory("PowerStrength", 1, 2)
		MP42 A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		MP42 A 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto Ready

	StopSprintTired:
		MP42 A 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		MP42 A 0 A_PlaySound("Tired", 2)
		Goto Ready

	Deselect:
        MP42 F 1
		TNT1 AAAAAAAAAAAA 0 A_Lower
		MP42 A 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 1 A_Lower
		Wait

	Select:
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_TakeInventory("FistsSelected", 1)
		TNT1 A 0 A_TakeInventory("ShotgunSelected", 1)
		TNT1 A 0 A_TakeInventory("MinigunSelected", 1)
		TNT1 A 0 A_TakeInventory("SSGSelected", 1)
		TNT1 A 0 A_TakeInventory("RocketLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("GrenadeLauncherSelected", 1)
		TNT1 A 0 A_TakeInventory("PlasmaGunSelected", 1)
		TNT1 A 0 A_TakeInventory("RailGunSelected", 1)
		TNT1 A 0 A_TakeInventory("RevenantLauncherSelected", 1)
		TNT1 A 0 A_GiveInventory("SubMachineGunSelected", 1)
		TNT1 A 0 A_GiveInventory("HasDualMP40",1)
		TNT1 A 0 A_TakeInventory("BFG10KSelected", 1)
		TNT1 A 0 A_TakeInventory("BFGSelected", 1)
		TNT1 A 0 A_TakeInventory("FlameCannonSelected", 1)
		TNT1 A 0 A_TakeInventory("SawSelected", 1)
		MP42 A 0 A_Takeinventory("HasBarrel",1)
		MP40 A 0 A_TakeInventory("MP40",1)
        MP42 A 0 A_GunFlash
		TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAAAA 0 A_Raise
		Goto SelectAnimation


	SelectAnimation:
		TNT1 A 1
	    MP42 A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
        MP42 A 0 A_PlaySound("CLIPIN")
        MP42 F 1
		MP42 A 0 A_Takeinventory("StartDualWield",1)
		Goto Ready


    Fire:
        TNT1 A 0
		MP42 A 0 A_JumpIfInventory("MP40Ammo",1,1)
        Goto FireLeft
		RIFF A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        MP42 A 0 A_PlaySound("MP40", 1)
		MP42 A 0 A_SpawnItemEx("PlayerMuzzle1",32,5,28)
		MP42 B 1 BRIGHT A_FireBullets (2.0, 1.6, -1, 15, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-2,2),0,8,0,0,random(-2,2))
		MP42 A 0 A_Takeinventory("MP40Ammo",1)
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
		MP42 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,16,-8)
		RIFG A 0 A_SetPitch(pitch-0.2)
		MP42 C 1
		TNT1 A 0 A_ZoomFactor(1.0)

		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,1)
        Goto NoAmmo
		RIFF A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        MP42 A 0 A_PlaySound("MP40", 1)
		MP42 A 0 A_SpawnItemEx("PlayerMuzzle1",32,-5,28)
		MP42 D 1 BRIGHT A_FireBullets (2.0, 1.6, -1, 15, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-2,2),0,-8,0,0,random(-2,2))
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
		MP42 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,-12,-8)
		RIFG A 0 A_SetPitch(pitch-0.2)
        MP42 E 1
		TNT1 A 0 A_ZoomFactor(1.0)
		MP42 A 1 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready3

	FireLeft:
        TNT1 A 0
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,1)
        Goto NoAmmo
		RIFF A 0 A_FireCustomMissile("DistantFireSoundPistol", random(-1,1), 0, 0, -12, 0, random(-1,1))
        MP42 A 0 A_PlaySound("MP40", 1)
		MP42 A 0 A_SpawnItemEx("PlayerMuzzle1",32,-5,28)
		MP42 D 1 BRIGHT A_FireBullets (2.0, 1.6, -1, 15, "WeakPuff", FBF_NORANDOM)
		TNT1 A 0 A_ZoomFactor(0.99)
        TNT1 A 0 A_FireCustomMissile("DecorativeTracer",random(-2,2),0,-8,0,0,random(-2,2))
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
		MP42 A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,-12,-8)
		RIFG A 0 A_SetPitch(pitch-0.2)
        MP42 E 1
		TNT1 A 0 A_ZoomFactor(1.0)
		MP42 A 2
		MP42 A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
		Goto Ready3

	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		MP42 A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("Mauser9mm",1,"Reload")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Goto Ready3

    Reload:
		MP42 A 1
		MP42 A 0 A_Takeinventory("ADSmode",1)
		MP42 A 0 A_Takeinventory("Reloading",1)
		MP42 A 0 A_Takeinventory("Zoomed",1)
		MP42 A 0 A_ZoomFactor(1.0)
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",64,"Ready")

        MP42 A 0 A_JumpIfInventory("Mauser9mm",1,3)
        Goto Ready
        TNT1 AAA 0
		MP42 A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		MP42 A 0 A_JumpIfInventory("MP40Unloaded", 1, "PutMag")
		MP40 A 0 A_PlaySound("RELO1")
		MP4R ABCDE 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP4R F 8 A_FireCustomMissile("EmptyPistolClipSpawn",0,0,0,-20)
	PutMag:
		MP4R F 8
		MP4R ED 2
		MP4R C 2 A_PlaySound("RELO2")
		MP4R BA 2
		MP42 A 0 A_JumpIfInventory("MP40Unloaded", 1, "PutMag2")

		MP40 A 0 A_PlaySound("RELO1")
		MP2R ABCDE 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP2R F 8 A_FireCustomMissile("EmptyPistolClipSpawn",225,0,-10,-20)
	PutMag2:
		MP2R F 8
		MP2R ED 2
		MP2R C 2 A_PlaySound("RELO2")
		MP2R BA 2
		MP40 A 0 A_Takeinventory("Reloading",1)
		MP40 A 0 A_Takeinventory("MP40Unloaded",1)
		Goto InsertBullets

	TurboReload:
		MP42 A 0 A_Takeinventory("MP40Unloaded",1)
		MP42 A 0 A_JumpIfInventory("Mauser9mm",1,3)
		Goto Ready
        MP42 AAA 0
        Goto InsertBullets

	InsertBullets:
		TNT1 AAAA 0
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",64,15)
		MP42 A 0 A_JumpIfInventory("Mauser9mm",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		MP42 A 0 A_Giveinventory("MP40Ammo",1)
		MP42 A 0 A_Giveinventory("DualMP40Ammo",1)
		MP42 A 0 A_Takeinventory("Mauser9mm",1)
		Goto InsertBullets

		TNT1 AAAAAAAAAA 0
		MP42 A 1 A_Takeinventory("Reloading",1)

		MP42 A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready
		TNT1 AAAA 0
		MP42 A 1 A_Takeinventory("Reloading",1)

		MP42 A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
        Goto Ready


 	 Unload:
		MP42 A 1
		MP42 A 0 A_Takeinventory("ADSmode",1)
		MP42 A 0 A_Takeinventory("Unloading",1)
		MP42 A 0 A_JumpIfInventory("MP40Ammo",1,3)
		Goto UnloadLeft
        TNT1 AAA 0

		MP42 A 0 A_Takeinventory("Zoomed",1)
        MP42 A 0 A_ZoomFactor(1.0)
		MP42 A 0 A_GiveInventory ("Pumping", 1)
		MP42 A 0 A_Takeinventory("Reloading",1)
		MP42 A 0 A_Giveinventory("MP40Unloaded",1)
        MP40 A 0 A_PlaySound("RELO1")
		MP4R ABCDE 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP4R F 8
		MP40 A 0 A_PlaySound("RELO1")
		MP2R ABCDE 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP2R F 8
		Goto RemoveBullets

	UnloadLeft:
		TNT1 A 0
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,3)
		Goto Ready
        TNT1 AAA 0
		MP42 A 0 A_Takeinventory("Zoomed",1)
        MP42 A 0 A_ZoomFactor(1.0)
		MP42 A 0 A_GiveInventory ("Pumping", 1)
		MP42 A 0 A_Takeinventory("Reloading",1)
		MP42 A 0 A_Giveinventory("MP40Unloaded",1)
		MP40 A 0 A_PlaySound("RELO1")
		MP2R ABCDE 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        MP2R F 8
		Goto RemoveBullets

	RemoveBullets:
		TNT1 AAAA 0
		MP42 A 0 A_JumpIfInventory("DualMP40Ammo",1,3)
		Goto FinishUnload
        TNT1 AAAAAA 0
		MP42 A 0 A_Takeinventory("MP40Ammo",1)
		MP42 A 0 A_Takeinventory("DualMP40Ammo",1)
		MP42 A 0 A_Giveinventory("Mauser9mm",1)
		Goto RemoveBullets

	FInishUnload:
		MP42 A 1
		MP40 A 0 A_GiveInventory("MP40Unloaded", 1)
		MP40 A 0 A_Takeinventory("Unloading",1)
		Goto Ready

	Spawn:
		MP40 I -1
		Stop


	Steady:
		TNT1 A 1
		Goto Ready
	}
}

ACTOR DualMP40Ammo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 64
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 64
   Inventory.Icon "MP40J0"
}