script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let dir;
	if(num==1)
	{
		dir=1;
	}
	if(num==2)
	{
		dir=-1;
	}
	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(1010);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(0);
	Tmain;
	}

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

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

        @Finalize
        {
		if(!BeVanished)
		{
			ItemSet(GetX,GetY,num);
		}
        } 

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


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

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

task move
{
	wait(48);
	SetSpeed(speed);
loop(240)
{
	angle+=1.5*dir;
	SetAngle(angle);
	yield;
}
}

task shot
{
alternative(SelectedDifficult)
case("Easy")
{
wait(60);
	loop(2)
	{
	if(GetLife<=1000)
	{
		break;
	}
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer, 0, RED01);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer,RED01,0);
		wait(120);
	}
}
case("Normal")
{
wait(60);
	loop(2)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -1..2)
		{
	//	CreateShot01(GetX,GetY,3,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 3, GetAngleToPlayer+i*8, 0, RED01);
		CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer+i*8,RED01,0);
		}
		wait(120);
	}
}
case("Hard")
{
wait(60);
	loop(2)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -1..2)
		{
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShot01(GetX,GetY,2.5,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShot01(GetX,GetY,3,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer+i*8, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2.5, GetAngleToPlayer+i*8, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 3, GetAngleToPlayer+i*8, 0, RED01);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+i*8,RED01,0);
		CreateShot01ToItem(GetX,GetY,2.5,GetAngleToPlayer+i*8,RED01,0);
		CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer+i*8,RED01,0);
		}
		wait(120);
	}
}
case("Lunatic")
{
wait(60);
	loop(2)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -2..3)
		{
	//	CreateShot01(GetX,GetY,2,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShot01(GetX,GetY,2.5,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShot01(GetX,GetY,3,GetAngleToPlayer+i*8,RED01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2, GetAngleToPlayer+i*8, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 2.5, GetAngleToPlayer+i*8, 0, RED01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 3, GetAngleToPlayer+i*8, 0, RED01);
		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+i*8,RED01,0);
		CreateShot01ToItem(GetX,GetY,2.5,GetAngleToPlayer+i*8,RED01,0);
		CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer+i*8,RED01,0);
		}
		wait(120);
	}
}

case("Extra")
{
wait(30);
	loop(2)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in -4..5)
		{

		CreateShot01ToItem(GetX,GetY,2,GetAngleToPlayer+i*5,RED01,0);
		CreateShot01ToItem(GetX,GetY,2.5,GetAngleToPlayer+i*5,RED01,0);
		CreateShot01ToItem(GetX,GetY,3.0,GetAngleToPlayer+i*5,RED01,0);
		CreateShot01ToItem(GetX,GetY,3.5,GetAngleToPlayer+i*5,RED01,0);
		CreateShot01ToItem(GetX,GetY,4,GetAngleToPlayer+i*5,RED01,0);
		}
		wait(90);
	}
}

}

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"
