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

    @Initialize {
        SetLife(200);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(0);
	SetInvincibility(60);
	SetAlpha(0);
	Tmain;
	}

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

        @DrawLoop {
		DrawFairy(imgEnemy);
	}

        @Finalize
        {
		DeleteEnemyShotInCircle(ALL,GetX,GetY,1);
		if(!BeVanished)
		{
			loop(6)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),2);
			}
		}
        } 

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

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

task move
{
	wait(240);
	SetSpeed(2);
	SetAngle(270);
}

task shot
{
wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop(40)
	{
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		wait(3);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		wait(3);
	}
}
case("Normal")
{
	loop(40)
	{
		CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		wait(2);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		wait(2);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		wait(2);
	}
}
case("Hard")
{
	loop(40)
	{
		CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,2.0,rand(0,360),YELLOW01,5);
		wait(1);
	}
}
case("Lunatic")
{
	loop(40)
	{
		CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,2.0,rand(0,360),YELLOW01,5);
		wait(1);
		CreateShot01(GetX,GetY,2.5,rand(0,360),YELLOW01,5);
		wait(1);
	}
}
}

task light
{
	let obj = Obj_Create(OBJ_SHOT);
	ObjShot_SetGraphic(obj, YELLOW01);
	Obj_SetAlpha(obj,0);
	Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	Obj_SetPosition(obj,GetX,GetY);
	let delay=0;
	loop(60)
	{
		ObjShot_SetDelay(obj,delay);
		delay+=0.5;
		yield;
	}
	SetAlpha(255);
	loop(120)
	{
		ObjShot_SetDelay(obj,delay);
		yield;
	}
	Obj_Delete(obj);
}

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

