ACTOR InsanePlasmaArray : IDMWeapon
{
  Weapon.SelectionOrder 50
  Weapon.AmmoUse 2
  Weapon.AmmoGive 100
  Weapon.AmmoType "IDMCell"
  //Weapon.PreferredSkin "PlasmaGunMarine"
  Inventory.PickupMessage "Insane Plasma Array! (Slot 6)"
  Tag "Insane Plasma Array"
  +WEAPON.BFG
  +WEAPON.NOLMS
  States
  {
  Spawn:
    IPLU A -1 Bright
	Stop
  Ready:
    IPLG A 1 A_WeaponReady
	Loop
  Deselect:
    TNT1 A 0 A_StopSoundEx(soundslot6)
    IPLG A 1 A_Lower
	Loop
  Select:
	TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
  Sloop:
    IPLG A 1 A_Raise
	Loop
  Fire:
    IPLG A 4 A_PlaysoundEx("weapons/iparevup",soundslot6)
	IPLG D 4
	IPLG AD 3
	IPLG AD 2
  Hold:
    TNT1 A 0 A_PlaysoundEx("weapons/iparevloop",soundslot6,1)
    TNT1 A 0 A_GunFlash
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	TNT1 A 0 A_FireCustomMissile("PhaseBall",frandom(-15,15),0,random(-5,5),0,0,frandom(-5,5))
	TNT1 A 0 A_FireCustomMissile("PlasmaArrayBall",frandom(-15,15),1,random(-5,5),1,0,frandom(-5,5))
	IPLG B 1 Bright
	IPLG C 2 Bright A_JumpIfNoAmmo("FireEnd")
	IPLG B 1 Bright A_Refire("Hold")
	IPLG AADDAADDAADDAADDAADD 1 A_Refire("Hold")
	Goto FireEnd
  Quad:
	TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
	TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	TNT1 A 0 A_FireCustomMissile("PhaseBall",frandom(-15,15),0,random(-5,5),0,0,frandom(-5,5))
	TNT1 A 0 A_FireCustomMissile("PlasmaArrayBall",frandom(-15,15),1,random(-5,5),1,0,frandom(-5,5))
	Goto Hold+6
  Level2:
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
	TNT1 AA 0 A_FireCustomMissile("PlasmaArrayBall",frandom(-15,15),0,random(-5,5),1,0,frandom(-5,5))
	IPLG B 1 Bright A_FireCustomMissile("PlasmaArrayBall",frandom(-15,15),1,random(-5,5),1,0,frandom(-5,5))
	IPLG C 2 Bright A_JumpIfNoAmmo("FireEnd")
	Goto Hold+8
  QuadLevel2:
	TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
	TNT1 AA 0 A_FireCustomMissile("ExtremePlasmaArrayBall",frandom(-15,15),0,random(-5,5),1,0,frandom(-5,5))
	IPLG B 1 Bright A_FireCustomMissile("ExtremePlasmaArrayBall",frandom(-15,15),1,random(-5,5),1,0,frandom(-5,5))
	IPLG C 2 Bright A_JumpIfNoAmmo("FireEnd")
	Goto Hold+8
  FireEnd:
	IPLG D 6 A_PlaysoundEx("weapons/iparevdown",soundslot6)
	IPLG E 6 A_Playsound("weapons/ipacool",CHAN_AUTO)
	IPLG FGDA 6
	TNT1 A 0 A_Refire("Fire")
	Goto Ready
  Flash:
    TNT1 A 3 A_Light2
	TNT1 A 3 A_Light1
	Goto Lightdone
  }
}

ACTOR PhaseBall : PulseBall
{
	Damage (10 * random(1,10))
	+SEEKERMISSILE
	+EXTREMEDEATH
	Alpha 0.8
	Decal Phasescorch
	Obituary "%o was insanely plasmatized by %k's Insane Plasma Array."
	SelfObituary "%o insanely plasmatized %hself."
	States
	{
	Spawn:
		PHBL AB 2 Bright
		TNT1 A 0 A_Jump(128,"SpawnLoop2")
	SpawnLoop:
		TNT1 A 0 A_SeekerMissile(2,10,SMF_LOOK|SMF_PRECISE)
		PHBL AA 1 Bright A_Weave(frandom(3,9),0,frandom(0,3),0)
		TNT1 A 0 A_SeekerMissile(2,10,SMF_LOOK|SMF_PRECISE)
		PHBL BB 1 Bright A_Weave(frandom(3,9),0,frandom(0,3),0)
		Loop
	SpawnLoop2:
		TNT1 A 0 A_SeekerMissile(2,10,SMF_LOOK|SMF_PRECISE)
		PHBL AA 1 Bright A_Weave(frandom(3,9),0,frandom(-3,0),0)
		TNT1 A 0 A_SeekerMissile(2,10,SMF_LOOK|SMF_PRECISE)
		PHBL BB 1 Bright A_Weave(frandom(3,9),0,frandom(-3,0),0)
		Loop
	Death:
		PHBX A 4 Bright A_Explode(random(1,5),64,1,1,64)
		PHBX BCDE 3 Bright
		Stop
	XDeath:
		PHBX A 4 Bright
		PHBX BCDE 3 Bright
		Stop
  }
}

ACTOR ExtremePhaseBall : PhaseBall
{
	States
	{
	XDeath:
		TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
		Goto Death
	}
}

ACTOR PlasmaArrayBall
{
	Radius 10
	Height 5
	Speed 40
	Damage (20*random(1,5))
	Projectile
	+RANDOMIZE
	-NOTELEPORT
	+SKYEXPLODE
	+NOGRAVITY
	+EXTREMEDEATH
	Alpha 0.9
	Renderstyle Add
	Obituary "%o was insanely plasmatized by %k's Insane Plasma Array."
	SelfObituary "%o insanely plasmatized %hself."
	Seesound "weapons/ionblf2"
	DeathSound "weapons/pulsex"
	DamageType "Pulse"
	Decal Plasmascorchlower
	States
	{
	Spawn:
	  IPAP AB 3 Bright
	  Loop
	Death:
	  TNT1 A 0
	  TNT1 A 0 A_Explode(96,80,1,0,80)
	  IPAP EFG 4 Bright A_CustomMissile("PhaseBall",0,0,random(105,255),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-45,45))
	  Stop
	}
}

ACTOR ExtremePlasmaArrayBall : PlasmaArrayBall
{
	States
	{
	XDeath:
		TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
		Goto Death
	}
}