script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy=csd~"..\lib\fairy_red.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(50);
        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(4)
			{
			ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),1);
			}
		}
        } 

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

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

task move
{
let dir;
if(angle==0)
{
dir=1;
}
if(angle==180)
{
dir=-1;
}
	SetSpeed(speed);
	SetAngle(angle);
	loop
	{
		SetSpeed(speed);
		SetAngle(angle);
		speed+=0.02;
		angle-=0.2*dir;
		yield;
	}
}

task shot
{
wait(10);
alternative(SelectedDifficult)
case("Easy")
{
	loop
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED02,0);
		wait(25);
	}
}
case("Normal")
{
	loop
	{
		CreateShot01(GetX,GetY,3,GetAngleToPlayer,RED02,0);
		wait(20);
	}
}
case("Hard")
{
	loop
	{
		CreateShot01(GetX,GetY,4,GetAngleToPlayer,RED02,0);
		wait(15);
	}
}
case("Lunatic")
{
	loop
	{
		CreateShot01(GetX,GetY,5,GetAngleToPlayer,RED02,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"
}

