script_enemy_main{

let angle=GetArgument;
let size=180;
let radius=0;
let shots=0;

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 SEmagics5=("\script\SoundEffects\magics5.wav");
let GRfamiliar=("\script\Images\OtherEffects\SpellCircle1b.png");

@Initialize{
	LoadGraphic("\script\Images\OtherEffects\SpellCircle1b.png");

	SetScore(1);
	SetLife(1);
}
	
@MainLoop{


if(GetCommonData("Difficulty")==1){
	if(radius>=220 && time%8==0 && shots<12){
	let anglex=angle;
	let shot1=0;
		loop(4){
		CreateShotA(shot1,GetX,GetY,20);
		SetShotDataA(shot1,0,1.5,-anglex+rand(-15,15),0,-0.03,0.4,179);
		SetShotKillTime(shot1,500);
		FireShot(shot1);
		anglex+=360/4;
		}
	shots++;
	if(time%16==0){ PlaySE(SEmagics5); }
	}
} //Easy

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

if(GetCommonData("Difficulty")==2){
	if(radius>=210 && time%6==0 && shots<15){
	let anglex=angle;
	let shot1=0;
		loop(4){
		CreateShotA(shot1,GetX,GetY,20);
		SetShotDataA(shot1,0,1.5,anglex+rand(-15,15),0,-0.03,0.4,179);
		SetShotKillTime(shot1,500);
		FireShot(shot1);
		anglex+=360/4;
		}
	shots++;
	if(time%12==0){ PlaySE(SEmagics5); }
	}
} //Normal

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

if(GetCommonData("Difficulty")==3){
	if(radius>=200 && time%4==0 && shots<25){
	let anglex=angle;
	let shot1=0;
		loop(4){
		CreateShotA(shot1,GetX,GetY,20);
		SetShotDataA(shot1,0,2,-anglex+rand(-15,15),0,-0.03,0.4,179);
		SetShotKillTime(shot1,500);
		FireShot(shot1);
		anglex+=360/4;
		}
	shots++;
	if(time%8==0){ PlaySE(SEmagics5); }
	}
} //Hard

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

if(GetCommonData("Difficulty")==4){
	if(radius>=200 && time%3==0 && shots<30){
	let anglex=angle;
	let shot1=0;
		loop(4){
		CreateShotA(shot1,GetX,GetY,20);
		SetShotDataA(shot1,0,2,anglex+rand(-15,15),0,-0.03,0.4,179);
		SetShotKillTime(shot1,500);
		FireShot(shot1);
		anglex+=360/4;
		}
	shots++;
	if(time%6==0){ PlaySE(SEmagics5); }
	}
} //Lunatic


radius=150+120*cos(size);
if(radius<150){ shots=0; }
if(GetCommonData("Difficulty")==2 || GetCommonData("Difficulty")==4){
	SetX(GetCommonDataDefault("Boss2X",cx)+radius*cos(angle));
	SetY(GetCommonDataDefault("Boss2Y",cy)+radius*sin(angle));
}
if(GetCommonData("Difficulty")==1 || GetCommonData("Difficulty")==3){
	SetX(GetCommonDataDefault("Boss2X",cx)+radius*cos(-angle));
	SetY(GetCommonDataDefault("Boss2Y",cy)+radius*sin(-angle));
}
angle+=1;
size+=0.75;


time++;
frame++;
}

@DrawLoop{
	SetGraphicScale(0.25,0.25);
	SetTexture(GRfamiliar);
	SetGraphicAngle(0,0,time*2);
	SetColor(0,255,255);
	SetRenderState(ADD);
	SetAlpha(255);
	SetGraphicRect(0,0,200,200);
	DrawGraphic(GetX,GetY);
}

@Finalize{
}

}