ACTOR HandGrenades : BrutalWeapon
{
	Weapon.AmmoUse1 1
	Weapon.AmmoGive1 1
	Weapon.SelectionOrder 99999
	Weapon.AmmoType1 "GrenadeAmmo"
	Obituary "%o was shreded by %k's grenade."
    AttackSound "None"
    Inventory.PickupSound "AmmoAPIN"
	Inventory.Pickupmessage "You got a Frag Grenade!  (Slot 0)"
	
    +WEAPON.NOAUTOAIM
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
	//+INVENTORY.UNDROPPABLE
    Scale 0.3
	States
	{
	
	Ready:
	Ready3:
	    TNT1 A 0
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 1)
		
		Goto NoGrenades
		GRHO AB 1
		Goto Steady
		
	Steady:
		GRHO C 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        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")
		Loop
	
	NoGrenades:
		TNT1 A 1 A_WeaponReady
		Goto Ready
	
	Deselect:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("FiredGrenade", 1, "DropGrenade")
		TNT1 A 1 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:
		GRWG A 1 A_Raise
		Loop
	Fire:
	    GRTH ABCD 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNPIN")
		GRTH EEFG 1
		
	Hold:
	    TNT1 A 1
		TNT1 A 1 A_Refire
		TNT1 A 0 A_PLaySound ("GRNTOSS")
		GRTH HI 1
		TNT1 A 0 A_FireCustomMissile("HandGrenade", random(-2,2), 1, 0, 0, 0, 0)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRTH JKLM 1
		TNT1 A 3 
		Goto Ready
		
	AltFire:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 1)
		Goto NoGrenades
		TNT1 A 0 A_TakeInventory("GrenadeAmmo", 1)
	    GRTH ABCD 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNPIN")
		GRTH EEFG 1
		
	AltHold:
	    TNT1 A 1
		TNT1 A 1 A_Refire
		TNT1 A 0 A_PLaySound ("GRNTOSS")
		GRTH HI 1
		TNT1 A 0 A_FireCustomMissile("HandGrenadeAlt", 0, 1, 0, 0, 0, 0)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRTH JKLM 1
		TNT1 A 3 
		Goto Ready	
		
 	Spawn:
		GRND H -1
		Stop
		
	CheckSprint:
		GRHO A 1 A_WeaponReady(WRF_NOFIRE)
		GRND F 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		GRND F 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
		Goto Ready
		
	StartSprint:
		GRHO A 1 A_WeaponReady(WRF_NOFIRE)
		GRND F 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
		
	Sprinting:	
		PISP A 0 offset(-9,32) 
		GRND F 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
		GRND F 0 offset(-9,32) A_JumpIfInventory("UsedStamina", 100, "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("PowerStrength", 1, 2)
		GRND F 0 offset(-9,32) A_GiveInventory("UsedStamina", 2)
		GRND F 0 offset(-9,32)
		GRHO A 1 offset(-9,34) A_SetPitch(pitch -0.5)
		GRHO A 1 offset(-6,36) A_SetPitch(pitch -0.5)
		GRHO A 1 offset(-3,38) A_SetPitch(pitch -0.5)
		GRHO A 1 offset(0,38) A_SetPitch(pitch -0.5)
		GRHO A 1 offset(3,36) A_SetPitch(pitch -0.5)
		GRHO A 1 offset(6,34) A_SetPitch(pitch -0.5)
		GRHO 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,"DoKick")
        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)
		GRHO A 1 offset(9,34) A_SetPitch(pitch +0.5)
		GRHO A 1 offset(6,36) A_SetPitch(pitch +0.5)
		GRHO A 1 offset(3,38) A_SetPitch(pitch +0.5)
		GRHO A 1 offset(0,38) A_SetPitch(pitch +0.5)
		GRHO A 1 offset(-3,36) A_SetPitch(pitch +0.5)
		GRHO A 1 offset(-6,34) A_SetPitch(pitch +0.5)
		GRHO 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:
		GRHO A 1
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		GRND F 0 A_PlaySound("Tired", 2)
		GRND F 0 A_TakeInventory("UsedStamina", 2)
		GRND F 5 A_WeaponReady
		GRND F 0 A_TakeInventory("UsedStamina", 2)
		GRND F 5 A_WeaponReady
		GRND F 0 A_TakeInventory("UsedStamina", 2)
		GRND F 5 A_WeaponReady
		GRND F 0 A_TakeInventory("UsedStamina", 2)
		GRND F 5 A_WeaponReady
		GRND F 0 A_TakeInventory("UsedStamina", 2)
		GRND F 5 A_WeaponReady
		Goto Ready
	StopSprint:
		GRHO A 1
		GRND F 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
		PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
		Goto Ready		
	}
}


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
	Species "Marines"
	BounceFactor 0.5
	WallBounceFactor 0.25
    Health 5
    SeeSound "GRNBNCE"
	DeathSound "none"
	Obituary "%o ate %k grenade."
	States
	{
	Spawn:
		GRND ABCDEFGH 2
		TNT1 A 0 A_GiveInventory("GrenadeTime", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeTime", 3, "Explode")
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0 A_AlertMonsters(200)
	    GRND H 16
		TNT1 A 0 A_GiveInventory("GrenadeTime", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeTime", 3, "Explode")
		Loop
		
		
		
	Explode:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("FragGrenadeExplosion")
		TNT1 AA 0
		Stop
	}
}


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 "Shrapnel"
DeathSound "Explosion"
Height 32
States    {
    Spawn:
	TNT1 A 0

		TNT1 A 0 A_Explode(100,500)
		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 ("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 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_PlaySound("FAREXPL", 3)
		TNT1 A 0 A_SpawnItem("BarrelExplosionSmokeColumn")
		TNT1 AAAAA 12 //A_CustomMissile ("ExplosionSmoke", 1, 0, random (0, 360), 2, random (50, 130))
        Stop}}
		
