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(1200);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(5);
	Tmain;
	}

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

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

        @Finalize
        {
		if(!BeVanished)
		{
			loop(10)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),1);
			}
			loop(5)
			{
				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(8)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),1);
			}
			loop(4)
			{
				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<1050)
		{
			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;
	}
		let angle=rand(0,360);
		ascent(let i in 0..24)
		{
	/*	CreateShot01(GetX,GetY,0.5,angle+i*15-2,RED01,60);
		CreateShot01(GetX,GetY,1,angle+i*15,RED01,60);
		CreateShot01(GetX,GetY,1.5,angle+i*15+2,RED01,60);
		CreateShot01(GetX,GetY,2,angle+i*15+4,RED01,60);
		CreateShot01(GetX,GetY,2.5,angle+i*15+6,RED01,60);
		CreateShot01(GetX,GetY,3,angle+i*15+8,RED01,60);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, angle+i*15-2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1, angle+i*15+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, angle+i*15+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2, angle+i*15+4, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, angle+i*15+6, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 3,angle+i*15+8, 60, RED01);
	*/	CreateShot01ToItem(GetX,GetY,1,angle+i*15,RED01,60);
		CreateShot01ToItem(GetX,GetY,1.5,angle+i*15+2,RED01,60);
		CreateShot01ToItem(GetX,GetY,2,angle+i*15+4,RED01,60);
		CreateShot01ToItem(GetX,GetY,2.5,angle+i*15+6,RED01,60);
		CreateShot01ToItem(GetX,GetY,3,angle+i*15+8,RED01,60);
		}
		wait(120);
	}
}
case("Normal")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=rand(0,360);
		ascent(let i in 0..30)
		{
	/*	CreateShot01(GetX,GetY,0.5,angle+i*12-2,RED01,60);
		CreateShot01(GetX,GetY,1,angle+i*12,RED01,60);
		CreateShot01(GetX,GetY,1.5,angle+i*12+2,RED01,60);
		CreateShot01(GetX,GetY,2,angle+i*12+4,RED01,60);
		CreateShot01(GetX,GetY,2.5,angle+i*12+6,RED01,60);
		CreateShot01(GetX,GetY,3,angle+i*12+8,RED01,60);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, angle+i*12-2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1, angle+i*12+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, angle+i*12+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2, angle+i*12+4, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, angle+i*12+6, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 3,angle+i*12+8, 60, RED01);
	*/	CreateShot01ToItem(GetX,GetY,1,angle+i*12,RED01,60);
		CreateShot01ToItem(GetX,GetY,1.5,angle+i*12+2,RED01,60);
		CreateShot01ToItem(GetX,GetY,2,angle+i*12+4,RED01,60);
		CreateShot01ToItem(GetX,GetY,2.5,angle+i*12+6,RED01,60);
		CreateShot01ToItem(GetX,GetY,3,angle+i*12+8,RED01,60);
		}
		wait(120);
	}
}
case("Hard")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=rand(0,360);
		ascent(let i in 0..40)
		{
	/*	CreateShot01(GetX,GetY,0.5,angle+i*9-2,RED01,60);
		CreateShot01(GetX,GetY,1,angle+i*9,RED01,60);
		CreateShot01(GetX,GetY,1.5,angle+i*9+2,RED01,60);
		CreateShot01(GetX,GetY,2,angle+i*9+4,RED01,60);
		CreateShot01(GetX,GetY,2.5,angle+i*9+6,RED01,60);
		CreateShot01(GetX,GetY,3,angle+i*9+8,RED01,60);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, angle+i*9-2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1, angle+i*9+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, angle+i*9+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2, angle+i*9+4, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, angle+i*9+6, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 3,angle+i*9+8, 60, RED01);
	*/	CreateShot01ToItem(GetX,GetY,1,angle+i*9,RED01,60);
		CreateShot01ToItem(GetX,GetY,1.5,angle+i*9+2,RED01,60);
		CreateShot01ToItem(GetX,GetY,2,angle+i*9+4,RED01,60);
		CreateShot01ToItem(GetX,GetY,2.5,angle+i*9+6,RED01,60);
		CreateShot01ToItem(GetX,GetY,3,angle+i*9+8,RED01,60);
		}
		wait(120);
	}
}
case("Lunatic")
{
	loop(1)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=rand(0,360);
		ascent(let i in 0..60)
		{
	/*	CreateShot01(GetX,GetY,0.5,angle+i*6-2,RED01,60);
		CreateShot01(GetX,GetY,1,angle+i*6,RED01,60);
		CreateShot01(GetX,GetY,1.5,angle+i*6+2,RED01,60);
		CreateShot01(GetX,GetY,2,angle+i*6+4,RED01,60);
		CreateShot01(GetX,GetY,2.5,angle+i*6+6,RED01,60);
		CreateShot01(GetX,GetY,3,angle+i*6+8,RED01,60);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, angle+i*6-2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1, angle+i*6+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, angle+i*6+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2, angle+i*6+4, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, angle+i*6+6, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 3,angle+i*6+8, 60, RED01);
	*/	CreateShot01ToItem(GetX,GetY,1,angle+i*6,RED01,60);
		CreateShot01ToItem(GetX,GetY,1.5,angle+i*6+2,RED01,60);
		CreateShot01ToItem(GetX,GetY,2,angle+i*6+4,RED01,60);
		CreateShot01ToItem(GetX,GetY,2.5,angle+i*6+6,RED01,60);
		CreateShot01ToItem(GetX,GetY,3,angle+i*6+8,RED01,60);
		}
		wait(120);
	}
}

case("Extra")
{
	loop(2)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=rand(0,360);
		ascent(let i in 0..90)
		{
	/*	CreateShot01(GetX,GetY,0.5,angle+i*6-2,RED01,60);
		CreateShot01(GetX,GetY,1,angle+i*6,RED01,60);
		CreateShot01(GetX,GetY,1.5,angle+i*6+2,RED01,60);
		CreateShot01(GetX,GetY,2,angle+i*6+4,RED01,60);
		CreateShot01(GetX,GetY,2.5,angle+i*6+6,RED01,60);
		CreateShot01(GetX,GetY,3,angle+i*6+8,RED01,60);
		CreateShotFromScript( "shot1",GetX, GetY, 0.5, angle+i*6-2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1, angle+i*6+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 1.5, angle+i*6+2, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2, angle+i*6+4, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 2.5, angle+i*6+6, 60, RED01);
		CreateShotFromScript( "shot1",GetX, GetY, 3,angle+i*6+8, 60, RED01);
	*/	CreateShot01ToItem(GetX,GetY,1,angle+i*4,RED01,60);
		CreateShot01ToItem(GetX,GetY,1.5,angle+i*4+1,RED01,60);
		CreateShot01ToItem(GetX,GetY,2,angle+i*4+2,RED01,60);
		CreateShot01ToItem(GetX,GetY,2.5,angle+i*4+3,RED01,60);
		CreateShot01ToItem(GetX,GetY,3,angle+i*4+4,RED01,60);
		CreateShot01ToItem(GetX,GetY,3.5,angle+i*4+5,RED01,60);
		}
		wait(180);
	}
}

}

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"
