script_enemy_main
{
	#include_function ".\System\CommonFunctions.dnh"
	#include_function ".\System\EnemyFunctions.dnh"
	let frame = 0;
	SetLife(6000);
	MaxLife = 6000;
	warping = true;
	xscale = 0;
	yscale = 10;
	let speed1 = 2;
	let speed2 = 1.5;
	@Initialize
	{
		Init;
		SetMovePosition02(GetCenterX, GetClipMinY + 100, 1);
		if(GetPlayerType != REIMU_A){
			SetDamageRate(500, 500);
		} else {
			SetDamageRate(250, 250);
		}
		MagicCircle(false);
		SetEnemyMarker(true);
	}
	
	@MainLoop
	{
		if(frame == 60)
		{
			warping = false;
		}
		if(frame == 120)
		{
			FireTask;
		}
		
		if(xscale > 0.1){
			SetCollisionA(GetX, GetY, 24);
			SetCollisionB(GetX, GetY, 12);
		}
		
		CheckForDamage;
		PlayTimerSound;
		frame ++;
		yield;
	}
	
	@DrawLoop
	{
		DrawLilyWhite;
	}
	
	@Finalize
	{
		Final;
	}
	
	function FireBullets(let bulletX, let bulletY, let speed, let ang, let col1, let col2)
	{
		CreateShot01(bulletX - 12*cos(ang), bulletY - 12*sin(ang), speed, ang, col2, 10);
		CreateShot01(bulletX - 6*cos(ang), bulletY -6*sin(ang), speed, ang, col2, 10);
		CreateShot01(bulletX, bulletY, speed, ang, col1, 10);
	}
	
	task FireTask
	{
		Concentration01(60);
		PlaySE(charge);
		loop(60)
		{
			yield;
		}
		warping = true;
		loop(60)
		{
			yield;
		}
		warping = false;
		SetX(rand(GetClipMinX + 60, GetClipMaxX - 60));
		SetY(GetClipMaxY+40);
		shooting = true;
		
		let firingangle = 130;
		let firecount = 0;
		let speed = 0;
		loop(30)
		{
			yield;
		}
		SetMovePosition02(GetX, GetClipMinY + 60, 55*3);
		while(firecount < 55)
		{
			if(firecount % 2 == 0)
			{
				speed = speed1;
			} else 
			{
				speed = speed2;
			}
			FireBullets(GetX + 5*cos(firingangle), GetY + 5*sin(firingangle), speed, 90+firingangle, BLUE04, BLUE05);
			CreateShot01(GetX, GetY, 2, firingangle + 270, BLUE22, 0);
			firingangle *= -1;
			FireBullets(GetX + 5*cos(firingangle), GetY + 5*sin(firingangle), speed, 90+firingangle, RED04, RED05);
			CreateShot01(GetX, GetY, 2, firingangle + 270, RED22, 0);
			firingangle *= -1;
			firingangle -= 15;
			PlaySE(shot1);
			PlaySE(wave);
			loop(3)
			{
				yield;
			}
			firecount ++;
		}
		shooting = false;
		if(decreasecount < maxdecreasecount)
		{
			decreasecount ++;
			delaydecrease += decreasestep;
		}
		loop(115-delaydecrease)
		{
			yield;
		}
		FireTask;
	}
}