script_enemy_main {

    #include_function ".\enemyanim.txt"
    #include_function ".\..\lib\enemyfunctions.txt"
	let frame=0;
	let angle=rand(0, 359);
	let item=0;
	let itemval=0;

	@Initialize {
		EnemyInit(10, 100);
		if(GetX>GetCenterX){
			SetMovePositionHermite(GetX-150, GetClipMinY-50, 1000, 90, 1000, 270, 200);
		}else{
			SetMovePositionHermite(GetX+150, GetClipMinY-50, 1000, 90, 1000, 270, 200);
		}
	}
	
	@MainLoop{
		SetCollisionA(GetX, GetY, 12);
		SetCollisionB(GetX, GetY, 12);
		if(frame%5==0){
			PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
			CreateShot02(GetX+35*cos(angle)+15*sin(-angle),
						GetY+35*sin(angle)+15*cos(-angle),
						5, -angle, -0.75, 2, 3, 10);
			angle+=90;
		}
		angle+=7.3;
		if(GetY<GetClipMinY-30){VanishEnemy; item=1;}
        yield;
	}
		
	@DrawLoop {
		redfairynew;
	}
	
	@Finalize {
		if(item==0){
			loop(5){ItemDrop(0, GetX, GetY);}
		}
		itemval=rand_int(1, 250);
			if(itemval==1){ItemDrop(2, GetX, GetY);}
			if(itemval==51){ItemDrop(3, GetX, GetY);}
			if(itemval==101){ItemDrop(5, GetX, GetY);}
			if(itemval==151){ItemDrop(7, GetX, GetY);}
			if(itemval==201){ItemDrop(9, GetX, GetY);}
		itemval=rand_int(1, 10);
			if(itemval==5){ItemDrop(6, GetX, GetY);}
	}
}