//DO A BARREL ROLL!!
actor BarrelSpawner : RandomSpawner replaces ExplosiveBarrel
{
    DropItem "BoomyBarrel" 255 1
    DropItem "StuffedBarrel" 255 1
}

ACTOR StuffedBarrel : ExplosiveBarrel
{
	DropItem HealthBonusSpawner 86
	DropItem ArmorBonusSpawner 64

	DropItem ClipSpawner 128
	DropItem ShellSpawner 128
	DropItem RocketAmmoSpawner 128
	DropItem CellSpawner 64

	DropItem MediumHp 48
	DropItem MajorHp 24

	DropItem MP40Pickup 8

	DropItem ChaingunSpawner 18
	DropItem ShotgunSpawner 18

	DropItem GreenArmorSpawner 6
	DropItem BackpackSpawner 6
	DropItem BerserkSpawner 6

	Obituary "%o thought that these barrels don't explode. Well, this one did!"
        DeathSound "barrel/destroy"
        +CANBLAST
   States
   {
   Spawn:
	BARR X -1
	Stop
   Death:
	TNT1 AAAAAAAAAAAAAAA 0 A_SpawnItemEx("BarrelParts",0,0,0,random(2,3),0,random(6,9),random(0,360),160,0) 
	BARR Y 0 A_NoBlocking
	BARR Y 0 A_CustomMissile("BarrelShell",0,0,0,0,2)
	BARR Y 1 A_Scream
	Stop
   }
}

ACTOR BoomyBarrel : ExplosiveBarrel
{
  DeathSound "Weapons/PushkaExp"
  Obituary "%o shouldn't touch that darn thing!"
  +CANBLAST
  States
  {
  Spawn:
    BAR1 AB 6
    Loop
  Death:
    TNT1 A 0 A_Jump(1,"PANTS")
  YeOldeBoom:
    BARR Y 0 A_NoBlocking
    BARR Y 0 A_CustomMissile("BarrelShell",0,0,0,0,2)
    TNT1 AAAAAAAAAAAAAAA 0 A_SpawnItemEx("BarrelParts",0,0,0,random(5,12),0,random(8,15),random(0,360),160,0) 
    TNT1 A 0 A_Explode(100,164)
    TNT1 A 1 A_SpawnItemEx("PushkaExplode",0,0,0,0,0,0,0,128,0)
    TNT1 A 0 A_Explode(100,256,0)
    TNT1 A 0 A_Scream
    TNT1 BCD 6
    Stop
  PANTS:
    TNT1 A 0 A_Jump(2,1)
	Goto YeOldeBoom
    TNT1 A 0 A_SpawnItem("Nuke", 0, 2, 0)
    Stop
  }
}


ACTOR BarrelShell
{
	+NOCLIP
	ReactionTime 400
	+CLIENTSIDEONLY
	States
	{
	Spawn:
      		BARY Y 0
      		BARY Y 0 A_Jump(128,2)
      		BARY Y 1 A_Countdown
			Loop
			BARY Y 1
			Goto Spawn
	Death:
			BARY Y 1 A_FadeOut(0.05)
			Wait
	}
}

ACTOR BarrelParts
{
   Radius 2
   Height 2
   Speed 0
   Damage 0
   Scale 0.3
   +CLIENTSIDEONLY
   ReactionTime 2
   SeeSound ""
   PROJECTILE
   -NOGRAVITY
   +HEXENBOUNCE
   Scale 0.75
   States
   {
   Spawn:
      TNT1 A 0 A_Countdown
      BARF AABBCCDDEE 2
      TNT1 A 0 A_Jump(128,2)
      TNT1 A 0 A_Countdown
      BARF FFGGHHIIJJ 2
      Loop
   Death:
      TNT1 A 1 A_SpawnItemEx("BarrelPartsDrop",0,0,0,0,0,0,128,0,0)
      Stop
   }
}

ACTOR BarrelPartsDrop
{
	+NOCLIP
	+CLIENTSIDEONLY
	Scale 0.75
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SetTranslucent(1,0)
		TNT1 A 0 A_Jump(255,"BARFA","BARFB","BARFC","BARFD","BARFE","BARFF","BARFG","BARFH","BARFI","BARFJ")
	BARFA:
		BARF A 200
		BARF A 1 A_FadeOut(0.01)
		Wait
	BARFB:
		BARF B 200
		BARF B 1 A_FadeOut(0.01)
		Wait
	BARFC:
		BARF C 200
		BARF C 1 A_FadeOut(0.01)
		Wait
	BARFD:
		BARF D 200
		BARF D 1 A_FadeOut(0.01)
		Wait
	BARFE:
		BARF E 200
		BARF E 1 A_FadeOut(0.01)
		Wait
	BARFF:
		BARF F 200
		BARF F 1 A_FadeOut(0.01)
		Wait
	BARFG:
		BARF G 200
		BARF G 1 A_FadeOut(0.01)
		Wait
	BARFH:
		BARF H 200
		BARF H 1 A_FadeOut(0.01)
		Wait
	BARFI:
		BARF I 200
		BARF I 1 A_FadeOut(0.01)
		Wait
	BARFJ:
		BARF J 200
		BARF J 1 A_FadeOut(0.01)
		Wait
	}
}
