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";

	let alpha = 0;

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

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

		MainTask;
		Event("melle");

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

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

	@Finalize
	{
	}

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

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

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

		loop
		{
			PlaySE(tan00);
			loop(25)
			{
				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, 41+2*time, 0, NULL, 0, 0.02, 2, 222);
					FireShot(0);
				}
				ang+=8.5;
				time++;
			}
			time = 0;
			Wait(90);

			PlaySE(tan00);
			loop(25)
			{
				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, 41+2*time, 0, NULL, 0, 0.02, 2, 222);
					FireShot(0);
				}
				ang-=8.5;
				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);
	}
}

script_event melle
{
	let gcsd = GetCurrentScriptDirectory;
	let boss = gcsd~"004.mp3";

	@Initialize
	{
		LoadMusic(boss);
	}

	@MainLoop
	{
		if(GetPlayerScriptName == "patchy.txt")
		{
			TextOut("\c[BLUE]When does this hallway end?");
			TextOut("\c[RED]It shall end with you.");
			TextOut("\c[BLUE]I didn't notice you there. \nYou nearly startled me.");
			SetNameFromText(RIGHT, TEXT_RED, "Melle van Schaik", "Silent Girl of the Sky");
			TextOut("\c[RED]This will not do... What now?");
			TextOut("\c[BLUE]I'll beat you and find the source of \nmagical energy.");
			DeleteName(RIGHT);
			TextOut("\c[RED]That magic source is here. \nI'll take you there.");
			TextOut("\c[BLUE]Where is it?");
			TextOut("\c[RED]Just leave through that door \nover there.");
			TextOut("\c[BLUE]So there was a door all along.");
			TextOut("\c[RED]However...");
			PlayMusic(boss);
			TextOut("\c[RED]That girl wouldn't want you there.");
		}
		else if(GetPlayerScriptName == "keine.txt")
		{
			TextOut("\c[RED]Long time no see.");
			TextOut("\c[BLUE]Have we met before?");
			SetNameFromText(RIGHT, TEXT_RED, "Melle van Schaik", "Silent Girl of the Sky");
			TextOut("\c[RED]Probably not.");
			TextOut("\c[BLUE]I would know if we had.");
			DeleteName(RIGHT);
			TextOut("\c[RED]I guess. Pleased to meet you then.");
			TextOut("\c[BLUE]What is this place? It looks like a \nschool building.");
			TextOut("\c[RED]Well, you would know.");
			TextOut("\c[BLUE]Such a troublesome person.");
			PlayMusic(boss);
			TextOut("\c[RED]Time to say farewell. Don't take this \npersonally.");
		}
		else{RaiseError("The player type chosen cannot be used in this script.", "Invalid Player Type");}

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

		End;
	}

	@Finalize
	{
	}
}