// Ion Blaster

ACTOR IonBlaster : IDMWeapon
{
	Inventory.PickupMessage "Ion Blaster! (Slot 6)"
	Weapon.AmmoType "IDMCell"
	Weapon.AmmoUse 5
	Weapon.AmmoGive 40
	Weapon.Selectionorder 100
	//Weapon.PreferredSkin "IonMarine"
	Tag "Ion Blaster"
	+WEAPON.NOLMS
	States
	{
	Spawn:
      ISPP A -1 Bright
      stop
	Ready:
      ISPG A 1 A_WeaponReady
      Loop
	Deselect:
	  ISPG A 0 A_Lower
      ISPG A 0 A_Lower
      ISPG A 1 A_Lower
      Loop
	Select:
	  TNT1 A 0 A_PlaySound("weapons/wswitch",CHAN_WEAPON)
	Sloop:
      ISPG A 0 A_Raise
      ISPG A 0 A_Raise
      ISPG A 1 A_Raise
      loop
    Fire:
	  TNT1 A 0 A_GunFlash
	  TNT1 A 0 A_Playsound("weapons/ionblasf",CHAN_WEAPON)
	  TNT1 A 0 A_JumpIfInventory("PowerIDMWeaponLevel2",1,"Level2")
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	  ISPG C 3 Bright Offset(0,46) A_FireCustomMissile("IonBall",0,1)
	  ISPG B 3 Bright Offset(0,43)
	  ISPG A 2 Offset(0,40)
	  ISPG A 2 Offset(0,37)
	  ISPG A 2 Offset(0,34)
	  TNT1 A 0 A_Refire
	  Goto Ready
	Quad:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
	  ISPG C 3 Bright Offset(0,44) A_FireCustomMissile("ExtremeIonBall",0,1)
	  Goto Fire+5
	Level2:
	  TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"QuadLevel2")
	  ISPG C 3 Bright Offset(0,46) A_FireCustomMissile("IonBall2",0,1)
	  Goto Fire+5
	QuadLevel2:
	  TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_5)
	  ISPG C 3 Bright Offset(0,44) A_FireCustomMissile("ExtremeIonBall2",0,1)
	  Goto Fire+5
	Flash:
	  TNT1 A 5 A_Light2
	  TNT1 A 4 A_Light1
	  Goto LightDone
	}
}

ACTOR IonBall
{
	Radius 10
	Height 5
	Speed 45
	Damage 20
	Projectile
	+RANDOMIZE
	-NOTELEPORT
	+SKYEXPLODE
	+NOGRAVITY
	ReactionTime 175
	Bouncetype "Doom"
	Bouncecount 4
	BounceFactor 1.0
	WallBounceFactor 1.0
	Alpha 0.9
	Renderstyle Add
	Obituary "%o was evaporated by %k's Ion Blaster."
	SelfObituary "%o ionized %hself with ion splash damage."
	Seesound "weapons/ionblf"
	DeathSound "weapons/ionblx"
	BounceSound "Weapons/ionbnce"
	DamageType "Plasma"
	Decal Plasmascorchlower
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_CountDown
      IONB A 1 Bright A_SpawnItemEx("IonBallTrail")
      Loop
	Death:
	  TNT1 A 0
	  IONB B 1 Bright A_Explode(48,80,1,0,80)
	  IONB B 2 Bright A_Playsound("weapons/ionblx",CHAN_VOICE)
	  IONB CDEFGHIJKL 3 Bright
	  Stop
	}
}

ACTOR IonBallTrail
{
	+NOGRAVITY
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	Alpha 0.75
	Scale 0.75
	Renderstyle Add
	States
	{
	Spawn:
	  TNT1 A 2
	  IONB A 1 Bright
	  IONB A 1 Bright A_SetScale(0.5)
	  IONB A 1 Bright A_SetScale(0.25)
	  Stop
	}
}

ACTOR ExtremeIonBall : IonBall
{
	+EXTREMEDEATH
	States
	{
	XDeath:
		TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
		Goto Death
	}
}

ACTOR IonBall2
{
	Radius 10
	Height 5
	Speed 45
	Damage 20
	Projectile
	+RANDOMIZE
	-NOTELEPORT
	+SKYEXPLODE
	+NOGRAVITY
	Alpha 0.9
	Renderstyle Add
	Obituary "%o was evaporated by %k's Ion Blaster."
	SelfObituary "%o ionized %hself with ion splash damage."
	Seesound "weapons/ionblf2"
	DeathSound "weapons/ionblx"
	BounceSound "Weapons/ionbnce"
	DamageType "Plasma"
	Decal Plasmascorchlower
	States
	{
	Spawn:
	  IOB2 ABCD 1 Bright A_SpawnItemEx("IonBallTrail2")
	  Loop
	Death:
	  TNT1 A 0
	  TNT1 A 0 A_Explode(48,80,1,0,80)
	  TNT1 A 0 A_Playsound("weapons/ionblx",CHAN_VOICE)
	  TNT1 AAAAA 0 A_CustomMissile("IonBall",0,0,random(0,359),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(0,359))
	  IOB2 GFEGH 4 Bright
	  Stop
	}
}

ACTOR IonBallTrail2
{
	+NOGRAVITY
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	Alpha 0.75
	Scale 0.75
	Renderstyle Add
	States
	{
	Spawn:
	  TNT1 A 2
	  TNT1 A 0 A_Jump(192,"Spawn2","Spawn3","Spawn4")
	  IOB2 A 1 Bright
	  IOB2 A 1 Bright A_SetScale(0.5)
	  IOB2 A 1 Bright A_SetScale(0.375)
	  IOB2 A 1 Bright A_SetScale(0.25)
	  IOB2 A 1 Bright A_SetScale(0.125)
	  Stop
	Spawn2:
	  IOB2 B 1 Bright
	  IOB2 B 1 Bright A_SetScale(0.5)
	  IOB2 B 1 Bright A_SetScale(0.375)
	  IOB2 B 1 Bright A_SetScale(0.25)
	  IOB2 B 1 Bright A_SetScale(0.125)
	  Stop
	Spawn3:
	  IOB2 C 1 Bright
	  IOB2 C 1 Bright A_SetScale(0.5)
	  IOB2 C 1 Bright A_SetScale(0.375)
	  IOB2 C 1 Bright A_SetScale(0.25)
	  IOB2 C 1 Bright A_SetScale(0.125)
	  Stop
	Spawn4:
	  IOB2 D 1 Bright
	  IOB2 D 1 Bright A_SetScale(0.5)
	  IOB2 D 1 Bright A_SetScale(0.375)
	  IOB2 D 1 Bright A_SetScale(0.25)
	  IOB2 D 1 Bright A_SetScale(0.125)
	  Stop
	}
}

ACTOR ExtremeIonBall2 : IonBall2
{
	+EXTREMEDEATH
	States
	{
	XDeath:
	  TNT1 A 0 A_Playsound("misc/crit",CHAN_AUTO)
	Death:
	  TNT1 A 0
	  TNT1 A 0 A_Explode(48,80,1,0,80)
	  TNT1 A 0 A_Playsound("weapons/ionblx",CHAN_VOICE)
	  TNT1 AAAAA 0 A_CustomMissile("ExtremeIonBall",0,0,random(0,359),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(0,359))
	  IOB2 GFEGH 4 Bright
	  Stop
	}
}