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(1200);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(0);
	SetInvincibility(60);
	SetAlpha(0);
	Tmain;
	}

    @MainLoop {
	if(GetLife>1000)
	{
	SetCollisionA(GetX(),GetY(),48);
	}
	yield;
    }

        @DrawLoop {
	if(GetLife>1000)
	{
		DrawFairy(imgEnemy);
	}
	}

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

task Tmain
{
yield;
GetDamege;
light;
move;
shot;
//eraze;
AutoErazeTime(900);
Explode(4);
ItemDrop;
}

task ItemDrop
{
	while(GetLife>1000)
	{
		yield;
	}
		if(!BeVanished)
		{
			loop(6)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),2);
			}
		DeleteEnemyShotInCircle(ALL,GetX,GetY,1);
		}
}

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

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

task shot
{
alternative(SelectedDifficult)
case("Easy")
{
wait(60);
	loop(40)
	{
	if(GetLife<=1000)
	{
		break;
	}
	ascent(let i in 1..3)
	{
		CreateShot01ToItem(GetX,GetY,0.5+i*0.5,rand(0,360),YELLOW01,5);
		wait(1);
	}
	/*	CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.0, rand(0,360), 5, YELLOW01);
		wait(3);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, rand(0,360), 5, YELLOW01);
		wait(3);
	*/
	}
}
case("Normal")
{
wait(60);
	loop(40)
	{
	if(GetLife<=1000)
	{
		break;
	}
	ascent(let i in 0..3)
	{
		CreateShot01ToItem(GetX,GetY,0.5+i*0.5,rand(0,360),YELLOW01,5);
		wait(2);
	}
	/*	CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, rand(0,360), 5, YELLOW01);
		wait(2);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.0, rand(0,360), 5, YELLOW01);
		wait(2);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, rand(0,360), 5, YELLOW01);
		wait(2);
	*/
	}
}
case("Hard")
{
wait(60);
	loop(40)
	{
	if(GetLife<=1000)
	{
		break;
	}
	ascent(let i in 0..4)
	{
		CreateShot01ToItem(GetX,GetY,0.5+i*0.5,rand(0,360),YELLOW01,5);
		wait(1);
	}
	/*	CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.0, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,2.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 2.0, rand(0,360), 5, YELLOW01);
		wait(1);
	*/
	}
}
case("Lunatic")
{
wait(60);
	loop(40)
	{
	if(GetLife<=1000)
	{
		break;
	}
	ascent(let i in 0..5)
	{
		CreateShot01ToItem(GetX,GetY,0.5+i*0.5,rand(0,360),YELLOW01,5);
		wait(1);
	}
	/*	CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.0, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,2.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 2.0, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,2.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, rand(0,360), 5, YELLOW01);
		wait(1);
	*/
	}
}

case("Extra")
{
wait(60);
	loop(40)
	{
	if(GetLife<=1000)
	{
		break;
	}
	ascent(let i in 0..5)
	{
		CreateShot01ToItem(GetX,GetY,0.5+i*0.5,rand(0,360),YELLOW01,5);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,rand(0,360),YELLOW01,5);
		CreateShot01ToItem(GetX,GetY,2.5+i*0.5,rand(0,360),YELLOW01,5);
		wait(1);
	}
	/*	CreateShot01(GetX,GetY,0.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,1.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.0, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,1.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,2.0,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 2.0, rand(0,360), 5, YELLOW01);
		wait(1);
		CreateShot01(GetX,GetY,2.5,rand(0,360),YELLOW01,5);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, rand(0,360), 5, YELLOW01);
		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"
}
#include_script ".\..\txt/EnemyShotData.txt"
