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(100);
        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)
		{
			loop(5)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),1);
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),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-180,20,3);
	wait(360);
	SetSpeed(speed);
	SetAngle(270);
}

task shot
{
wait(90);
alternative(SelectedDifficult)
case("Easy")
{
	ascent(let i in 0..3)
	{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		wait(60);
	}
}
case("Normal")
{
	ascent(let i in 0..4)
	{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,0);
	}
}
case("Hard")
{
	ascent(let i in 0..5)
	{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+10,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-10,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,0);
	}
}
case("Lunatic")
{
	ascent(let i in 0..5)
	{
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+10,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-10,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-30,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+40,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-40,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+50,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-50,GREEN01,0);
	}
}
}

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"
}

