script_enemy_main{

let side=GetArgument[0];
let distance=0;
let wavesize=GetArgument[2];
let waveangle=0;
let speed=3;
let size=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 SEshot1=("script\SoundEffects\shotm4.wav");

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

@Initialize{
	LoadSE("script\SoundEffects\shotm4.wav");
	LoadGraphic("\script\Images\OtherEffects\SpellCircle1b.png");

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

if(distance<GetArgument[1]){ distance+=GetArgument[1]/30; size+=1/30; }
if(speed<8 && time>=30){ speed+=5/60; }

if(GetCommonData("Difficulty")==1){
if(side==1){ SetX((cx+distance)+(wavesize*size)*cos((time+240)*2)); }
if(side==2){ SetX((cx-distance)-(wavesize*size)*cos((time+240)*2)); }
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,5,90+4*cos(time*1.5),12,5);
		CreateShot01(GetX,GetY,5,270-4*cos(time*1.5),12,5);	
		CreateShot01(GetX,GetY,5,0+60*cos(time*1.5),11,5);	
		}
		if(side==2){
		CreateShot01(GetX,GetY,5,90-4*cos(time*1.5),12,5);
		CreateShot01(GetX,GetY,5,270+4*cos(time*1.5),12,5);
		CreateShot01(GetX,GetY,5,180-60*cos(time*1.5),11,5);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Easy

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

if(GetCommonData("Difficulty")==2){
if(side==1){ SetX((cx+distance)+(wavesize*size)*cos((time+240)*2.3)); }
if(side==2){ SetX((cx-distance)-(wavesize*size)*cos((time+240)*2.3)); }
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,5,90+7*cos(time*2),12,5);
		CreateShot01(GetX,GetY,5,270-7*cos(time*2),12,5);	
		CreateShot01(GetX,GetY,5,0+60*cos(time*2),11,5);	
		}
		if(side==2){
		CreateShot01(GetX,GetY,5,90-7*cos(time*2),12,5);
		CreateShot01(GetX,GetY,5,270+7*cos(time*2),12,5);
		CreateShot01(GetX,GetY,5,180-60*cos(time*2),11,5);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Normal

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

if(GetCommonData("Difficulty")==3){
if(side==1){ SetX((cx+distance)+(wavesize*size)*cos((time+240)*2.6)); }
if(side==2){ SetX((cx-distance)-(wavesize*size)*cos((time+240)*2.6)); }
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,5,90+10*cos(time*2.5),12,5);
		CreateShot01(GetX,GetY,5,270-10*cos(time*2.5),12,5);	
		CreateShot01(GetX,GetY,5,0+70*cos(time*2.5),11,5);	
		}
		if(side==2){
		CreateShot01(GetX,GetY,5,90-10*cos(time*2.5),12,5);
		CreateShot01(GetX,GetY,5,270+10*cos(time*2.5),12,5);
		CreateShot01(GetX,GetY,5,180-70*cos(time*2.5),11,5);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Hard

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

if(GetCommonData("Difficulty")==4){
if(side==1){ SetX((cx+distance)+(wavesize*size)*cos((time+240)*3)); }
if(side==2){ SetX((cx-distance)-(wavesize*size)*cos((time+240)*3)); }
	if(time%2==0 && time>=30){
		if(side==1){
		CreateShot01(GetX,GetY,5,90+10*cos((time+40)*3),12,5);
		CreateShot01(GetX,GetY,5,270-10*cos((time+40)*3),12,5);	
		CreateShot01(GetX,GetY,5,0+80*cos((time+40)*3),11,5);	
		}
		if(side==2){
		CreateShot01(GetX,GetY,5,90-10*cos((time+40)*3),12,5);
		CreateShot01(GetX,GetY,5,270+10*cos((time+40)*3),12,5);
		CreateShot01(GetX,GetY,5,180-80*cos((time+40)*3),11,5);
		}
	}
	if(time%4==0 && time>=30){ PlaySE(SEshot1); }
} //Lunatic



time++;
frame++;

}

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

@Finalize{
}

}