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

    @Initialize {
        SetLife(1200);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(7);
	Tmain;
	}

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

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

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

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

task ItemDrop
{
	while(GetLife>1000)
	{
		yield;
	}
		if(!BeVanished)
		{
			loop(10)
			{
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
}

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
{
	SetMovePosition03(GetX,GetCenterY-80,20,3);
	wait(360);
	SetSpeed(speed);
	SetAngle(angle);
}

task shot
{
alternative(SelectedDifficult)
case("Easy")
{
	wait(60);
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer+30,RED01,0);
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer-30,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer+30, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer-30, 0, RED01);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+30,RED01,0);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer-30,RED01,0);
		wait(30);
	}
}
case("Normal")
{
	wait(60);
	loop(5)
	{
	if(GetLife<=1000)
	{
		break;
	}
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer+30,RED01,0);
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer-30,RED01,0);
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer+60,RED01,0);
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer-60,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer+30, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer-30, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer+60, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer-60, 0, RED01);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+30,RED01,0);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer-30,RED01,0);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+60,RED01,0);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer-60,RED01,0);
		wait(30);

	}
}
case("Hard")
{
	wait(60);
	loop(5)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -4..5)
		{
	//	CreateShot01(GetX,GetY,3,GetAngleToPlayer+i*15,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 3, GetAngleToPlayer+i*15, 0, RED01);
		CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer+i*15,RED01,0);
		}
		wait(20);

	}
}
case("Lunatic")
{
	wait(60);
	loop(10)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -6..7)
		{
	//	CreateShot01(GetX,GetY,4,GetAngleToPlayer+i*10,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 4, GetAngleToPlayer+i*10, 0, RED01);
		CreateShot01ToItem(GetX,GetY,4,GetAngleToPlayer+i*10,RED01,0);
		}
		wait(10);

	}
}

case("Extra")
{
	wait(30);
	loop(20)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -12..13)
		{
		CreateShot01ToItem(GetX,GetY,5,GetAngleToPlayer+i*5,RED01,0);
		}
		wait(10);

	}
}

}

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"