script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy=csd~"..\lib\fairy_red.png";
	let imgFam  = csd ~ "..\img\familiar.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(2500);
        SetDamageRate(100,100);
	SetInvincibility(300);
	SetTexture(imgEnemy);
	SetTexture(imgFam);
	Initialize_Fairy(7);
	Tmain;
	}

    @MainLoop {
	SetCollisionA(GetX(),GetY(),48);
        SetCollisionB(GetX(),GetY(),8);
	if(GetLife<=1000)
	{
       	 	SetLife(0);
	}
	yield;
    }

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

        @Finalize
        {
		if(!BeVanished)
		{
			loop(40)
			{
				ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
	DeleteEnemyShotToItem(SHOT);
        } 

task Tmain
{
yield;
GetDamege;
move;
summon;
Explode(1);
ItemDrop;
eraze;
}

task ItemDrop
{
	while(GetLife>1000)
	{
		yield;
	}
		if(!BeVanished)
		{
			loop(40)
			{
				ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
	SetCommonData("stage5daizakoVanish",true);
	VanishEnemy;
}

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

task move
{
	SetMovePosition03(GetX,GetCenterY-140,20,5);
	wait(240);
	SetSpeed(0.1);
	SetAngle(90);
}

task summon
{
wait(120);
alternative(SelectedDifficult)
case("Easy")
{
	ascent(let i in 0..3)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*120,1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*120, -1);
	}
}
case("Normal")
{
	ascent(let i in 0..4)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*90,1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*90, -1);
	}
}
case("Hard")
{
	ascent(let i in 0..5)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*72,1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*72, -1);
	}
}
case("Lunatic")
{
	ascent(let i in 0..6)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*60,1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*60, -1);
	}
}
case("Extra")
{
	ascent(let i in 0..8)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*45,1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*45, -1);
	}
}
}


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"
}

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
	let dir = num;
	let angle=GetAngle;
	let speed=GetSpeed;
	let X=GetX;
	let Y=GetY;
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(10000);
	SetDamageRateEx(100,100,100,1);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
	SetCollisionA(GetX(),GetY(),32);
	if(GetCommonDataDefault("stage5daizakoVanish",false)==true)
	{
		ItemSet(GetX,GetY,1);
		VanishEnemy;
	}
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

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

    task TMain {
        yield;
	move;
	shot;
    }

task move
{
let r=0;
loop(60)
{
	SetX(X+r*cos(angle));
	SetY(Y+r*sin(angle));
	r+=1.1+0.4*dir;
	angle+=5*dir;
	yield;
}
loop
{
SetCoordinateType(COODINATE_TYPE_PARENT);
	SetX(r*cos(angle));
	SetY(r*sin(angle));
SetCoordinateType(COODINATE_TYPE_ABSOLUTE);
	angle+=5*dir;
	yield;
}
VanishEnemy;
}

task shot
{
wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop
	{
	//	CreateShot01(GetX,GetY,1.5,angle,33,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1.5,angle, 0, 33);
		CreateShot01ToItem(GetX,GetY,1.5,angle,33,0);
		wait(5);
	}
}
case("Normal")
{
	loop
	{
	//	CreateShot01(GetX,GetY,1.5,angle,33,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1.5,angle, 0, 33);
		CreateShot01ToItem(GetX,GetY,1.5,angle,33,0);
		wait(5);
	}
}
case("Hard")
{
	loop
	{
	//	CreateShot01(GetX,GetY,1.5,angle,33,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1.5,angle, 0, 33);
		CreateShot01ToItem(GetX,GetY,1.5,angle,33,0);
		wait(5);
	}
}
case("Lunatic")
{
	loop
	{
	//	CreateShot01(GetX,GetY,1.5,angle,33,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1.5,angle, 0, 33);
		CreateShot01ToItem(GetX,GetY,1.5,angle,33,0);
		wait(5);
	}
}
case("Extra")
{
	loop
	{
	//	CreateShot01(GetX,GetY,2.5,angle,33,0);
	//	CreateShotFromScript( "shot1",GetX, GetY, 1.5,angle, 0, 33);
		CreateShot01ToItem(GetX,GetY,2.5,angle,33,0);
		wait(4);
	}
}
}


    // OtBbN̐ݒ
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}

#include_script ".\..\txt/EnemyShotData.txt"