actor BarrelRocketDamage : ExplosiveBarrel
{
	PROJECTILE
	-SOLID
	-SHOOTABLE
	DamageType "Rocket"
	States
	{
	  Spawn:
	    TNT1 A 0
	    TNT1 A 0 A_Explode
		Stop
	}
}
actor BarrelFireDamage : BarrelRocketDamage
{
	+NODAMAGETHRUST
	DamageType "Fire"
	States
	{
	  Spawn:
	    TNT1 A 0
	    TNT1 A 0 A_Explode(32,64, 1)
		Stop
	}
}
ACTOR Onoes : Inventory
{
    Inventory.Amount 1
    Inventory.MaxAmount 10
}
ACTOR BarrelForcedRespawn : Inventory
{
    Inventory.Amount 1
    Inventory.MaxAmount 1
}

actor BarrelPuff
{
  +NOBLOCKMAP
  +NOGRAVITY
  -ALLOWPARTICLES
  -RANDOMIZE
  +DONTSPLASH
  RenderStyle Translucent
  Alpha 0.5
  VSpeed 0
  Gravity 0.66
  Scale 0.85
  Mass 5
  States
  {
  Spawn:
    PUFF A 1 bright
    //TNT1 A 0 A_Playsound("barrel/pain")
	NULL A 0 A_SpawnItemEx ("ClangSound", 0,0,0, 0,0,0, 0, 160) 
	NULL A 0 A_SpawnItemEx ("PuffEffectSpawner", 0,0,0, 0,0,0, 0, 160) 
	NULL A 0 A_SpawnItemEx("ricochetspawner",0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_CLIENTSIDE,64)
    PUFF A 2 bright
    PUFF B 2 bright
    PUFF CD 2
    stop
  }
}
ACTOR clangsound
{
   Radius 1
   Height 1
   +NOBLOCKMAP
   +NOCLIP
  +DONTSPLASH
   +ALLOWCLIENTSPAWN
   States
   {
   Spawn:
      NULL A 0
      NULL A 1 A_Playsound("barrel/pain")
      Stop
   }
}

ACTOR BarrelExplosion1
{
  -SOLID
  +NOBLOCKMAP
  +NOTELEPORT
  +NOGRAVITY
  +NOCLIP
  +DONTSPLASH
  RENDERSTYLE ADD
  Alpha 0.67//0.8
  XScale 1.8
  YScale 1.4
  States
  {
  Spawn:
    NULL A 0
    XPLO ABCDEEFFGGHHHIIIJJJKKKLLLMMM 1 BRIGHT A_Fadeout(0.02)
    Stop
  }
}

ACTOR BarrelExplosion2 : BarrelExplosion1
{
  -NOGRAVITY
  +LOWGRAVITY
  XScale 0.8
  YScale 1.0
  States
  {
  Spawn:
    NULL A 0
    XPLO ABCDEEFFGGHHIIJJKKLLMM 1 BRIGHT A_Fadeout(0.03)
    Stop
  }
}
ACTOR BarrelExplosion3 : BarrelExplosion1
{
  -NOGRAVITY
  XScale 0.4
  YScale 2.0//0.4
  States
  {
  Spawn:
    NULL A 0
    XPLO ABCDEFGHIJKLM 1 BRIGHT A_Fadeout(0.05)
    Stop
  }
}
ACTOR BarrelEffectSpawner
{
	+NOTELEPORT
  +NOBLOCKMAP
  +NOTELEPORT
  +NOGRAVITY
  +NOCLIP
  +DONTSPLASH
  RENDERSTYLE NONE
  States
  {
  Spawn:
    NULL A 0
	NULL A 0 Radius_Quake (random(1.0,2.5), random(10,20), 0, 8, 0)
   	TNT1 A 0 Thing_ChangeTID (0, 1330) 
	BEXP B 0 bright A_SpawnItemEx("rocketflare", 0,0,random(0,40), 0,0,10, 0, 160)
	BEXP B 0 bright A_SpawnItemEx("rocketflare", 0,0,random(0,40), 0,0,20, 0, 160)
	BEXP B 0 bright A_SpawnItemEx("rocketflare", 0,0,random(0,40), 0,0,30, 0, 160)
      NULL AAA 0 A_custommissile("BarrelSlag",random(0,16),random(-8,8),random(-360,360),2,random(10,70))
      NULL A 0 Bright A_CustomMissile("PowEffect3",random(0,40),random(-4,4),random(-180,180),2,random(45,90))
      NULL A 0 Bright A_CustomMissile("PowEffect4",random(0,40),random(-4,4),random(-180,180),2,random(45,90))
      NULL AA 0 Bright A_CustomMissile("PowEffect5",random(0,40),random(-4,4),random(-180,180),2,random(0,45))
      NULL AA 0 Bright A_CustomMissile("PowEffect6",random(0,40),random(-4,4),random(-180,180),2,random(0,45))
      NULL AAAAA 1 Bright A_CustomMissile("PowEffect",random(0,32),random(-1,1),random(-180,180),2,random(0,90))
      NULL AAAAA 1 Bright A_CustomMissile("PowEffect",random(0,24),0,random(-180,180),2,random(0,35))
      Stop
  }
}
ACTOR BarrelEffectSpawner2 : BarrelEffectSpawner
{
  States
  {
  Spawn:
    NULL A 0
	NULL A 0 Radius_Quake (random(1.0,2.5), random(10,20), 0, 8, 0)
   	TNT1 A 0 Thing_ChangeTID (0, 1330) 
	BEXP BBB 0 bright A_SpawnItemEx("rocketflare", 0,0,random(0,40), random(-15,15),random(-15,15),0, 0, 160)
	BEXP B 0 bright A_SpawnItemEx("rocketflare", 0,0,random(0,40), 0,0,10, 0, 160)
	BEXP B 0 bright A_SpawnItemEx("rocketflare", 0,0,random(0,40), 0,0,20, 0, 160)
      NULL A 0 A_custommissile("BarrelSlag",random(0,16),random(-8,8),random(-360,360),2,random(10,70))
      NULL A 0 Bright A_CustomMissile("PowEffect3",random(0,40),random(-4,4),random(-180,180),2,random(45,90))
      NULL A 0 Bright A_CustomMissile("PowEffect4",random(0,40),random(-4,4),random(-180,180),2,random(45,90))
      NULL A 0 Bright A_CustomMissile("PowEffect5",random(0,40),random(-4,4),random(-180,180),2,random(0,45))
      NULL A 0 Bright A_CustomMissile("PowEffect6",random(0,40),random(-4,4),random(-180,180),2,random(0,45))
      NULL A 1 Bright A_CustomMissile("PowEffect",random(0,32),random(-1,1),random(-180,180),2,random(0,90))
      NULL A 1 Bright A_CustomMissile("PowEffect",random(0,24),0,random(-180,180),2,random(0,35))
      Stop
  }
}


ACTOR SSTExplosiveBarrel : ExplosiveBarrel replaces ExplosiveBarrel
{
  Game Doom
  SpawnID 125
  Health 30
  Radius 10
  Height 34
  +SOLID
  +SHOOTABLE
  -NOBLOOD
  +ACTIVATEMCROSS
  //+DONTGIB
  +NOICEDEATH
  //+OLDRADIUSDMG
  +PUSHABLE
  //+CORPSE
	+NoTeleport
  bloodtype "barrelpuff"
  DeathSound "world/barrelx"
  Obituary "$OB_BARREL" // "%o went boom."
   painchance 255
   bloodcolor "green"
   Painsound "barrel/pain"
  //damagetype "Rocket"
  +FIREDAMAGE
  mass 200//80
  pushfactor 0.6
  States
  {
  Spawn:
    BAR1 A 0
	NULL A 0 A_CheckFloor(1)
	Goto Falling
    BAR1 A 6
	NULL A 0 A_CheckFloor(1)
	Goto Falling
    BAR1 B 6
    Loop
  Falling:
	BAR1 A 1
	NULL A 0 A_CheckFloor("FallEnd")
	BAR1 B 1
	NULL A 0 A_CheckFloor("FallEnd")
	BAR1 A 0
	NULL A 0 A_giveinventory("Onoes",1)
	Loop
  FallEnd:
	BAR1 A 0 A_jumpifinventory("onoes",5,2)
	NULL A 0 A_Takeinventory("Onoes",10)
	Goto Spawn
    PLAY A 0 A_JumpIf(waterlevel > 2, "Nevermind")
	NULL A 0 A_Die
	Goto Death
  Nevermind:
	NULL A 0 A_Takeinventory("Onoes",10)
	Goto Spawn
  Pain:
	BEXP A 0 A_Pain
	BEXP A 0 A_ChangeFlag("Pushable",0)
	BAR1 AB 6
	BEXP A 0 A_ChangeFlag("Pushable",1)
	Goto spawn
  Pain.GreenPaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 0,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.BluePaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 1,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.RedPaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 2,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.OrangePaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 3,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.PurplePaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 4,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.WhitePaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 5,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.YellowPaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 6,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn
  Pain.BlackPaint:
	BEXP A 0 A_Stop
    TNT1 A 0 ACS_ExecuteAlways(926,0, 7,0,0)
    BAR1 A 1 HealThing(100)
	Goto Spawn

  Crush:
  //Crash:
  Death:
	BEXP A 0
	NULL A 0 A_Takeinventory("Onoes",10)
	BEXP A 0 A_Playsound("barrel/pain")
    BEXP A 1 BRIGHT A_Jump(64,1)
    BEXP A 1 BRIGHT A_Jump(64,1)
    BEXP A 1 BRIGHT A_Jump(64,1)
    BEXP A 1 BRIGHT A_Jump(64,1)
    BEXP B 2 BRIGHT A_Scream
    BEXP B 2 BRIGHT
	BEXP B 0 bright A_SpawnItemEx("barrelrocketdamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP C 2 BRIGHT //A_Explode
    NULL A 0 A_SpawnItemEx ("BarrelEcho", 0,0,0, 0,0,0, 0, 160)
    BEXP C 0 BRIGHT A_NoBlocking
	NULL A 0 A_SpawnItemEx ("BarrelDebrisSpawner", 0,0,0, 0,0,0, 0, 160)
    BEXP C 0 BRIGHT A_SpawnItemEx ("BarrelExplosion1", 0,0,0, 0,0,random(1,8), 0, 160) 
    BEXP C 0 BRIGHT A_SpawnItemEx ("BarrelExplosion2", 0,0,0, 0,0,random(1,4), 0, 160) 
    BEXP C 0 BRIGHT A_SpawnItemEx ("BarrelExplosion3", 0,0,0, 0,0,0, 0, 160) 
    BEXP C 2 BRIGHT A_SpawnItemEx ("BarrelEffectSpawner", 0,0,2, 0,0,0, 0, 160) 
    BEXP DDDD 1 BRIGHT A_SpawnItemEx("imonfire", random(-5,-5),Random(-5,5),random(8, 32), 0, 0, random(8,22)*0.1, 0, 160,128)
	NULL A 0 A_SpawnItemEx ("BarrelDeathEffectSpawner", 0,0,random(20,24), 0,0,random(1.0,2.0), 0, 160)
	//TNT1 A 0 A_Mushroom("CacolanternFire",8)
    BEXP FFFFFFFF 2 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(8, 24), 0, 0, random(4,16)*0.1, 0, 160,16)
	BEXP B 0 bright A_SpawnItemEx("barrelfiredamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP FFFFFFFF 3 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(8, 16), 0, 0, random(4,16)*0.1, 0, 160,16)
	BEXP B 0 bright A_SpawnItemEx("barrelfiredamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP FFFFFFFF 4 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(0, 8), 0, 0, random(4,16)*0.1, 0, 160,32)
	BEXP B 0 bright A_SpawnItemEx("barrelfiredamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP FFFFFFFF 5 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(0, 8), 0, 0, random(4,16)*0.1, 0, 160,32)
    BEXP FFFFFFFF 6 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(0, 8), 0, 0, random(4,16)*0.1, 0, 160,64)
    BEXP F 1050
	NULL A 0 A_SpawnItemEx ("BarrelFade", 0,0,0, 0,0,0, 0, 160)
	
	BAR1 A 0 A_jumpifinventory("BarrelForcedRespawn",1,"DontDestroy")
    BEXP F 0 A_BarrelDestroy
  DontDestroy:
    BEXP E 5 A_Respawn
    Wait
	
	
	
  Death.Rocket:
	BEXP B 1 BRIGHT A_Scream
	BEXP B 0 bright A_SpawnItemEx("barrelrocketdamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP C 2 BRIGHT //A_Explode
    NULL A 0 A_SpawnItemEx ("BarrelEcho", 0,0,0, 0,0,0, 0, 160)
    BEXP C 0 BRIGHT A_NoBlocking
	NULL A 0 A_SpawnItemEx ("BarrelDebrisSpawner", 0,0,0, 0,0,0, 0, 160)
    BEXP C 0 BRIGHT A_SpawnItemEx ("BarrelExplosion1", 0,0,0, 0,0,random(1,8), 0, 160) 
    BEXP C 0 BRIGHT A_SpawnItemEx ("BarrelExplosion3", 0,0,0, 0,0,0, 0, 160) 
    BEXP C 2 BRIGHT A_SpawnItemEx ("BarrelEffectSpawner2", 0,0,2, 0,0,0, 0, 160) 
    BEXP DDDD 1 BRIGHT A_SpawnItemEx("imonfire", random(-5,-5),Random(-5,5),random(8, 32), 0, 0, random(8,22)*0.1, 0, 160,128)
	NULL A 0 A_SpawnItemEx ("BarrelDeathEffectSpawner", 0,0,random(20,24), 0,0,random(1.0,2.0), 0, 160)
    BEXP FFFFFFFF 2 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(8, 24), 0, 0, random(4,16)*0.1, 0, 160,16)
	BEXP B 0 bright A_SpawnItemEx("barrelfiredamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP FFFFFFFF 3 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(8, 16), 0, 0, random(4,16)*0.1, 0, 160,16)
	BEXP B 0 bright A_SpawnItemEx("barrelfiredamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP FFFFFFFF 4 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(0, 8), 0, 0, random(4,16)*0.1, 0, 160,32)
	BEXP B 0 bright A_SpawnItemEx("barrelfiredamage", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
    BEXP FFFFFFFF 5 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(0, 8), 0, 0, random(4,16)*0.1, 0, 160,32)
    BEXP FFFFFFFF 6 BRIGHT A_SpawnItemEx("imonfire", random(-8,-8),Random(-8,8),random(0, 8), 0, 0, random(4,16)*0.1, 0, 160,64)
    BEXP F 1050
	NULL A 0 A_SpawnItemEx ("BarrelFade", 0,0,0, 0,0,0, 0, 160)
    BEXP F 0 A_BarrelDestroy
    BEXP E 5 A_Respawn
    Wait
  }
}

actor BarrelFade
{
 -NOGRAVITY
 +CLIENTSIDEONLY
 +NOINTERACTION
 States
 {
  Spawn:
  NULL A 0
  BEXP F 1 A_Fadeout(0.01)
  Loop
 }
}
actor BarrelDebrisSpawner
{
 renderstyle NONE
 +NOGRAVITY
 States
 {
  Spawn:
  NULL A 0
  NULL A 0 A_SpawnDebris("barrelchips",1)
  Stop
 }
}

Actor BarrelChips
{
    Radius 1
    Height 1
    Speed  3
    Damage 0
	scale 1.33//0.75
	Gravity 0.88
    Health 5//8
    RenderStyle Normal//Translucent
    Alpha 1.0
    PROJECTILE
    -NOGRAVITY
    +HEXENBOUNCE
    +DONTSPLASH
    -ACTIVATEPCROSS
    -ACTIVATEIMPACT
    +RANDOMIZE
    +CLIENTSIDEONLY
    +PAINLESS
	+FORCEXYBILLBOARD
	bouncefactor 0.5
    States
    {
    Spawn:
    	NULL A 0
   	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    	NULL A 0 A_Jump(128,"Spawn2")
    Spawn1:
    	BAF1 A 350 A_Jump(128,"Spawn1a")
    	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    	BAF1 A 350 A_Jump(128,"Spawn1a")
    	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    Spawn1a:
    	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    	BAF1 A 1 A_Fadeout(0.01)
		loop
    Spawn2:
    	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    	BAF2 A 350 A_Jump(128,"Spawn2a")
    	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    	BAF2 A 350 A_Jump(128,"Spawn2a")
    Spawn2a:
    	TNT1 A 0 Thing_ChangeTID (0, 1330) 
    	BAF2 A 1 A_Fadeout(0.01)
		loop
    }
}  
