#TouhouDanmakufu
#Title[Bernkastel Nonspell 1]
#Text[]
#BackGround[User(".\img\cathedral.png", 0, 0)]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let gd = GetCurrentScriptDirectory;
	let bgm = gd~"FinalAnswer.mp3";
	let shot = gd~"lib\supershot.txt";
	let enemy = gd~"img\bern.png";


	@Initialize
	{
		SetLife(3000);
		SetTimer(60);
		SetMovePosition02(GetCenterX, GetCenterY-120, 90);
		LoadUserShotData(shot);
		SetInvincibility(120);

		main;

		LoadMusic(bgm);
		LoadGraphic(enemy);
		PlayMusic(bgm);
	}

	@MainLoop
	{
		SetCollisionA(GetX, GetY, 64);
		SetCollisionB(GetX, GetY, 48);

		yield;
	}

	@DrawLoop
	{
		SetTexture(enemy);
		SetGraphicRect(0, 0, 191, 480);
		SetGraphicScale(0.2, 0.2);
		DrawGraphic(GetX, GetY);
	}

	@Finalize
	{
	}

	task main
	{
		loop(120){yield;}
		shoot;
		move;
	}

	task shoot
	{
		loop
		{
			ascent(r in 0..24)
			{
				ascent(a in 0..8)
				{
					CreateShotA(0, GetX, GetY, 10);
					SetShotDataA(0, 0, 2.5, a*45+60*sin(r*15), 0, -0.02, 0, 102);
					SetShotDataA(0, 140, 0, NULL, -0.1*cos(r*15), 0.02, 1, 102);
					FireShot(0);

					CreateShotA(0, GetX, GetY, 10);
					SetShotDataA(0, 0, 2, a*45-60*sin(r*15), 0, -0.02, 0, 102);
					SetShotDataA(0, 130, 0, NULL, -0.1*cos(r*15), 0.02, 1, 102);
					FireShot(0);

					CreateShotA(0, GetX, GetY, 10);
					SetShotDataA(0, 0, 1.5, a*45-60*sin(r*15), 0, -0.02, 0, 103);
					SetShotDataA(0, 120, 0, NULL, -0.1*cos(r*15), 0.02, 1, 103);
					FireShot(0);
				}
				loop(2){yield;}
			}
			loop(120){yield;}
		}
	}

	task move
	{
		loop
		{
			loop(240){yield;}
			SetMovePositionRandom01(rand(80, 100), rand(20, 50), 1, GetClipMinX+100, GetClipMinY+100, GetClipMaxX-100, GetCenterY-50);
		}
	}
}