ACTOR GrenadeLauncher : BrutalWeapon
{
	Weapon.AmmoUse 0
	Weapon.AmmoGive1 0
	Weapon.AmmoType1 "AmmoGL"
	Weapon.AmmoType2 "AmmoGLShell"
    Inventory.PickupSound "ROCKPKUP"
    +WEAPON.NOAUTOAIM
	Weapon.SelectionOrder 8500
	Inventory.PickupMessage "M79 Thumper"
	//+WEAPON.CHEATNOTWEAPON
	States
	{
	
	Ready:
	Ready3:
        GLAN A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLAN A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		"----" # 0 A_JumpIfInventory("UsedBandage", 1, "UseBandages")
		GLAN A 1 A_WeaponReady
        Goto Ready
	Deselect:
		GLAN A 0
        GLSW CBA 1
		TNT1 AAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait
	Select:
		GLAN A 0 A_Giveinventory("GoSpecial",1)
		GLAN A 0 A_Takeinventory("FistsSelected",1)
		GLAN A 0 A_Takeinventory("SawSelected",1)
		GLAN A 0 A_Takeinventory("ShotgunSelected",1)
		GLAN A 0 A_Takeinventory("SSGSelected",1)
		GLAN A 0 A_Takeinventory("MinigunSelected",1)
		GLAN A 0 A_Takeinventory("PlasmaGunSelected",1)
		//GLAN A 0 A_Giveinventory("RocketLauncherSelected",1)
		GLAN A 0 A_Takeinventory("RocketLauncherSelected",1)
		GLAN A 0 A_Giveinventory("GrenadeLauncherSelected",1)
		GLAN A 0 A_Takeinventory("BFGSelected",1)
		GLAN A 0 A_Takeinventory("BFG10kSelected",1)
		GLAN A 0 A_Takeinventory("RailGunSelected",1)
		GLAN A 0 A_Takeinventory("SubMachineGunSelected",1)
		GLAN A 0 A_Takeinventory("RevenantLauncherSelected",1)
		GLAN A 0 A_Takeinventory("LostSoulSelected",1)
		GLAN A 0 A_Takeinventory("FlameCannonSelected",1)
		GLAN A 0 A_Takeinventory("HasBarrel",1)
	
		MISG A 1 A_Raise
		TNT1 AAAAAAAAAA 0 A_Raise
		Goto SelectAnimation
		
	SelectAnimation:
		GLAN A 0
		GLAN A 0 A_PlaySound("RLANDRAW")
		GLAN A 0 A_GunFlash
        GLSW ABC 1
		Goto Ready
		
	Fire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("GLFireShell", 1, "FireShell")

		TNT1 A 0 A_JumpIfInventory("AmmoGL", 1, 2)
		Goto NoAmmo
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("AmmoGL", 1)
		GLAN A 0 A_FireCustomMissile("ShortGrenade", 0, 1, 0, 0, 0, 0)
		GLAN A 0 A_FireCustomMissile("RedFlareSpawn",-5,0,0,0)
		TNT1 AAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-16,16), 0, -1, random(-9,9))
		GLAN A 0 A_PlaySound("weapons/firegrenade")
		GLAN A 0 A_ZoomFactor(0.9)
		GLAN A 0 A_Recoil(8)
		GLAF A 1 BRIGHT 
        GLAF C 1
		GLAN A 0 A_ZoomFactor(1.0)
		GLAN A 0 A_SetPitch(-8.0 + pitch)
		GLAF CCBBB 1 A_SetPitch(1.0 + pitch)
		GLAN A 5 A_SetPitch(1.0 + pitch)
        Goto NoAmmo

	FireSHell:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("AmmoGLShell", 1, 2)
		Goto NoAmmo2
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("AmmoGLShell", 1)
		GLAN A 0 A_FireCustomMissile("RedFlareSpawn",-5,0,0,0)
		SHTA A 0 A_FireBullets (12.0, 5.0, 20, 18, "ShotgunPuff", FBF_NORANDOM)
		SHTA A 0 A_FireBullets (4.0, 2.0, 7, 18, "ShotgunPuff", FBF_NORANDOM)
		TNT1 AAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-16,16), 0, -1, random(-9,9))
		SHTN A 0 A_PlaySound("weapons/sg", 1)
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, 0, 0, random(-1,1))
		GLAN A 0 A_ZoomFactor(0.9)
		GLAN A 0 A_Recoil(8)
		GLAF A 1 BRIGHT 
        GLAF C 1
		GLAN A 0 A_ZoomFactor(1.0)
		GLAN A 0 A_SetPitch(-8.0 + pitch)
		GLAF CCBBB 1 A_SetPitch(1.0 + pitch)
		GLAN A 5 A_SetPitch(1.0 + pitch)
        Goto NoAmmo2
		

	Reloads:	
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("Reloading", 1)
		GLR1 ABCDEFGHIJKL 1
		GLAN A 0 A_PlaySound("Weapons/GrenadeOpen")
		GLR1 MMM 1 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		GLR1 NNNN 1 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		GLR1 OPQQRRSS 1
		GLAN A 0 A_PlaySound("Weapons/GrenadeLoad")
		GLR1 T 1
		GLR1 UVWX 1
		GLAN A 0 A_PlaySound("Weapons/GrenadeClose")
		GLR1 YZ 1
		GLAN A 1
		Goto Ready

	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIFInventory("GLFireShell", 1, "StopAlt")
		TNT1 A 0 A_JumpIFInventory("AmmoGLShell", 1, 1)
		Goto CantSwitch
		TNT1 A 0 A_GiveInventory("GLFireShell", 1)
		TNT1 A 0 A_Print("Switched to 00 Buck")
		Goto Reloads
		
	StopAlt:
		GLAN A 1
		TNT1 A 0 A_JumpIFInventory("AmmoGL", 1, 1)
		Goto CantSwitch
		TNT1 A 0 A_TakeInventory("GLFireShell", 1)
		TNT1 A 0 A_Print("Switched to 40mm High-Explosive")
		Goto Reloads

	CantSwitch:
		GLAN A 3
		TNT1 A 0 A_Print("You don`t have alt ammo.")
		Goto Ready3

	NoAmmo:
		RIFG A 0
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLAN A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reloads")
		RIFG A 0 A_JumpIfInventory("AmmoGL",1,"Reloads")
		Goto Ready3	
	
	NoAmmo2:
		RIFG A 0
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLAN A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reloads")
		RIFG A 0 A_JumpIfInventory("AmmoGLShell",1,"Reloads")
		Goto Ready3	


	Spawn:
		TNT1 A 1
		TNT1 A 0 A_SpawnItemEx("GrenadeLauncherWeapon", 0, 0, 0, momx, momy, momz)
		Stop
		
	}
}


