script_enemy_main
{

	//Oh god it's so nice to be able to use comments again
	let frame = 0;
	let attack = false;
	
	//DEFINE DEM IMAGES
	let bkg = GetCurrentScriptDirectory ~ "c6/enem1bg1.png";
	let boss = GetCurrentScriptDirectory ~ "c6/enem1.png";
	
    @Initialize
	{
		LoadUserShotData(GetCurrentScriptDirectory ~ "c6/c6shots.txt");
		LoadGraphic(bkg);
		LoadGraphic(boss);
		
		SetLife(4000);
		SetTimer(90);
		SetScore(100000);
		SetInvincibility(180);
		SetDamageRate(90, 50);
		//MagicCircle(false);
		CutIn(KOUMA, "Autumn Harvest", bkg, 0, 0, 0, 0);
		
		SetMovePosition02(-10, -10, 0);
		
		intro;
    }

    @MainLoop
	{
		SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
		
		frame++;
		yield;
    }

    @DrawLoop
	{
		//Background
		SetAlpha(255);
		SetTexture(bkg);
		SetGraphicRect(0, 0, 1024, 1024);
		SetColor(255, 100, 100);
		SetGraphicScale(0.5, 0.5);
		DrawGraphic(GetCenterX, GetCenterY);
		
		SetTexture(bkg);
		SetGraphicScale(1, 1);
		SetColor(255, 255, 255);
		SetGraphicRect(0, 0, 512, 512+frame);
		SetAlpha(50);
		DrawGraphic(GetCenterX, GetCenterY);
		
		SetTexture(boss);
		SetAlpha(255);
		
		//Minoriko
		if(!attack)
		{
			if(GetSpeedX<-0.2 && GetSpeedX>=-1){
				SetGraphicRect(128, 191, 191, 255);
				SetGraphicAngle(180, 0, 0);
			}
			else if(GetSpeedX<-1){
				SetGraphicRect(64, 191, 128, 255);
				SetGraphicAngle(180, 0, 0);
			}
			else if(GetSpeedX>0.2 && GetSpeedX<=1){
				SetGraphicRect(128, 191, 191, 255);
				SetGraphicAngle(0, 0, 0);
			}
			else if(GetSpeedX>1){
				SetGraphicRect(64, 191, 128, 255);
				SetGraphicAngle(0, 0, 0);
			}
			else{SetGraphicRect(0, 128, 63, 191);}
		}
		else{SetGraphicRect(128, 128, 191, 191);}
		
		DrawGraphic(GetX,GetY+5*cos(frame*2));
    }

    @Finalize
	{
		FadeOutMusic(GetCurrentScriptDirectory ~ "bgm/1.mp3", 20);
    }
	
	function Wait(frames){loop(frames){yield;}}
	
	task intro
	{
		Wait(10);
		SetMovePosition03(GetCenterX, GetCenterY - 120, 15, 5);
		Wait(60);
		loop
		{
			Concentration01(90);
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_ch00.wav");
			Wait(90);
			attack = true;
			let r = rand(40,60);
			let f = 0;

			ascent(i in 0..50)
			{
				ascent(j in -2..2)
				{
					CreateShotA(0, GetCenterX + r + j*100 + 7*cos(f*10+r), 490 - i*8, 20);
					SetShotDataA(0, 0, 0, 90, 0, 0, 0, 24);
					SetShotDataA(0, 210, 1, r + i*10, 0, 0.01, 3, 20);
					FireShot(0);
					CreateShotA(1, GetCenterX + r + j*100 + 7*cos(f*10+r) + 3, 490 - i*8, 20);
					SetShotDataA(1, 0, 0, 90, 0, 0, 0, 24);
					SetShotDataA(1, 210, 1, r + i*8, 0, 0.01, 3, 20);
					FireShot(1);
					PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
				}
				f++;
				Wait(3);
			}
			
			ascent(j in -2..2)
			{
				CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)+1, 90, 30);
				SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(2);
				CreateShotA(3, GetCenterX + r + j*100 + 7*cos(f*10)+1, 90, 30);
				SetShotDataA(3, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(3, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(3);
			}
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
			Wait(3);
			ascent(j in -2..2)
			{
				CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)-3, 87, 30);
				SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(2);
				CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)+4, 87, 30);
				SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(2);
			}
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
			Wait(3);
			ascent(i in 1..9)
			{
				ascent(j in -2..2)
				{
					CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)-4, 87 - 4*i, 30);
					SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
					SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
					FireShot(2);
					CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)+1, 87 - 4*i, 30);
					SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
					SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
					FireShot(2);
					CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)+5, 87 - 4*i, 30);
					SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
					SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
					FireShot(2);
				}
				PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
				Wait(3);
			}
			ascent(j in -2..2)
			{
				CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)-3, 87 - 4*9, 30);
				SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(2);
				CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)+4, 87 - 4*9, 30);
				SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(2);
			}
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
			Wait(3);
			ascent(j in -2..2)
			{
				CreateShotA(2, GetCenterX + r + j*100 + 7*cos(f*10)+1, 87 - 4*10, 30);
				SetShotDataA(2, 0, 0, 90, 0, 0, 0, 3);
				SetShotDataA(2, 60, rand(1,2), rand(0,360), 0, 0.02, rand(1.5,3), 41);
				FireShot(2);
			}
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_kira00.wav");
			
			ascent(l in 0..36){CreateShot02(GetX, GetY, 10, GetAngleToPlayer+l*360/36, -1, 2, 33, 10);}
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_tan00.wav");
			Wait(15);
			ascent(l in 0..36){CreateShot02(GetX, GetY, 10, GetAngleToPlayer+l*360/36, -1, 2, 33, 10);}
			PlaySE(GetCurrentScriptDirectory ~ "sfx/se_tan00.wav");
			
			attack = false;
			SetMovePositionRandom01(rand(-80,80),rand(30,60), 3, 140,100, 300,GetCenterY-100);
			Wait(120);
		}
		
	}
}