class Destructinator : SquareMonster
{
	Default
	{
		Health 4500;
		Height 100;
		Mass 1000;
		MinMissileChance 160;
		Radius 44;
		PainChance 10;
		Speed 14;
		FastSpeed 20;

		DamageFactor "HellDamage", 2.0;
		DamageFactor "MarbazookaBlast", 1.5;
		DamageFactor "Vacuum", 0.0;

		+BOSS;
		+MISSILEMORE;
		+FLOORCLIP;
		+NORADIUSDMG;
		+DONTMORPH;
		+BOSSDEATH;
		+NOBLOOD;
		+NEVERRESPAWN;
		+LOOKALLAROUND;
		+DONTRIP;

		Obituary "$OB_DESTRUCTINATOR";
		SeeSound "destructinator/sight";
		AttackSound "destructinator/minigun/fire";
		ActiveSound "destructinator/active";
		PainSound "destructinator/pain";
		DeathSound "destructinator/death";
	}
	States
	{
	Spawn:
		DEST A 10 A_Look();
		Loop;
	See:
		DEST AAA 35 A_FaceTarget(); // You have three seconds to comply!
	SeeLoop:
		DEST BB 2 A_Chase();
		DEST C 0 A_PlaySound("destructinator/hoof", CHAN_ITEM);
		DEST CC 2 A_Chase();
		DEST DD 2 A_Chase();
		DEST E 0 A_PlaySound("destructinator/hoof", CHAN_ITEM);
		DEST EE 2 A_Chase();
		DEST J 0 A_GiveInventory("DestructinatorSteps", 1);
		DEST J 0 A_JumpIfInventory("DestructinatorSteps", 3, 1);
		Goto SeeLoop;
		DEST J 0 A_Jump(128, "TeleportFar");
		Goto SeeLoop;
	Missile:
		DEST J 0 A_TakeInventory("DestructinatorSteps", 3);
		DEST J 0 A_Jump(128, 2);
		DEST J 0 A_JumpIfCloser(512, "Bloodnades");
		DEST J 0 A_Jump(128, "LockOn", "FaceRay");
		DEST J 0 A_Jump(256, "Minigun");
		Loop;
	Minigun:
		DEST J 0 Bright A_PlaySound("destructinator/minigun/begin");
		DEST AJAJAJAJAJAJ 2 Bright A_FaceTarget();
	MinigunLoop:
		DEST I 2 Bright A_CustomBulletAttack(10, 3, 3, 3, "PaintPuff4");
		DEST J 2 Bright A_FaceTarget();
		DEST I 2 Bright A_CustomBulletAttack(10, 3, 3, 3, "PaintPuff4");
		DEST J 2 Bright A_FaceTarget();
		DEST I 2 Bright A_CustomBulletAttack(10, 3, 3, 3, "PaintPuff4");
		DEST J 2 Bright A_FaceTarget();
		DEST A 0 A_Jump(32, 2);
		DEST A 0 A_MonsterRefire(10, "SeeLoop");
		Goto MinigunLoop;
		DEST A 0;
		Goto SeeLoop;
	FaceRay:
		DEST A 13 A_FaceTarget();
	FaceRayStart:
		DEST H 3 Bright A_SpawnProjectile("DestructiLaser", 100, 0, random(-2,2));
		DEST A 4 A_FaceTarget();
		DEST A 0 A_Jump(30, 2);
		DEST A 0 A_MonsterRefire(10, "SeeLoop");
		Goto FaceRayStart;
		DEST A 0;
		Goto SeeLoop;
	LockOn:
		DEST A 0 A_PlaySound("destructinator/acquiring");
		DEST A 13 A_FaceTarget();
		DEST H 0 A_VileTarget("DestructinatorCrosshair");
		DEST H 0 { self.bNoPain = true; }
		DEST HAHAHAH 10 Bright A_FaceTarget();
		DEST H 0 { self.bNoPain = false; }
		Goto HellShell;
	Hellshell:
		DEST KL 5;
		DEST G 0 A_PlaySound("weapons/hellshot");
		DEST G 0 Bright A_SpawnProjectile("SuperHellshell", 92, -45.0, 0);
		DEST L 6 Bright A_SpawnProjectile("SuperHellshell", 92, 45.0, 0);
		DEST KH 9;
		Goto SeeLoop;
	Bloodnades:
		DEST F 0 A_StopSound(CHAN_VOICE);
		DEST F 0 A_PlaySound("destructinator/active");
		DEST FFFFFF 3 A_FaceTarget();
	BloodnadesInstant:
		DEST G 0 A_PlaySound("weapons/hellshot", CHAN_ITEM);
		DEST G 0 A_FaceTarget();
		DEST G 2 Bright A_SpawnProjectile("BloodnadeProjectile", 32, -50.0);
		DEST F 7;
		DEST G 0 A_PlaySound("weapons/hellshot", CHAN_ITEM);
		DEST G 0 A_FaceTarget();
		DEST G 2 Bright A_SpawnProjectile("BloodnadeProjectile", 32, 50.0);
		DEST F 7;
		DEST G 0 A_PlaySound("weapons/hellshot", CHAN_ITEM);
		DEST G 0 A_FaceTarget();
		DEST G 2 Bright A_SpawnProjectile("BloodnadeProjectile", 32, -50.0);
		DEST F 7;
		DEST G 0 A_PlaySound("weapons/hellshot", CHAN_ITEM);
		DEST G 0 A_FaceTarget();
		DEST G 2 Bright A_SpawnProjectile("BloodnadeProjectile", 32, 50.0);
		DEST F 25;
		Goto SeeLoop;
	Pain:
		DEST M 5;
		DEST M 5 A_Pain();
	Teleport:
		DEST H 0 A_TakeInventory("DestructinatorSteps", 3);
		DEST H 0 A_Teleport("PortIn", "DestructinatorSpot", "DestructinatorFog", 0, 192, 512);
		Goto SeeLoop;
	TeleportFar:
		DEST H 0 A_TakeInventory("DestructinatorSteps", 3);
		DEST H 0 A_Teleport("PortIn", "DestructinatorSpot", "DestructinatorFog", 0, 800, 0);
		Goto SeeLoop;
	PortIn:
		// teleport sound is already played, but might need a louder one for better telegraphing
		TNT1 A 0 A_PlaySound("destructinator/teleport");
		TNT1 A 8 A_UnSetShootable();
		DEST H 0 Bright A_FaceTarget();
		DEST H 1 Bright A_SetTranslucent(0.05);
		DEST H 1 Bright A_SetTranslucent(0.20);
		DEST H 1 Bright A_SetTranslucent(0.10);
		DEST H 1 Bright A_SetTranslucent(0.40);
		DEST H 1 Bright A_SetTranslucent(0.15);
		DEST H 1 Bright A_SetTranslucent(0.60);
		DEST H 1 Bright A_SetTranslucent(0.20);
		DEST H 1 Bright A_SetTranslucent(0.80);
		DEST H 0 Bright A_FaceTarget();
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 0 A_SetShootable();
		Goto SeeLoop;
	Death:
		DEST H 1 A_FaceTarget();
		DEST H 0 A_Scream();
		DEST H 0 A_SpawnItemEx("MibSpawnerDestructinator", random[SquareEffectRandom](-50,50), random[SquareEffectRandom](-40,40), random[SquareEffectRandom](40,50));
		DEST H 18 A_SpawnItemEx("ExplosionAlt", random(-50,50), random(-40,40), random(40,50));
		DEST H 0 A_SpawnItemEx("MibSpawnerDestructinator", random[SquareGibRandom](-50,50), random[SquareGibRandom](-40,40), random[SquareGibRandom](40,50));
		DEST H 18 A_SpawnItemEx("ExplosionAlt", random(-50,50), random(-40,40), random(40,50));
		DEST H 0 A_SpawnItemEx("MibSpawnerDestructinator", random[SquareGibRandom](-50,50), random[SquareGibRandom](-40,40), random[SquareGibRandom](40,50));
		DEST H 18 A_SpawnItemEx("ExplosionAlt", random(-50,50), random(-40,40), random(40,50));
		DEST H 0 A_SpawnItemEx("MibSpawnerDestructinator", random[SquareGibRandom](-50,50), random[SquareGibRandom](-40,40), random[SquareGibRandom](40,50));
		DEST H 18 A_SpawnItemEx("ExplosionAlt", random(-50,50), random(-40,40), random(40,50));
		DEST N 4 A_NoBlocking();
		DEST O 4;
		DEST P 25;
		DEST QR 4;
		DEST S 0 Bright A_SpawnItem("CrystalGibSpawner");
		DEST SSS 0 A_SpawnItemEx("MibSpawnerDestructinator", random[SquareGibRandom](-50,50), random[SquareGibRandom](-40,40), random[SquareGibRandom](0, 24));
		DEST SSSSSSSS 1 A_SpawnItemEx("Explosion", random(-50,50), random(-40,40), random(40,50));
		DEST SSSSSSSSSS 2 A_SpawnItemEx("Smoke", frandom[SquareEffectRandom](-9.0,9.0), frandom[SquareEffectRandom](-9.0,9.0), 9.0, 0, 0, 3);
		DEST T 2 A_SpawnItemEx("Smoke", frandom[SquareEffectRandom](-9.0,9.0), frandom[SquareEffectRandom](-9.0,9.0), 9.0, 0, 0, 3);
		DEST T 35;
		DEST U 0 A_SpawnItemEx("Explosion", 0.0, 0.0, 32.0);
		DEST U 0 A_SpawnItemEx("DestructinatorBrain", 0.0, 0.0, 32.0, 0, 0, 0, 0, SXF_TELEFRAG);
		DEST U -1 A_BossDeath();
		Stop;
	}
}

class DestructinatorSteps : Inventory
{
	Default
	{
		Inventory.MaxAmount 3;
	}
}

class DestructinatorBrain : SquareMonster
{
	Default
	{
		+NOPAIN;
		+NOGRAVITY;
		+NOBLOOD;
		+FLOAT;
		Health 200;
		Radius 16;
		Height 32;
		Speed 14;
		FastSpeed 20;
		Obituary "$OB_DESTRUCTINATORBRAIN";
		DeathSound "colorcube/death";
	}
	States
	{
	Spawn:
		DSTH A 1 A_Look();
		Loop;
	See:
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH A 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH A 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH B 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH B 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH C 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH C 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH D 1 A_Chase();
		DSTH A 0 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH D 1 A_Chase();
		Loop;
	Missile:
		DSTH C 0 A_FaceTarget();
		DSTH CCCC 1 Bright A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH D 0 A_FaceTarget();
		DSTH DDDD 1 Bright A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
	MisileLoop:
		DSTH E 0 A_SpawnProjectile("DestructiLaser", 4, 0, random(-2,2));
		DSTH EEE 1 Bright A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH A 0 A_FaceTarget();
		DSTH AAAA 1 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH B 0 A_FaceTarget();
		DSTH BBBB 1 A_SpawnItemEx("JetpackFlame", -8.0, 0.0, -2.0, 0.0, 0.0, -2.0);
		DSTH A 0 A_Jump(30, 2);
		DSTH A 0 A_MonsterRefire(10, "See");
		Loop;
		DEST A 0;
		Goto See;
	Death:
		TNT1 A 0 A_SpawnItem("MibSpawnerDestructinator");
		TNT1 A 0 A_SpawnItem("Explosion");
		TNT1 A 18 A_Explode(60,100);
		Stop;
	}
}

class DestructinatorFog : TeleportFog
{
	Default
	{
		+NOBLOCKMAP;
		+NOTELEPORT;
		+NOGRAVITY;
		RenderStyle 'Add';
	}
	States
	{
	Spawn:
		DEST H 1 Bright;
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(1.00);
		DEST H 1 Bright A_SetTranslucent(0.25);
		DEST H 1 Bright A_SetTranslucent(0.80);
		DEST H 1 Bright A_SetTranslucent(0.20);
		DEST H 1 Bright A_SetTranslucent(0.60);
		DEST H 1 Bright A_SetTranslucent(0.15);
		DEST H 1 Bright A_SetTranslucent(0.40);
		DEST H 1 Bright A_SetTranslucent(0.10);
		DEST H 1 Bright A_SetTranslucent(0.20);
		DEST H 1 Bright A_SetTranslucent(0.05);
		Stop;
	}
}

class DestructinatorSpot : SpecialSpot {}
