script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy;
	imgEnemy=csd~"..\lib\fairy_green.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

    @Initialize {
        SetLife(180);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(3);
	Tmain;
	}

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

        @DrawLoop {
		DrawFairy(imgEnemy);
	}

        @Finalize
        {
		if(!BeVanished)
		{
			loop(3)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),1);
			}
			loop(3)
			{
				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);
		if(GetLife<45)
		{
			SetColor(255,150,150);
		}
	}
yield;
}
}

task move
{
	SetMovePosition03(GetX,GetCenterY-100,20,5);
	wait(480);
	SetSpeed(3);
	SetAngle(270);
}

task shot
{
wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop(1)
	{
		ascent(let i in 0..5)
		{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+5,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-5,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,BLUE01,30);
		}
		wait(120);
	}
}
case("Normal")
{
	loop(1)
	{
		ascent(let i in 0..5)
		{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+5,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-5,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+25,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-25,BLUE01,30);
		}
		wait(120);
	}
}
case("Hard")
{
	loop(1)
	{
		ascent(let i in 0..5)
		{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,BLUE01,30);
		}
		wait(120);
	}
}
case("Lunatic")
{
	loop(1)
	{
		ascent(let i in 0..5)
		{
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+33,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-33,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+39,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-39,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+45,BLUE01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-45,BLUE01,30);
		}
		wait(120);
	}
}
}

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

