script_enemy_main
{
	#include_function ".\func.txt"


	let gcsd = GetCurrentScriptDirectory;
	let boss = gcsd~"b03.png";
	let name = gcsd~"nm3.png";

	let tan00 = gcsd~"se006.wav";

	@Initialize
	{
		Init(0, 100, 100, 45, 120, true, false, false, 0, false, false);
		SetLife(1400);

		LoadUserShotData(gcsd~"supershot.txt");
		SetMovePosition03(GetCenterX, GetClipMinY+120, 10, 5);

		MainTask;

		LoadGraphic(boss);
		LoadGraphic(name);
		LoadSE(tan00);
	}

	@MainLoop
	{
		SetCollision(GetX, GetY, 24);

		yield;
	}

	@DrawLoop
	{
		SetColor(255, 255, 255);
		SetTexture(boss);
		SetGraphicRect(0, 0, 64, 64);
		SetGraphicScale(1, 1);
		DrawGraphic(GetX, GetY);

		SetTexture(name);
		SetGraphicRect(0, 0, 180, 30);
		SetGraphicScale(1, 1);
		DrawGraphic(GetClipMinX+90, GetClipMinY+30);
	}

	@Finalize
	{
	}

	task MainTask
	{
		Wait(180);
		move;
		attack;
	}

	task attack
	{
		let ang = 0;
		let time = 0;

		loop
		{
			PlaySE(tan00);
			loop(40)
			{
				ascent(a in 0..4)
				{
					CreateShotA(0, GetX, GetY, 10);
					SetShotDataA(0, 0, 2, ang+90*a+10*time, 0, -0.05, 0, 222);
					SetShotDataA(0, 40, 0, NULL, 0, 0, 0, 222);
					SetShotDataA(0, 60+2*time, 0, NULL, 0, 0.02, 2, 222);
					FireShot(0);
				}
				ang+=9.2;
				time++;
			}
			time = 0;
			Wait(90);

			PlaySE(tan00);
			loop(40)
			{
				ascent(a in 0..4)
				{
					CreateShotA(0, GetX, GetY, 10);
					SetShotDataA(0, 0, 2, ang+90*a-10*time, 0, -0.05, 0, 222);
					SetShotDataA(0, 40, 0, NULL, 0, 0, 0, 222);
					SetShotDataA(0, 60+2*time, 0, NULL, 0, 0.02, 2, 222);
					FireShot(0);
				}
				ang-=9.2;
				time++;
			}
			time = 0;
			Wait(120);
		}
	}

	task move
	{
		loop
		{
			Wait(60);
			SetMovePosition03(rand(GetClipMinX+80, GetClipMaxX-80), rand(GetClipMinY+90, GetClipMinY+150), 10, 2);
			Wait(120);
		}
	}

	task CreateShotH(v,a,t)
	{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, GetX, GetY);
		Obj_SetSpeed(obj, v);
		Obj_SetAngle(obj, a);
		ObjShot_SetGraphic(obj, 246);
		ObjShot_SetDelay(obj, 10);
		ObjShot_SetBombResist(obj, false);
	}
}