// Grenade Rifle (KDiZD)

ACTOR GrenadeRifle : IDMWeapon
{
	Weapon.AmmoType "IDMRocketAmmo"
	Weapon.AmmoGive 3
	Weapon.AmmoUse 1
	Inventory.PickupMessage "Grenade Rifle! (Slot 5)"
	Tag "Grenade Rifle"
	Weapon.SelectionOrder 700
	//Weapon.PreferredSkin "GrenadeRifleMarine"
	+WEAPON.EXPLOSIVE
	+WEAPON.NOAUTOAIM
	+WEAPON.ALLOW_WITH_RESPAWN_INVUL
	+WEAPON.NOLMS
	States
	{
	Spawn:
      GLA2 A -1 Bright
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
      TNT1 A 0 A_Raise
      TNT1 A 0 A_Raise
      GLAG A 1 A_Raise
      Loop
	Deselect:
      TNT1 A 0 A_Lower
      TNT1 A 0 A_Lower
      GLAG A 1 A_Lower
      Loop
	Ready:
      GLAG A 1 A_WeaponReady
      Loop
	Fire:
      TNT1 A 0 A_GunFlash
      TNT1 A 0 A_PlaySound("Weapons/ShannonFire")
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	Normal:
      GLAG B 4 Bright A_FireCustomMissile("GRifleGrenade", 0, 1, 0, 0, 1, 3.0)
      GLAG I 4
      TNT1 A 0 A_CheckReload
      GLAG C 5
      GLAG D 5
      GLAG E 5 A_PlaySound("Weapons/ShannonOpen")
      GLAG FG 4
      GLAG H 5 A_PlaySound("Weapons/ShannonLoad")
      GLAG FE 4
      GLAG D 4 A_PlaySound("Weapons/ShannonClose")
      GLAG A 3
	  TNT1 A 0 A_Refire
      Goto Ready
	Level2:
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
      GLAG B 4 Bright A_FireCustomMissile("ClusterGrenade", 0, 1, 0, 0, 1, 3.5)
      Goto Normal+1
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
      GLAG B 4 Bright A_FireCustomMissile("ExtremeGRifleGrenade", 0, 1, 0, 0, 1, 3.5)
	  Goto Normal+1
	QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
      GLAG B 4 Bright A_FireCustomMissile("ExtremeClusterGrenade", 0, 1, 0, 0, 1, 3.5)
      Goto Normal+1
	Flash:
      TNT1 A 2 A_Light1
      TNT1 A 2 A_Light2
      TNT1 A 2 A_Light0
      Stop
	}
}

ACTOR MortarGrenadeRifle : GrenadeRifle // Grenade Rifle for the Mortar modifier
{
	Weapon.Ammouse 0
	Weapon.AmmoType None
	+WEAPON.NOLMS
	+WEAPON.CHEATNOTWEAPON
	+WEAPON.ALLOW_WITH_RESPAWN_INVUL
	Tag "Grenade Rifle (Mortar)"
	States
	{
	Fire:
      TNT1 A 0 A_GunFlash
      TNT1 A 0 A_PlaySound("Weapons/ShannonFire")
      GLAG B 4 Bright A_FireCustomMissile("MortarGRifleGrenade", 0, 1, 0, 0, 1, 3.0)
      GLAG I 4
      GLAG C 5 A_CheckReload
      GLAG D 5
      GLAG E 5 A_PlaySound("Weapons/ShannonOpen")
      GLAG FG 4
      GLAG H 5 A_PlaySound("Weapons/ShannonLoad")
      GLAG FE 4
      GLAG D 4 A_PlaySound("Weapons/ShannonClose")
      GLAG A 3
	  TNT1 A 0 A_Refire
      Goto Ready
	}
}

// Grenade Rifle's Grenade

ACTOR GRifleGrenade : IDMGrenade
{
	Damage (100 + (20*random(1,10)))
	Radius 6
	Height 4
	Speed 50
	Obituary "%o was splottered by %k's grenade."
	SelfObituary "%o got shrapnel from %p own grenade."
	Bouncetype none
	-GRENADETRAIL
	+ROCKETTRAIL
	States
	{
	Spawn:
      GRND A 1 Bright
	  Loop
	XDeath:
	Death:
	  TNT1 A 0
	  TNT1 A 0 A_ScaleVelocity(0)
	  TNT1 A 0 A_ChangeFlag(NOGRAVITY,true)
	  TNT1 A 0 A_Scream
	  TNT1 A 0 A_SetScale(1.25)
      MISL B 6 Bright A_Explode(128,160)
      MISL C 5 Bright
      MISL D 4 Bright
      Stop
	}
}

ACTOR ExtremeGRifleGrenade : GRifleGrenade
{
	+EXTREMEDEATH
}

ACTOR ClusterGrenade : GRifleGrenade
{
	Radius 20
	States
	{
	Spawn:
	  GRND A 1 Bright A_CustomMissile("GrenadePuff", 3, 0, 0, 1)
	  Loop
	XDeath:
	Death:
	  SGRN A 0 A_ChangeFlag(NOGRAVITY,true)
	  SGRN A 0 A_ScaleVelocity(0)
	  TNT1 AAAAAAAAAA 0 A_CustomMissile("IDMSmallGrenade",8,0,random(-180,180),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(0,45))
	  MISL B 0 A_Scream
      MISL B 6 Bright A_Explode(32,128)
      MISL C 5 Bright
	  MISL D 4 Bright
	  Stop
	}
}

ACTOR GrenadePuff : BulletPuff
{
	+ClientSideOnly
	States
	{
	Spawn:
	  PUFF ABCD 4
      Stop
	}
}

ACTOR ExtremeClusterGrenade : ClusterGrenade
{
	+EXTREMEDEATH
	States
	{
	XDeath:
	Death:
	  SGRN A 0 A_ChangeFlag(NOGRAVITY,true)
	  SGRN A 0 A_ScaleVelocity(0)
	  TNT1 AAAAAAAAAA 0 A_CustomMissile("ExtremeSmallGrenade",8,0,random(-180,180),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(0,45))
	  MISL B 0 A_Scream
      MISL B 6 Bright A_Explode(32,128)
      MISL C 5 Bright
	  MISL D 4 Bright
	  Stop
	}
}

ACTOR IDMSmallGrenade : IDMGrenade
{
	Obituary "%o was splottered by %k's grenade."
	Speed 60
	Seesound none
	BounceFactor 0.9
	WallBounceFactor 0.9
	States
	{
	Spawn:
      SGRN A 63 Bright
	  Goto Death
    }
}

ACTOR ExtremeSmallGrenade : IDMSmallGrenade
{
	+EXTREMEDEATH
}

ACTOR MortarGRifleGrenade : GRifleGrenade
{
	Damage (200 + (40*random(1,10)))
	ProjectileKickBack 300
	+EXTREMEDEATH
	States
	{
	Death:
	  TNT1 A 0
	  TNT1 A 0 A_ScaleVelocity(0)
	  TNT1 A 0 A_ChangeFlag(NOGRAVITY,true)
	  TNT1 A 0 A_Scream
	  TNT1 A 0 A_SetScale(1.25)
      MISL B 6 Bright A_Explode(256,160,1,0,160)
      MISL C 5 Bright
      MISL D 4 Bright
      Stop
	}
}