script_enemy_main {
	#include_function ".\..\ShotSheet\shot_replace.dnh"
	#include_function ".\..\functions.txt"
	#include_function ".\..\s3\y_functions.txt"

	SpellID=66;

	let i=0;
	let frame=0;

    @Initialize {
	StartFunctions(1,0,0);
	Randomize;
        SetLife(3000);
        SetTimer2(45);
	SetDamageRate(100,100);
	MagicCircle(false);
	SetEnemyMarker(true);
	SetBG(5);
	YukariInit;

	shotinit;

	CutIn2(5,"Gap [Pandemonium Boundary]");
	SpellCircle2(6,1,4,250);
	SetShotAutoDeleteClip(80,80,80,80);

	MainTask;
    }


function Wait(frames){loop(frames){yield;}}

task MainTask{
	SetMovePosition03(GetCenterX,150,10,5);
	DelayBombTask;
	Wait(60);
	let angle=0;
	let speed=3;
	MainTask2;
//	let objgap1=Gap(GetCenterX+100,GetCenterY-100,GetCenterX-100,GetCenterY-100,20,50,60*60,[0,1]);
//	let objgap2=Gap(GetCenterX+60,300,GetCenterX-60,300,30,50,60*60,[0,1]);

	Gap(GetCenterX+50,GetCenterY+40,GetCenterX-50,GetCenterY+40,30,40,60*60,[0,1]);
	Gap(GetCenterX+90,GetCenterY-70,GetCenterX-90,GetCenterY-70,30,40,60*60,[0,1]);

	let xx=0;
	let yy=0;
	let frame2=0;
	let frame3=0;
	let adda=0;
	loop{
		if(frame2%4==0){
			GapShot(GetX,GetY,3,GetAngleToPlayer+sin(frame2*2)*10,PURPLE52,0,0.8);
			GapShot(GetX,GetY,3,GetAngleToPlayer-sin(frame2*2)*10,PURPLE52,0,0.8);

//			GapShot(GetX,GetY,2.5,prand(0,360),WHITE52,0,0.7);
		}

		xx=GetCenterX+sin(frame3)*50;
		yy=100+cos(frame3)*50;
		SetX(xx);
		SetY(yy);
		frame2+=1;
		frame3+=adda;
		if(adda<1){adda+=0.01;}
		yield;
	}
}
task MainTask2{
	let frame=0;
	let k=0;
	Wait(180);
	loop{
		k=0;
		loop(3){
			GapShot(GetX,GetY,2.5,frame*8+k,RED01,0,0.7);
			GapShot(GetX,GetY,2.5,-frame*8+k,YELLOW01,0,0.7);
			k+=120;
		}
		frame++;
		Wait(7);
	}
}
    @MainLoop {
        SetCollisionA(GetX, GetY, 90);
	SetCollisionB(GetX, GetY, 20);

	HandleGaps;
	YukariDrawLogic;
	yield;
}
    @DrawLoop {
	YukariDrawLoop;
}

    @Finalize {
	YukariFinalize;
	PointItems(GetX,GetY,3,1);
	EndingFunc(3);
    }

task DelayGap(x1,y1,xo2,yo2,xw,yw,time,target,delay){
	Wait(delay);
	Gap(x1,y1,ScreenX(xo2+GetPlayerX),ScreenY(yo2+GetPlayerY),xw,yw,time,target);
}
function ScreenX(x){
	return center(GetClipMinX+25,x,GetClipMaxX-25);
}
function ScreenY(y){
	return center(GetClipMinY+25,y,GetClipMaxY-25);
}
}