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

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

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

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

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

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

task move
{
	SetSpeed(1);
	SetAngle(90);
}

task summon
{
	CreateEnemyFromScript("Familiar", GetX, GetY,2, 0, 1);
	CreateEnemyFromScript("Familiar", GetX, GetY,2, 180, -1);
}

task shot
{
wait(60);
let r=2;
let angle=90;
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..5)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+60,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-60,33,0);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..6)
		{
			CreateShot01(GetX,GetY,1.8+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,1.8+i*0.2,angle+30,33,0);
			CreateShot01(GetX,GetY,1.8+i*0.2,angle-30,33,0);
		}
		wait(60);
	}
}
case("Hard")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..8)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+40,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-40,33,0);
		}
		wait(60);
	}
}
case("Lunatic")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+10,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-10,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+30,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-30,33,0);
		}
		wait(60);
	}
}
}

task eraze
{
while(!BeVanished)
{
        	if(GetX<GetClipMinX-64||GetX>GetClipMaxX+64||GetY<GetClipMinY-32||GetY>GetClipMaxY+64)
        	{
        		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;
	if(num<=3)
	{
		dir=1;
	}
	else
	{
		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,10);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
	SetCollisionA(GetX(),GetY(),32);
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

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

    task TMain {
        yield;
	move;
	shot;
    }

task move
{
let r=50;
loop
{
	SetCoordinateType(COODINATE_TYPE_PARENT);
	SetX(r*num);
	SetY(0);
	SetCoordinateType(COODINATE_TYPE_ABSOLUTE);
	yield;
	if(BeParentVanished==true)
	{
		break;
	}
}
VanishEnemy;
}

task shot
{
wait(60);
alternative(SelectedDifficult)
case("Easy")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..5)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+60,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-60,33,0);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..6)
		{
			CreateShot01(GetX,GetY,1.8+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,1.8+i*0.2,angle+30,33,0);
			CreateShot01(GetX,GetY,1.8+i*0.2,angle-30,33,0);
		}
		wait(60);
	}
}
case("Hard")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..8)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+40,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-40,33,0);
		}
		wait(60);
	}
}
case("Lunatic")
{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+10,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-10,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-20,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle+30,33,0);
			CreateShot01(GetX,GetY,2+i*0.2,angle-30,33,0);
		}
		wait(60);
	}
}
}



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