ACTOR M1911 : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.SelectionOrder 500
	Weapon.AmmoType1 "Ammo45"
	Weapon.AmmoType2 "M1911Ammo"
	Obituary "%o was shot down by %k's assault M1911."
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "$GOTM1911"
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
	+FORCEXYBILLBOARD
	Tag "M1911 Pistol"
	States
	{
	
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_SpawnItemEx("M1911Weapon", 0, 0, 0, momx, momy, momz)
		Stop
	
	Ready:
	Ready3:
		PIST A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		PIST A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
        PIST A 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		"----" # 0 A_JumpIfInventory("UsedBandage", 1, "UseBandages")
		Loop
	
	Deselect:
		PIST AAAAAA 1 A_Lower
		TNT1 A 1 A_Lower
		Wait
		
	Select:
		PIST AAA 1 A_Raise
		TNT1 AAAAAAAAA 0 A_Raise
		Goto Ready3
	
    Fire:
        PIST A 0 A_JumpIfInventory("M1911Ammo",1,2)
        Goto NoAmmo
        TNT1 AA 0
		PIST A 0 A_AlertMonsters
		PIST A 0 A_PlaySound("M19FIRE", 1)
		SMGG A 0 A_PlaySound("FARM16", 6) //play a similar sound that can be heard further
		PIST B 1 A_FireCustomMissile("SmokeSpawner", random(-0.3,0.3), 0, 0, 0, 0, random(-0.3,0.3))
		PIST C 1 BRIGHT A_FireBullets (3.0, 3.0, -1, 30, "HitPuff", FBF_NORANDOM)
		PIST A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
        PIST A 0 A_FireCustomMissile("DecorativeTracer", random(-1,1), 0, 0, -12, 0, random(-1,1))
		PIST A 0 A_ZoomFactor(0.98)
		PIST A 0 A_SetPitch(pitch-1.6)
		PIST A 0 A_Takeinventory("M1911Ammo",1)
		PIST D 1 A_FireCustomMissile("PistolCaseSpawn",5,0,6,-14)
		PIST A 0 A_ZoomFactor(1.0)
		PIST EF 1 A_SetPitch(pitch+0.2)
		PIST A 1 A_WeaponReady
		PIST A 0 A_SetPitch(pitch+0.2)
		PIST A 1 A_WeaponReady
		PIST A 0 A_SetPitch(pitch+0.1)
		PIST A 1 A_WeaponReady
		PIST A 0 A_SetPitch(pitch+0.1)
		PIST A 1 A_WeaponReady
		PIST A 0 A_SetPitch(pitch+0.1)
		TNT1 A 0 A_Refire
		Goto Ready3
	
    Reload:
		PIST A 1 A_WeaponReady
		PIST A 0 A_ZoomFactor(1.0)
		PIST A 0 A_Takeinventory("Reloading",1)
		PIST A 0 A_Takeinventory("ADSmode",1)
		PIST A 0 A_Takeinventory("Zoomed",1)
		PIST A 0 A_JumpIfInventory("M1911Ammo",8,76)
        PIST A 0 A_JumpIfInventory("Ammo45",1,3)
        Goto FinishReloading
        TNT1 AAA 0
		PIST A 0 A_Takeinventory("Zoomed",1)
		PIST A 0 A_GiveInventory ("Pumping", 1)
		PIST A 0 A_Takeinventory("Reloading",1)
		
		PIST A 0
		TNT1 A 0 A_PLaySound("RELO1", 4)
        PISR ABCD 1
		PISR D 10
		PISR EFG 1 
		TNT1 A 0 A_PLaySound("RELO2", 4)
		PISR HIJKL 1
		PISR K 10
		PISR MNOP 1
		TNT1 A 0 A_PLaySound("RELO3", 4)
		PISR Q 5
		PISR RSTU 1
		PIST A 0 A_JumpIfInventory("M1911Ammo",1,"InsertBullets2")
		Goto InsertBullets
		
		
	InsertBullets:
		TNT1 AAAA 0
		PIST A 0 A_JumpIfInventory("M1911Ammo",7,15)
		PIST A 0 A_JumpIfInventory("Ammo45",1,3)
		Goto FinishReload3
        TNT1 AAAAAA 0
		PIST A 0 A_Giveinventory("M1911Ammo",1)
		PIST A 0 A_Giveinventory("DoubleM1911Ammo",1)
		PIST A 0 A_Takeinventory("Ammo45",1)
		Goto InsertBullets
		
		TNT1 AAAAAAAAAA 0
		PIST A 0 A_Takeinventory("Reloading",1)
        Goto FinishReload3	
		TNT1 AAAA 0
		PIST A 0 A_Takeinventory("Reloading",1)
        Goto FinishReload3	
		
	InsertBullets2:
		TNT1 AAAA 0
		PIST A 0 A_JumpIfInventory("M1911Ammo",8,15)
		PIST A 0 A_JumpIfInventory("Ammo45",1,3)
		Goto FinishReload2	
        TNT1 AAAAAA 0
		PIST A 0 A_Giveinventory("M1911Ammo",1)
		PIST A 0 A_Giveinventory("DoubleM1911Ammo",1)
		PIST A 0 A_Takeinventory("Ammo45",1)
		Goto InsertBullets2
		
		TNT1 AAAAAAAAAA 0
		PIST A 0 A_Takeinventory("Reloading",1)
        Goto FinishReload2	
		TNT1 AAAA 0
		PIST A 0 A_Takeinventory("Reloading",1)
        Goto FinishReload2	
		
	FinishReloading:
		PIST A 0
		PIST A 0 A_Refire
		Goto Ready3
		
		

		
	FinishReload2:
		Goto Ready3
		

	FinishReload3:
		Goto Ready3		
		
				
		
	NoAmmo:
		PIST A 0
		PIST A 0 A_ZoomFactor(1.0)
		PIST A 0 A_Takeinventory("Zoomed",1)
		PIST A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
	NoAmmo2:
		PIST A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
        PIST A 0 A_JumpIfInventory("Reloading",1,"Reload")
		PIST A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PIST A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOPRIMARY)
		PIST A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
		PIST A 0 A_JumpIfInventory("Ammo45",1,"Reload")
		Goto Ready3
	}
}

ACTOR M1911Ammo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 8
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 8
   Inventory.Icon "WPISA0"
}