// Barrel Launcher (A ridiculous commission by Alfredo)

ACTOR BarrelGun : IDMWeapon
{
	Weapon.AmmoType "IDMRocketAmmo"
	Weapon.AmmoUse 1
	Weapon.AmmoGive 15
	Weapon.Selectionorder 50
	//Weapon.PreferredSkin "RocketMarine"
	Inventory.PickupMessage "Barrel Launcher! (Slot 5)"
	Tag "Barrel Launcher"
	Obituary "%o was barrel rolled by %k!"
	SelfObituary "%o did a barrel roll with %p own barrel!"
	+WEAPON.BFG
	+WEAPON.EXPLOSIVE
	+WEAPON.NOLMS
	+WEAPON.NOAUTOAIM
	States
	{
	Spawn:
	  BRLG A -1 Bright
	  Stop
    Ready:
	  BARG A 1 A_WeaponReady
	  Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
    Sloop:
	  BARG A 1 A_Raise
	  Loop
	Deselect:
	  TNT1 A 0 A_ResetReloadCounter
	Desloop:
	  BARG A 1 A_Lower
	  Loop
	Fire:
	  TNT1 A 0 A_Playsound("weapons/grenlf2")
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	FireLoop:
	  TNT1 A 0 A_Playsound("weapons/grenlf2")
	  TNT1 A 0 A_Jump(192,"FireBarrel","IceBarrel","OilBarrel")
	  BARG A 3 Bright Offset(0,55) A_FireCustomMissile("BarrelMissile",random(-10,10),1,random(-6,6),-8,0,5)
	  TNT1 A 0 A_CheckReload
	  TNT1 A 0 A_CheckForReload(5,"FireLoop")
	  TNT1 A 0 A_ResetReloadCounter
	  BARG A 15
	FireEnd:
	  BARG A 2 Offset(0,49)
	  BARG A 2 Offset(0,44)
	  BARG A 2 Offset(0,40)
	  BARG A 2 Offset(0,37)
	  BARG A 2 Offset(0,34)
	  BARG A 2 A_Refire
	  Goto Ready
	FireBarrel:
	  BARG A 3 Bright Offset(0,55) A_FireCustomMissile("FireBarrelMissile",random(-10,10),1,random(-6,6),-8,0,5)
	  Goto Fireloop+3
	IceBarrel:
	  BARG A 3 Bright Offset(0,55) A_FireCustomMissile("IceBarrelMissile",random(-10,10),1,random(-6,6),-8,0,5)
	  Goto Fireloop+3
	OilBarrel:
	  BARG A 3 Bright Offset(0,55) A_FireCustomMissile("OilBarrelMissile",random(-10,10),1,random(-6,6),-8,0,5)
	  Goto Fireloop+3
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	  Goto FireLoop
	Level2:
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
	  TNT1 A 0 A_FireCustomMissile("BigBarrelMissile",0,1)
	  BARG A 3 Bright Offset(0,53) A_TakeInventory("IDMRocketAmmo",2)
	  BARG A 15
	  Goto FireEnd
	QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	  Goto Level2+1
	}
}

ACTOR BarrelMissile
{
	Health 20
	Radius 10
	Height 20
	Mass 10
	Speed 40
	Gravity 0.25
	SeeSound "weapons/grenlf2"
	Deathsound "world/barrelx"
	Damage 200
	Projectile
	ProjectileKickBack 100
	-NOGRAVITY
	-NOTELEPORT
	-NOBLOOD
	-OLDRADIUSDMG
	+SKYEXPLODE
	+ACTIVATEMCROSS
	+DONTGIB
	+NOICEDEATH
	+EXTREMEDEATH
	Obituary "%o was barrel rolled by %k!"
	SelfObituary "%o did a barrel roll with %p own barrel!"
	BloodColor "Green"
	States
	{
	Spawn:
	  BAR1 AB 3 Bright
	  Loop
	Death:
	  BEXP A 5 Bright
      BEXP B 5 Bright //A_Scream
      BEXP CCCCC 1 Bright A_Explode(random(50,150),160,1,0,160)
	  TNT1 A 0 A_SpawnItemEx("BarrelMissileExplosion",random(-32,32),random(-32,32),random(0,20),0,0,4,0,SXF_ABSOLUTEPOSITION|SXF_TRANSFERPOINTERS)
      BEXP DDDDD 1 Bright A_Explode(random(100,300),192,1,0,192)
	  TNT1 A 0 A_SetTranslucent(0.5)
	  TNT1 A 0 A_SpawnItemEx("BarrelMissileExplosion",random(-32,32),random(-32,32),random(0,20),0,0,4,0,SXF_ABSOLUTEPOSITION|SXF_TRANSFERPOINTERS)
      BEXP EEEEE 1 Bright A_Explode(random(25,75),160,1,0,160)
	  TNT1 A 0 A_SpawnItemEx("BarrelMissileExplosion",random(-32,32),random(-32,32),random(0,20),0,0,4,0,SXF_ABSOLUTEPOSITION|SXF_TRANSFERPOINTERS)
      BEXP EEE 1 Bright A_Explode(random(25,75),160,1,0,160)
      Stop
	}
}

ACTOR BarrelMissileExplosion : IDMBarrelExplosion
{
	Obituary "%o was barrel rolled by %k!"
	SelfObituary "%o did a barrel roll with %p own barrel!"
}

ACTOR FireBarrelMissile : BarrelMissile
{
  States
  {
  Spawn:
    BAR2 AB 3 Bright
    Loop
  Death:
  XDeath:
    BEX2 A 5 Bright
    BEX2 B 5 Bright //A_Scream
	BEX2 C 5 Bright
	TNT1 AAAAAAAAAA 0 A_SpawnItemEx("FireBarrelMissileMushroom",0,0,16,random(10,30),0,random(5,25),random(0,359),SXF_TRANSFERPOINTERS)
    BEX2 DDDDD 1 Bright A_SpawnItemEx("FireBarrelMissileMushroom",0,0,16,random(10,30),0,random(5,25),random(0,359),SXF_TRANSFERPOINTERS)
	TNT1 A 0 A_SetTranslucent(0.5)
	BEX2 E 8 Bright
    Stop
  }
}

ACTOR FireBarrelMissileMushroom : IDMFireBarrelMushroom
{
	Obituary "%o was barrel rolled by %k!"
	SelfObituary "%o did a barrel roll with %p own barrel!"
}

ACTOR IceBarrelMissile : BarrelMissile
{
  States
  {
  Spawn:
    BAR3 AB 3 Bright
    Loop
  Death:
  XDeath:
    BEX3 A 5 Bright
    BEX3 B 5 Bright //A_Scream
	BEX3 C 5 Bright
	TNT1 A 0 A_SetTranslucent(0.5)
	TNT1 A 0 A_Playsound("weapons/freezeshot",CHAN_AUTO)
	TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("IDMIceBarrelBall",0,0,16,random(20,40),0,random(-2,5),random(0,359),SXF_TRANSFERPOINTERS)
    BEX3 D 2 Bright
	TNT1 A 0 A_Playsound("weapons/freezeshot",CHAN_AUTO)
	TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("IDMIceBarrelBall",0,0,16,random(20,40),0,random(-2,5),random(0,359),SXF_TRANSFERPOINTERS)
    BEX3 D 3 Bright
	BEX3 E 8 Bright
    Stop
  }
}

ACTOR OilBarrelMissile : BarrelMissile
{
  States
  {
  Spawn:
    BAR4 A 1
    Loop
  Death:
  XDeath:
    BEX4 A 5 Bright
    BEX4 A 5 Bright //A_Scream
	BEX4 B 5 Bright
	TNT1 A 0 A_SetTranslucent(0.5)
	TNT1 AAAAA 0 A_SpawnItemEx("OilBarrelMissilePyroSpawner",0,0,10,15,0,random(5,15),random(0,359),SXF_TRANSFERPOINTERS)
    BEX4 CCCCCDDD 1 Bright A_SpawnItemEx("OilBarrelMissilePyroSpawner",0,0,16,15,0,random(-5,15),random(0,359),SXF_TRANSFERPOINTERS)
	BEX4 D 5 Bright
    Stop
  }
}

ACTOR OilBarrelMissilePyroSpawner : OilPyroSpawner
{
	Obituary "%o was barrel rolled by %k!"
	SelfObituary "%o did a barrel roll with %p own barrel!"
}

ACTOR BigBarrelMissile : BarrelMissile
{
	Scale 5.0
	States
	{
	Death:
      BEXP A 5 Bright
	  BEXP B 5 Bright //A_Playsound("world/barrelx",CHAN_VOICE)
	  TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("BigBarrelMissileExplosion",random(-32,32),random(-32,32),random(10,100),random(10,50),random(10,50),random(-5,25),random(0,359),SXF_ABSOLUTEPOSITION|SXF_TRANSFERPOINTERS)
	  BEXP CCCCCDDDDDEEEEEEEE 1 Bright A_SpawnItemEx("BigBarrelMissileExplosion",random(-32,32),random(-32,32),random(10,100),random(10,50),random(10,50),random(-5,25),random(0,359),SXF_ABSOLUTEPOSITION|SXF_TRANSFERPOINTERS)
      Stop
	}
}

ACTOR BigBarrelMissileExplosion : BarrelMissileExplosion
{
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_Playsound("weapons/rocklx",CHAN_VOICE,1.0)
	TNT1 A 0 A_SetScale(1.75)
	MISL BBBBBBBBCCCCCCDDDD 1 Bright A_Explode(256,256,1,0,192)
	Stop
  }
}

ACTOR BarrelMushroom : IDMMushroom
{
	Obituary "%o was barrel rolled by %k!"
	SelfObituary "%o did a barrel roll with %p own barrel!"
}