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

    @MainLoop {
	SetCollisionA(GetX(),GetY(),48);
        SetCollisionB(GetX(),GetY(),8);
	yield;
    }

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

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

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

task ItemDrop
{
	while(GetLife>1000)
	{
		yield;
	}
		if(!BeVanished)
		{
			loop(20)
			{
				ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),2);
			}
		}
	DeleteEnemyShotToItem(SHOT);
	if(num==1)
	{
	SetCommonData("stage5cyuubossmaeVanish1",true);
	}
	else
	{
	SetCommonData("stage5cyuubossmaeVanish2",true);
	}
	VanishEnemy;
}

task GetDamege
{
loop
{
	if(GetHitCount!=0)
	{
		SetColor(150,150,255);
		wait(10);
	}
	else
	{
		SetColor(255,255,255);
		if(GetLife<1150)
		{
			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 4..8)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*90, i*num);
	}
}
case("Normal")
{
	ascent(let i in 4..10)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*60, i*num);
	}
}
case("Hard")
{
	ascent(let i in 4..12)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*45, i*num);
	}
}
case("Lunatic")
{
	ascent(let i in 4..15)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*36, i*num);
	}
}
case("Extra")
{
	ascent(let i in 4..20)
	{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, i*24, i*num);
	}
}
}

task Subshot
{
wait(180);
let r=2;
let angle=90;
alternative(SelectedDifficult)
case("Easy")
{
	loop
	{
		ascent(let i in -2..3)
		{
		//	CreateShot01(GetX,GetY,3,GetAngleToPlayer+2*i,9,10);
			CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer+2*i,9,10);
		}
		wait(120);
	}
}
case("Normal")
{
	loop
	{
		ascent(let i in -3..4)
		{
		//	CreateShot01(GetX,GetY,3,GetAngleToPlayer+2*i,9,10);
			CreateShot01ToItem(GetX,GetY,3,GetAngleToPlayer+2*i,9,10);
		}
		wait(120);
	}
}
case("Hard")
{
	loop
	{
		ascent(let i in -4..5)
		{
		//	CreateShot01(GetX,GetY,3.5,GetAngleToPlayer+2*i,9,10);
			CreateShot01ToItem(GetX,GetY,3.5,GetAngleToPlayer+2*i,9,10);
		}
		wait(120);
	}
}
case("Lunatic")
{
	loop
	{
		ascent(let i in -5..6)
		{
		//	CreateShot01(GetX,GetY,3.5,GetAngleToPlayer+2*i,9,10);
			CreateShot01ToItem(GetX,GetY,3.5,GetAngleToPlayer+2*i,9,10);
		}
		wait(120);
	}
}
case("Extra")
{
	loop
	{
		ascent(let i in -6..7)
		{
		//	CreateShot01(GetX,GetY,3.5,GetAngleToPlayer+2*i,9,10);
			CreateShot01ToItem(GetX,GetY,4.0,GetAngleToPlayer+2*i,9,10);
		}
		wait(60);
	}
}
}

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=-1;
	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("stage5cyuubossmaeVanish1",false)==true && num>0)
	{
		ItemSet(GetX,GetY,1);
		VanishEnemy;
	}
	if(GetCommonDataDefault("stage5cyuubossmaeVanish2",false)==true && num<0)
	{
		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);
		CreateShot01ToItem(GetX,GetY,1.5,angle,33,0);
		wait(5);
	}
}
case("Normal")
{
	loop
	{
	//	CreateShot01(GetX,GetY,1.5,angle,33,0);
		CreateShot01ToItem(GetX,GetY,1.5,angle,33,0);
		wait(5);
	}
}
case("Hard")
{
	loop
	{
		CreateShot01(GetX,GetY,2.0,angle,33,0);
		CreateShot01ToItem(GetX,GetY,2.0,angle,33,0);
		wait(5);
	}
}
case("Lunatic")
{
	loop
	{
	//	CreateShot01(GetX,GetY,2.5,angle,33,0);
		CreateShot01ToItem(GetX,GetY,2.5,angle,33,0);
		wait(5);
	}
}
case("Extra")
{
	loop
	{
	//	CreateShot01(GetX,GetY,2.5,angle,33,0);
		CreateShot01ToItem(GetX,GetY,3,angle,33,0);
		wait(4);
	}
}
}


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