script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy=csd~"..\lib\fairy_green.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(1100);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(4);
	Tmain;
	}

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

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

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

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

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

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

task move
{
	SetMovePosition03(GetX,GetCenterY-180,20,3);
	wait(360);
	SetSpeed(speed);
	SetAngle(270);
}

task shot
{
wait(90);
alternative(SelectedDifficult)
case("Easy")
{
	if(GetLife<=1000)
	{
		return;
	}
	ascent(let i in 0..3)
	{
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+20,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-20,GREEN01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+20, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-20, 0, GREEN01);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-20,GREEN01,0);
	}
}
case("Normal")
{
	if(GetLife<=1000)
	{
		return;
	}
	ascent(let i in 0..4)
	{
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+15, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-15, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+30, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-30, 0, GREEN01);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,0);
	}
}
case("Hard")
{
	if(GetLife<=1000)
	{
		return;
	}
	ascent(let i in 0..5)
	{
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+10,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-10,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+20,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-20,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,0);
	//	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+10, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-10, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+20, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-20, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+30, 0, GREEN01);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-30, 0, GREEN01);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+10,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-10,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,0);
	}
}
case("Lunatic")
{
	if(GetLife<=1000)
	{
		return;
	}
	ascent(let i in 0..5)
	{
	/*	CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+10,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-10,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-30,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+40,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-40,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+50,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-50,GREEN01,0);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+10, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-10, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+20, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-20, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+30, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-30, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+40, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-40, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+50, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-50, 0, GREEN01);
	*/	CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+10,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-10,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-30,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+40,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-40,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+50,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-50,GREEN01,0);
	}
}

case("Extra")
{
	loop(2)
	{
	if(GetLife<=1000)
	{
		return;
	}
	ascent(let i in 0..7)
	{
	/*	CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+10,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-10,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+20,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-20,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+30,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-30,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+40,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-40,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+50,GREEN01,0);
		CreateShot01(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-50,GREEN01,0);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+10, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-10, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+20, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-20, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+30, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-30, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+40, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-40, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer+50, 0, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5+i*0.5, GetAngleToPlayer-50, 0, GREEN01);
	*/	CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+8,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-8,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+16,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-16,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+24,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-24,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+32,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-32,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+40,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-40,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+48,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-48,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer+56,GREEN01,0);
		CreateShot01ToItem(GetX,GetY,1.5+i*0.5,GetAngleToPlayer-56,GREEN01,0);
	}
	wait(240);
	}
}

}

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"