ACTOR PDGrenade : Weapon
{
  Weapon.Kickback 100
  Scale 0.050
  
  Tag "Grenade"
        Weapon.Ammotype "PDGrenadeAmmo"
    Weapon.AmmoUse 1
  Weapon.AmmoGive 1
  Inventory.PickupMessage "Picked up a Grenade."
  Obituary  "%k drew his Falcon 2 too fast for %o to react."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
  States
  {
  Spawn:
    TKB4 D -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/WeaponDraw","Weapon")
    TL27 A 2 
    TL27 B 2
    TL27 C 2
    TL27 D 2
    TL27 EFGHI 2
    TL27 J -1 A_WeaponReady
    Goto Ready+7
	
  Deselect:
    TL28 GHI 2
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
  TNT1 A 0 A_JumpIfInventory("PlayingasSimulant",1,"FireSimulant")
  TNT1 A 0 A_JumpIfInventory("PlayingasPerfectKirby",1,"FirePerfectKirby")
  TNT1 A 0 A_JumpIfInventory("PlayingasRED",1,"FireRED")
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade1",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	AltFire: 
	TNT1 A 0 A_JumpIfInventory("PlayingasSimulant",1,"AltFireSimulant")
	TNT1 A 0 A_JumpIfInventory("PlayingasPerfectKirby",1,"AltFirePerfectKirby")
	TNT1 A 0 A_JumpIfInventory("PlayingasRED",1,"AltFireRED")
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade2",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	
	  FireSimulant: 
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PD/SimGrenadeThrow","Weapon")
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade1",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	AltFireSimulant: 
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PD/SimGrenadeThrow","Weapon")
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade2",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	
	 FirePerfectKirby: 
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PerfectKirby/PerfectKirbyGrenadeThrowRandom","Weapon")
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade1",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	AltFirePerfectKirby: 
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PerfectKirby/PerfectKirbyGrenadeThrowRandom","Weapon")
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade2",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	
		 FireRED: 
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Player/RED/REDGrenadeThrow","Weapon")
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade1",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	AltFireRED: 
 	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/GrenadePin","Weapon")
    TL27 K 2
	TL27 L 2 
	TL27 M 2
	TL27 NOPQRSTUVXYZ 2
	TNT1 A 0 A_PlaySound ("PerfectDark/Player/RED/REDGrenadeThrow","Weapon")
	TNT1 A 0 A_PlaySound ("PerfectDark/Weapons/Throw","Weapon")
	TL28 ABC 2
	TL28 A 0 A_FireCustomMissile ("PDGrenade2",0,1,0,15,0)
	TL28 DEF 2
	TNT1 A 40
    Goto Ready
	
  }
}

actor PDGrenade1
{
  obituary "%o was shattered by %k's Grenade."
  radius 5
  height 5
  speed 30
  damage 20
  scale 0.2
  seesound "PerfectDark/Weapons/GrenadeHit"
  PROJECTILE
  +DOOMBOUNCE
  -NOGRAVITY
  +FORCEXYBILLBOARD
  states
  {
  Spawn:
    PDGR WXYZ 4 A_CustomMissile ("PDDevastatorGrenadeTrail",0,0,0,0,0)
    loop
  Death:
	MISL B 0 bright A_Explode(64, 128, 1)
	MISL B 0 A_NoGravity
	TNT1 A 0 radius_quake(2, 10, 0, 3, 0)
	TNT1 A 0 A_PlaySoundEx("PerfectDark/Weapons/Boom", "Auto", 0)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris1", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris2", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris3", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris4", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris5", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris1", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris2", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris3", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris4", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris5", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", 0, 0, 0, 0, 0, 0, 0, 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 AAAAAAA 5 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	stop
  }
}

actor PDGrenade2
{
  obituary "%o was shattered by %k's Grenade."
  radius 20
  height 5
  speed 30
  damage 20
  bouncefactor 2.0
  bouncecount 50
  scale 0.2
  seesound "PerfectDark/Weapons/Ricochet"
  PROJECTILE
  +HEXENBOUNCE
  -NOGRAVITY
  +NODAMAGETHRUST 
  +PIERCEARMOR
  +FORCEXYBILLBOARD
  states
  {
  Spawn:
    NULL A 0 A_Recoil (-1)
    PDGR WWXXYYZZ 2 A_CustomMissile ("PDDevastatorGrenadeTrail",0,0,0,0,0)
    loop
  Death:
	MISL B 0 bright A_Explode(64, 128, 1)
	MISL B 0 A_NoGravity
	TNT1 A 0 radius_quake(2, 10, 0, 3, 0)
	TNT1 A 0 A_PlaySoundEx("PerfectDark/Weapons/Boom", "Auto", 0)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris1", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris2", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris3", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris4", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris5", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-5, 5), Random(-5, 5), Random(-6, 7), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris1", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris2", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris3", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris4", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 AAAAAAAAAAAA 0 A_SpawnItemEx("Debris5", Random(-8, 8), Random(-8, 8), Random(-8, 8), Random(-3, 3), Random(-3, 3), Random(1, 6), Random(-360, 360), 128, 24)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", 0, 0, 0, 0, 0, 0, 0, 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 A 0 A_SpawnItemEx ("ExplosionSmoke2", Random(-44, 44), Random(-44, 44), Random(0, 38), 0, 0, 0, 0, 128, 0)
	TNT1 A 3 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	TNT1 AAAAAAA 5 A_SpawnItemEx ("RollingExplosion2", Random(-24, 24), Random(-24, 24), Random(0, 38), 0, 0, 0, Random(-360, 360), 0, 0)
	stop
  }
}

ACTOR PDGrenadePickup : Custominventory
{
   Scale 0.050
  Inventory.PickupMessage "Picked up a Grenade."
  	Inventory.PickupSound "PerfectDark/Items/PickupWeapon"
   States
   {
   Spawn:
	  TKB4 D -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("PDGrenade")
	  TNT1 A 0 A_JumpIfInventory("PlayingasPerfectKirby",1,"PickupPerfectKirby")
	  TNT1 A 0 A_JumpIfInventory("PlayingasRED",1,"PickupRED")
	  stop
	  PickupPerfectKirby:
	 	TNT1 A 0 A_PlaySound ("PerfectDark/Player/PerfectKirby/PerfectKirbyWeaponPickup")
		Stop
	  PickupRED:
	 	TNT1 A 0 A_PlaySound ("PerfectDark/Player/RED/REDWeaponPickup")
		Stop
   }
}
