#e
#Title[`Last Spell`]
#Text[]
#Image[]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let count2=0;
	let attack=0;
	let MT=0;
	let N15=0;
	let mm=0;
	let mm2=30;
	let mm3=0;
	let mm4=0;
	let cx=GetCenterX();
	let img=GetCurrentScriptDirectory~"img\ExUtuho.png";
	let img2=GetCurrentScriptDirectory~"effect\NuclearRing6.png";
	@Initialize
	{
		SetScore(80000000);
		SetNormPoint(-1);
		SetLife(5489);
		SetTimer(120);
		SetInvincibility(120);
		LoadGraphic(img);
		LoadGraphic(img2);
		SetShotAutoDeleteClip(150,150,150,150);
		SetEffectForZeroLife(440,193,1);
		SetMovePosition02(cx,GetCenterY()-8,120);
		DeleteEnemyShot(ALL);
		SetDamageRate(32,0);
		MagicCircle(false);
		SetRateScoreSystemEnable(false);
		LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");
		CutIn(YOUMU,"`Last Spell`uIcJCjATv",0,0,0,0,0);
	}

	@MainLoop
	{
		attack=1;
		if (count%5==0&&mm<mm2)
		{
			mm++;
		}

		if (count%10==0&&mm3<mm4)
		{
			mm3+=0.001;
		}

		if (count==0||count==180)
		{
			PlaySE(GetCurrentScriptDirectory~"\se\push02.wav");
			SetColor(255,32,32);
			Concentration01(320-count);
		}

		if (count==120)
		{
			PlaySE(GetCurrentScriptDirectory~"\se\push.wav");
			SetColor(255,32,32);
			Concentration01(200);
		}

		if (count==720-100||count==1350-100||count==2000-120||count==2800-150)
		{
			PlaySE(GetCurrentScriptDirectory~"\se\push.wav");
		}

		if (count==300||count==720||count==1350||count==2000||count==2800)
		{
			PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
			mm2+=13;
			mm4+=0.06;
		}

		if (count>=360&&count<=1350) {
			if (count%4==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
				ascent( let t in 0..4 ) {
					CreateShot01(GetX()+mm*cos(count+t*90),GetY()+mm*sin(count+t*90),0.6+mm3,count+t*90+rand(-9,9),196,10);
				}
			}
		}

		if (count>1350&&count<=2800) {
			if (count%3==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
				ascent( let t in 0..4 ) {
					CreateShot01(GetX()+mm*cos(count+t*90),GetY()+mm*sin(count+t*90),0.6+mm3,count+t*90+rand(-9,9),196,10);
				}
			}
		}

		if (count>2800) {
			if (count%3==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
				ascent( let t in 0..4 ) {
					CreateShot01(GetX()+mm*cos(count+t*90),GetY()+mm*sin(count+t*90),0.6+mm3,count+t*90+rand(-9,9),196,10);
				}
			}
		}

		if (count>=300&&count<=720) {
			SetPlayerX(GetPlayerX()+((GetX()-GetPlayerX())/270));
			SetPlayerY(GetPlayerY()+((GetY()-GetPlayerY())/270));
			if (count%45==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
				ascent( let t in 0..12 ) {
					CreateShot01(GetX()+320*cos(count+t*30),GetY()+320*sin(count+t*30),-1,count+t*30,49,20);
				}
			}
		}

		if (count>720&&count<=1350) {
			SetPlayerX(GetPlayerX()+((GetX()-GetPlayerX())/186));
			SetPlayerY(GetPlayerY()+((GetY()-GetPlayerY())/186));
			if (count%45==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
				ascent( let t in 0..12 ) {
					CreateShot01(GetX()+320*cos(count+t*30),GetY()+320*sin(count+t*30),-1.2,count+t*30,49,20);
				}
			}
		}

		if (count>1350&&count<=2000) {
			SetPlayerX(GetPlayerX()+((GetX()-GetPlayerX())/150));
			SetPlayerY(GetPlayerY()+((GetY()-GetPlayerY())/150));
			if (count%45==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
				ascent( let t in 0..12 ) {
					CreateShot01(GetX()+320*cos(count+t*30),GetY()+320*sin(count+t*30),-1.4,count+t*30,49,20);
				}
			}
		}

		if (count>2000&&count<=2800) {
			SetPlayerX(GetPlayerX()+((GetX()-GetPlayerX())/120));
			SetPlayerY(GetPlayerY()+((GetY()-GetPlayerY())/120));
			if (count%45==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
				ascent( let t in 0..12 ) {
					CreateShot01(GetX()+320*cos(count+t*30),GetY()+320*sin(count+t*30),-1.6,count+t*30,49,20);
				}
			}
		}

		if (count>2800&&count<=5400) {
			SetDamageRate(34,0);
			SetPlayerX(GetPlayerX()+((GetX()-GetPlayerX())/80));
			SetPlayerY(GetPlayerY()+((GetY()-GetPlayerY())/80));
			if (count%45==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
				ascent( let t in 0..12 ) {
					CreateShot01(GetX()+320*cos(count+t*30),GetY()+320*sin(count+t*30),-1.8,count+t*30,49,20);
				}
			}
		}

		if (count>4200&&count<=5400) {
			SetDamageRate(38,0);
		}

		if (count==5400) {
			PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
			mm2+=70;
			mm4+=0.8;
		}

		if (count>5400) {
			SetPlayerX(GetPlayerX()+((GetX()-GetPlayerX())/30));
			SetPlayerY(GetPlayerY()+((GetY()-GetPlayerY())/30));
			if (count%6==0) {
				PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
			}
			if (count%12==0) {
				ascent( let t in 0..12 ) {
					CreateShot01(GetX()+320*cos(count+t*30),GetY()+320*sin(count+t*30),-2.5,count+t*30,49,20);
				}
			}
		}

		if (count<300)
		{
			SetCollisionA(GetX(),GetY()-5,14);
		}

		if (count>=300)
		{
			SetCollisionA(GetX(),GetY()-5,mm-5);
			SetCollisionB(GetX(),GetY()+12,mm-5);
		}

		DeleteEnemyShotInCircle(SHOT,GetX(),GetY(),mm-20);

		if (GetEnemyLife<=0&&MT==0) {
			SetPlayerInvincibility(445);
			MT++;
			count=5220;
			return;
		}

		if (count>=300&&GetEnemyLife>0&&count%90==0) {
			PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
		}
		if (GetEnemyLife<=0&&count%20==0) {
			PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
		}
		if (GetEnemyLife<=0&&count%45==0) {
			PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
		}

		count++;
		count2++;
	}


	@Finalize
	{
		DeleteGraphic(img);
		DeleteGraphic(img2);
		SetShotAutoDeleteClip(32,32,32,32);
	}

	@DrawLoop
	{
		SetTexture(img);
		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());

		SetTexture(img2);
		SetRenderState(ADD);
		SetGraphicRect(0,0,512,512);
		if (count>=300&&count<360) {
			SetGraphicScale((count-300)*0.005,(count-300)*0.005);
			DrawGraphic(GetX(),GetY());
		}
		if (count>=360) {
			SetGraphicScale((360-300)*0.005+(mm-40)*0.0058,(360-300)*0.005+(mm-40)*0.0058);
			DrawGraphic(GetX(),GetY());
		}


	}
}
