script_enemy_main{

let angle=GetArgument[0];
let type=GetArgument[1];
let radius=0;
let size=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 SEshots5=("\script\SoundEffects\shots5.wav");
let SEshots7=("\script\SoundEffects\shots7.wav");
let SEshotm3=("\script\SoundEffects\shotm3.wav");

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

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

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


if(GetCommonData("Difficulty")==1){
	if(type==1){
		if(time%60==0){
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX);
		CreateShot02(GetX,GetY,1,angle2,0.05,1.2,13,0);
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if((time+15)%60==0){
		let angle2=atan2(GetY-cy,GetX-cx);
			loop(8){
			CreateShot02(GetX,GetY,3,angle2,-0.1,0.7,77,0);
			angle2+=360/8;
			}
		PlaySE(SEshotm3);
		}
	}
	if(type==3){
		if(time%25==0){
		let angle2=atan2(GetY-cy,GetX-cx);
		CreateShot01(GetX,GetY,rand(1,1.5),angle2,8,0);
		PlaySE(SEshots7);
		}
	}
} //Easy

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

if(GetCommonData("Difficulty")==2){
	if(type==1){
		if(time%50==0){
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX);
		CreateShot02(GetX,GetY,1,angle2,0.05,1.4,13,0);
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if((time+15)%60==0){
		let angle2=atan2(GetY-cy,GetX-cx);
			loop(10){
			CreateShot02(GetX,GetY,3,angle2,-0.1,0.7,77,0);
			angle2+=360/10;
			}
		PlaySE(SEshotm3);
		}
	}
	if(type==3){
		if(time%21==0){
		let angle2=atan2(GetY-cy,GetX-cx);
		CreateShot01(GetX,GetY,rand(1,1.5),angle2,8,0);
		PlaySE(SEshots7);
		}
	}
} //Normal

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

if(GetCommonData("Difficulty")==3){
	if(type==1){
		if(time%40==0){
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX);
		CreateShot02(GetX,GetY,1,angle2,0.05,1.7,13,0);
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if((time+15)%60==0){
		let angle2=atan2(GetY-cy,GetX-cx);
			loop(12){
			CreateShot02(GetX,GetY,3,angle2,-0.1,0.7,77,0);
			angle2+=360/12;
			}
		PlaySE(SEshotm3);
		}
	}
	if(type==3){
		if(time%18==0){
		let angle2=atan2(GetY-cy,GetX-cx);
		CreateShot01(GetX,GetY,rand(1,1.5),angle2,8,0);
		PlaySE(SEshots7);
		}
	}
} //Hard

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

if(GetCommonData("Difficulty")==4){
	if(type==1){
		if(time%30==0){
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX);
		CreateShot02(GetX,GetY,1,angle2,0.05,2,13,0);
		PlaySE(SEshots5);
		}
	}
	if(type==2){
		if((time+15)%60==0){
		let angle2=atan2(GetY-cy,GetX-cx);
			loop(15){
			CreateShot02(GetX,GetY,3,angle2,-0.1,0.7,77,0);
			angle2+=360/15;
			}
		PlaySE(SEshotm3);
		}
	}
	if(type==3){
		if(time%15==0){
		let angle2=atan2(GetY-cy,GetX-cx);
		CreateShot01(GetX,GetY,rand(1,1.5),angle2,8,0);
		PlaySE(SEshots7);
		}
	}
} //Lunatic



if(type==1){
	let radius=(115*size)*cos(time*1.1);
	SetX(cx+(radius)*cos(angle));
	SetY(cy+(radius)*sin(angle));
	angle+=1.1+0.8*cos(time*1.2);
}
if(type==2){
	let radius=(110*size)*cos(-(time+180)*1.3);
	SetX(cx+(radius)*sin(angle));
	SetY(cy+(radius)*cos(angle));
	angle+=1.2+0.6*cos((time+180)*1.2);
}
if(type==3){
	let radius=(120*size)*cos(time*1.2);
	SetX(cx+(radius)*cos(angle+180));
	SetY(cy+(radius)*sin(angle+180));
	angle+=1-0.7*sin((time+180)*1.2);
}
if(size<1){ size+=0.01; }


time++;
frame++;
}

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

@Finalize{
}

}