script_enemy_main {

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

	@Initialize {
		EnemyInit(5, 100);
		SetMovePosition03(GetX+80*cos(GetAngleToPlayer), GetY+80*sin(GetAngleToPlayer), 10, 3);
	}
	
	@MainLoop{
		SetCollisionA(GetX, GetY, 12);
		SetCollisionB(GetX, GetY, 12);
		frame++;
		if(frame==50){
			PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
			if(GetCommonData("DIFFICULTY")=="EASY"){
				if(rand_int(1, 2)==1){
					CreateShot02(GetX, GetY, 3, GetAngleToPlayer, -0.02, 1.5, 22, 10);
				}
			}
			if(GetCommonData("DIFFICULTY")=="NORMAL"){
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer, -0.02, 1.5, 22, 10);
			}
			if(GetCommonData("DIFFICULTY")=="HARD"){
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer, -0.02, 1.5, 22, 10);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer-10, -0.02, 1.5, 22, 10);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer+10, -0.02, 1.5, 22, 10);
			}
			if(GetCommonData("DIFFICULTY")=="LUNATIC"){
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer, -0.02, 1.5, 22, 10);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer-10, -0.02, 1.5, 22, 10);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer+10, -0.02, 1.5, 22, 10);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer, -0.02, 1.5, 22, 20);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer-10, -0.02, 1.5, 22, 20);
				CreateShot02(GetX, GetY, 3, GetAngleToPlayer+10, -0.02, 1.5, 22, 20);
			}
			SetMovePosition03(GetX-5*cos(GetAngleToPlayer), GetY-5*sin(GetAngleToPlayer), 10, 1);
		}
		if(frame>=75){
			SetY(GetY-2);
		}
		if(GetY<GetClipMinY-20){VanishEnemy; item=1;}
        yield;
	}
		
	@DrawLoop {
		bluefairynew;
	}
	
	@Finalize {
		if(item==0){
			loop(rand_int(3, 5)){ItemDrop(0, GetX, GetY);}
			itemval=rand_int(1, 500);
			if(itemval==500){ItemDrop(2, GetX, GetY);}
		}
	}
}