class Eyescreamer : SquareMonster
{
	int projchainchance;
	int spyeyetokens;

	Default
	{
		Health 400;
		Radius 31;
		Height 64;
		Mass 1000;
		Speed 12;
		FastSpeed 12;
		PainChance 64;
		BloodColor "fa fa fa";
		Obituary "$OB_EYESCREAMER";
		+FLOAT;
		+NOGRAVITY;
		+MISSILEMORE;

		SeeSound "eyescreamer/sight";
		PainSound "eyescreamer/pain";
		DeathSound "eyescreamer/death";
	}
	States
	{
	Spawn:
		EYSC ABCD 12 A_Look();
		Loop;
	See:
		EYSC AABBCCDD 6 A_Chase();
		Loop;
	Missile:
		EYSC A 0 A_Jump(128, "Projectile");
	SpyEyeSpawn:
		EYSC A 0 A_JumpIf(spyeyetokens <= 0, "Projectile");
		EYSC L 0 { self.spyeyetokens--; }
		EYSC L 0 A_PlaySound("eyescreamer/attack");
		EYSC L 12 A_FaceTarget();
		EYSC I 5 A_SpawnProjectile("EyescreamerSpyEye", 36);
		EYSC JK 5;
		Goto See;
	Projectile:
		EYSC E 0 {
			self.spyeyetokens++;
			self.projchainchance = 256;
		}
	ProjectileLoop:
		EYSC E 0 A_PlaySound("eyescreamer/spit");
		EYSC HE 3 A_FaceTarget();
		EYSC G 0 A_FaceTarget();
		EYSC G 5 A_SpawnProjectile("EyescreamerBall", 24);
		EYSC FE 5;
		EYSC E 0 { self.projchainchance -= 64; }
		EYSC E 0 A_MonsterRefire(0, "See");
		EYSC E 0 A_Jump(projchainchance, "ProjectileLoop");
		Goto See;
	Pain:
		EYSC L 3;
		EYSC L 4 A_Pain();
		Goto See;
	Death:
		EYSC L 5 A_Scream();
		EYSC L 5 A_SpawnItem("GibSpawnerEyescreamer");
		EYSC L 0 A_PainDie("SpyEye");
		TNT1 A 18;
		Stop;
	}
}

class EyescreamerSpyEye : SquareActor
{
	// Make slightly bigger than the SpyEye
	Default
	{
		Height 34;
		Radius 17;
		Speed 20;
		FastSpeed 26;
		Damage 12;
		Health 1;
		BloodType 'SquareBlood';
		BloodColor "fa fa fa";

		PROJECTILE;
		-NOBLOCKMAP;
		+SHOOTABLE;
		+STRIFEDAMAGE;

		SeeSound "spyeye/attack";
		DeathSound "spyeye/pain";
	}
	States
	{
	Spawn:
		SPYE GF 4;
		Loop;
	Pain:
	Death:
		TNT1 A 15 A_SpawnItemEx("SpyEye", 0, 0, 0, 0, 0, 0, angle, SXF_TRANSFERPOINTERS);
		Stop;
	}
}
