script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let dir;
	if(num==1)
	{
		dir=1;
	}
	if(num==2)
	{
		dir=-1;
	}
	let imgEnemy;
	if(num==1)
	{
		imgEnemy=csd~"..\lib\fairy_red.png";
	}
	if(num==2)
	{
		imgEnemy=csd~"..\lib\fairy_blue.png";
	}
    let imgFam  = csd ~ "..\img\familiar.png";
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

    @Initialize {
        SetLife(500);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	SetTexture(imgFam);
	Initialize_Fairy(7);
	Tmain;
	}

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

        @DrawLoop {
		DrawFairy(imgEnemy);
	}

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

task Tmain
{
yield;
GetDamege;
move;
summon;
shot;
eraze;
}

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

task summon
{
	wait(60);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, 0, 1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, 120, 1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, 240, 1);
}

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

task shot
{
wait(120);
alternative(SelectedDifficult)
case("Easy")
{
	loop
	{
		ascent(let i in 0..8)
		{
			CreateShot01(GetX,GetY,2,GetAngleToPlayer+45*i+22.5,BLUE01,0);
		}
		wait(60);
	}
}
case("Normal")
{
	loop
	{
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,2.5,GetAngleToPlayer+30*i+15,BLUE01,0);
		}
		wait(60);
	}
}
case("Hard")
{
	loop
	{
		ascent(let i in 0..18)
		{
			CreateShot01(GetX,GetY,3,GetAngleToPlayer+20*i+10,BLUE01,0);
		}
		wait(30);
	}
}
case("Lunatic")
{
	loop
	{
		ascent(let i in 0..24)
		{
			CreateShot01(GetX,GetY,4,GetAngleToPlayer+15*i+7.5,BLUE01,0);
		}
		wait(20);
	}
}
}

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 angle=GetAngle;
	let speed=GetSpeed;
	let X=GetX;
	let Y=GetY;
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");
    @Initialize {
        SetLife(2000);
        SetTexture(imgFam);
        setGraphic;
	SetSpeed(speed);
	SetAngle(angle);
	TMain;
    }

    @MainLoop {
        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;
	angle+=1;
	yield;
}
loop(300)
{
	SetX(X+r*cos(angle));
	SetY(Y+r*sin(angle));
	angle+=1;
	yield;
}
loop(60)
{
	SetX(X+r*cos(angle));
	SetY(Y+r*sin(angle));
	r-=1;
	angle+=1;
	yield;
}
VanishEnemy;
}

task shot
{
wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer,RED01,5);
		wait(30);
	}
}
case("Normal")
{
	loop
	{
		CreateShot01(GetX,GetY,2.5,GetAngleToPlayer,RED01,5);
		wait(20);
	}
}
case("Hard")
{
	loop
	{
		CreateShot01(GetX,GetY,3,GetAngleToPlayer,RED01,5);
		wait(15);
	}
}
case("Lunatic")
{
	loop
	{
		CreateShot01(GetX,GetY,3.5,GetAngleToPlayer,RED01,5);
		wait(10);
	}
}
}



    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}