actor BarrelSpawner replaces ExplosiveBarrel
{
	+DONTSPLASH
	+NOGRAVITY
	+NOINTERACTION
	States
	{
	Spawn:
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("led_BarrelToggle")==0, 3)
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("led_BarrelToggle")==1, "VanSpawn")
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("led_BarrelToggle")==2, "MixSpawn")
		TNT1 A 0 A_SpawnItem("ModBarrel")
		Goto Death
	MixSpawn:
		TNT1 A 0 A_Jump(64, "VanSpawn", "CrateSpawn")
		Goto Spawn+3
	CrateSpawn:
		TNT1 A 1 A_SpawnItem("SupplyCrate")
		Goto Death
	VanSpawn:
		TNT1 A 1 A_SpawnItem("VanBarrel", 0, 0, 1, 0)
		Goto Death
	Death:
		TNT1 A 1
		Stop
	}
}

actor VanBarrel : ExplosiveBarrel
{
	DeathSound "weapons/rocklx"
	+RANDOMIZE
	States
	{
	Spawn:
		BAR1 AB 6
		Loop
  }
}

actor ModBarrel : ExplosiveBarrel
{
	DamageFactor "Melee", 0.0
	DamageFactor "FistFace", 0.0
	PainChance 256
	DeathSound "weapons/launcher/hit"
	+PUSHABLE
	+DONTGIB
	+BRIGHT
	+BOUNCEONWALLS
	+QUICKTORETALIATE
	+RANDOMIZE
	States
	{
	Pain:
		TNT1 AAAAAAAAAA 0 A_SpawnItemEx("BulletArmorSpark",0,0,32,frandom(-2.0,2.0),frandom(-2.0,2.0),frandom(3.0,6.0),frandom(0.0,359.9),SXF_NOCHECKPOSITION)
		TNT1 A 0 A_PlaySound("player/armorhit")
		Goto Spawn
	Death:
		BEXL ABC 1 Bright
		TNT1 A 0 A_Scream
		TNT1 A 0 Radius_Quake(2, 8, 0, 6, 0)
		BEXL EFG 1 Bright
		BEXL HIJ 1 Bright
		TNT1 A 0 A_Explode
		TNT1 A 0 A_PlaySound("rocket/distexp",6,0.5,0,ATTN_NONE)
		BEXL KLMNO 1 Bright A_FadeOut(0.15)
		BEXL P 5 Bright 
		BEXL Q 5 Bright
		TNT1 A 0 A_BarrelDestroy
		Stop
   }
}

ACTOR SupplyCrate
{
   +SOLID
   +SHOOTABLE
   +NOBLOOD
   Health 10
   Radius 10
   Height 32
   DeathSound "misc/crateopen"
   DropItem "HealthBonus" 256 100
   DropItem "ArmorBonus" 256 100
   DropItem "Clip" 192 100
   DropItem "RocketAmmo" 128 5
   DropItem "ShellSpawner" 64 4
   DropItem "LightArmor" 64 1
   DropItem "Cell" 64 2
   DropItem "MiniStim" 32 2
   DropItem "StimPack" 16 2
   DropItem "Medikit" 4 2
   States
   {
   Spawn:
      WBAR A -1
      Stop
   Death:
      WBAR B 2 A_ScreamAndUnblock
      TNT1 AAA 0 A_SpawnItemEx("CrateDustSmoke", random(1, 3), random(1, 3), random(1, 3), frandom(1.0, 2.0), frandom(1.0, 2.0), frandom(1.0, 2.0), random(0, 359), 128)
      WBAR C 2
      TNT1 AAA 0 A_SpawnItemEx("CrateDustSmoke", random(1, 3), random(1, 3), random(1, 3), frandom(1.0, 2.0), frandom(1.0, 2.0), frandom(1.0, 2.0), random(0, 359), 128)
      WBAR D 2
      WBAR EF 2
      WBAR G -1
      Stop
    }
}

ACTOR CrateDustSmoke
{
   PROJECTILE
   +NOCLIP
   +FORCEXYBILLBOARD

   Radius 1
   Height 1
   Damage 0
   Scale 0.5
   VSpeed 4
   Renderstyle Translucent
   Alpha 0.5

   States
   {
   Spawn:
   Death:
      SMKE ABCDDEEFFFGGGGHHHH 1 A_FadeOut(0.05)
      Stop
   }
}