script_enemy_main{

let outfit=6;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotm8=("script\SoundEffects\shotm8.wav");

let GRboss=("\script\Images\CharacterSprites\Kurumi.png");

@Initialize{
	LoadSE("script\SoundEffects\shotm8.wav");

	LoadGraphic(GRboss);

	SetColor(190,255,60);
	Concentration01(90);
	SetColor(255,255,255);
	SetLife(10000);
	MagicCircle(false);
	SetInvincibility(120);
	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetMovePosition03(rand(maxx-50,cx+40),miny+rand(70,90),8,3);
}
	
@MainLoop{

if(time>=90){ SetCollisionB(GetX,GetY,16); }

if((time+100)%200==0 && time>=200){
	if(GetPlayerX<maxx-50 && GetPlayerX>cx+40){
	SetMovePosition01(GetPlayerX+rand(-30,30),miny+rand(70,90),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(maxx-50-rand(15,30),miny+rand(70,90),1.5);
	}
	if(GetPlayerX<=cx+40){
	SetMovePosition01(cx+40+rand(15,30),miny+rand(70,90),1.5);
	}
}


if(GetCommonData("Difficulty")==3){

if((time+0)%180==0 && time>=360){
let angle=GetAngleToPlayer;
	loop(12){
	let speed=1.5;
	let color=100;
		loop(5){
		SetShotColor(255-color,255-color,255-color);
		CreateShot01(GetX,GetY-10,speed,angle,20,0);
		speed+=0.6;
		color-=100/7;
		}
	angle+=360/12;
	}
angle+=360/24;
	loop(12){
	let speed=1;
	let color=100;
		loop(5){
		SetShotColor(255-color,255-color,255-color);
		CreateShot01(GetX,GetY-10,speed,angle,20,0);
		speed+=0.6;
		color-=100/7;
		}
	angle+=360/12;
	}
SetShotColor(255,255,255);
PlaySE(SEshotm8);
usespell=-40;
}

} //Hard

//==================================================================

if(GetCommonData("Difficulty")==4){

if((time+0)%150==0 && time>=300){
let angle=GetAngleToPlayer;
	loop(24){
	let speed=1.25;
	let color=100;
		loop(7){
		SetShotColor(255-color,255-color,255-color);
		CreateShot01(GetX,GetY-10,speed,angle,20,0);
		speed+=0.5;
		color-=100/7;
		}
	angle+=360/24;
	}
SetShotColor(255,255,255);
PlaySE(SEshotm8);
usespell=-40;
}

} //Lunatic


time++;
frame++;

if(GetCommonData("UseSpell1")!=0){ usespell=GetCommonData("UseSpell1"); SetCommonData("UseSpell1",0); }
if(usespell>0){ usespell--; }
if(usespell<0){ usespell++; }

SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY); 
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
	CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,"Kurumi");
}

}