/*
CREDITS:
This weapon is not made by me in 90%, so it's sounds sources were one great mystery to me... and some of them still do.
Whole thing was made by Woodchuck, my cousin. I only did some small adjustments. :P

Sprites:
Source - Westwood (C&C Renegade)
Rip and animation - Woodchuck
Reload animation - Hellcatx
Pickup - WildWeasel

Sounds:
Up, Down, Clang, Beep2, Beep3 - ID (Doom 3)
Fire, Reload, Trocky pickup, Ion storm, Ion struck, Beep4 (Steam eject) - Westwood (C&C Renegade)
Impact - Raven (Wolfenstein 3)
Boom - A mashup for sure, one must be the EMP discharge from C&C Tiberian Sun... the other part? Dunno.
Hit, Charge1, Charge2, Charge3 - ?
Ready - Monolith (Blood 2)
Charge - ID (Quake 4)
Beep1 - ID (Quake 1)
Mechanism1-Mechanism3 - LucasArts (SW:JKIII)
Void - ?
*/

ACTOR PlanetCracker : Weapon 24526
{
    //$Category Weapons
    //$Title Planet NutCracker
    //$Sprite IONGX0
    Tag "Planet Cracker"
	inventory.pickupsound "misc/w_pkup"
	inventory.PickupMessage "You got the ''Planet Cracker'' ion cannon! You know what they say - all toasters toast... ''You''. (8)"
	obituary "%o was definitely charged up positively by %k's concentrated ion struck."
	Weapon.UpSound "Weapons/PlanetCrackerUp"
	Weapon.SelectionOrder 1
	Weapon.AmmoType "IonAmmo"
	Weapon.AmmoGive 30
	Weapon.AmmoUse 3
	Weapon.AmmoType2 "IonAmmo"
	Weapon.AmmoUse2 15
	Weapon.Kickback 100
	Weapon.SlotNumber 8
	States
	{
   Spawn:
   	IONG X -1
	Stop
   Ready:
   	IONG A 1 A_Weaponready
	Loop
   Deselect:
   	IONG A 0 A_PlaySound("Weapons/PlanetCrackerDown",0)
    IONG A 2 A_Lower
	Goto Deselect+1
   Select:
    IONG A 2 A_Raise
	Loop
   Fire:
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Fire",6)
	IONZ A 0 A_FireCustomMissile("PlanetBeam", 0, 1, 15, 10)
	IONZ A 0 A_Recoil(30)
   	TNT1 A 0 A_Quake(7,25,0,2,0)
   	IONG A 0 A_SetBlend("Blue",0.1,40)
	IONF A 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.985)
	IONF B 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF B 0 A_ZoomFactor(0.965)
	IONF C 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF C 0 A_ZoomFactor(0.92)
	IONF D 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF D 0 A_ZoomFactor(0.85)
	IONF E 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF E 0 A_ZoomFactor(0.8)
	IONF F 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF F 0 A_ZoomFactor(0.825)
	IONF G 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF G 0 A_ZoomFactor(0.85)
	IONF F 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF F 0 A_ZoomFactor(0.875)
	IONF E 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF E 0 A_ZoomFactor(0.9)
	IONF D 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF D 0 A_ZoomFactor(0.925)
	IONF C 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF C 0 A_ZoomFactor(0.95)
	IONF B 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF B 0 A_ZoomFactor(0.975)
	IONF A 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(1)
   	IONG AAAAA 3 A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 0 A_PlaySoundEx("weapons/PlanetCrackerReload","SoundSlot5")
   	IONR ABC 2
   	IONR DEFDEFDEF 2
   	IONR CBA 2
   	IONG A 10
        Goto Ready
   AltFire:
   	IONG A 0 A_JumpIfInventory("TrockyActive",1,"WooptieWoo")
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_Charge",5)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip1",1)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge1",6)
   	TNT1 A 0 A_Quake(1,43,0,2,0)
	IONG ABCDEF 5 BRIGHT
	IONC A 13 BRIGHT
	TNT1 A 0 A_Quake(3,21,0,2,0)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge2",6)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip2",1)
	IONC ABCDEFGHIJKKKKKKKKKKK 1 BRIGHT
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge3",6)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip3",1)
	TNT1 A 0 A_Quake(5,52,0,2,0)
	IONC LMNO 13 BRIGHT
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_Ready",6)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_Cling",1)
	TNT1 A 0 A_Quake(7,13,0,2,0)
   	IONZ ABCDEFGHIJKLM 1 BRIGHT
	IONZ A 0 A_Recoil(50)
   	IONG A 0 A_SetBlend("Blue",0.2,90)
   	IONG A 0 A_SetBlend("Cyan",0.4,90)
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Fire",6)
	IONZ A 0 A_FireCustomMissile("PlanetOrbiter1",0,0, 00.000+15, -16.000+10)
	IONZ A 0 A_FireCustomMissile("PlanetOrbiter2",0,0,-13.856+15, 08.000+10)
	IONZ A 0 A_FireCustomMissile("PlanetOrbiter3",0,0, 13.856+15, 08.000+10)
	IONZ A 0 A_FireCustomMissile("PlanetBeamSuper", 0, 1, 15, 10)
   	TNT1 A 0 A_Quake(9,35,0,2,0)
	IONF A 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.975)
	IONF B 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF B 0 A_ZoomFactor(0.9)
	IONF C 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF C 0 A_ZoomFactor(0.85)
	IONF D 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF D 0 A_ZoomFactor(0.825)
	IONF E 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF E 0 A_ZoomFactor(0.8)
	IONF F 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF F 0 A_ZoomFactor(0.775)
	IONF G 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF G 0 A_ZoomFactor(0.765)
	IONF F 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF F 0 A_ZoomFactor(0.755)
	IONF E 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF E 0 A_ZoomFactor(0.785)
	IONF D 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF D 0 A_ZoomFactor(0.815)
	IONF C 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF C 0 A_ZoomFactor(0.825)
	IONF B 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF B 0 A_ZoomFactor(0.85)
	IONF A 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.875)
	IONZ M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.9)
	IONZ M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.925)
	IONZ M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.965)
	IONZ M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.985)
	IONZ M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.995)
	IONZ M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(1)
	IONZ MM 2 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 0 A_PlaySoundEx("weapons/PlanetCracker_MiniCharge1","SoundSlot5")
   	IONZ MLKJIHGFEDCBA 1 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
  	IONC ONML 4 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 0 A_PlaySoundEx("weapons/PlanetCracker_MiniBip4","Weapon")
  	IONC KJIHGFEDCBA 2 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
  	IONG FEDCBA 3 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG AAAAA 4 A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 20
        Goto Ready
   WooptieWoo: //Supreme AltFire, if somebody is still not fed up with "firepower"!
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_Charge",5)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip1",1)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge1",6)
   	TNT1 A 0 A_Quake(1,43,0,2,0)
	IONG ABCDEF 5 BRIGHT
	IONC A 13 BRIGHT
	TNT1 A 0 A_Quake(3,21,0,2,0)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge2",6)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip2",1)
	IONC ABCDEFGHIJKKKKKKKKKKK 1 BRIGHT
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge3",6)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip3",1)
	TNT1 A 0 A_Quake(5,52,0,2,0)
	IONC LMNO 13 BRIGHT
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_Ready",6)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_Cling",1)
	TNT1 A 0 A_Quake(7,13,0,2,0)
   	IONZ ABCDEFGHIJKLM 1 BRIGHT
   	TNT1 A 0 A_Quake(7,10,0,6,0)
   	IONZ M 10 BRIGHT
   
   	TNT1 A 0 A_Quake(7,14,0,2,0)
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Void",6)
   	IONO ABCDEFG 2 BRIGHT
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Mechanism1",0)
   	TNT1 A 0 A_Quake(8,8,0,2,0)
   	IONO HIJK 2 BRIGHT
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Mechanism2",0)
   	TNT1 A 0 A_Quake(9,90,0,2,0)
    IONO LMNOP 10 BRIGHT
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Mechanism3",5)
    IONG A 0 ACS_Execute(708)
    IONO P 40 BRIGHT
        

	IONG A 0 A_JumpIfInventory("InfiniteAmplifier",1,3)
   	IONG A 0 A_TakeInventory("TrockyActive")
   	IONG A 0 A_TakeInventory("Trocky",1)
	IONZ A 0 A_Recoil(70)
   	IONG A 0 A_SetBlend("Blue",0.4,180)
   	IONG A 0 A_SetBlend("Cyan",0.8,180)
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Hyper",5)
    IONG A 0 A_PlaySound("weapons/PlanetCracker_Fire",6)
	IONZ A 0 A_FireCustomMissile("PlanetBeamHyper", 0, 0, 15, 10)
   	TNT1 A 0 A_Quake(9,35,0,2,0)
   
	IONO A 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.95)
	IONO B 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF B 0 A_ZoomFactor(0.85)
	IONO C 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF C 0 A_ZoomFactor(0.8)
	IONO D 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF D 0 A_ZoomFactor(0.7)
	IONO E 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF E 0 A_ZoomFactor(0.55)
	IONO F 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF F 0 A_ZoomFactor(0.5)
	IONO G 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF G 0 A_ZoomFactor(0.515)
	IONO F 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF F 0 A_ZoomFactor(0.525)
	IONO E 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF E 0 A_ZoomFactor(0.55)
	IONO D 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF D 0 A_ZoomFactor(0.575)
	IONO C 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF C 0 A_ZoomFactor(0.6)
	IONO B 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF B 0 A_ZoomFactor(0.75)
	IONO A 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.85)
	IONO M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.9)
	IONO M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.925)
	IONO M 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.95)
	IONO P 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.975)
	IONO P 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONF A 0 A_ZoomFactor(0.985)
	IONO P 1 Bright A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONO A 0 A_ZoomFactor(1)
	IONO PPPPPPP 2 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONO ONML 2 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
	IONO KJIHGFEDCBA 2 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniCharge1",5)
   	IONZ MLKJIHGFEDCBA 1 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
  	IONC ONML 4 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 0 A_PlaySound("weapons/PlanetCracker_MiniBip4",1)
  	IONC KJIHGFEDCBA 2 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
  	IONG FEDCBA 3 BRIGHT A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG AAAAA 4 A_FireCustomMissile("PlanetCrackerSmokeSpawner",0,0,8,5)
   	IONG A 60
    Goto Ready
	}
}

ACTOR DullInheritance
{ 
    RenderStyle Add
    +NOINTERACTION
    +NOGRAVITY
}

//Supercharge

actor TrockyPickup : CustomInventory
{
	Inventory.PickupMessage "Picked up a ''Trocky'' ion storm charge!"
	Inventory.PickupSound "Ammo/Trocky"
	States
	{
		Spawn:
		SION ABCD 3
		Loop
		Pickup:
		TNT1 A 0 A_JumpIfInventory("Trocky",0,"Bailure")
		TNT1 A 0 A_GiveInventory("Trocky")
		Stop
		Bailure:
		TNT1 A 1
		Fail
	}
}

actor Trocky : CustomInventory
{
  Inventory.PickupMessage "Picked up a ''Trocky'' ion storm charge!"
  Inventory.Amount 1
  Inventory.MaxAmount 2
  Inventory.InterHubAmount 2
  Inventory.PickupSound "Ammo/Trocky"
  Inventory.Icon ARTISION
  +INVENTORY.FANCYPICKUPSOUND
  +INVBAR
  states
  {
  Spawn:
	SION ABCD 3
	loop
  Use:
   	TNT1 A 0 A_JumpIfInventory("TrockyActive",1,"Use2")

	TNT1 A 0 A_SetBlend("Green",0.1,15)
	TNT1 A 0 A_PlaySoundEx("weapons/PlanetCracker_MiniBip2","Item")
	TNT1 A 0 A_GiveInventory("TrockyActive")
	TNT1 A 1 A_Print("Ion storm charge activated.")
	Fail
  Use2:
	TNT1 A 0 A_SetBlend("Red",0.1,15)
	TNT1 A 0 A_PlaySoundEx("weapons/PlanetCracker_MiniBip3","Item")
 	TNT1 A 0 A_TakeInventory("TrockyActive")
	TNT1 A 1 A_Print("Ion storm charge deactivated.")
	Fail
  }
}

actor TrockyActive : Inventory
{
  Inventory.MaxAmount 1
}

//Fire

ACTOR PlanetBeam : FastProjectile
{
  Speed 100
  Radius 19
  Height 10
  Damage 0
  Renderstyle Add
  +RIPPER
  -CANNOTPUSH
  -NODAMAGETHRUST
  +EXTREMEDEATH
  +FORCERADIUSDMG
  +EXPLODEONWATER
  +DONTBLAST
  DeathSound ""
  MissileType "PlanetBeamTrail"
  Scale 0.2
  states
  {
  Spawn:
      TNT1 A 0
      TNT1 A 1 A_Explode(3000,92,0,0)
      Loop
  Death:
      TNT1 A 0 A_PlaySoundEx("weapons/PlanetCrackerImpact","Normal")
      TNT1 A 0 A_Explode(5000,256,0,1)
      TNT1 A 0 A_BFGSpray("PlanetCrackerProjectileSpray",30,30)
      TNT1 A 0 A_SpawnItemEx("PlanetCrackerImpact1", 0, 0, 0, 0, 0, 0, 0, 128, 0)
      TNT1 A 0 A_SpawnItemEx("PlanetCrackerImpact2", 0, 0, 0, 0, 0, 0, 0, 128, 0)
      TNT1 A 0 A_SpawnItemEx("PlanetCrackerImpact3", 0, 0, 0, 0, 0, 0, 0, 128, 0)
      TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("IonRainFlare",random(-150,150),random(-150,150),random(-25,50),0,0,frandom(1,2),0,0,0)
      TNT1 A 1 A_SpawnItemEx("PlanetCrackerBeamHit", 0, 0, 0, 0, 0, 0, 0, 128, 0)
      TNT1 AAAAAAAAAAA 1 A_SpawnItemEx("IonRainFlare",random(-150,150),random(-150,150),random(-25,50),0,0,frandom(1,2),0,0,0)
      Stop
  }
}

ACTOR PlanetCrackerProjectileSpray : DullInheritance
{ 
    Scale 1
    Alpha 1
    Renderstyle Normal
	+CLIENTSIDEONLY
    States
    {
    Spawn:
      TNT1 A 0
      TNT1 A 0 A_SpawnItemEx("PlanetBeamTrail", 0, 0, 0, 0, 0, 0, 0, 128, 0)
      TNT1 A 0 A_SpawnItemEx("PlanetCrackerMiniImpact", 0, 0, 0, 0, 0, 0, 0, 128, 0)
      TNT1 AAAAAAA 1 A_SpawnItemEx("IonRainFlare",random(-50,50),random(-50,50),random(-15,25),0,0,frandom(1,2),0,0,0)
      Stop
    }
}

ACTOR PlanetCrackerImpact1
{
  +NOGRAVITY
  +NOINTERACTION
  +CLIENTSIDEONLY
  Renderstyle Add
  Alpha 0.99
  Scale 0.5
  States
  {
  Spawn:
  TNT1 A 2
  Looplet:
  TNT1 A 0 //A_SetScale(ScaleX +0.04, ScaleY +0.04)
  TNT1 A 0 A_FadeOut(0.07)
  BLUF A 1 Bright
  Loop
  }
}

ACTOR PlanetCrackerImpact2 : PlanetCrackerImpact1
{
  Scale 0.75
  Alpha 0.8
  +CLIENTSIDEONLY
  States
  {
  Spawn:
  TNT1 A 4
  Looplet:
  TNT1 A 0 //A_SetScale(ScaleX +0.05, ScaleY +0.05)
  TNT1 A 0 A_FadeOut(0.07)
  BLUF A 1 Bright
  Loop
  }
}

ACTOR PlanetCrackerImpact3 : PlanetCrackerImpact1
{
  Scale 0.9
  Alpha 0.7
  +CLIENTSIDEONLY
  States
  {
  Spawn:
  TNT1 A 6
  Looplet:
  TNT1 A 0 //A_SetScale(ScaleX +0.06, ScaleY +0.06)
  TNT1 A 0 A_FadeOut(0.07)
  BLUF A 1 Bright
  Loop
  }
}

ACTOR PlanetCrackerMiniImpact : PlanetCrackerImpact1
{
  Scale 0.2
  +CLIENTSIDEONLY
  States
  {
  Spawn:
  TNT1 A 2
  Looplet:
  TNT1 A 0 //A_SetScale(ScaleX +0.05, ScaleY +0.05)
  TNT1 A 0 A_FadeOut(0.07)
  BLUF A 1 Bright
  Loop
  }
}

ACTOR PlanetCrackerBeamHit
{ 
    Projectile
    Scale 2.5
    Alpha 0.8
    RenderStyle Add
    +NOINTERACTION
	+CLIENTSIDEONLY
    +NOGRAVITY
    States
    {
    Spawn:
      PBOM ABCDEFGHIJKLMN 1 BRIGHT //A_SetScale(ScaleX +0.06, ScaleY +0.06)
      Stop
    }
}

ACTOR PlanetBeamSuper : FastProjectile
{
  Speed 75
  Radius 19
  Height 10
  Damage 200
  PROJECTILE
  -CANNOTPUSH
  -NODAMAGETHRUST
  +EXTREMEDEATH
  +FORCERADIUSDMG
  +EXPLODEONWATER
  +DONTBLAST
  Renderstyle Add
  MissileType "PlanetBeamTrail"
  DamageType "Superweapon"
  DeathSound ""
  states
  {
  Spawn:
      TNT1 A 1
      Loop
  Death:
      TNT1 A 0 A_StopSoundEx("Body")
      TNT1 A 0 A_PlaySound("weapons/PlanetCrackerBoom",6)
      TNT1 A 0 A_BFGSpray("PlanetCrackerProjectileSpray",30,30)
      TNT1 A 0 A_Explode(5000,384,0,1)
      PBAL BBBBB 0 A_SpawnItemEx("PlanetCrackerProjectileBoom", 0, 0, 0, 0.1*random(20,15), 0.1*random(25,15), 2+random(1,-1), 0, 128, 0)
      PBAL BBBBBB 2 A_SpawnItemEx("PlanetCrackerProjectileBoom", 0, 0, 0, random(3,2), random(3,2), 3+random(3,2), 0, 128, 0)
      TNT1 A 0 A_PlaySound("weapons/PlanetCrackerRain",0)
      PBAL B 28 A_SpawnItemEx("IonRain",0,0,0,0,0,0,0,0,0)
      PBAL BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 1 A_SpawnItemEx("BeamFire", 0, 0, 0, 0.1*Random(-3,3), 0.1*Random(-3, 3), 0.01*Random(20, 30), random(0,359), 0, 0)
      PBAL B 1 ACS_ExecuteAlways(384, 0, 0, 0, 0)
      PBAL B 1 A_FadeOut(0.05)
      Wait
  }
}

//Smoke

ACTOR PlanetSmoke
{
	Radius		1
	Height		1
	RenderStyle ADD
	Alpha		.3
	Scale		.2
	Speed		0.65
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	States
	{
	Spawn:
		ISMK ABCDEFGHIJKLMNOP 3
		Stop
	}
}

ACTOR PlanetSmoke2 : PlanetSmoke
{
	Speed		1
}

ACTOR PlanetSmoke3 : PlanetSmoke
{
	Speed		0.35
}

//Trails

ACTOR PlanetBeamTrail
{
  RenderStyle Add
  Alpha 0.75
  Scale 0.15
  +NOCLIP
  +NOGRAVITY
  +CLIENTSIDEONLY
  States
  {
  Spawn:
    BLUF A 0
    BLUF A 0 A_SpawnItemEx("PlanetCrackerProjectileTrail1", random(15,-15), random(15,-15), random(15,-15), 0, 0, 0, 0, 128, 0)
  Looplet:
    BLUF A 0 //A_SetScale(ScaleX -0.006, ScaleY -0.006)
    BLUF A 2 bright A_FadeOut(0.05)
    Loop
  }
}

ACTOR PlanetBeamTrailSmall : PlanetBeamTrail
{
  Scale 0.05
  +CLIENTSIDEONLY
  States
  {
  Spawn:
    BLUF A 0
    BLUF A 2 bright A_FadeOut(0.05)
    Wait
  }
}

ACTOR PlanetCrackerProjectileTrail1 : DullInheritance
{ 
    Scale 1
    Alpha 0.25
	+CLIENTSIDEONLY
    States
    {
    Spawn:
      PBOM EFGHIJKLMN 2 BRIGHT
      Stop
    }
}

ACTOR PlanetCrackerProjectileTrail2 : DullInheritance
{ 
    Scale 2
    Alpha 0.5
	+CLIENTSIDEONLY
    States
    {
    Spawn:
      PLNS ABCDEFGHIJKLMNOP 3 BRIGHT A_ChangeVelocity (1, frandom(-3, 3), frandom(-3, 3), 1)
      Stop
    }
}

//Fire smoke

ACTOR PlanetCrackerSmokeSpawner
{
    Radius 1
    Height 1
    Speed 25
	+CLIENTSIDEONLY
    PROJECTILE
    States
    {
    Spawn:
        TNT1 A 1
        TNT1 A 0 A_Die
        Goto Death
    Death:
        TNT1 AAAAA 0 A_CustomMissile("PlanetSmoke",0, 0, random(-90, 90), 2, random(-90, 90))
        TNT1 AAAAA 0 A_CustomMissile("PlanetSmoke2",0, 0, random(-90, 90), 2, random(-90, 90))
        TNT1 AAAAA 0 A_CustomMissile("PlanetSmoke3",0, 0, random(-90, 90), 2, random(-90, 90))
        Stop
    }
}

ACTOR PlanetCrackerProjectileBoom : DullInheritance
{ 
    Projectile
    Scale 2
    Alpha 0.5
	+CLIENTSIDEONLY
    Renderstyle Add
    States
    {
    Spawn:
      PULS ABCDEFGHIJKLMNOPQRST 2 BRIGHT
      Stop
    }
}

Actor IonRain
{
 +NoInteraction
 Height 3
 Radius 2
 RenderStyle Add
 Scale 0.1
 +CLIENTSIDEONLY
 reactiontime 11
 States
 {
  Spawn:
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 3 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 2 A_SpawnItemEx("IonRainFlare",random(-1200,1200),random(-1200,1200),random(50,800),0,0,frandom(1,2),0,128,0)
   TNT1 A 0 A_Countdown
   loop
  Death:
   TNT1 A 0
   stop
 }
}

actor IonRainFlare
{
  RenderStyle Add
  alpha 1
  +NOINTERACTION
  +RANDOMIZE
  +NOCLIP
  +NOGRAVITY
  +CLIENTSIDEONLY
  Scale 0.1
  states
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_ChangeVelocity (frandom(-0.2, 0.2), frandom(-0.2, 0.2), frandom(-0.1, 0.1), 0)
    //TNT1 A 0 A_CustomMissile("PlanetCrackerIonBolter",0,0,random(0,360),4,random(45,0))
    PBAL B 5 bright A_FadeOut(0.1)
    Loop
  }
}

actor PlanetCrackerIonBolter
{
  Radius 11
  Height 8
  Scale 0.1
  Speed 45
  Damage 1
  Projectile
  Renderstyle Add
  +NOGRAVITY
  +FORCERADIUSDMG
  Obituary "%o was neutralized %k's ion storm."
  States
  {
  Spawn:
    TNT1 A 1 A_ChangeVelocity (frandom(-16, 16), frandom(-16, 16), frandom(-6,6), 1)
    Loop
  Death:
    TNT1 A 0 A_SpawnItemEx("IonBolt",0,0,0,0,0,0,0,128,0)
    PBOM ABCDEF 1 Bright
    PBOM GHIJKLMN 1 Bright
    stop
  }
}

ACTOR IonBolt
{
	+NOINTERACTION
	+NOCLIP
 	+FORCEXYBILLBOARD
  	+FORCERADIUSDMG
	Renderstyle Add
 	XScale 0.05
 	YScale 4.0
 	Alpha 0.5
	States
	{
	Spawn:
   		SBBL A 0
   		SBBL AAAAAAAAAA 1 A_FadeIn(0.1)
       		TNT1 A 0 A_SpawnItemEx("IonBoltHitFlare",0,0,10,0,0,0,0,128,0)
   	Looper:
   		SBBL A 0 A_SpawnItemEx("BeamFire", 0, 0, 0, 0.01 * Random(-10, 10), 0.01 * Random(-10, 10), 0.01 * Random(0, 125), 0, 128, 0)
   		SBBL A 0 A_Explode(1000,64,0,1)
   		SBBL A 1 Bright A_FadeOut(0.1)
		Loop
	}
}

ACTOR IonBoltHitFlare
{
	+NOINTERACTION
	+CLIENTSIDEONLY
	Renderstyle Add
  	Scale 0.1
	States
	{
	Spawn:
	TNT1 A 0
	BLUF A 2 A_Fadeout(0.05)
	Wait
	}
}

//Supercharged shot
ACTOR PlanetBeamHyper : FastProjectile
{
  Speed 400
  Radius 19
  Height 10
  Damage 0
  Decal BFGScorch
  Renderstyle Add
  +RIPPER
  -CANNOTPUSH
  -NODAMAGETHRUST
  +EXTREMEDEATH
  +FORCERADIUSDMG
  +DONTBLAST
  DeathSound ""
  MissileType "PlanetBeamTrail"
  DamageType "Superweapon"
  Scale 0.2
  states
  {
  Spawn:
      TNT1 A 0
      TNT1 A 1 A_Explode(9000,128,0,0)
      Loop
  Death:
      TNT1 A 0 A_StopSoundEx("Body")
      TNT1 A 0 A_PlaySound("weapons/PlanetCrackerBoom",6)
      TNT1 A 0 A_BFGSpray("PlanetCrackerProjectileSpray",30,30)
      TNT1 A 0 A_Explode(75000,256,0,1)
      PBAL BBBBBBBBBB 0 A_SpawnItemEx("PlanetCrackerProjectileBoom", 0, 0, 0, 0.1*random(20,15), 0.1*random(25,15), 2+random(1,-1), 0, 128, 0)
      PBAL BBBBBBBBBBBBBBBBBB 1 A_SpawnItemEx("PlanetCrackerProjectileBoom", 0, 0, 0, random(3,2), random(3,2), 3+random(3,2), 0, 128, 0)
      TNT1 AAAAAAAAAA 10 A_SpawnItemEx("PlanetCrackerHyperBolter",0,0,10,10,10,0,random(0,359),0,0)
      Stop
  }
}


//Orbiters

actor PlanetOrbiter1 : FastProjectile
{
  Speed 75
  Radius 12
  Height 8
  WeaveIndexXY 0
  WeaveIndexZ 48
  Renderstyle Normal
  +CLIENTSIDEONLY
  +NOGRAVITY
  Scale 1
  MissileType "PlanetBeamTrailSmall"
  States
  {
  Spawn:
    TNT1 AA 1 A_Weave(1.5, 1.5, 2.5, 2.5)
    Loop
  Death:
    TNT1 A 1
    stop
  }
}

ACTOR PlanetOrbiter2 : PlanetOrbiter1 { WeaveIndexXY 21  WeaveIndexZ 5 }
ACTOR PlanetOrbiter3 : PlanetOrbiter1 { WeaveIndexXY 42  WeaveIndexZ 26 }

actor PlanetCrackerHyperBolter
{
  Radius 11
  Height 8
  Scale 0.1
  Speed 45
  Damage 1
  Projectile
  ReactionTime 20
  Renderstyle Add
  +NOGRAVITY
  +FORCERADIUSDMG
  +NOCLIP
  Obituary "%o was neutralized %k's ion storm."
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_Countdown
    TNT1 A 1 A_ChangeVelocity (frandom(-32, 32), frandom(-32, 32), frandom(-6, 6), 1)
    Loop
  Death:
    TNT1 A 0 A_SpawnItemEx("HyperBombing",0,0,0,0,0,0,0,0,0)
    PBOM ABCDEF 1 Bright
    PBOM GHIJKLMN 1 Bright
    stop
  }
}

ACTOR HyperBombing
{
	+NOINTERACTION
	+NOCLIP
	Renderstyle Add
	DamageType "Superweapon"
	States
	{
	Spawn:
      TNT1 A 0 A_StopSoundEx("Body")
      TNT1 A 0 A_Explode(75000,256,0,1)
      PBAL B 28
      PBAL BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 1 A_SpawnItemEx("BeamFire", 0, 0, 0, 0.1*Random(-3,3), 0.1*Random(-3, 3), 0.01*Random(20, 30), random(0,359), 0, 0)
      PBAL B 1 A_SpawnItemEx("BlueStrike",0,0,100,0,0,0,0,SXF_TRANSFERPOINTERS,0)
      PBAL B 1 A_FadeOut(0.05)
      Wait
	}
}
