script_enemy_main
{
	#include_function ".\func.txt"

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

	let kira01 = gcsd~"se007.wav";

	let alpha = 0;

	@Initialize
	{
		Init(0, 100, 100, 0, 60, true, false, false, 0, false, false);
		SetLife(1800);

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

		MainTask;
		Event("dani");

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

	@MainLoop
	{
		if(OnEvent==false){SetCollision(GetX, GetY, 24);}

		yield;
	}

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

		SetTexture(name);
		SetAlpha(alpha);
		SetGraphicRect(0, 0, 150, 30);
		SetGraphicScale(1, 1);
		DrawGraphic(GetClipMinX+75, GetClipMinY+30);
	}

	@Finalize
	{
	}

	task MainTask
	{
		Wait(120);
		while(OnEvent==true){yield;}
		CreateEnemyFromFile(gcsd~"bgm.txt", 0, 0, 0, 0, gcsd~"menu406.png");
		nameTask;
		SetTimer(45);
		Wait(60);
		move;
		attack;
	}

	task nameTask
	{
		loop(30)
		{
			alpha+=(255/30);
			yield;
		}
	}

	task attack
	{
		loop
		{
			PlaySE(kira01);
			CreateShotA(0, GetX-80, GetY, 10);
			SetShotDataA(0, 0, 3, GetAngleToPlayer+5, 0, 0, 0, 247);
			ascent(t in 0..30)
			{
				CreateShotA(1, 0, 0, 0);
				SetShotDataA(1, 0, 0, GetAngleToPlayer+t*36, 0, 0.01, 1, 41);
				AddShot(t*4, 0, 1, 0);
			}
			FireShot(0);

			CreateShotA(0, GetX+80, GetY, 10);
			SetShotDataA(0, 0, 3, GetAngleToPlayer-5, 0, 0, 0, 248);
			ascent(t in 0..30)
			{
				CreateShotA(1, 0, 0, 0);
				SetShotDataA(1, 0, 0, GetAngleToPlayer+t*36, 0, 0.01, 1, 45);
				AddShot(t*4, 0, 1, 0);
			}
			FireShot(0);
			
			Wait(240);
		}
	}

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

script_event dani
{
	let gcsd = GetCurrentScriptDirectory;
	let boss = gcsd~"006.mp3";

	@Initialize
	{
		LoadMusic(boss);
	}

	@MainLoop
	{
		if(GetPlayerScriptName == "patchy.txt")
		{
			TextOut("\c[RED]Aah, please stop`");
			TextOut("\c[BLUE]It's the strange person again.");
			SetNameFromText(RIGHT, TEXT_RED, "Danielle Post", "Western Shrine Maiden");
			TextOut("\c[RED]How rude! The only strange person \naround here is you.");
			TextOut("\c[BLUE]I assume you know where I can find \nthe source of the magical energy \nthat has been distorting this place?");
			TextOut("\c[RED]Don't change the subject. \nAnd yes, I do know where to find it.");
			DeleteName(RIGHT);
			TextOut("\c[BLUE]But you won't tell me. Well then...");
			TextOut("\c[RED]A youkai in the back garden. \nThat must be a bad omen.");
			TextOut("\c[BLUE]No it isn't.");
			PlayMusic(boss);
			TextOut("\c[RED]You are looking for senpai. \nI can't let you meet her now.");
			TextOut("\c[BLUE]Because I would disrupt your plans?");
			TextOut("\c[RED]No! Senpai is very fickle. \nIt's for your own safety.");
		}
		else if(GetPlayerScriptName == "keine.txt")
		{
			TextOut("\c[RED]Aah, please stop`");
			TextOut("\c[BLUE]Finally I found you! Stop right there!");
			SetNameFromText(RIGHT, TEXT_RED, "Danielle Post", "Western Shrine Maiden");
			TextOut("\c[RED]Exactly! You won't escape this time!");
			TextOut("\c[BLUE]Don't think you can get away from me!");
			DeleteName(RIGHT);
			TextOut("\c[RED]...Wait, what?");
			TextOut("\c[BLUE]You won't be running away then? \nAll the easier.");
			PlayMusic(boss);
			TextOut("\c[RED]Oh please, I'll show you how to use \nshooting battle super magic!");
			TextOut("\c[BLUE]It's called danmaku!");
			TextOut("\c[RED]Danmaku, is it? All the same to me. \nLeave this instant!");
			TextOut("\c[BLUE]I wasn't supposed to escape, was I?");
		}
		else{RaiseError("The player type chosen cannot be used in this script.", "Invalid Player Type");}

		LoadCommonDataEx("MusicUnlock", gcsd~"DATA/MENU/MUSIC.dat");
		SetCommonDataEx("MusicUnlock", "Music06", 1);
		SaveCommonDataEx("MusicUnlock", gcsd~"DATA/MENU/MUSIC.dat");

		End;
	}

	@Finalize
	{
	}
}