actor SubMachineGun : AOWWeapon 21043 {
	//$Category Weapons
    Weapon.BobSpeed 1.75
    Weapon.BobRangeX 0.2
    Weapon.BobRangeY 0.4
    Weapon.BobStyle Alpha
	obituary "$OB_SUBBY"
	inventory.pickupmessage "You got the submachinegun!"
	weapon.selectionorder 15
	weapon.kickback 80
	weapon.ammotype "SMGMag"
	weapon.ammouse 1
	weapon.ammogive2 30
	weapon.ammotype2 "NewClipAmmo"
	weapon.preferredskin "MarineSMG"
	Weapon.UpSound "weapons/up/smg"
	decal "BulletChip"
	tag "Sub-Machine Gun"
	+WEAPON.AMMO_OPTIONAL
	states {
    Select:
		TNT1 A 0 A_JumpIfInventory("IsBlue",1,"Select.Blue")
		SUBR A 1 offset (-90,100)
		SUBR A 1 offset (-80,89)
		SUBR A 1 offset (-70,79)
		SUBR A 1 offset (-60,70)
		SUBR A 1 offset (-50,62)
		SUBR A 1 offset (-40,55)
		SUBR A 1 offset (-30,49)
		SUBR A 1 offset (-20,44)
		SUBR A 1 offset (-15,40)
		SUBR A 1 offset (-10,37)
		SUBR A 1 offset (-5,34)
		SUBR A 1 offset (0,0)
		TNT1 A 0 A_TakeInventory("SelectAnimation",1)
		goto ready
	Select.Blue:
		SUBB A 1 offset (-90,100)
		SUBB A 1 offset (-80,89)
		SUBB A 1 offset (-70,79)
		SUBB A 1 offset (-60,70)
		SUBB A 1 offset (-50,62)
		SUBB A 1 offset (-40,55)
		SUBB A 1 offset (-30,49)
		SUBB A 1 offset (-20,44)
		SUBB A 1 offset (-15,40)
		SUBB A 1 offset (-10,37)
		SUBB A 1 offset (-5,34)
		SUBB A 1 offset (0,0)
		TNT1 A 0 A_TakeInventory("SelectAnimation",1)
		goto ready
    Deselect:
		TNT1 A 0 A_TakeInventory("ActionFragGrenade",1)	
        TNT1 A 0 A_TakeInventory("ActionFlashbang",1)
        TNT1 A 0 A_TakeInventory("ActionRemoteC4",1)	
        TNT1 A 0 A_TakeInventory("ActionMeleeAttack",1)
		TNT1 A 0 A_TakeInventory("ActionReload",1)	
		SUBR A 0 A_JumpIfInventory ("IsBlue", 1, "Deselect.Blue")
		SUBR A 1 offset (-4,34)
		SUBR A 1 offset (-8,40)
		SUBR A 1 offset (-16,49)
		SUBR A 1 offset (-24,62)
		SUBR A 1 offset (-32,79)
		SUBR A 1 offset (-40,100)
		TNT1 A 0 offset (-1, 33)
		TNT1 A 0 A_Lower
		wait
	Deselect.Blue:
		SUBB A 1 offset (-4,34)
		SUBB A 1 offset (-8,40)
		SUBB A 1 offset (-16,49)
		SUBB A 1 offset (-24,62)
		SUBB A 1 offset (-32,79)
		SUBB A 1 offset (-40,100)
		TNT1 A 0 offset (-1, 33)
		TNT1 A 0 A_Lower
		wait
	Ready:
	    TNT1 A 0 A_JumpIfInventory("SelectAnimation",1,"Select")
	    TNT1 A 0 A_JumpIfInventory("IsBlue",1,"Ready.Blue")
		TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_JumpIfInventory("ActionReload",1,"Reload")
		SUBR A 1 A_WeaponReady
		Loop
	Ready.Blue:
		TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_JumpIfInventory("ActionReload",1,"Reload.Blue")
		SUBB A 1 A_WeaponReady
		Loop
	Fire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory("IsBlue",1,"Fire.Blue")
		TNT1 A 0 A_JumpIfNoAmmo("Empty")
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 bright A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		SUBR A 1 bright offset (1, 32) A_FireBullets (1.5, 1.5, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBR A 1 bright offset (3, 35) A_SetPitch(pitch-0.2)
		SUBR A 1 offset (5, 37) A_SetPitch(pitch+0.2)
		
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 bright A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		SUBR A 1 bright offset (1, 32) A_FireBullets (1.5, 1.5, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBR A 1 bright offset (3, 35) A_SetPitch(pitch-0.2)
		SUBR A 1 offset (6, 37) A_SetPitch(pitch+0.2)
		
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 bright A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		SUBR A 1 bright offset (1, 32) A_FireBullets (1.5, 1.5, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBR A 1 bright offset (3, 35) A_SetPitch(pitch-0.2)
		SUBR A 1 offset (5, 37) A_SetPitch(pitch+0.2)
		SUBR A 1 offset (7, 37)

		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBR A 3 A_JumpIfInventory ("IsGunman", 1, 1)
		SUBR AAA 3 offset (1, 32) A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		SUBR A 2 A_ReFire
		goto Ready
	Fire.Blue:
	    TNT1 A 0 A_JumpIfNoAmmo("Empty.Blue")
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 bright A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		SUBB A 1 bright offset (1, 32) A_FireBullets (1.5, 1.5, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBB A 1 bright offset (3, 35) A_SetPitch(pitch-0.2)
		SUBB A 1 offset (5, 37) A_SetPitch(pitch+0.2)
		
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 bright A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		SUBB A 1 bright offset (1, 32) A_FireBullets (1.5, 1.5, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBB A 1 bright offset (3, 35) A_SetPitch(pitch-0.2)
		SUBB A 1 offset (6, 37) A_SetPitch(pitch+0.2)
		
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 bright A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		SUBB A 1 bright offset (1, 32) A_FireBullets (1.5, 1.5, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBB A 1 bright offset (3, 35) A_SetPitch(pitch-0.2)
		SUBB A 1 offset (5, 37) A_SetPitch(pitch+0.2)
		SUBB A 1 offset (7, 39)
		
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBB A 3 A_JumpIfInventory ("IsGunman", 1, 1)
		SUBB AAA 3 offset (1, 32) A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		SUBB A 2 A_ReFire
		goto Ready
	AltFire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory("IsBlue",1,"AltFire.Blue")
		TNT1 A 0 A_JumpIfInventory("SMGMag",1,1)
	    Goto Empty
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		SUBR A 0 A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		TNT1 A 0 A_TakeInventory("SMGMag",1)
		SUBR A 1 bright offset (1, 32) A_FireBullets (3.75, 3.75, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBR A 1 bright offset (3, 35) A_SetPitch(pitch - 0.4)
		SUBR A 1 offset (5, 37) A_SetPitch(pitch + 0.4)
		SUBR A 1 offset (7, 39)
		SUBR A 2 offset (1, 32) A_ReFire
		goto Ready
	AltFire.Blue:
	    TNT1 A 0 A_JumpIfInventory("SMGMag",1,1)
	    Goto Empty.Blue
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlaySound ("subby/fire", CHAN_WEAPON)
		TNT1 A 0 A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
		TNT1 A 0 A_TakeInventory("SMGMag",1)
		SUBB A 1 bright offset (1, 32) A_FireBullets (3.75, 3.75, -1, 12, "HandgunPuff",FBF_NORANDOM|FBF_USEAMMO, 2048)
		SUBB A 1 bright offset (3, 35) A_SetPitch(pitch-0.4)
		SUBB A 1 offset (5, 37) A_SetPitch(pitch+0.4)
		SUBB A 1 offset (7, 39)
		SUBB A 2 offset (1, 32) A_ReFire
		goto Ready
	Empty:
		SUBR A 10 A_PlayWeaponSound("weapons/empty1")
	Reload:
		TNT1 A 0 A_JumpIfInventory("IsBlue",1,"Reload.Blue")
		TNT1 A 0 A_TakeInventory("ActionReload",1)
		TNT1 A 0 A_JumpIfInventory("SMGMag",30,2)
		TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,2)
		TNT1 A 0
		Goto Ready
		TNT1 A 0 A_PlayWeaponSound("weapons/SMGOUT")
		SUBR BCDE 3 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBR FGHI 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("SMGEmptyMagSpawner",0,0,0,1)
		SUBR J 12 A_JumpIfInventory("IsGunman",1,1)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBR JJJJJJ 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_PlayWeaponSound("weapons/SMGIN")
		SUBR KL 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		SUBR MNO 3
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBR P 3 A_PlayWeaponSound("weapons/SMGSLAP")
		SUBR QRST 3
		TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,"Reload2")		 
		Goto Ready
	Reload2:
		TNT1 A 0 A_TakeInventory("NewClipAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_GiveInventory("SMGMag",1)
		TNT1 A 0 A_JumpIfInventory("SMGMag",30,2)
		TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,"Reload2")
		TNT1 A 0 
		Goto Ready
	Empty.Blue:
		SUBB A 10 A_PlayWeaponSound("weapons/empty1")
	Reload.Blue:
	    TNT1 A 0 A_TakeInventory("ActionReload",1)
		TNT1 A 0 A_JumpIfInventory("SMGMag",30,2)
		TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,2)
		TNT1 A 0
		Goto Ready
		TNT1 A 0 A_PlayWeaponSound("weapons/SMGOUT")
		SUBB BCDE 3 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBB FGHI 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("SMGEmptyMagSpawner",0,0,0,1)
		SUBB J 12 A_JumpIfInventory("IsGunman",1,1)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBB JJJJJJ 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_PlayWeaponSound("weapons/SMGIN")
		SUBB KL 2 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		SUBB MNO 3
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		SUBB P 3 A_PlayWeaponSound("weapons/SMGSLAP")
		SUBB QRST 3
		TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,"Reload2")		 
		Goto Ready
	Flash:
		//TNT1 A 0 bright A_FireCustomMissile("MuzzleFlashSpawner",0,0,5,5)
		//TNT1 A 0 Bright A_SpawnItemEx("MuzzleFlashSpawner",32,5,36,momx*sin(angle)*cos(angle)*1.414,momy*sin(angle)*cos(angle)*1.414,0,0,SXF_ABSOLUTEMOMENTUM)
		TNT1 A 0 Bright A_SpawnItemEx("MuzzleFlashSpawner",27,5,38*(1+(-sin(pitch)*0.707)),momx*2.332*(sin(angle)*cos(angle)/2.332),momy*2.332*(sin(angle)*cos(angle)/2.332),momz*0.1415,0,SXF_ABSOLUTEMOMENTUM)
		TNT1 A 2 Bright A_Light2
		TNT1 A 2 Bright A_Light1
		Goto LightDone
	Spawn:
		SUBR X -1
		stop
	}
}

ACTOR SMGEmptyMag
{
	Radius 3
	Scale 0.2
	+MISSILE
    +CLIENTSIDEONLY
	+NOTELEPORT	
	+DOOMBOUNCE
	+THRUACTORS
	+DROPOFF
	BounceFactor 0.5
	WallBounceFactor 0.25
	BounceCount 3
    SeeSound "weapons/SMGEmpty"
    States
    {
	Spawn:
	  TNT1 A 0
      SMEC ABCDEF 3  
	  Loop
    Death:
	  TNT1 A 0
      TNT1 A 0 A_Jump(128,3)
      SMEC A 100
      SMEC A 5 A_FadeOut(0.10)
      Goto Death+3
      SMEC D 100
	  SMEC D 5 A_FadeOut(0.10)
	  Goto Death+5
	  }
}

ACTOR SMGEmptyMagSpawner
{
Height 1
Radius 1
+CLIENTSIDEONLY
+NOGRAVITY
+NOBLOCKMAP
+NOCLIP
States
{
Spawn:
    TNT1 A 0
    TNT1 A 1 A_SpawnItemEx("SMGEmptyMag", -2, 0, -14, 1, 0, 0, Random(80, 90), 128)
    Stop
    }
}

ACTOR SMGMag : Ammo
{
Inventory.Amount 0
Inventory.MaxAmount 30
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 30
+IGNORESKILL
}
