//Ze barrel, shamelessly stolen and modified from Xaser and Prophet's work. God bless 'em both, and curse me for eternity!

ACTOR XaserBarrel : ExplosiveBarrel replaces ExplosiveBarrel
{
  States
  {
  Spawn:
    BAR1 ABCDEFGHIJKLM 1 A_SpawnItemEx("BarrelParticle",frandom(10.0,-10.0),frandom(10.0,-10.0),26+frandom(2.0,-2.0),frandom(0.4,-0.4),frandom(0.4,-0.4),frandom(2.2,0.4),frandom(0.0,360.0),SXF_CLIENTSIDE,164)
    Loop
  Death:
	BEXP ABC 5 Bright
	TNT1 A 0 A_SpawnItemEx("BarrelExplode",0,0,0,0,0,0,0,SXF_TRANSFERPOINTERS,0)
	TNT1 A 0 A_NoBlocking
	TNT1 A 0 A_SpawnItemEx("BarrelShell",0,0,0,0,0,0,0,SXF_CLIENTSIDE,0)
	TNT1 A 1050 A_BarrelDestroy
    TNT1 A 5 A_Respawn
   	Wait
  }
}
ACTOR BarrelExplode
{
	+NOINTERACTION
	DamageType Patriarch //Because barrels are your best friends
	States
	{
	Spawn:
    TNT1 A 0 NoDelay A_PlaySound("Explosion/Init",5,0.8)
    TNT1 A 0 A_PlaySound("Explosion/Main",6,0.8)
    TNT1 A 0 A_PlaySound("Explosion/Layer",4,0.8)
    TNT1 A 0 A_PlaySound("Explosion/Flavor",7,0.8)
	TNT1 A 0 A_Quake(3,12,0,512,"none")
    TNT1 A 0 A_SpawnItemEx("Patriarch_Main",0,0,0,0,0,0,SXF_CLIENTSIDE,0)
	TNT1 A 28 A_Explode(175,148)
	Stop
	}
}

ACTOR BarrelParticle
{
	+NOINTERACTION
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOTONAUTOMAP
	Renderstyle Add
	Alpha 0.5
	States
	{
	Spawn:
	GPRT A 0
	SetScale:
	"####" "#" 0 A_SetScale(0.05)
	Main:
	"####" "#" 0 A_JumpIf(ScaleX <= 0,"NULL")
	"####" "#" 0 A_FadeOut(frandom(0.015,0.025))
	"####" "#" 0 A_ChangeVelocity(frandom(0.1,-0.1),frandom(0.1,-0.1),frandom(0.1,-0.1),CVF_RELATIVE)
	"####" "#" 1 Bright A_SetScale(ScaleX-frandom(0.0025,0.005))
	Loop
	}
}

ACTOR BarrelShell
{
	+FLOORCLIP
	-NOGRAVITY
	States
	{
	Spawn:
      		BARR Y 0
			"####" "#" 210 A_CheckSight("Fadying")
			Loop
	Fadying:
			"####" "#" 1 A_FadeOut(0.1)
			Wait
	}
}