//Weapon: Hand Grenade
//Original By: Froon
//BD Version By: Saegiru
//Sprites By: Pa1nki113r

#include "EXPLODE"


ACTOR J_HandGrenade : Weapon 
{
   Inventory.PickupMessage "you shouldn't see this"
   Scale 0.5
	Weapon.SelectionOrder 99999
	Weapon.AmmoType "J_HandGrenadeAmmo"
   Weapon.AmmoGive 0
   Weapon.AmmoUse 1
	+WEAPON.NO_AUTO_SWITCH
   +WEAPON.NOAUTOAIM
   +NOALERT
   States
   {
   Spawn:
      PGRN D -1
      Loop
   Ready: 
      HNDG A 0 
      HNDG BCD 1
      HNDG E 2 A_PlaySound("weapons/grnpullpin")
      HNDG FGHH 1
      //NULL A 2 
      //NULL A 0 A_Refire
      HNDG I 2 A_PlaySound("weapons/grntoss") 


      
      HNDG J 1 A_FireCustomMissile("J_ThrownGrenade",0,1,7,3,true,3)
      
      HNDG J 0 A_PlaySound("weapons/grntoss")
      HNDG JKLMNOPQ 2
	  TNT1 A 1
  Deselect:
      NULL A 1 A_Lower
      Loop
   Select:
      HNDG A 0 A_Raise
      Loop
   Fire:
      Goto Ready
   }
}


ACTOR J_ThrownGrenadeBase
{
   Radius 2
   Height 4
   Speed 1
   Damage 30
   Scale 0.3
   SeeSound "None"
   PROJECTILE
   +CANBOUNCEWATER
   +FORCEXYBILLBOARD
   -NOGRAVITY
   Gravity 0.750
   +BOUNCEONFLOORS
   +BOUNCEONWALLS
   +BOUNCEONCEILINGS
   -BOUNCEONACTORS
   -ALLOWBOUNCEONACTORS
   +EXTREMEDEATH
   BounceFactor 0.500
   States
   {
   Spawn:
      GRND A 0
	  TNT1 A 0 A_PlaySound("TIMGRN", 5,1,1)
      GRND ABCDEFGABCDEFG 4
	  TNT1 A 0 A_StopSound(5)
	  TNT1 A 0 A_PlaySound("ALRTGRN", 6,1,1)
	  GRND ABCDEFG 4
	  Goto Death
   Death:
      TNT1 A 0 A_StopSound(6)
	  TNT1 A 0 A_SpawnItem ("BigRicoChet", 0, -30)
      NULL A 0 A_PlaySound("Explosion")
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, 150)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, -150)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, -30)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, 30)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, -60)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, 60)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, -90)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, 90)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, -120)
      NULL A 0 A_CustomMissile("FootStep6", 0, 0, 120)
      EXPL AAA 0 A_CustomMissile ("G_BigNeoSmoke", 0, 0, random (0, 360), 2, random (0, 360))
      TNT1 AAAAAAAA 0 A_CustomMissile ("G_ExplosionSmoke", 22, 0, random (0, 360), 2, random (0, 360))
      EXPL A 0 A_Explode
    TNT1 A 0 A_CustomMissile("MuzzleFlashMedium",0,0,0)
      TNT1 AAAAAA 0 A_CustomMissile ("G_ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 180))
      TNT1 AAAAAAAAAAAAAAA 0 A_CustomMissile ("G_ExplosionParticleHeavy", 0, 0, random (0, 180), 2, random (0, 180))
      XXXX A 0 A_CustomMissile ("ExplosionQuake", 1, 0, random (0, 360), 2, random (0, 160))
      TNT1 AAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("G_MediumExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
      EXPL AAA 0 A_CustomMissile ("G_BigNeoSmoke", 0, 0, random (0, 360), 2, random (0, 360))
      Stop
   }
}


ACTOR J_ThrownGrenade : J_ThrownGrenadeBase
{
	Radius 2
	Height 4
	Speed 25
	Damage 1
	Reactiontime 3
	DamageType Explosive
	+MISSILE
	+DONTFALL
	-EXPLODEONWATER
    +CANBOUNCEWATER
	//+USEBOUNCESTATE
	BounceFactor 0.3
	WallBounceFactor 0.2
	BounceType "Doom"
	BounceSound "GBOUNCE"
    -NOTELEPORT
	-TELESTOMP
    -NOLIFTDROP
    +MOVEWITHSECTOR
	-BOUNCEONACTORS
	+ALLOWBOUNCEONACTORS
	Gravity 0.7
	Scale 0.3
	Mass 5
    Decal "Scorch"
	DeathSound ""
	Obituary "%o was popped by %k's grenade"
	States
	{
	Spawn:
	    GRND BCDEFA 3
		GRND A 0 A_Countdown
		Loop
		
	Bounce.Actor.Creature:
		TNT1 A 0 A_ChangeFlag("NOEXTREMEDEATH", 0)
		TNT1 A 0 A_ChangeFlag("ALLOWBOUNCEONACTORS", 0)
		Goto Death

	Death:
	XDeath:
        TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_Fall
		TNT1 A 0 A_ChangeFlag("NOEXTREMEDEATH", 0)
		TNT1 A 0 A_ChangeFlag("ALLOWBOUNCEONACTORS", 0)
		TNT1 A 0 A_ChangeFlag("NOGRAVITY", 0)
		TNT1 A 0 A_ChangeFlag("THRUACTORS", 1)
		GRND C 25
		TNT1 A 0 A_AlertMonsters
		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("G_ExplosionFlareSpawner",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 A 0 A_SpawnItemEx("G_BarrelKaboom",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		TNT1 AAAAAAAAAAAA 0 A_CustomMissile("G_ExplosionFlames", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAAAAAAA 0 A_CustomMissile("G_ExplosionParticleHeavy", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAAAAAAAAAAAAAAA 0 A_CustomMissile("G_ExplosionParticleVeryFast", 0, 0, random (0, 360), 2, random (0, 360))
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("G_ShrapnelParticle", 0, 0, random (0, 360), 2, random (0, 360))
    TNT1 A 0 A_CustomMissile("MuzzleFlashExplosion",0,0,0)
		TNT1 A 0 A_PlaySound("GBANG", 0)
		TNT1 A 0 A_PlaySound("FAREXPL", 0)
		TNT1 AA 0 A_SpawnItem("G_BarrelExplosionSmokeColumn")
		TNT1 A 1 A_Explode(75,200,true)
		TNT1 A 1 A_Explode(65,255,true)
		TNT1 AAAA 8 BRIGHT A_CustomMissile("G_ExplosionSmoke", 1, 0, random (0, 360), 2, random (50, 130))
		Stop
	}
}
