script_enemy_main
{
	#include_function ".\func.txt"


	let gcsd = GetCurrentScriptDirectory;
	let boss = gcsd~"b04.png";
	let back = gcsd~"03b.png";
	let name = gcsd~"nm4.png";

	let cardget = gcsd~"se001.wav";
	let kira00 = gcsd~"se002.wav";

	let spell = gcsd~"03s.png";
	let backalpha = 0;

	@Initialize
	{
		Init(800, 25, 20, 40, 240, true, true, true, 600, false, false);
		SetLife(500);

		LoadUserShotData(gcsd~"supershot.txt");
		SetMovePosition03(GetCenterX, GetClipMinY+120, 10, 5);
		CutIn(YOUMU, "Calming Song uBlue Lullabyv -Easy-", "", 0, 0, 0, 0);

		MainTask;

		LoadGraphic(boss);
		LoadGraphic(name);
		LoadGraphic(back);
		LoadGraphic(spell);
		LoadSE(cardget);
		LoadSE(kira00);
	}

	@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, 150, 30);
		SetGraphicScale(1, 1);
		DrawGraphic(GetClipMinX+75, GetClipMinY+30);
	}

	@BackGround
	{
		if(backalpha<255){backalpha+=5;}

		SetTexture(back);
		SetGraphicRect(0, 0, 640, 640);
		SetGraphicScale(1, 1);
		SetAlpha(255);
		DrawGraphic(GetCenterX, GetCenterY);

		SetTexture(spell);
		SetGraphicRect(0, 0, 640, 640);
		SetGraphicScale(1, 1);
		SetAlpha(backalpha);
		DrawGraphic(GetCenterX, GetCenterY);

		let string = "" ~ ToString(GetGraze);
     		let number = 0;
     		let graze = "";
      		while(number < length(string) && string[number] != '.')
		{
             			graze = graze ~ ToString(string[number]);
             			number++;
      		}
		let str = "Graze: " ~ graze ~ "/750";

		if(GetGraze<750){SetFontColor(0, 0, 255, 0, 0, 255);}
		else{SetFontColor(0, 200, 0, 0, 200, 0);}
		DrawText(str, GetClipMinX+8, GetClipMaxY-32, 12, 255);
		SetFontColor(255, 255, 255, 255, 255, 255);
	}

	@Finalize
	{
		if(GotSpellCardBonus)
		{
			PlaySE(cardget);
		}
	}

	task MainTask
	{
		Wait(120);
		//move;
		attack;
		attack2;
	}

	task attack
	{
		let ang = 0;

		loop
		{
			CreateShotA(0, GetX, GetY, 10);
			SetShotDataA(0, 0, 1, GetAngleToPlayer, 0, 0, 0, 15);
			loop(256)
			{
				CreateShotA(1, 0, 0, 0);
				SetShotDataA(1, 0, rand(0.1, 2), GetAngleToPlayer+rand(16, 346), 0, 0, 0, 15);
				AddShot(60, 0, 1, 0);
			}
			SetShotDataA(0, 60, -1, NULL, 0, 0, 0, 15);
			FireShot(0);
			Wait(70);
			PlaySE(kira00);
			Wait(50);
		}
	}

	task attack2
	{
		loop
		{
			CreateLaserA(0, GetX, GetY, 400, 32, 15, 90);
			SetLaserDataA(0, 0, GetAngleToPlayer, 0, 0, 0, 0);
			SetShotKillTime(0, 240);
			FireShot(0);
			Wait(300);
		}
	}

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