ACTOR GE007GrenadeLauncher : Weapon
{
  Weapon.Kickback 100
  Scale 0.1
      Weapon.Ammotype1 "GrenadeLauncherClip"
   Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
         Weapon.AmmoUse2 1
	Weapon.AmmoGive2 6
	Weapon.AmmoType2 "GE007GrenadeAmmo"
	+WEAPON.AMMO_OPTIONAL
	tag "Grenade Launcher"
  Inventory.PickupMessage "Picked up a Grenade Launcher."
  Obituary  "%k's Grenade Launcher round took %o's leg with it."
  	Inventory.PickupSound "GE007/Weapons/WeaponSFX1"
  States
  {
  Spawn:
    TKA1 F -1
    Loop
  Ready:
  TNT1 A 0 A_PlaySound ("GE007/Weapons/WeaponSFX1","Weapon")
    TK48 A 1 
    TK48 B 1
    TK48 C 1
    TK48 D 1
    TK48 EFGHIJKLMN 1
    TK49 M -1 A_WeaponReady
	goto ReloadCheck
	TK49 M 1 A_WeaponReady
    Goto Ready+6
	
		ReloadCheck:
	 KLBG A 0 A_JumpIfInventory("GrenadeLauncherClip",6,2)
	 KLBG A 0 A_JumpIfInventory("GE007GrenadeAmmo",1,"ReloadStart")
	 KLBG A 0
	 goto Ready+15

  ReloadStart:
	 KLBR A 0 A_PlayWeaponSound("GE007/Weapons/Reload")
     TK48 NMLKJIHGFEDCBA 1
	 TNT1 A 5
	 goto ReloadAmmo

  ReloadAmmo:
	 TNT1 A 0 A_TakeInventory("GE007GrenadeAmmo",1)
	 TNT1 A 0 A_GiveInventory("GrenadeLauncherClip",1)
	 TNT1 A 0 A_JumpIfInventory("GrenadeLauncherClip",6,"ReloadDone")
	 TNT1 A 0 A_JumpIfInventory("GE007GrenadeAmmo",1,"ReloadAmmo")
	 goto ReloadDone
	 
	 ReloadDone:
	 TNT1 A 5
	 TK48 ABCDEFGHIJKLMN 1
	 TK49 M 1
	 goto Ready+15
  Deselect:
    TK48 NMLKJIHGFEDCB 1
    TK48 A 1
    TK08 A 0 A_Lower
    wait
  Select: 
    TK08 A 0 A_Raise 
    Loop  
  Fire: 
    KLBG A 0 A_JumpIfNoAmmo("ReloadCheck")
    TK48 O 1
	TK48 PQ 1
    TK48 R 1
	TK48 S 1
	 	TNT1 A 0 A_PlaySound ("GE007/Weapons/GL","Weapon")
	TK48 T 1 Bright A_FireCustomMissile("GE007Grenade", 0, 1, 1, 9, 0)
	TK48 U 1
	TK48 VXYZ 1
	TK49 ABCDEFGHIJKLM 1
    Goto Ready+15
		AltFire:
		TK04 A 0
		goto ReloadCheck
  }
}

ACTOR GrenadeLauncherClip : Ammo
{
Inventory.MaxAmount 6 // size of the clip
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 6 //MUST be the same as Inventory.MaxAmmount
+INVENTORY.IGNORESKILL
}

actor GE007Grenade
{
  Radius 8
  Height 8
  PROJECTILE
  Speed 25
  Damage 100
  Scale 0.1
  BounceCount 3
  BounceFactor 0.5
  Gravity 0.6
  DamageType Grenade
  +HEXENBOUNCE
  +FORCEXYBILLBOARD
  -NOGRAVITY
    Obituary  "%k's Grenade Launcher round took %o's leg with it."
  States
  {
  Spawn:
	TF01 A 0
	TF01 A 0 Thing_ChangeTID(0, 255)
	TF01 A 0 ThrustThingZ(0, 25, 0, 1)
	TF01 A 0 A_StopSound
	TF01 A 1 A_SpawnItemEx("GE007GrenadeTrail", Random(-2,2), Random(-2,2), Random(-2,2), 0, 0, 0, 0, 128, 0)
	goto Spawn+4
  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("GE007/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 GE007GrenadeTrail
{
  Projectile
  Radius 1
  Height 1
  Damage 0
  Speed 0
  Scale 0.08
  RenderStyle Add
  Alpha 0.6
  +NOCLIP
  +FORCEXYBILLBOARD
  States
  {
   Spawn:
   TNT1 A 0
   TNT1 A 2
   SMOK ABCDEFGHIJKLMNOPQ 1
   stop
  }
}

actor RollingExplosion2
{
  Radius 1
  Height 1
  Speed 0
  Scale 1.25
  Obituary "%k's Grenade Launcher's Rolling Explosion burned %o's corpse away."
  RenderStyle Translucent
  Alpha 0.9
  -SOLID
  +NOGRAVITY
  +NODAMAGETHRUST
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
   FIR2 ABCDEFGH 2 BRIGHT A_Explode(10, 56, 1)
   FIR2 IJKLMN 2 BRIGHT
   stop
  }
}

actor ExplosionSmoke2
{
  Projectile
  Radius 1
  Height 1
  Damage 0
  Speed 0
  Scale 0.6
  RenderStyle Translucent
  Alpha 0.3
  +NOCLIP
  +FORCEXYBILLBOARD
  States
  {
   Spawn:
   SMO2 ABCDEFGHIJKLMNOPQ 10
   stop
  }
}

actor Debris1
{
  Projectile
  Speed 3
  Height 1
  Radius 1
  Gravity 0.2
  RenderStyle Translucent
  Alpha 1.0
  -NOGRAVITY
  -ACTIVATEMCROSS
  -ACTIVATEPCROSS
  -ACTIVATEIMPACT
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
   DEB1 ABCDEFGH 4
   DEB1 A 0 A_CheckFloor("Death")
   loop
  Death:
   TNT1 A 1
   stop
  }
}

actor Debris2
{
  Projectile
  Speed 3
  Height 1
  Radius 1
  Gravity 0.12
  RenderStyle Translucent
  Alpha 1.0
  -NOGRAVITY
  -ACTIVATEMCROSS
  -ACTIVATEPCROSS
  -ACTIVATEIMPACT
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
   DEB2 ABCDEFGH 4
   DEB2 A 0 A_CheckFloor("Death")
   loop
  Death:
   TNT1 A 1
   stop
  }
}

actor Debris3
{
  Projectile
  Speed 3
  Height 1
  Radius 1
  Gravity 0.3
  RenderStyle Translucent
  Alpha 1.0
  -NOGRAVITY
  -ACTIVATEMCROSS
  -ACTIVATEPCROSS
  -ACTIVATEIMPACT
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
   DEB3 ABCDEFGH 4
   DEB3 A 0 A_CheckFloor("Death")
   loop
  Death:
   TNT1 A 1
   stop
  }
}

actor Debris4
{
  Projectile
  Speed 3
  Height 1
  Radius 1
  Gravity 0.1
  RenderStyle Translucent
  Alpha 1.0
  -NOGRAVITY
  -ACTIVATEMCROSS
  -ACTIVATEPCROSS
  -ACTIVATEIMPACT
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
   DEB4 ABCDEFGH 4
   DEB4 A 0 A_CheckFloor("Death")
   loop
  Death:
   TNT1 A 1
   stop
  }
}

actor Debris5
{
  Projectile
  Speed 3
  Height 1
  Radius 1
  Gravity 0.5
  RenderStyle Translucent
  Alpha 1.0
  -NOGRAVITY
  -ACTIVATEMCROSS
  -ACTIVATEPCROSS
  -ACTIVATEIMPACT
  +FORCEXYBILLBOARD
  States
  {
  Spawn:
   DEB5 ABCDEFGH 3
   DEB5 A 0 A_CheckFloor("Death")
   loop
  Death:
   TNT1 A 1
   stop
  }
}

ACTOR GE007GrenadeLauncherPickup : Custominventory
{
   Scale 0.1
  Inventory.PickupMessage "Picked up a Grenade Launcher."
  	Inventory.PickupSound "GE007/Weapons/WeaponSFX1"
   States
   {
   Spawn:
	  TKA5 H -1
	  loop
   Pickup:
	  TNT1 A 0 A_GiveInventory("GE007GrenadeLauncher")
	TNT1 A 0 A_JumpIfInventory("PlayingasSnake",1,"Itsshowtime")
	  stop
	  	Itsshowtime:
	 	TNT1 A 0 A_PlaySound ("SSBB/SolidSnake/Showtime")
		Stop
   }
}
