
script_enemy_main
{
	let count=0;
	let attack=0;
	let N15=0;
	let imgEx=GetCurrentScriptDirectory~"img\ExUtuho.png";
	let imgNu =GetCurrentScriptDirectory~"effect\NuclearSpark.png";
	let imgNuR=GetCurrentScriptDirectory~"effect\NuclearRing3.png";
	let imgNuc=GetCurrentScriptDirectory~"effect\NuclearWave2.png";
	let sh00=GetCurrentScriptDirectory~"\se\Shot00.wav";
	let Beem=GetCurrentScriptDirectory~"\se\Laser.wav";
	let Baaa=GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav";
	let P=GetCurrentScriptDirectory~"\se\push.wav";
	@Initialize
	{
		SetScore(5000000);
		SetLife(500);
		SetGraphicRect(0,0,128,128);
		SetDamageRate(8,4);
		SetTimer(85);
		SetShotAutoDeleteClip(128,128,128,128);
		SetInvincibility(120);
		LoadUserShotData(GetCurrentScriptDirectory~".\UtuhoShotData.txt");
		LoadGraphic(imgEx);
		SetMovePosition02(GetCenterX(),145,160);
		CutIn(YOUMU,"jMuj[NAt[WUv",0,0,0,0,0);
	}

	@MainLoop
	{
		if (count%700==120) {
			SetColor(255,255,128);
			Concentration01(105);
		}
		if (count>120) {
			attack=0;
			if (count%700>=180&&count%700<=680) {
				attack=1;
			}if (count%700==180) {
				attack=1;
				PlaySE(P);
			}
		}
		if (count%700==270) {
			PlaySE(Baaa);
			ascent(let t in 0..6) {
				CreateShot02(GetX(),GetY()-58,0,count+55+t*60+rand(-15,15),0.005,0.6,4,0);
			}
			ascent( let t in 0..6 ) {
				CreateShotA(N15,GetX(),GetY()-58,0);
				SetShotDataA(N15,0,0,count+25+t*60,0,0.01,1.1,4);
				SetShotDataA(N15,110,NULL,NULL,rand(-0.1,0.1),0.01,1.1,4);
				FireShot(N15);
			}
			ascent( let t in 0..6 ) {
				CreateShotA(N15,GetX(),GetY()-58,0);
				SetShotDataA(N15,0,-0.1,count+55+t*60+rand(0,-2),0,0.03,1.5,4);
				SetShotDataA(N15,95,NULL,NULL,rand(-0.1,0.1),0.02,1.5,4);
				FireShot(N15);
			}
		}
		if (count%700>=350&&count%700<=650&&count%2==0) {
			PlaySE(sh00);
			ascent(let t in 0..6) {
				CreateShot02(GetX(),GetY()-50,5,count*4+t*60,-0.2,1.8,ORANGE01,22);
			}
		}
		if (count%700>=350&&count%700<=650&&count%21==0) {
			PlaySE(sh00);
			ascent(let t in 0..6) {
				CreateShot02(GetX(),GetY()-50,5,count*4+t*60+rand(-12,12),-0.2,2.5,ORANGE02,22);
			}
		}
		if (count>120&&count%700==0)
		{
			SetMovePositionRandom01(85,4,5,GetClipMinX()+100,130,GetClipMaxX()-100,150);
		}
		SetCollisionA(GetX(),GetY(),35);
		SetCollisionB(GetX(),GetY(),15);
		count++;
	}


	@Finalize
	{
		LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");
		loop(40)
		{
			CreateItem(ITEM_SCORE,GetX()+rand(-65,65),GetY()+rand(-20,60));
		}
		CreateItem(ITEM_1UP,GetX(),GetY()+20);
		SetShotAutoDeleteClip(32,32,32,32);
	}

	@DrawLoop
	{
		SetTexture(imgEx);
		SetColor(255,255,255);
		SetAlpha(255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetRenderState(ALPHA);
		if (int(GetSpeedX())==0&&count/22%4==0) {
			SetGraphicRect(0,0,128,128);
		}
		if (int(GetSpeedX())==0&&count/22%4==1) {
			SetGraphicRect(0,128,128,256);
		}
		if (int(GetSpeedX())==0&&count/22%4==2) {
			SetGraphicRect(0,256,128,384);
		}
		if (int(GetSpeedX())==0&&count/22%4==3) {
			SetGraphicRect(128,128,256,256);
		}
		if (int(GetSpeedX())==0&&attack>0) {
			SetGraphicRect(128,0,256,128);
		}
		else if (GetSpeedX()>0) {
			SetGraphicRect(384,256,512,384);
		}
		else if (GetSpeedX()<0) {
			SetGraphicRect(256,256,384,384);
		}
		DrawGraphic(GetX(),GetY());

		if (count%700>=200&&count%700<=280&&GetEnemyLife()>0)
		{

			SetTexture(imgNu);
			SetColor(255,255,255);
			SetRenderState(ADD);
			SetGraphicAngle(0,0,-35*count);
			SetGraphicRect(0,0,256,256);
			if (count%700>=200&&count%700<=210) {
				SetGraphicScale(int((count%700)-200)*0.042,int((count%700)-200)*0.042);
			}
			if (count%700>=210&&count%700<=360) {
				SetGraphicScale(0.32+int(count%5)*0.04,0.32+int(count%5)*0.04);
			}
			DrawGraphic(GetX()+2,GetY()-55);
		}

		if (count%700>=190&&count%700<=277&&GetEnemyLife()>0)
		{

			SetTexture(imgNuR);
			SetColor(255,255-rand(-200,0),73);
			SetRenderState(ADD);
			SetGraphicAngle(0,0,80*count);
			SetGraphicRect(0,0,128,128);
			if (count%700>=190&&count%700<=210) {
				SetGraphicScale(int((count%700)-190)*0.13,int((count%700)-190)*0.12);
			}
			if (count%700>=210&&count%700<=360) {
				SetGraphicScale(2.8+int(count%3)*0.22,2.5+int(count%3)*0.21);
			}
			DrawGraphic(GetX()+2,GetY()-52);
		}

		if (count%700>=268&&count%700<=450&&GetEnemyLife()>0)
		{
			if (count%700==268) {
				SetGraphicAngle(0,0,225);
			}

			SetTexture(imgNuc);
			SetRenderState(ADD);
			SetGraphicRect(0,0,256,256);
			if (count%700>=268&&count%700<=296) {
				SetColor(255,255,255);
				SetGraphicScale(int((count%700)-268)*0.12,int((count%700)-268)*0.12);
			}
			if (count%700>296&&count%700<=450) {
				if (255-int((count%700)-296)*2>0) {
					SetColor(255-int((count%700)-296)*2,255-int((count%700)-296)*2,255-int((count%700)-296)*2);
				}else {
					SetColor(0,0,0);
				}
				SetGraphicScale(3.5+int((count%700)-296)*0.006,3.5+int((count%700)-296)*0.006);
			}
			DrawGraphic(GetX()-12,GetY()-45);
		}

	}
}
