script_enemy_main
{
	#include_function ".\func.txt"

	let gcsd = GetCurrentScriptDirectory;
	let enemy = gcsd~"e07.png";
	let kira00 = gcsd~"se002.wav";

	@Initialize
	{
		SetLife(400);

		LoadUserShotData(gcsd~"supershot.txt");

		MainTask;
		FieldChecker;

		LoadGraphic(enemy);
		LoadSE(kira00);
	}

	@MainLoop
	{
		SetCollision(GetX, GetY, 16);
		yield;
	}

	@DrawLoop
	{
		SetColor(255, 255, 255);
		SetTexture(enemy);
		SetGraphicRect(0, 0, 48, 48);
		SetGraphicScale(1, 1);
		DrawGraphic(GetX, GetY);
	}

	@Finalize
	{
		if(GetLife<=0)
		{
			loop(4){CreateItem(ITEM_SCORE, GetX+rand(0, 24)*cos(rand(0, 360)), GetY+rand(0, 24)*sin(rand(0, 360)));}
		}
	}

	task MainTask
	{
		let initSpeed = GetSpeed;
		loop(30){SetSpeed(GetSpeed-(initSpeed/30)); yield;}
		SetSpeed(0);
		attack;
		SetAngle(GetArgument);
		loop(30){SetSpeed(GetSpeed+(0.5/30)); yield;}
		SetSpeed(0.5);
	}

	task attack
	{
		let ang = 0;

		loop
		{
			PlaySE(kira00);
			ascent(a in 0..6)
			{
				CreateShot01(GetX+32*cos(ang+a*60), GetY+32*sin(ang+a*60), 2, ang+a*60, 21, 10);
				CreateShot01(GetX+32*cos(-ang+a*60), GetY+32*sin(-ang+a*60), 2, -ang+a*60, 21, 10);
				CreateShot01(GetX+32*cos(ang+a*60+3.5), GetY+32*sin(ang+a*60+3.5), 1, ang+a*60+3.5, 19, 10);
				CreateShot01(GetX+32*cos(-ang+a*60-3.5), GetY+32*sin(-ang+a*60-3.5), 1, -ang+a*60-3.5, 19, 10);
			}
			ang+=7;
			Wait(20);
		}
	}

	task FieldChecker
	{
		loop
		{
			if(GetX<GetClipMinX-64||GetX>GetClipMaxX+64||GetY<GetClipMinY-64||GetY>GetClipMaxY+64)
			{
				VanishEnemy;
			}
			yield;
		}
	}
}