// BFG Prototype

ACTOR IDMBFG9000 : IDMWeapon
{
	Height 20
	//Weapon.PreferredSkin "BFGMarine"
	Weapon.SelectionOrder 50
	Weapon.AmmoUse 25
	Weapon.AmmoGive 100
	Weapon.AmmoType "IDMCell"
	+WEAPON.BFG
	+WEAPON.EXPLOSIVE
	+WEAPON.NOAUTOAIM
	+WEAPON.NOLMS
	Inventory.PickupMessage "BFG Prototype! (Slot 7)"
	Tag "BFG Prototype"
	States
	{
	Ready:
      BFGG A 17 A_WeaponReady
	  BFGG B 17 A_WeaponReady
      Loop
	Deselect:
      BFGG A 0 A_StopSound(CHAN_WEAPON)
      BFGG A 1 A_Lower
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
	  BFGG A 1 A_Raise
      Loop
	Fire:
      BFGG A 20 A_BFGSound
      BFGG B 5 Offset(0,35) A_GunFlash
      BFGG B 5 Offset(0,38)
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	  BFGG B 0 A_JumpIfInventory("PowerQuadDamage", 1, "Quad")
	Normal:
      BFGG B 3 Offset(0,40) A_FireCustomMissile("IDMBFGBall",0,1)
      BFGG B 3 Offset(0,38)
      BFGG B 3 Offset(0,35)
	  BFGG B 1 Offset(0,33) A_JumpIfNoAmmo("FireEnd")
	  TNT1 A 0 A_Refire
	  Goto Ready
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO,1)
	  BFGG B 3 Offset(0,40) A_FireCustomMissile("ExtremeBFGBall",0,1)
	  BFGG B 3 Offset(0,38)
	  BFGG B 3 Offset(0,35)
	  BFGG B 1 Offset(0,33) A_JumpIfNoAmmo("FireEnd")
	  TNT1 A 0 A_Refire
	  Goto Ready
	Level2:
	  TNT1 A 0 A_GunFlash("Flash2")
	  BFGG B 0 A_JumpIfInventory("PowerQuadDamage", 1, "QuadLevel2")
      BFGG B 2 A_FireCustomMissile("IDMBFGBall",random(-12,12),1)
      BFGG BBBB 2 A_FireCustomMissile("IDMBFGBall",random(-12,12),0)
	  TNT1 A 0 A_Refire
	  Goto Ready
	QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO,1)
      BFGG B 2 A_FireCustomMissile("ExtremeBFGBall",random(-12,12),1)
      BFGG BBBB 2 A_FireCustomMissile("ExtremeBFGBall",random(-12,12),0)
	  TNT1 A 0 A_Refire
	  Goto Ready
	FireEnd:
      BFGG A 0 A_PlaySound("weapons/bfgcool")
	  BFGG ABABABA 6 Offset(0,33)
	  BFGG B 6 A_Refire
	  BFGG AB 6
	  Goto Ready
	Flash:
      BFGF A 6 Bright A_Light1
      BFGF B 6 Bright A_Light2
	  BFGF C 5 Bright A_Light0
	  Goto LightDone
	Flash2:
      BFGF B 4 Bright A_Light2
	  BFGF C 5 Bright A_Light0
	  Goto LightDone
	Spawn:
      BFUG A -1 Bright
      Stop
	}
}

// BFG Ball & Tracer

ACTOR IDMBFGBall : BFGBall
{
  Radius 13
  Height 8
  Speed 30
  Damage (random(1,100) * random(1,100))
  DamageType "BFG"
  ProjectileKickBack 500
  +RANDOMIZE
  +RIPPER
  +EXTREMEDEATH
  -NOTELEPORT
  +SKYEXPLODE
  RenderStyle Add
  Alpha 1
  SeeSound "weapons/bfgblf"
  DeathSound "weapons/bfgx"
  Obituary "%o was disintegrated by %k's BFG Prototype."
  Decal BFGScorch
  Decal BFGLightning
  States
  {
  Spawn:
    BFS1 AB 2 Bright
    Loop
  Death:
    BFE1 A 8 Bright
	TNT1 A 0 A_Explode(random(10,50)*random(10,50),160,0)
	BFE1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	BFE1 B 8 Bright A_BFGSpray("IDMBFGExtra",40,100)
	BFE1 CDEF 8 Bright
	Stop
  Level2:
	BFE1 BBBB 2 Bright A_BFGSpray("IDMBFGExtra",40,100)
	BFE1 CCCC 2 Bright A_BFGSpray("IDMBFGExtra",40,100)
	BFE1 DDDD 2 Bright A_BFGSpray("IDMBFGExtra",40,100)
	BFE1 EEEE 2 Bright A_BFGSpray("IDMBFGExtra",40,100)
	BFE1 FFFF 2 Bright A_BFGSpray("IDMBFGExtra",40,100)
    Stop
  }
}

ACTOR ExtremeBFGBall : IDMBFGBall
{
	ProjectileKickBack 1000
	States
	{
	XDeath:
		TNT1 A 0
		TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
		Goto Death
	}
}

ACTOR IDMBFGExtra : BFGExtra replaces BFGExtra
{
  +NOBLOCKMAP
  +NOGRAVITY
  +EXTREMEDEATH
  +CLIENTSIDEONLY
  RenderStyle Add
  Alpha 0.75
  DamageType "BFGSplash"
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	Goto End
  Quad:
	TNT1 A 0
	TNT1 A 0 A_PlaySound("misc/crit")
  End:
	BFE2 A 4 Bright A_PlaySound("weapons/bfgtracer")
	BFE2 ABCD 4 Bright
    Stop
  }
}

ACTOR IDMSpamChecker : CustomInventory
{
	+INVENTORY.AUTOACTIVATE
	-INVENTORY.INVBAR
	States
	{
	Pickup:
	  TNT1 A 0 ACS_NamedExecuteAlways("SpamRemover",0)
	  TNT1 A 0 A_JumpIfInventory("IDMSpam",1,"GiveMedal")
	  TNT1 A 0 A_GiveInventory("IDMSpam",1)
	  Stop
	GiveMedal:
	  TNT1 A 0 A_GivePlayerMedal("Spam",0)
	  Stop
	}
}

ACTOR IDMSpam : Inventory
{
	Inventory.MaxAmount 63
}