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

    @Initialize {
        SetLife(1180);
        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)
		{
			loop(3)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),1);
				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(3)
			{
				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 GetDamege
{
loop
{
	if(GetHitCount!=0)
	{
		SetColor(150,150,255);
		wait(10);
	}
	else
	{
		SetColor(255,255,255);
		if(GetLife<1045)
		{
			SetColor(255,150,150);
		}
	}
yield;
}
}

task move
{
	SetMovePosition03(GetX,GetCenterY-100,20,5);
	wait(480);
	SetSpeed(3);
	SetAngle(270);
}

task shot
{
wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in 0..5)
		{
	/*	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+5,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-5,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+5, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-5, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-15, 30, GREEN01);
	*/	CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+15, 30, GREEN01);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+5,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-5,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		}
		wait(120);
	}
}
case("Normal")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in 0..5)
		{
	/*	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+5,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-5,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+25,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-25,GREEN01,30);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+5, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-5, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+25, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-25, 30, GREEN01);
	*/	CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+5,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-5,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+25,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-25,GREEN01,30);
		}
		wait(120);
	}
}
case("Hard")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in 0..5)
		{
	/*	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,GREEN01,30);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+3, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-3, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-9, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+9, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-21, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+21, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-27, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+27, 30, GREEN01);
	*/	CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,GREEN01,30);
		}
		wait(120);
	}
}
case("Lunatic")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in 0..5)
		{
	/*	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+33,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-33,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+39,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-39,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+45,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-45,GREEN01,30);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+3, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-3, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-9, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+9, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-21, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+21, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-27, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+27, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+33, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-33, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-39, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+39, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+45, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-45, 30, GREEN01);
	*/	CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+33,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-33,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+39,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-39,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+45,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-45,GREEN01,30);
		}
		wait(120);
	}
}
case("Extra")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		ascent(let i in 0..5)
		{
	/*	CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+3,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-3,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+9,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-9,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-15,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+21,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-21,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+27,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-27,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+33,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-33,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+39,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-39,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer+45,GREEN01,30);
		CreateShot01(GetX,GetY,1+i*0.5,GetAngleToPlayer-45,GREEN01,30);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+3, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-3, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-9, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+9, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-15, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-21, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+21, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-27, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+27, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+33, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-33, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-39, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+39, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer+45, 30, GREEN01);
		CreateShotFromScript( "shot1",GetX, GetY, 1+i*0.5, GetAngleToPlayer-45, 30, GREEN01);
	*/	CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+2,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-2,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+6,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-6,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+10,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-10,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+14,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-14,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+18,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-18,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+22,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-22,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+26,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-26,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+30,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-30,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+34,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-34,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+38,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-38,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+42,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-42,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+46,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-46,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+50,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-50,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+54,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-54,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer+58,GREEN01,30);
		CreateShot01ToItem(GetX,GetY,1+i*0.5,GetAngleToPlayer-58,GREEN01,30);
		}
		wait(120);
	}
}
}

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"
