#e
#Title[uHv]
#Text[`mB]
#ScriptVersion[2]

script_enemy_main
{
	let count=-60;
	let bg=0;
	let lv = GetCommonDataDefault("lv",2);
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SxW擾
	let no1;
	let no2;
	let answer = 0;
	while(answer<1 || answer>9)
	{
		no1=rand_int(2,9);
		no2=rand_int(1,8);
		answer = no1 - no2;
	}
	let n1 = ToString(no1);
	let n2 = ToString(no2);
	let name        = "u"~n1[0..1]~"|"~n2[0..1]~"Hv";
	if (lv==1)
	{
		no1 = rand_int(0,4);
		no2 = rand_int(1,5);
		answer=no1+no2;
		n1 = ToString(no1);
		n2 = ToString(no2);
		name        = "u"~n1[0..1]~"{"~n2[0..1]~"Hv";
	}
	let answerX;
	let answerY;
	if (answer%3==0)
	{
		answerX=3*cx*2/3;
	} else {
		answerX=answer%3*cx*2/3;
	}
	if (answer<4)
	{
		answerY=1*cy*2/3;
	} else if (answer<7) {
		answerY=2*cy*2/3;
	} else {
		answerY=3*cy*2/3;
	}
	#include_function ".\lib\lib_anime_Remilia.txt"
	let imageBoss = ".\script\wx\img\dot_cirno.png";
	@Initialize{
		CutIn(KOUMA, name, "", 0, 0, 0, 0);
		LoadGraphic(imageBoss);
		InitializeAction();
		SetLife(180);
		SetTimer(15);
		SetDamageRate(0,0);
       		SetScore(5000000);
		SetMovePosition02(cx,cy,120);
		SetAction(ACT_SPELL,120);
		PlaySE(".\script\wx\sound\enemy_powereffect.wav");
		Concentration02(300);
		SetDurableSpellCard;
		LoadGraphic("script\wx\img\bg.png");
	}
	
	@MainLoop
	{
		if (GetTimer>0 && GetTimer<12 && count%60==0)
		{
			PlaySE(".\script\wx\sound\clock.wav");
		}
		if (GetTimer==10 && count%60==0)
		{
			PlaySE(".\script\wx\sound\enemy_vanish.wav");
			//͂
			let y=0;
			loop(10)
			{
				let obj = CreateShot01(cx*2/3,y,0,0,AQUA03,60);
				ObjShot_SetBombResist(obj,true);
				y+=cy/4.5;
			}
			loop(11)
			{
				let obj = CreateShot01(cx*4/3,y,0,0,WHITE03,60);
				ObjShot_SetBombResist(obj,true);
				y-=cy/4.5;
			}
			let x=0;
			loop(10)
			{
				let obj = CreateShot01(x,cy*2/3,0,0,AQUA03,60);
				ObjShot_SetBombResist(obj,true);
				x+=cx/4.5;
			}
			loop(10)
			{
				let obj = CreateShot01(x,cy*4/3,0,0,WHITE03,60);
				ObjShot_SetBombResist(obj,true);
				x-=cx/4.5;
			}
			//1
			ObjShot_SetBombResist(CreateShot01(cx*2/3/2,cy*2/3/2,0,0,BLUE01,60),true);
			//2
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*4/9,cy*2/9*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9,cy*2/9*2,0,0,BLUE01,60),true);
			//3
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*1,cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*2,cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*3,cy*2/12*3,0,0,BLUE01,60),true);
			//4
			ObjShot_SetBombResist(CreateShot01(cx*2/9*1,cy*2/3+cy*2/9*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*2,cy*2/3+cy*2/9*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*1,cy*2/3+cy*2/9*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*2,cy*2/3+cy*2/9*2,0,0,BLUE01,60),true);
			//5
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/12*1,cy*2/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/12*3,cy*2/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/12*2,cy*2/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/12*1,cy*2/3+cy*2/12*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/12*3,cy*2/3+cy*2/12*3,0,0,BLUE01,60),true);
			//6
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/9*1,cy*2/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/9*1,cy*2/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/9*1,cy*2/3+cy*2/12*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/9*2,cy*2/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/9*2,cy*2/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/9*2,cy*2/3+cy*2/12*3,0,0,BLUE01,60),true);
			//7
			ObjShot_SetBombResist(CreateShot01(cx*2/9*1,cy*4/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*1,cy*4/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*1,cy*4/3+cy*2/12*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*2,cy*4/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*2,cy*4/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/9*2,cy*4/3+cy*2/12*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/12*2,cy*4/3+cy*2/12*2,0,0,BLUE01,60),true);
			//8
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*1,cy*4/3+cy*2/15*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*1,cy*4/3+cy*2/15*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*1,cy*4/3+cy*2/15*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*1,cy*4/3+cy*2/15*4,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*2,cy*4/3+cy*2/15*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*2,cy*4/3+cy*2/15*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*2,cy*4/3+cy*2/15*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*2/3+cx*2/9*2,cy*4/3+cy*2/15*4,0,0,BLUE01,60),true);
			//9
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*1,cy*4/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*2,cy*4/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*3,cy*4/3+cy*2/12*1,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*1,cy*4/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*2,cy*4/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*3,cy*4/3+cy*2/12*2,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*1,cy*4/3+cy*2/12*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*2,cy*4/3+cy*2/12*3,0,0,BLUE01,60),true);
			ObjShot_SetBombResist(CreateShot01(cx*4/3+cx*2/12*3,cy*4/3+cy*2/12*3,0,0,BLUE01,60),true);
		}
		if (GetTimer%2==0 && GetTimer>6 && GetTimer<14 && count%60==0)
		{
			let x=cx/3+cx*2/3*rand_int(1,2);
			let y=cy/3+cy*2/3*rand_int(1,2);
			SetMovePosition02(x,y,60);
			SetAction(ACT_MOVE,60);
		}
		if (GetTimer==6 && count%60==0)
		{
			let x=cx;
			let y=cy;
			while(!(x<answerX-cx*2/3 || x>answerX || y<answerY-cy*2/3 || y>answerY))
			{
				x=cx/3+cx*2/3*rand_int(1,2);
				y=cy/3+cy*2/3*rand_int(1,2);
			}
			SetMovePosition02(x,y,60);
			SetAction(ACT_MOVE,60);
		}
		if (GetTimer==5 && count%60==0)
		{
			PlaySE(".\script\wx\sound\enemy_vanish.wav");
			//͂
			let y=cy/9;
			loop(10)
			{
				let obj = CreateShot01(cx*2/3,y,0,0,AQUA03,60);
				ObjShot_SetBombResist(obj,true);
				y+=cy/4.5;
			}
			loop(11)
			{
				let obj = CreateShot01(cx*4/3,y,0,0,WHITE03,60);
				ObjShot_SetBombResist(obj,true);
				y-=cy/4.5;
			}
			let x=cx/9;
			loop(10)
			{
				let obj = CreateShot01(x,cy*2/3,0,0,AQUA03,60);
				ObjShot_SetBombResist(obj,true);
				x+=cx/4.5;
			}
			loop(11)
			{
				let obj = CreateShot01(x,cy*4/3,0,0,WHITE03,60);
				ObjShot_SetBombResist(obj,true);
				x-=cx/4.5;
			}
		}
		if (GetTimer<3)
		{
			PlaySE(".\script\wx\sound\shot1.wav");
			PlaySE(".\script\wx\sound\enemy_damage.wav");
			AddLife(-1);
			loop(3)
			{
				let x=rand(32,cx*2-32);
				let y=rand(32,cy*2-32);
				while(!(x<answerX-cx*2/3 || x>answerX || y<answerY-cy*2/3 || y>answerY))
				{
					x=rand(32,cx*2-32);
					y=rand(32,cy*2-32);
				}
				CreateShot01(x,y,0,0,BLUE03,30);
			}
		}
		if (GetTimer<3 && count%60==0)
		{
			CreateShot01(GetX,GetY,0,0,BLUE03,60);
		}
		count++;

		SetCollisionB(GetX(),GetY(),12);//蔻(̓)o^
		yield;
	}
	@DrawLoop{DrawBoss( imageBoss);}
	@BackGround{SetTexture("script\wx\img\bg.png");SetAlpha(64);SetGraphicRect(bg,bg,cx*2+bg,cy*2+bg);bg++;DrawGraphic(cx,cy);SetGraphicRect(-bg,-bg,cx*2-bg,cy*2-bg);DrawGraphic(cx,cy);SetGraphicRect(bg,-bg,cx*2+bg,cy*2-bg);DrawGraphic(cx,cy);SetGraphicRect(-bg,bg,cx*2-bg,cy*2+bg);DrawGraphic(cx,cy);}
	function getAngleToPlayer(x, y)
	{
  		return atan2(GetPlayerY - y, GetPlayerX - x);
 	}	
	@Finalize
	{//ǂ݂񂾃t@C폜
		loop(16){CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));}
	}
	
}