ACTOR M3A1 : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	YScale 0.6
	XScale 0.8
	Weapon.SelectionOrder 2500
	Weapon.AmmoType1 "Ammo45"
	Weapon.AmmoType2 "M31Ammo"
	Obituary "%o was shot down by %k's assault AKM."
    AttackSound "None"
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "You got an AK-47!"
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
	+FORCEXYBILLBOARD
	Tag "M3A1 SMG"
    Scale 0.8
	States
	{
 	Spawn:
		WAK4 A 1
		TNT1 A 0 A_SpawnItemEx("M3A1Weapon", 0, 0, 0, momx, momy, momz)
		Stop	
	
	Ready:
	Ready3:
		M31G A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		M31G A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
        M31G A 0 A_JumpIfInventory("Reloading",1,"Reload")
		M31G A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		"----" # 0 A_JumpIfInventory("UsedBandage", 1, "UseBandages")
		Loop
	
		
	Deselect:
		M31G A 0
		M31G A 0 A_TakeInventory("TossGrenade", 1)
        M31G A 0 A_TakeInventory("Reloading",1)
		M31G A 0 A_TakeInventory("Unloading",1)
        M31G A 0 A_ZoomFactor(1.0)
		M31G AAAAA 1 A_Lower
		TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait

	Drop:
		RIFF A 0
		TNT1 A 0 A_TakeInventory("DropWeapon", 1)
		RIFF A 0 A_SpawnItemEx("AK47Weapon", 0, 0, 30, 10, 0, 2)
		TNT1 A 0 A_TakeInventory("AK47", 1)
		TNT1 A 0 A_TakeInventory("Slot2Weapon", 1)
		Goto Ready
		
	Select:
		M31G A 0
		M31G AAAAA 1 A_Raise
		TNT1 AAAAAAAAA 0 A_Raise
		Goto Ready3
	
    Fire:
        M31G A 0 A_JumpIfInventory("M31Ammo",1,2)
        Goto NoAmmo
        TNT1 AA 0
		M31G A 0 A_AlertMonsters
		M31G A 0 A_PlaySound("PISFIR3", 1)
		
		M31F A 1 A_FireBullets (3.0, 2.0, -1, 13, "HitPuff", FBF_NORANDOM)
		M31F B 1 A_FireCustomMissile("SmokeSpawner", random(-0.3,0.3), 0, 0, 0, 0, random(-0.3,0.3))
		M31G A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
        M31F A 0 A_FireCustomMissile("Tracer", random(-1,1), 0, 0, 0, 0, random(-1,1))
		M31G A 0 A_ZoomFactor(0.98)
		M31G A 0 A_SetPitch(pitch-0.3)
		M31G A 0 A_SetANgle(angle-0.1)
		M31G A 0 A_Takeinventory("M31Ammo",1)
		M31F C 1 A_FireCustomMissile("PistolCaseSpawn",5,0,6,-14)
		M31G A 0 A_SetPitch(pitch-0.1)
		M31G A 0 A_SetANgle(angle-0.05)
		M31G A 0 A_ZoomFactor(1.0)
		M31F D 1
		M31G A 1
		M31G A 0 A_Refire
		Goto Ready3
	
     
	NoAmmo:
		M31G A 0
		M31G A 0 A_ZoomFactor(1.0)
		M31G A 0 A_Takeinventory("Zoomed",1)
		M31G A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		TNT1 A 0 A_giveinventory("M3FiredUntilEmpty", 1)
	NoAmmo2:
		M31G A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
        M31G A 0 A_JumpIfInventory("Reloading",1,"Reload")
		M31G A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		M31G A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOPRIMARY)
		M31G A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
		M31G A 0 A_JumpIfInventory("Ammo45",1,"Reload")
		Goto Ready3
	
    Reload:
		M31G A 1 A_WeaponReady
		M31G A 0 A_ZoomFactor(1.0)
		M31G A 0 A_Takeinventory("Reloading",1)
		M31G A 0 A_Takeinventory("ADSmode",1)
		M31G A 0 A_Takeinventory("Zoomed",1)
		M31G A 0 A_JumpIfInventory("M31Ammo",30,"FinishReload")
        M31G A 0 A_JumpIfInventory("Ammo45",1,3)
        Goto FinishReload
        TNT1 AAA 0
		M31G A 0 A_Takeinventory("Zoomed",1)
		M31G A 0 A_GiveInventory ("Pumping", 1)
		M31G A 0 A_Takeinventory("Reloading",1)
		
		M31R A 0
        M31R ABCDD 1  A_JumpIfInventory("Kicking",1,"DoKick")
		TNT1 A 0 A_PLaySound("RELO1", 3)
		M31R EFGHI 1
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		M31R J 10
        M31R K 1
		TNT1 A 0 A_PLaySound("RELO2", 4)
		M31R LMNO 1
		M31R P 8
		Goto InsertBullets
		
		
	InsertBullets:
		TNT1 AAAA 0
		M31G A 0 A_JumpIfInventory("M31Ammo",30,15)
		M31G A 0 A_JumpIfInventory("Ammo45",1,3)
		Goto FinishReload
        TNT1 AAAAAA 0
		M31G A 0 A_Giveinventory("M31Ammo",1)
		M31G A 0 A_Takeinventory("Ammo45",1)
		Goto InsertBullets
		
		TNT1 AAAAAAAAAA 0
		M31G A 0 A_Takeinventory("Reloading",1)
        Goto FinishReload	
		TNT1 AAAA 0
		M31G A 0 A_Takeinventory("Reloading",1)
        Goto FinishReload
		
	FinishReload:
		M31R BA 1
		M31G A 1
		M31R A 0 A_Takeinventory("HasUnloaded",1)
		TNT1 A 0 A_JumpIfInventory("M3FiredUntilEmpty", 1, "Cook")
		Goto Ready3
	Cook:
		M31R QR 1
		TNT1 A 0 A_PlaySound("weapons/empty", 1)
		M31R STSSS 2
		M31R A 0 A_Takeinventory("M3FiredUntilEmpty",1)
		M31R RQ 1
		Goto Ready3
	}
}

ACTOR M31Ammo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 30
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 30
   Inventory.Icon "WAK4A0"
}