ACTOR GrenadeLauncher : BrutalWeapon
{
	Weapon.AmmoUse 0
	Weapon.AmmoGive1 1
	Weapon.AmmoType1 "AmmoRocket"
	Weapon.AmmoType2 "GLAmmo"
    Inventory.PickupSound "ROCKPKUP"
    +WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+WEAPON.EXPLOSIVE
	Weapon.SelectionOrder 2600
	Inventory.PickupMessage "$GOTGL"
	Tag "Grenade Launcher"
	Scale 0.8
	DropItem "GrenadeLauncherSpawner"
	States
	{

	Ready:
	Ready3:
		GLAN A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		GLAN A 0 A_JumpIfInventory("Unloading", 1, "Unload")
		GLAN A 0 A_JumpIfInventory("Reloading", 1, "Reload")
        GLAN A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLAN A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		GLAN A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        GLAN A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		GLAN A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
		GLAN A 0 A_JumpIfInventory("IsRunning", 1, "StartSprint")
        Goto Ready

	Deselect:
		GLAN A 0
		TNT1 A 0 A_TakeInventory("StartDualWield",1)
        GLSW CBA 1
		TNT1 AAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		Wait

	Select:
		GLAN 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_GiveInventory("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_TakeInventory("SubMachineGunSelected", 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)
		GLAN A 0 A_Takeinventory("HasBarrel",1)
		GLAN A 0 A_GunFlash
		MISG A 1 A_Raise
		TNT1 AAAAAAAAAA 0 A_Raise
		Goto SelectAnimation

	SelectAnimation:
		GLAN A 0
		GLAN A 0 A_PlaySound("RLANDRAW")
        GLSW ABC 1
		Goto Ready

	Fire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("GLAmmo", 1, 2)
		Goto NoAmmo
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("GLAmmo", 1)
		GLAF A 1 BRIGHT
		GLAN A 0 A_SpawnItemEx("PlayerMuzzle2",32,0,28)
		TNT1 AAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-16,16), 0, 0, 0, 0, random(-9,9))
		GLAN A 0 A_PlaySound("weapons/firegrenade")
		GLAN A 0 A_FireCustomMissile("GrenadeMissileBreaksGlass", 0, 0, 0, 0)
		GLAN A 0 A_FireCustomMissile("ShortGrenade", 0, 1, 0, 0)
		RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		RIFG A 0 A_SetPitch(-1.0 + pitch)
		GLAN A 0 A_SetPitch(-1.0 + pitch)
		GLAN A 0 A_Recoil(1)
		TNT1 A 0 A_ZoomFactor(0.98)
        GLAF C 1
		TNT1 A 0 A_ZoomFactor(1.0)

		GLAF CCBBB 1 A_SetPitch(0.2 + pitch)
		GLAN A 5
        Goto NoAmmo2

	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("GLAmmo", 1, 2)
		Goto NoAmmo
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("GLAmmo", 1)
		GLAF A 1 BRIGHT
		GLAN A 0 A_SpawnItemEx("PlayerMuzzle2",32,0,28)
		TNT1 AAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-16,16), 0, 0, 0, 0, random(-9,9))
		GLAN A 0 A_FireCustomMissile("GrenadeMissileBreaksGlass", 0, 0, 0, 0)
		GLAN A 0 A_PlaySound("weapons/firegrenade")
		GLAN A 0 A_FireCustomMissile("GrenadeMissile", 0, 1, 0, 0)
		RIFG A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 2)//tactical mode has muzzle climb
		RIFG A 0 A_SetPitch(-1.0 + pitch)
		GLAN A 0 A_SetPitch(-1.0 + pitch)
		GLAN A 0 A_Recoil(1)
		TNT1 A 0 A_ZoomFactor(0.98)
        GLAF C 1
		TNT1 A 0 A_ZoomFactor(1.0)
		GLAF CCBBB 1 A_SetPitch(0.2 + pitch)
		GLAN A 5
        Goto NoAmmo2

	Reload:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("Reloading", 1)
		TNT1 A 0 A_JumpIfInventory("GLAmmo", 1, "Ready3")
		TNT1 A 0 A_JumpIfInventory("AmmoRocket", 1, 1)
		Goto Ready
		TNT1 AAA 0
		A12G A 0 A_JumpIfInventory("GLUnloaded", 1, "PutMag")
		GLR1 ABCDEFGHIJKLM 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLAN A 0 A_PlaySound("Weapons/GrenadeOpen")
		TNT1 A 0 A_GiveInventory("GLUnloaded", 1)
		GLR1 MMMM 1 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		Goto PutMag+1

	PutMag:
		TNT1 A 0 A_PlaySound("Weapons/GrenadeOpen")
		A12G A 0 A_Takeinventory("Reloading",1)
		A12G A 0 A_Takeinventory("ADSmode",1)
		A12G A 0 A_Takeinventory("Zoomed",1)
		A12G A 0 A_Takeinventory("GLUnloaded",1)
		GLR1 M 4
		GLR1 NOPQRS 1
		TNT1 A 0 A_TakeInventory("AmmoRocket", 1)
		TNT1 A 0 A_GiveInventory("GLAmmo", 1)
		GLAN A 0 A_PlaySound("Weapons/GrenadeLoad")
		GLR1 S 4

		GLR1 TUV 1
		GLR1 V 4
		GLAN A 0 A_PlaySound("Weapons/GrenadeClose")
		GLR1 WXYZ 1
		TNT1 A 0 A_TakeInventory("Reloading", 1)
		TNT1 A 0 A_TakeInventory("GLUnloaded", 1)
		Goto Ready

	Unload:
		TNT1 A 0
		GLAN A 1 A_WeaponReady
		A12G A 0 A_Takeinventory("Unloading",1)
		A12G A 0 A_Takeinventory("ADSmode",1)
		A12G A 0 A_Takeinventory("Zoomed",1)
		A12G A 0 A_ZoomFactor(1.0)
		A12G A 0 A_SetCrosshair(0)
		TNT1 A 0 A_JumpIfInventory("GLAmmo", 1, 2)
		Goto Ready
		TNT1 AAA 0

		GLR1 ZYXWV 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLAN A 0 A_PlaySound("Weapons/GrenadeOpen")
		GLR1 V 8 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLR1 UTSRQPON 1 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		A12R A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		GLR1 N 8
		TNT1 A 0 A_GiveInventory("AmmoRocket", 1)
		TNT1 A 0 A_TakeInventory("GLAmmo", 1)
		TNT1 A 0 A_GiveInventory("GLUnloaded", 1)

		GLAN A 0 A_PlaySound("Weapons/GrenadeClose")
		GLR1 MLKJIHGFEDCBA 1
		TNT1 A 0 A_TakeInventory("Unloading", 1)
		TNT1 A 0 A_GiveInventory("GLUnloaded", 1)
		Goto Ready

	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)
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
	NoAmmo2:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("Reloading", 1)
		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")
		GLAN A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, 2)
		RIFG A 0 A_JumpIfInventory("AmmoRocket",1,"Reload")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"StartSprint")
		Goto Ready3

	StartSprint:
		GLAN 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:
		GLAN S 1 offset(-9,34) A_SetPitch(pitch -0.5)
		GLAN S 1 offset(-6,36) A_SetPitch(pitch -0.5)
		GLAN S 1 offset(-3,38) A_SetPitch(pitch -0.5)
		GLAN S 1 offset(0,38) A_SetPitch(pitch -0.5)
		GLAN S 1 offset(3,36) A_SetPitch(pitch -0.5)
		GLAN S 1 offset(6,34) A_SetPitch(pitch -0.5)
		GLAN S 1 offset(9,32) A_SetPitch(pitch -0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		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")

		GLAN S 1 offset(9,34) A_SetPitch(pitch +0.5)
		GLAN S 1 offset(6,36) A_SetPitch(pitch +0.5)
		GLAN S 1 offset(3,38) A_SetPitch(pitch +0.5)
		GLAN S 1 offset(0,38) A_SetPitch(pitch +0.5)
		GLAN S 1 offset(-3,36) A_SetPitch(pitch +0.5)
		GLAN S 1 offset(-6,34) A_SetPitch(pitch +0.5)
		GLAN S 1 offset(-9,32) A_SetPitch(pitch +0.5)
		TNT1 A 0 A_GiveInventory("UsedStamina", 2)
		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:
		GLAN S 0 A_JumpIfInventory("PowerStrength", 1, 2)
		GLAN A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		GLAN S 1 ACS_NamedExecuteAlways("BDTacticalSpeed", 0, 0, 0, 0)//Makes player slower.
		Goto Ready

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

	Spawn:
		GLAP A -1
		Stop
	}
}

ACTOR GLAmmo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 1
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 1
   Inventory.Icon "GLAPA0"
}