script_enemy_main{

let angle=GetCommonData("Angle");

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 SEshots3=("\script\SoundEffects\shots3.wav");

let GRfamiliar=("\script\Images\OtherEffects\SpellCircle1a.png");

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

	LoadGraphic("\script\Images\OtherEffects\SpellCircle1a.png");

	SetScore(1);
	SetLife(100);

	SetAngle(angle);
}
	
@MainLoop{

if(GetX<=minx-100 || GetX>=maxx+100 || GetY<=miny-100 || GetY>=maxy+100 && frame>=60){ VanishEnemy; }

if((GetX>minx && GetX<maxx) && (GetY>miny && GetY<maxy)){


let distance=(((GetPlayerX-GetX)^2+(GetPlayerY-GetY)^2)^0.5);

if(GetCommonData("Difficulty")==1){
SetSpeed(GetSpeed+0.04);
let color=0;
if(time%10==0){ color=3; }
if(time%10!=0){ color=15; }
		if(time%5==0 && GetArgument==1 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+90,0,0,0,color);
			SetShotDataA(shot1,45,0,GetAngle+90,0,rand(0.01,0.015),rand(1.5,2),color);
			FireShot(shot1);
		}
		if(time%5==0 && GetArgument==2 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-90,0,0,0,color);
			SetShotDataA(shot1,45,0,GetAngle-90,0,rand(0.01,0.015),rand(1.5,2),color);
			FireShot(shot1);
		}
		if(time%6==0){ PlaySE(SEshots3); }
} //Easy

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

if(GetCommonData("Difficulty")==2){
SetSpeed(GetSpeed+0.03);
		if((time+0)%8==0 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+90,0,0,0,3);
			SetShotDataA(shot1,45,0,GetAngle+90,0,0.01,rand(1.5,2),3);
			FireShot(shot1);
		}
		if((time+4)%8==0 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-90,0,0,0,15);
			SetShotDataA(shot1,45,0,GetAngle-90,0,0.01,rand(1.5,2),15);
			FireShot(shot1);
		}
		if(time%6==0){ PlaySE(SEshots3); }
} //Normal

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

if(GetCommonData("Difficulty")==3){
SetSpeed(GetSpeed+0.04);
	if(GetArgument==1){ SetAngle(GetAngle+0.75); }
	if(GetArgument==2){ SetAngle(GetAngle-0.75); }
		if((time+0)%8==0 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+90,0,0,0,3);
			SetShotDataA(shot1,45,0,GetAngle+90,0,0.02,rand(1.5,2),3);
			FireShot(shot1);
		}
		if((time+4)%8==0 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-90,0,0,0,15);
			SetShotDataA(shot1,45,0,GetAngle-90,0,0.01,rand(1.5,2),15);
			FireShot(shot1);
		}
		if(time%6==0){ PlaySE(SEshots3); }
} //Hard

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

if(GetCommonData("Difficulty")==4){
SetSpeed(GetSpeed+0.04);
	if(GetArgument==1){ SetAngle(GetAngle+1.25); }
	if(GetArgument==2){ SetAngle(GetAngle-1.25); }
		if((time+0)%6==0 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle+90,0,0,0,3);
			SetShotDataA(shot1,45,0,GetAngle+90,0,0.02,rand(1.5,2),3);
			FireShot(shot1);
		}
		if((time+3)%6==0 && distance>=30){
		let shot1=0;
			CreateShotA(shot1,GetX,GetY,10);
			SetShotDataA(shot1,0,0,GetAngle-90,0,0,0,15);
			SetShotDataA(shot1,45,0,GetAngle-90,0,0.01,rand(1.5,2),15);
			FireShot(shot1);
		}
		if(time%6==0){ PlaySE(SEshots3); }
} //Lunatic

} //Onscreen



time++;
frame++;

}

@DrawLoop{
	SetGraphicScale(0.2,0.2);
	SetTexture(GRfamiliar);
	SetGraphicAngle(0,0,time*2);
	SetColor(255,255,100);
	SetRenderState(ALPHA);
	SetAlpha(255);
	SetGraphicRect(0,0,199,199);
	DrawGraphic(GetX,GetY);
}

@Finalize{
}

}