script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy=csd~"..\lib\fairy_green.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(200);
        SetDamageRate(100,100);
	LoadGraphic(imgEnemy);
	Initialize_Fairy(4);
	Tmain;
	}

    @MainLoop {
	SetCollisionA(GetX(),GetY(),32);
        SetCollisionB(GetX(),GetY(),16);
	yield;
    }

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

        @Finalize
        {
		if(!BeVanished)
		{
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),1);
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),1);
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
		}
        } 

task Tmain
{
yield;
GetDamege;
move;
shot;
eraze;
}

task GetDamege
{
loop
{
	if(GetHitCount!=0)
	{
		SetColor(150,150,255);
		wait(10);
	}
	else
	{
		SetColor(255,255,255);
	}
yield;
}
}

task move
{
	SetMovePosition03(GetX,GetCenterY-160,20,3);
	wait(360);
	SetSpeed(speed);
	SetAngle(angle);
}

task shot
{
alternative(SelectedDifficult)
case("Easy")
{
	wait(60);
	loop(1)
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer+10,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer-10,RED01,0);
		wait(60);
	}
}
case("Normal")
{
	wait(60);
	loop(2)
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer+10,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer-10,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer+45,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer-45,RED01,0);
		wait(60);
	}
}
case("Hard")
{
	wait(60);
	loop(3)
	{
		CreateShot01(GetX,GetY,3,GetAngleToPlayer,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+5,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-5,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+10,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-10,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+45,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-45,RED01,0);
		wait(30);
	}
}
case("Lunatic")
{
	wait(60);
	loop(5)
	{
		CreateShot01(GetX,GetY,3,GetAngleToPlayer,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+5,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-5,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+10,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-10,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+15,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-15,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+45,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-45,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+40,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-40,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+50,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-50,RED01,0);
		wait(30);
	}
}
}

task eraze
{
while(!BeVanished)
{
        	if(GetX<GetClipMinX-64||GetX>GetClipMaxX+64||GetY<GetClipMinY-32||GetY>GetClipMaxY+32)
        	{
        		VanishEnemy();
        	}
yield;
}
}


#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib\lib_anime_fairy.txt"
}

