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

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

        @DrawLoop {
	if(GetLife>1000)
	{
		DrawFairy(imgEnemy );
       SetTexture(imgFam);
	setGraphic;
        DrawGraphic(GetX+50, GetY);
       SetTexture(imgFam);
	setGraphic;
        DrawGraphic(GetX-50, GetY);
	}
	}

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

task Tmain
{
yield;
GetDamege;
move;
shot;
//summon;
eraze;
AutoErazeTime(3600);
Explode(1);
ItemDrop;
}

task ItemDrop
{
	while(GetLife>1000)
	{
		yield;
	}
		if(!BeVanished)
		{
			loop(8)
			{
				ItemSet(GetX+rand(-20,20),GetY+rand(-20,20),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
{
	SetSpeed(1);
	SetAngle(90);
loop
{
	if(GetLife<=1000)
	{
	SetSpeed(10);
	}
yield;
}
}

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)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer+rand(-10,10);
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX-50)+rand(-10,10);
		let angle3=atan2(GetPlayerY-GetY,GetPlayerX-GetX+50)+rand(-10,10);
		ascent(let i in 0..5)
		{
		//	CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		//	CreateShot01(GetX+50,GetY,2+i*0.2,angle2,33,0);
		//	CreateShot01(GetX-50,GetY,2+i*0.2,angle3,33,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01ToItem(GetX+50,GetY,2+i*0.2,angle2,33,0);
			CreateShot01ToItem(GetX-50,GetY,2+i*0.2,angle3,33,0);
		}
		wait(60);

	}
}
case("Normal")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer+rand(-10,10);
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX-50)+rand(-10,10);
		let angle3=atan2(GetPlayerY-GetY,GetPlayerX-GetX+50)+rand(-10,10);
		ascent(let i in 0..6)
		{
		//	CreateShot01(GetX,GetY,1.8+i*0.2,angle,33,0);
		//	CreateShot01(GetX+50,GetY,1.8+i*0.2,angle2,33,0);
		//	CreateShot01(GetX-50,GetY,1.8+i*0.2,angle3,33,0);
			CreateShot01ToItem(GetX,GetY,1.8+i*0.2,angle,33,0);
			CreateShot01ToItem(GetX+50,GetY,1.8+i*0.2,angle2,33,0);
			CreateShot01ToItem(GetX-50,GetY,1.8+i*0.2,angle3,33,0);
		}
		wait(60);

	}
}
case("Hard")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer+rand(-10,10);
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX-50)+rand(-10,10);
		let angle3=atan2(GetPlayerY-GetY,GetPlayerX-GetX+50)+rand(-10,10);
		ascent(let i in 0..8)
		{
		//	CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		//	CreateShot01(GetX+50,GetY,2+i*0.2,angle2,33,0);
		//	CreateShot01(GetX-50,GetY,2+i*0.2,angle3,33,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01ToItem(GetX+50,GetY,2+i*0.2,angle2,33,0);
			CreateShot01ToItem(GetX-50,GetY,2+i*0.2,angle3,33,0);
		}
		wait(60);

	}
}
case("Lunatic")
{
	loop(3)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer+rand(-10,10);
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX-50)+rand(-10,10);
		let angle3=atan2(GetPlayerY-GetY,GetPlayerX-GetX+50)+rand(-10,10);
		ascent(let i in 0..12)
		{
		//	CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		//	CreateShot01(GetX+50,GetY,2+i*0.2,angle2,33,0);
		//	CreateShot01(GetX-50,GetY,2+i*0.2,angle3,33,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01ToItem(GetX+50,GetY,2+i*0.2,angle2,33,0);
			CreateShot01ToItem(GetX-50,GetY,2+i*0.2,angle3,33,0);
		}
		wait(60);

	}
}

case("Extra")
{
	loop(6)
	{
	if(GetLife<=1000)
	{
		break;
	}
		let angle=GetAngleToPlayer+rand(-10,10);
		let angle2=atan2(GetPlayerY-GetY,GetPlayerX-GetX-50)+rand(-10,10);
		let angle3=atan2(GetPlayerY-GetY,GetPlayerX-GetX+50)+rand(-10,10);
		ascent(let i in 0..15)
		{
		//	CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		//	CreateShot01(GetX+50,GetY,2+i*0.2,angle2,33,0);
		//	CreateShot01(GetX-50,GetY,2+i*0.2,angle3,33,0);
			CreateShot01ToItem(GetX,GetY,2+i*0.2,angle,33,0);
			CreateShot01ToItem(GetX+50,GetY,2+i*0.2,angle2,33,0);
			CreateShot01ToItem(GetX-50,GetY,2+i*0.2,angle3,33,0);
		}
		wait(30);

	}
}

}

task eraze
{
while(!BeVanished)
{
        	if(GetX<GetClipMinX-64||GetX>GetClipMaxX+64||GetY<GetClipMinY-32||GetY>GetClipMaxY+64)
        	{
        		VanishEnemy();
        	}
yield;
}
}

sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }

#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+rand(-10,10);
		ascent(let i in 0..5)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		}
		wait(60);
	}
}
case("Normal")
{
	loop(3)
	{
		let angle=GetAngleToPlayer+rand(-10,10);
		ascent(let i in 0..6)
		{
			CreateShot01(GetX,GetY,1.8+i*0.2,angle,33,0);
		}
		wait(60);
	}
}
case("Hard")
{
	loop(3)
	{
		let angle=GetAngleToPlayer+rand(-10,10);
		ascent(let i in 0..8)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		}
		wait(60);
	}
}
case("Lunatic")
{
	loop(3)
	{
		let angle=GetAngleToPlayer+rand(-10,10);
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,2+i*0.2,angle,33,0);
		}
		wait(60);
	}
}
}


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