script_enemy_main {

    #include_function ".\enemyanim.txt"
    #include_function ".\..\lib\enemyfunctions.txt"
	let frame=0;
	let item=0;
	let itemval=0;
	let ang=0;

	@Initialize {
		EnemyInit(30, 100);
		SetMovePosition03(GetX, GetY+150, 10, 3);
	}
	
	@MainLoop{
		SetCollisionA(GetX, GetY, 12);
		SetCollisionB(GetX, GetY, 12);
		frame++;
		if(frame>=100 && frame<=300 && frame%8==0){
			PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
			if(GetCommonData("DIFFICULTY")=="EASY"){
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+i*180), GetY+25*sin(ang+i*180), -1, ang+90+i*180, 0.02, 2, 8, 5);
				}
			}
			if(GetCommonData("DIFFICULTY")=="NORMAL"){
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+i*180), GetY+25*sin(ang+i*180), -1, ang+90+i*180, 0.02, 2, 8, 5);
				}
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+90+i*180), GetY+25*sin(ang+90+i*180), -1, ang+180+i*180, 0.02, 2, 8, 5);
				}
			}
			if(GetCommonData("DIFFICULTY")=="HARD"){
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+i*180), GetY+25*sin(ang+i*180), -1, ang+90+i*180, 0.02, 2, 8, 5);
				}
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+90+i*180), GetY+25*sin(ang+90+i*180), -1, ang+180+i*180, 0.02, 2, 8, 5);
				}
				ascent(i in 0..4){
					CreateShot02(GetX+45*cos(ang+i*90), GetY+45*sin(ang+i*90), -0.5, ang-90+i*90, 0.01, 1, 9, 5);
				}
			}
			if(GetCommonData("DIFFICULTY")=="LUNATIC"){
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+i*180), GetY+25*sin(ang+i*180), -1, ang+90+i*180, 0.02, 2, 8, 5);
				}
				ascent(i in 0..2){
					CreateShot02(GetX+25*cos(ang+90+i*180), GetY+25*sin(ang+90+i*180), -1, ang+180+i*180, 0.02, 2, 8, 5);
				}
				ascent(i in 0..4){
					CreateShot02(GetX+45*cos(ang+i*90), GetY+45*sin(ang+i*90), -0.5, ang-90+i*90, 0.01, 1, 9, 5);
				}
				ascent(i in 0..20){
					CreateShot01(GetX, GetY, 1, GetAngleToPlayer+i*18, 29, 5);
				}
			}
			ang+=7;
		}
		if(frame>=300){
			SetY(GetY-2);
		}
		if(GetY<GetClipMinY-20){VanishEnemy; item=1;}
        yield;
	}
		
	@DrawLoop {
		bigfairy;
	}
	
	@Finalize {
		if(item==0){
			loop(rand_int(15, 25)){ItemDrop(0, GetX, GetY);}
		}
	}
}