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

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

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

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

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

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<25)
		{
			SetColor(255,150,150);
		}
	}
yield;
}
}

task move
{
	SetSpeed(speed);
	SetAngle(angle);
}

task shot
{
	wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop(5)
	{
		loop(3)
		{
		//	CreateShot01(GetX,GetY,2,90,RED01,0);
		//	CreateShot01(GetX,GetY,2,120,RED01,0);
		//	CreateShot01(GetX,GetY,2,60,RED01,0);
			CreateShotFromScript( "shot1",GetX, GetY, 2.0,90, 0, 33);
			CreateShotFromScript( "shot1",GetX, GetY, 2.0,120, 0, 33);
			CreateShotFromScript( "shot1",GetX, GetY, 2.0,60, 0, 33);
			wait(10);
		}
		wait(30);
	}
}
case("Normal")
{
	loop(2)
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		wait(30);
	}
}
case("Hard")
{
	loop(2)
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer+15,RED01,0);
		CreateShot01(GetX,GetY,2,GetAngleToPlayer-15,RED01,0);
		wait(30);
	}
}
case("Lunatic")
{
	loop(3)
	{
		CreateShot01(GetX,GetY,3,GetAngleToPlayer,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+15,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-15,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer+30,RED01,0);
		CreateShot01(GetX,GetY,3,GetAngleToPlayer-30,RED01,0);
		wait(30);
	}
}
}

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"