script_enemy_main{

let GRfamiliar=("\script\Images\Enemies\Geometric.png");
let SEdeath=("script\SoundEffects\enemydeath1.wav");
let SEshots5=("script\SoundEffects\shots5.wav");

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 shots=0;
let direction=0;
SetAngle(GetArgument);
SetSpeed(3);

@Initialize{
	LoadGraphic("\script\Images\Enemies\Geometric.png");
	LoadSE("script\SoundEffects\enemydeath1.wav");
	LoadSE("script\SoundEffects\shots5.wav");

	SetScore(100);
	SetLife(15);
	SetDamageRate(10,10); 
	MagicCircle(false);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);

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



if(GetCommonData("Difficulty")==1){
	if(time%4==0 && shots<20){
	let shot1=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,-2,GetAngle+180+rand(-5,5),0,0.05,rand(2,2.5),155);
		FireShot(shot1);
	shots++;
	}
	if(time%8==0 && shots<20){ PlaySE(SEshots5); }
} //Easy

if(GetCommonData("Difficulty")==2){
	if(time%3==0 && shots<28){
	let shot1=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,-2,GetAngle+180+rand(-7,7),0,0.05,rand(2.5,3),155);
		FireShot(shot1);
	shots++;
	}
	if(time%6==0 && shots<25){ PlaySE(SEshots5); }
} //Normal

if(GetCommonData("Difficulty")==3){
	if(time%3==0 && shots<32){
	let shot1=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,-2,GetAngle+180+rand(-10,10),0,0.05,rand(2.5,3),155);
		FireShot(shot1);
	shots++;
	}
	if(time%6==0 && shots<25){ PlaySE(SEshots5); }
} //Hard

if(GetCommonData("Difficulty")==4){
	if(time%3==0 && shots<35){
	let shot1=0;
		CreateShotA(shot1,GetX,GetY,0);
		SetShotDataA(shot1,0,-2,GetAngle+180+rand(-14,14),0,0.05,rand(2.5,3.5),155);
		FireShot(shot1);
	shots++;
	}
	if(time%6==0 && shots<30){ PlaySE(SEshots5); }
} //Lunatic


if(time<120){ SetAngle(GetAngle+direction); }


time++;
frame++;

}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRfamiliar);
	SetGraphicAngle(0,0,time*2);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicRect(150,550,200,600);
	DrawGraphic(GetX,GetY);
}

@Finalize{
if(BeVanished==false){ PlaySE(SEdeath); SetCommonData("FamiliarDestroyed",1); }
}

}