ACTOR HandGrenades : BrutalWeapon
{
	Weapon.AmmoUse1 1
	Weapon.AmmoGive1 1
	Weapon.SelectionOrder 99999
	Weapon.AmmoType1 "GrenadeAmmo"
	Obituary "%o was shredded by %k's grenade."
    AttackSound "None"
    Inventory.PickupSound "AmmoAPIN"
	Inventory.Pickupmessage "$GOTGRENADE"
    +WEAPON.NOAUTOAIM
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
	tag"High Explosive Handgrenade"
	//+INVENTORY.UNDROPPABLE
    Scale 0.3
	States
	{
	
	Ready:
	SELECTANIMATION:
	TNT1 A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
	    TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 1)		
		Goto NoGrenades
		GRHE ABCD 1
		Goto READY3
		
	READY3:
		GRHE E 1 A_WeaponReadyLit
		GRHE E 0 A_JumpIfInventory("Kicking",1,"dokickgrenade")
		Loop
	
	NoGrenades:
		TNT1 A 1 A_WeaponReadyLit
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"dokickgrenade")
		RIFG A 0 A_selectweapon("proxbomb",SWF_SELECTPRIORITY)
		Goto Ready 
	
	goingtoaction:
		TNT1 A 0 A_PlaySound("weapons/changing")
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 2)		
		TNT1 A 0 A_Jump(255, 5)		
		GRHE DCBA 1
		TNT1 A 0 A_TakeInventory("StartDualWield", 1)
		TNT1 A 0 A_TakeInventory("readythrow", 1)
		TNT1 A 0 A_JumpIfInventory("weargasmask", 1, "wearanimation")
		TNT1 A 0 A_JumpIfInventory("removegasmask", 1, "removeanimation")
		TNT1 A 0 A_JumpIfInventory("battledrugtoken",1,"drugshot")
		TNT1 A 0 A_JumpIfInventory("BANDAGETOKEN",1,"BANDAGE")
		goto repair
	
	Deselect:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("FiredGrenade", 1, "DropGrenade")
		TNT1 A 0 A_Lower
		Wait
	
	DropGrenade:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		TNT1 A 0 A_FireCustomMissile("HandGrenadeDroped", random(-2,2), 1, 0, 0, 0, 0)
		Goto Deselect
		
	Select: 
		TNT1 A 0 A_Overlay(-10,"FirstPersonLegsStand")
		TNT1 A 0 a_removelight(1)
		TNT1 A 0 A_removelight(2)
		TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetRoll(0)
		TNT1 A 0 A_TakeInventory("raredropselected",1)
		GRWG A 0 A_Raise
		Loop
	Fire:
	    GRHE OPQRST 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNTPIN2")
		GRHE UV 1
		TNT1 A 0 A_PLaySound ("BEP")
		GRHE WXYZ 1
		GRH3 AB 1
		
	Hold:
	    GRHE T 0 a_giveinventory("grenadecookingtime",1)
		 GRHE T 0 a_jumpifinventory("grenadecookingtime",18,"AddSecond")
		GRH3 B 1 a_jumpifinventory("grenadetime",4,"Overcook")
		GRH3 B 1 A_Refire

		GRH3 BCD 1
		TNT1 A 0 A_PLaySound ("GRNTOSS2")
	
	///GRENADE TIMER
		GRHE T 0 a_jumpifinventory("grenadetime",3,4)
		GRHE T 0 a_jumpifinventory("grenadetime",2,4)
		GRHE T 0 a_jumpifinventory("grenadetime",1,4)
		GRHE T 0 a_jump(255,4)
				
		TNT1 A 0 A_FireCustomMissile("HandGrenadehalfsec", random(-2,2), 1, 0, 0, 0, 0)
		goto FinishThrow
		TNT1 A 0 A_FireCustomMissile("HandGrenade1sec", random(-2,2), 1, 0, 0, 0, 0)
		goto FinishThrow
		TNT1 A 0 A_FireCustomMissile("HandGrenade1andhalfsec", random(-2,2), 1, 0, 0, 0, 0)
		goto FinishThrow
		TNT1 A 0 A_FireCustomMissile("HandGrenade", random(-2,2), 1, 0, 0, 0, 0)
	////	
		
	FinishThrow:	
		GRHE T 0 a_takeinventory("GrenadeTime",6)
		GRHE T 0 a_takeinventory("grenadecookingtime",35)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRTH PQRSTU 1
		TNT1 A 1 
		Goto Ready
	
	AddSecond:
		GRHE T 0 a_giveinventory("GrenadeTime",1)
		GRHE T 0 a_takeinventory("grenadecookingtime",35)
		GRHE Z 1 A_startSound ("BEP",925, CHANF_OVERLAP)
		GRHE T 0 A_Refire
		goto hold
	
	Overcook:
		TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRHE T 0 a_takeinventory("grenadeAMMO",1)
		GRHE T 0 a_TAKEinventory("GrenadeTime",6)
		GRHE T 0 a_takeinventory("grenadecookingtime",35)
		GRHE T 0 a_spawnitemex("FragGrenadeExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		GRTH RQPOOO 1
		GOTO READY
	
	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 1)
		Goto NoGrenades
		TNT1 A 0 A_TakeInventory("GrenadeAmmo", 1)
	    GRHO CBA 1
		GRHE OPQRST 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNTPIN2")
		
	AltHold:
	    GRHE T 1
		GRHE T 1 A_Refire
		GRHE UV 1
		TNT1 A 0 A_PLaySound ("BEP")
		GRHE WXYZ 1
		GRH3 ABCD 1
		TNT1 A 0 A_PLaySound ("GRNTOSS2")
		TNT1 A 0 A_FireCustomMissile("HandGrenadeAlt", 0, 1, 0, -15, 0, 0)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		THRO ABCDEFGHI 2
		TNT1 A 1
		Goto Ready	
		
 	Spawn:
		GRH3 G -1
		Stop
		
	CheckSprint:
		GRND F 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		GRND F 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		GRHE C 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 70, "Trip")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 1400, "Trip")
		
	Sprinting:	
		PISP A 0 offset(-9,32) 
		GRND F 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 2000, "StopSprintTired")
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		GRND F 0 offset(-9,32) A_JumpIfInventory("Powerstrength2", 1, 2)
		GRND F 0 offset(-9,32) A_GiveInventory("usedstamina", 1)
		GRND F 0 offset(-9,32)
		GRHE C 1 offset(-9,34) A_SetPitch(pitch -0.5)
		GRHE C 1 offset(-6,36) A_SetPitch(pitch -0.5)
		GRHE C 1 offset(-3,38) A_SetPitch(pitch -0.5)
		GRHE C 1 offset(0,38) A_SetPitch(pitch -0.5)
		GRHE C 1 offset(3,36) A_SetPitch(pitch -0.5)
		GRHE C 1 offset(6,34) A_SetPitch(pitch -0.5)
		GRHE C 1 offset(9,32) A_SetPitch(pitch -0.5)
		GRND F 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		GRND F 0 A_JumpIfInventory("Kicking",1,"dokickgrenade")
        GRND F 0 A_JumpIfInventory("Taunting",1,"Taunt")
		GRND F 0 offset(-9,32) A_GiveInventory("UsedStamina", 3)
		GRND F 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		GRHE C 1 offset(9,34) A_SetPitch(pitch +0.5)
		GRHE C 1 offset(6,36) A_SetPitch(pitch +0.5)
		GRHE C 1 offset(3,38) A_SetPitch(pitch +0.5)
		GRHE C 1 offset(0,38) A_SetPitch(pitch +0.5)
		GRHE C 1 offset(-3,36) A_SetPitch(pitch +0.5)
		GRHE C 1 offset(-6,34) A_SetPitch(pitch +0.5)
		GRHE C 1 offset(-9,32) A_SetPitch(pitch +0.5)
		GRND F 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		GRND F 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		
		Goto StopSprint
	StopSprintTired:
		GRHE E 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		GRND F 0 A_PlaySound("Tired", 2)
		GRHE E 25
		Goto Ready
	StopSprint:
		GRHE E 1
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 70, "StopSprintTired")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 1400, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready		
		
	Dokickgrenade:
		TNT1 A 0 A_JumpIfInventory("isdoomguy", 1, 4)
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpifInventory("UsedStamina",95,4)
		TNT1 A 0 A_JumpifInventory("UsedStamina",1995,3)
		TNT1 A 0 A_overlay(3,"kickgrenade")
		TNT1 A 0 a_Jump(256,"Dokick")
		goto Ready3
		TNT1 A 0 A_overlay(3,"kickgrenadetired")
		TNT1 A 0 a_Jump(256,"Dokick")
		goto Ready3	
	kickgrenade:
		TNT1 A 0 A_JumpIfInventory("grenadeammo", 1, 1)
		stop
		GRHE IJK 1
		GRHE L 12 
		GRHE KJI 1 
		TNT1 A 0 A_JumpIfInventory("airkicking", 1, 2)
		TNT1 A 0 A_JumpIfInventory("isSliding", 1, 2)
		stop
		GRHE I 10
		STOP
		GRHE IJKL 1
		TNT1 A 6
		STOP
	kickgrenadetired:
		TNT1 A 0 A_JumpIfInventory("grenadeammo", 1, 1)
		stop
		GRHE IJK 2
		GRHE L 37 
		GRHE KJI 2
		STOP		
	
	}
}


ACTOR HandGrenade
{
	Radius 4
	Height 4
	Projectile
	Speed 30
    Damage (random (2, 2))
    Gravity 0.7
	Scale 0.4
	Projectile
	+MISSILE
    -NOGRAVITY
    -BLOODSPLATTER
	-EXTREMEDEATH
	+EXPLODEONWATER
	+SKYEXPLODE
	+BOUNCEONFLOORS
	+BOUNCEONWALLS
	+BOUNCEONCEILINGS
	-NOTELEPORT
	+THRUSPECIES
	+ROLLSPRITE
	+ROLLCENTER
	Species "Marines"
	BounceCount 3
	BounceFactor 0.5
	WallBounceFactor 0.25
    Health 5
    bouncesound "Weapons/GrenadeBounce"
	DeathSound "none"
	Obituary "%o ate %k grenade."
	States
	{
	Spawn:
		GRH3 EEEEEEEE 2 a_SETROLL(ROLL+45)
		TNT1 A 0 A_GiveInventory("GrenadeTime", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeTime", 4, "Explode")
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0 A_AlertMonsters(200)
	    GRH3 E 16 a_SETROLL(0)
		TNT1 A 0 A_GiveInventory("GrenadeTime", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeTime", 4, "Explode")
		Loop
		
	Explode:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("FragGrenadeExplosion")
		TNT1 AA 0
		Stop
	}
}

Actor HandGrenade1andhalfsec : HandGrenade
{States
	{Spawn:
	TNT1 A 0 nodelay A_GiveInventory("GrenadeTime", 1)
	goto Super::Spawn}}

Actor HandGrenade1sec : HandGrenade
{States
	{Spawn:
	TNT1 A 0 nodelay A_GiveInventory("GrenadeTime", 2)
	goto Super::Spawn}}

Actor HandGrenadehalfsec : HandGrenade
{States
	{Spawn:
	TNT1 A 0 nodelay A_GiveInventory("GrenadeTime", 3)
	goto Super::Spawn}}


Actor FakeGrenade: HandGrenade
{
SeeSound "None"
Damage (random (5, 5))
	States
	{
Spawn:
		TNT1 ABCDEFGH 2
		Loop
	Death:
		TNT1 A 0
		Stop
	}	
}

Actor HandGrenadeDroped: HandGrenade
{
Speed 4
}

Actor HandGrenadeAlt: HandGrenade
{
Speed 8
}

actor FragGrenadeExplosion
{
+NOBLOCKMAP
+MISSILE
+DONTSPLASH
Damagetype "ExplosiveImpact"
Height 32
States    {
    Spawn:
	TNT1 A 0

		TNT1 A 0 A_Explode(320,200,XF_HURTSOURCE,1,40,0,0,"hitpuff","ExplosiveImpact")					 
		TNT1 A 0 A_SpawnItemEx ("ExplosionSplashSpawner", 0, 0, -20)
		TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx ("fireEMBERSBIG",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("UnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		
		TNT1 A 0 A_SpawnItem("TacticalShrapnelSpawner2")
        TNT1 AAAAAAAAAA 0 A_CustomMissile ("BDExplosionparticlesBig", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAA 0 A_CustomMissile ("BDExplosionparticles2", 0, 0, random (0, 360), 2, random (0, 90))
		TNT1 AAAA 0 A_CustomMissile ("SmallExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
	    EXPL A 0 Radius_Quake (2, 24, 0, 15, 0)
		BEXP B 0 BRIGHT A_Scream
        TNT1 A 0 A_ALertMonsters
		TNT1 A 0 A_startSound("weapons/Grenades", 256)
		TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
		TNT1 AAAAA 12 //A_CustomMissile ("ExplosionSmoke", 1, 0, random (0, 360), 2, random (50, 130))
        Stop}}
		
////////////////
///////////////
//////////////

ACTOR ClusterGrenades : BrutalWeapon
{
	Weapon.AmmoUse1 1
	Weapon.AmmoGive1 1
	Weapon.SelectionOrder 99999
	Weapon.AmmoType1 "ClusterAmmo"
	Obituary "%o was shreded by %k's cluster grenade."
    AttackSound "None"
    Inventory.PickupSound "AmmoAPIN"
	Inventory.Pickupmessage "$GOTCLUSTER"
	
    +WEAPON.NOAUTOAIM
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
	//+INVENTORY.UNDROPPABLE
    Scale 0.3
	States
	{
	
	Ready:
	SELECTANIMATION:
	    TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("ClusterAmmo", 1, 1)		
		Goto NoGrenades
		CLU5 ABCDEFGHIJ 1
		Goto READY3
		
	READY3:
		CLU5 K 1 A_WeaponReadyLit
		CLU5 K 0 A_JumpIfInventory("Kicking",1,"dokickcluster")
		Loop
	
	NoGrenades:
		TNT1 A 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_JumpIfInventory("weargasmask", 1, "goingtoaction")
		TNT1 A 0 A_JumpIfInventory("removegasmask", 1, "goingtoaction")
		TNT1 A 0 A_JumpIfInventory("battledrugtoken",1,"goingtoaction")
		TNT1 A 0 A_JumpIfInventory("BANDAGETOKEN",1,"goingtoaction")
		TNT1 A 0 A_Jumpifinventory("throwtoken",1, "Quickthrow")
		TNT1 A 0 A_Jumpifinventory("slashtoken",1, "Quickslash")
		TNT1 A 0 A_JumpIfInventory("flaretoken",1,"TossFlare")
		TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & BT_USER3, "TOSSGRENADE")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"dokickcluster")
        TNT1 A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		TNT1 A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		TNT1 A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
		RIFG A 0 A_selectweapon("handgrenades",SWF_SELECTPRIORITY)
		Goto Ready
	
	goingtoaction:
		TNT1 A 0 A_PlaySound("weapons/changing")
		TNT1 A 0 A_JumpIfInventory("clusterAmmo", 1, 2)		
		TNT1 A 0 A_Jump(255, 5)		
		CLU5 GFEDCBA 1
		TNT1 A 0 A_TakeInventory("StartDualWield", 1)
		TNT1 A 0 A_TakeInventory("readythrow", 1)
		TNT1 A 0 A_JumpIfInventory("weargasmask", 1, "wearanimation")
		TNT1 A 0 A_JumpIfInventory("removegasmask", 1, "removeanimation")
		TNT1 A 0 A_JumpIfInventory("battledrugtoken",1,"drugshot")
		TNT1 A 0 A_JumpIfInventory("BANDAGETOKEN",1,"BANDAGE")
		goto repair
	
	Deselect:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("FiredGrenade", 1, "DropGrenade")
		TNT1 A 0 A_Lower
		Wait
	
	DropGrenade:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		TNT1 A 0 A_FireCustomMissile("CLUSTERDropped", random(-2,2), 1, 0, 0, 0, 0)
		Goto Deselect
		
	Select: 
		TNT1 A 0 A_Overlay(-10,"FirstPersonLegsStand")
		TNT1 A 0 SetPlayerProperty(0,0,2)
		TNT1 A 0 A_SetRoll(0)
		GRWG A 0 A_Raise
		Loop
	Fire:
	    CLUS ABCDEFGHI 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNTPIN2")
		CLUS JKLMNO 1
		TNT1 A 0 A_PLaySound ("BEPBEP")
		CLUS PQR 1
		
	Hold:
		GRHE T 0 a_giveinventory("grenadecookingtime",1)
		GRHE T 0 a_jumpifinventory("grenadecookingtime",18,"AddSecond")
		CLUS S 1 a_jumpifinventory("grenadetime",4,"Overcook")    
		CLUS S 1 A_Refire
		CLUS STUV 1
		GRTH OOOP 1
		TNT1 A 0 A_PLaySound ("GRNTOSS2")
	
		///GRENADE TIMER
		GRHE T 0 a_jumpifinventory("grenadetime",3,4)
		GRHE T 0 a_jumpifinventory("grenadetime",2,4)
		GRHE T 0 a_jumpifinventory("grenadetime",1,4)
		GRHE T 0 a_jump(255,4)
				
		TNT1 A 0 A_FireCustomMissile("CLUSTERGrenadehalfsec", random(-2,2), 1, 0, 0, 0, 0)
		goto FinishThrow
		TNT1 A 0 A_FireCustomMissile("CLUSTERGrenade1sec", random(-2,2), 1, 0, 0, 0, 0)
		goto FinishThrow
		TNT1 A 0 A_FireCustomMissile("CLUSTERGrenade1andhalfsec", random(-2,2), 1, 0, 0, 0, 0)
		goto FinishThrow
		TNT1 A 0 A_FireCustomMissile("CLUSTERGrenade", random(-2,2), 1, 0, 0, 0, 0)
	////	
		
	FinishThrow:	
		GRHE T 0 a_takeinventory("GrenadeTime",6)
		GRHE T 0 a_takeinventory("grenadecookingtime",35)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRTH PQRSTU 1
		TNT1 A 1 
		Goto Ready
	
	AddSecond:
		GRHE T 0 a_giveinventory("GrenadeTime",1)
		GRHE T 0 a_takeinventory("grenadecookingtime",35)
		CLUS R 1 A_startSound ("BEP",925, CHANF_OVERLAP)
		GRHE T 0 A_Refire
		goto hold
	
	Overcook:
		TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRHE T 0 a_takeinventory("CLUSTERAMMO",1)
		GRHE T 0 a_TAKEinventory("GrenadeTime",6)
		GRHE T 0 a_takeinventory("grenadecookingtime",35)
		GRHE T 0 a_spawnitemex("CLUSTERExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		GRTH RQPOOO 1
		GOTO READY
	
	
	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("clusterAmmo", 1, 1)
		Goto NoGrenades
		TNT1 A 0 A_TakeInventory("clusterAmmo", 1)
	    CLUS ABCDEFGH 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNTPIN2")
		
	AltHold:
	    CLUS I 1
		CLUS I 1 A_Refire
		CLUS JKLMNO 1
		TNT1 A 0 A_PLaySound ("BEPBEP")
		CLUS PQRSTUV 1
		GRTH OOO 1
		TNT1 A 0 A_PLaySound ("GRNTOSS2")
		TNT1 A 0 A_FireCustomMissile("ClusterAlt", 0, 1, 0, -15, 0, 0)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		THRO ABCDEFGHI 2
		TNT1 A 1
		Goto Ready	
		
 	Spawn:
		GRND G -1
		Stop
		
	CheckSprint:
		GRND F 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		GRND F 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		TNT1 A 0 A_JUMPIFINVENTORY("CLUSTERAMMO",1, 1)
		GOTO STARTSPRINT
		Goto Ready
		
	StartSprint:
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 70, "Trip")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 1400, "Trip")
		TNT1 A 0 A_JUMPIFINVENTORY("CLUSTERAMMO",1, 1)
		GOTO SPRINTING
		CLUS A 2 A_WeaponReady(WRF_NOFIRE)
		
	Sprinting:	
		PISP A 0 offset(-9,32) 
		GRND F 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 2000, "StopSprintTired")
		PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
		GRND F 0 offset(-9,32) A_JumpIfInventory("Powerstrength2", 1, 2)
		GRND F 0 offset(-9,32) A_GiveInventory("usedstamina", 1)
		GRND F 0 offset(-9,32)
		TNT1 A 1 offset(-9,34) A_SetPitch(pitch -0.5)
		TNT1 A 1 offset(-6,36) A_SetPitch(pitch -0.5)
		TNT1 A 1 offset(-3,38) A_SetPitch(pitch -0.5)
		TNT1 A 1 offset(0,38) A_SetPitch(pitch -0.5)
		TNT1 A 1 offset(3,36) A_SetPitch(pitch -0.5)
		TNT1 A 1 offset(6,34) A_SetPitch(pitch -0.5)
		TNT1 A 1 offset(9,32) A_SetPitch(pitch -0.5)
		GRND F 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
		GRND F 0 A_JumpIfInventory("Kicking",1,"dokickcluster")
        GRND F 0 A_JumpIfInventory("Taunting",1,"Taunt")
		GRND F 0 offset(-9,32) A_GiveInventory("UsedStamina", 3)
		GRND F 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
		TNT1 A 1 offset(9,34) A_SetPitch(pitch +0.5)
		TNT1 A 1 offset(6,36) A_SetPitch(pitch +0.5)
		TNT1 A 1 offset(3,38) A_SetPitch(pitch +0.5)
		TNT1 A 1 offset(0,38) A_SetPitch(pitch +0.5)
		TNT1 A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		TNT1 A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		TNT1 A 1 offset(-9,32) A_SetPitch(pitch +0.5)
		GRND F 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
		GRND F 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
		Goto StopSprint
		
	StopSprintTired:
		GRND F 0 A_PlaySound("Tired", 2)
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		TNT1 A 0 A_JUMPIFINVENTORY("CLUSTERAMMO",1, 1)
		GOTO NOGRENADES
		CLU5 A 25
		Goto Ready
	StopSprint:
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 70, "StopSprintTired")
		TNT1 A 0 A_JumpIfInventory("UsedStamina", 1400, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		TNT1 A 0 A_JUMPIFINVENTORY("CLUSTERAMMO",1, 1)
		GOTO NOGRENADES
		CLU5 A 1
		Goto Ready		
		
	Dokickcluster:
		TNT1 A 0 A_JumpIfInventory("LARGESTAMINA", 1, 2)
		TNT1 A 0 A_JumpifInventory("UsedStamina",95,4)
		TNT1 A 0 A_JumpifInventory("UsedStamina",1995,3)
		TNT1 A 0 A_overlay(3,"kickcluster")
		TNT1 A 0 a_Jump(256,"Dokick")
		goto Ready3
		TNT1 A 0 A_overlay(3,"kickclustertired")
		TNT1 A 0 a_Jump(256,"Dokick")
		goto Ready3	
	kickcluster:
		TNT1 A 0 A_JumpIfInventory("clusterammo", 1, 1)
		stop
		CLU5 EDC 1
		CLU5 B 12 
		CLU5 CDE 1 
		TNT1 A 0 A_JumpIfInventory("AIRKICKING", 1, 2)
		TNT1 A 0 A_JumpIfInventory("isSliding", 1, 2)
		stop
		CLU5 E 10
		STOP
		CLU5 EDCB 1
		TNT1 A 6
		STOP
	kickclustertired:
		TNT1 A 0 A_JumpIfInventory("clusterammo", 1, 1)
		stop
		CLU5 EDC 2
		CLU5 B 37 
		CLU5 CDE 2
		STOP	
	
	}
}


ACTOR ClusterGrenade
{
	Radius 4
	Height 4
	Projectile
	Speed 20
    Damage (random (2, 2))
    Gravity 0.9
	Scale 0.45
	Projectile
	+MISSILE
    -NOGRAVITY
    -BLOODSPLATTER
	-EXTREMEDEATH
	+EXPLODEONWATER
	+SKYEXPLODE
	+BOUNCEONFLOORS
	+BOUNCEONWALLS
	+BOUNCEONCEILINGS
	-NOTELEPORT
	+THRUSPECIES
	+canbouncewater
	Species "Marines"
	BounceFactor 0.6
	WallBounceFactor 0.6
    Health 5
    bounceSound "Weapons/GrenadeBounce"
	DeathSound "none"
	Obituary "%o ate %k cluster grenade."
	States
	{
	Spawn:
		GRND ABCDEFGH 2
		TNT1 A 0 A_GiveInventory("GrenadeTime", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeTime", 4, "Explode")
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0 A_AlertMonsters(200)
	    GRND G 16
		TNT1 A 0 A_GiveInventory("GrenadeTime", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeTime", 4, "Explode")
		Loop
				
	Explode:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("CLUSTERExplosion")
		TNT1 AA 0
		Stop
	}
}

Actor CLUSTERGrenade1andhalfsec : CLUSTERGrenade
{States
	{Spawn:
	TNT1 A 0 nodelay A_GiveInventory("GrenadeTime", 1)
	goto Super::Spawn}}

Actor CLUSTERGrenade1sec : CLUSTERGrenade
{States
	{Spawn:
	TNT1 A 0 nodelay A_GiveInventory("GrenadeTime", 2)
	goto Super::Spawn}}

Actor CLUSTERGrenadehalfsec : CLUSTERGrenade
{States
	{Spawn:
	TNT1 A 0 nodelay A_GiveInventory("GrenadeTime", 3)
	goto Super::Spawn}}

Actor ClusterDropped: ClusterGrenade
{
Speed 4
}

Actor ClusterAlt: ClusterGrenade
{
Speed 8
}

actor ClusterExplosion
{
+NOBLOCKMAP
+MISSILE
+DONTSPLASH
Damagetype "ExplosiveImpact"
DeathSound "Grenades"
Height 32
States    {
    Spawn:
	TNT1 A 0

		TNT1 A 0 A_Explode(80,100,0,1,100,15,10,"hitpuff","Explosive")					 
		TNT1 A 0 A_SpawnItemEx ("ExplosionSplashSpawner", 0, 0, -20)
		TNT1 A 0 A_SpawnItem("TacticalShrapnelSpawner2")
		TNT1 A 0 A_SpawnItemEx ("DetectFloorCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("DetectCeilCrater",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx ("FIREEMBERSBIG",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("UnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		
        TNT1 AAA 0 A_CustomMissile ("BDExplosionparticlesBig", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AA 0 A_CustomMissile ("BDExplosionparticles2", 0, 0, random (0, 360), 2, random (0, 90))
		TNT1 AA 0 A_CustomMissile ("SmallExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
	    EXPL A 0 Radius_Quake (2, 24, 0, 15, 0)
		BEXP B 0 BRIGHT A_Scream
        TNT1 A 0 A_ALertMonsters
		TNT1 A 0 A_startSound("weapons/Grenades", 256)
		TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
		TNT1 AAAAAAAAAAAA 0 A_CustomMissile ("clusterpellet", 1, 0, random (0, 360), 2, random (0, 40))
        Stop}}
		
		
ACTOR ClusterPELLET
{
	Radius 2
	Height 2
	Projectile
	Speed 20
    Damage (random (2, 2))
    Gravity 0.7
	Scale 0.31
	Projectile
	+MISSILE
    -NOGRAVITY
    -BLOODSPLATTER
	-EXTREMEDEATH
	+canbouncewater
	+SKYEXPLODE
	+BOUNCEONFLOORS
	+BOUNCEONWALLS
	+BOUNCEONCEILINGS
	-NOTELEPORT
	+THRUSPECIES
	+canbouncewater
	Species "Marines"
	BounceFactor 0.7
	WallBounceFactor 0.7
    Health 5
    SeeSound "GRNBNCE"
	DeathSound "none"
	Obituary "%o ate %k cluster grenade."
	States
	{
	Spawn:
		CLUS WXYZWXYZ 1
		CLUS WXYZWXYZ 2
		CLUS WXYZWXYZ 3
		CLUS WW 4
		CLUS XX 2
		TNT1 A 0 A_JUMP(120,2)
		CLUS X 3
		TNT1 A 0 A_JUMP(120,2)
		CLUS X 3
		TNT1 A 0 A_JUMP(120,2)
		CLUS X 3
		TNT1 A 0 A_JUMP(120,2)
		CLUS X 3
		TNT1 A 0 A_JUMP(120,2)
		CLUS X 3
		TNT1 A 0 A_JUMP(120,2)
		CLUS X 3
		
	XDEATH:	
	Death:
		TNT1 A 0
		TNT1 A 0 A_AlertMonsters(200)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("PELLETBOOM")
		TNT1 AA 0
		Stop

	}
}

actor PELLETBOOM
{
+NOBLOCKMAP
+MISSILE
+DONTSPLASH
Damagetype "Explosive"
DeathSound "GREXPLO2"
Height 32
States    {
    Spawn:
	TNT1 A 0

		TNT1 A 0 A_Explode(70,100,0,1,100,15,10,"hitpuff","ExplosiveImpact")					 
		TNT1 A 0 A_SpawnItemEx ("ExplosionSplashSpawner", 0, 0, -20)
		TNT1 A 0 A_SpawnItemEx ("DetectFloorCraterSMALL",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("DetectCeilCraterSMALL",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx ("ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	    TNT1 A 0 A_SpawnItemEx ("UnderwaterExplosion",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		
        TNT1 AAA 0 A_CustomMissile ("BDExplosionparticlesBig", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AA 0 A_CustomMissile ("BDExplosionparticles2", 0, 0, random (0, 360), 2, random (0, 90))
		TNT1 AA 0 A_CustomMissile ("SmallExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
	    EXPL A 0 Radius_Quake (2, 24, 0, 15, 0)
		BEXP B 0 BRIGHT A_Scream
        TNT1 A 0 A_ALertMonsters
		TNT1 A 0 A_startSound("GREXPLO2", 280)
		TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
        Stop}}
		
		
ACTOR ClusterGL1 : ClusterGrenade
{
	Speed 40
    Damage (random (40, 40))
	-BOUNCEONFLOORS
	-BOUNCEONWALLS
	-BOUNCEONCEILINGS
	States
	{
	Spawn:
		GBPJ A 1
		Loop
		
	Death:
		TNT1 A 0
		TNT1 A 0 A_AlertMonsters(200)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("CLUSTERExplosion")
		TNT1 AA 0
		Stop
	}
}

ACTOR ClusterGL2 : ClusterGrenade
{
	Speed 40
    Damage (random (40, 40))
}

ACTOR grenadecookingtime : Inventory { Inventory.MaxAmount 35 }