script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy;

		imgEnemy=csd~"..\lib\fairy_red.png";

	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

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

    @MainLoop {
	BulletNum=GetEnemyShotCount;
	SetSkyCollision(GetX,GetY,48);
	SetDummySkyCollision(GetX+60,GetY,48);
	SetDummySkyCollision(GetX-60,GetY,48);
	yield;
    }

        @DrawLoop {
		SetColor(ZakoColor[0],ZakoColor[1],ZakoColor[2]);
		DrawFairy(imgEnemy);
		DrawMagicCircle("BLUE",0.50);
	}

        @Finalize
        {
		MagicCircleBreak(GetX,GetY,2,0.5);
		FinalizeItemAndShotnumWithDelete(5);
	//	SetCommonData("STAGE5BIGENEMY1HAYAMAWASI",false);
        } 

task Tmain
{
yield;
OutDamageRateZero;
AutoErazeTime(900);
GetDamege;
move;

summon;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
		shotM;
	}
	case("Extream")
	{
		shotE;
	}
	case("Apocalypse")
	{
		shotA;
	}

}

task shotM
{
wait(60);
while(GetLife>750)
{
	let angle=GetAngleToPlayer+rand(-1,1);
	ascent(i in -2..3)
	{
	GroundCreateShot01(GetX,GetY,5,angle+i*15,9,5);
	}
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	wait(15);
}
SetCommonData("S5BE2",true);
loop
{
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	let angle=GetAngleToPlayer;
	loop(5)
	{
	ascent(j in -1..2)
	{
	ascent(i in -1..2)
	{
	GroundCreateShot01(GetX,GetY,5,angle+2*i+j*30,9,5);
	}
	}
	wait(3);
	}
	wait(30);
}

}

task shotE
{
wait(60);
while(GetLife>750)
{
	let angle=GetAngleToPlayer+rand(-3,3);
	ascent(i in -4..5)
	{
	GroundCreateShot01(GetX,GetY,4,angle+i*12,9,5);
	}
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	wait(12);
}
SetCommonData("S5BE2",true);
loop
{
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	let angle=GetAngleToPlayer;
	ascent(let k in 0..5)
	{
	ascent(let j in 0..k+1)
	{
	ascent(i in -1..2)
	{
	GroundCreateShot01(GetX,GetY,5,angle+j*3-1.5*k+i*30,9,5);
	}
	}
	wait(3);
	}
	wait(30);
}

}


task shotA
{
wait(60);
while(GetLife>750)
{
	let angle=GetAngleToPlayer+rand(-1,1);
	ascent(i in -5..6)
	{
	GroundCreateShot01(GetX,GetY,5,angle+i*10,9,5);
	}
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	wait(10);
}
SetCommonData("S5BE2",true);
wait(30);
loop
{
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	let angle=GetAngleToPlayer;
	ascent(let k in 0..5)
	{
	ascent(let j in 0..k+1)
	{
	ascent(i in -2..3)
	{
	GroundCreateShot01(GetX,GetY,5,angle+j*3-1.5*k+i*30,9,5);
	}
	}
	wait(3);
	}
	descent(let k in 0..4)
	{
	ascent(let j in 0..k+1)
	{
	ascent(i in -2..3)
	{
	GroundCreateShot01(GetX,GetY,5,angle+j*3-1.5*k+i*30,9,5);
	}
	}
	wait(3);
	}
	wait(18);
}

}


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

task move
{
	SetMovePosition03(GetX,GetCenterY-120,10,2);
	wait(120);
	SetMovePosition03(GetX+50,GetCenterY-120,10,1);
	//SetSpeed(0.5);
	//SetAngle(0);
	wait(90);
	SetSpeed(0);
	SetAngle(180);
	wait(60);
	SetSpeed(0.5);
	SetAngle(180);
	wait(360);
	SetCommonData("S5BE2ShotStop",true);
}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib\lib_anime_fairy.txt"
}

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
	let num = GetArgument;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,0,100,0);
	TMain;
    }

    @MainLoop {
	SetServantSkyCollision(GetX,GetY,48);
	SetX(60*num);
	SetY(0);
        yield;
    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }
        @Finalize
        {
		MagicCircleBreak(GetX,GetY,11,0.3);
		FinalizeItemAndShotnum(1);
        } 
    task TMain {
        yield;
	ElementalEffect(0,0,255,0.75);
	GetDamege;
	OutDamageRateZero;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
		shotM1;
		shotM2;
	}
	case("Extream")
	{
		shotE1;
		shotE2;
	}
	case("Apocalypse")
	{
		shotA1;
		shotA2;
	}

	ElementalAutoErazeTime(890);
    }
task shotM1
{
wait(60+num*7.5);
let angle=90;
while(!GetCommonDataDefault("S5BE2",false))
{
	loop(2)
	{
		angle=GetAngleToPlayer;
		loop(5)
		{
			SkyCreateShot01(GetX,GetY,4.0,angle,14,5);
			wait(3);
		}
		if(GetCommonDataDefault("S5BE2",false)){break;}
		wait(15);
	}
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	wait(30);
}

}

task shotM2
{
while(!GetCommonDataDefault("S5BE2",false)){yield;}
//wait(30);
let angle=20;
loop
{
if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
loop(15)
{
	SkyCreateShot01(GetX,GetY,4.0,angle,14,5);
	angle+=10;
	wait(2);
}
loop(15)
{
	SkyCreateShot01(GetX,GetY,4.0,angle,14,5);
	angle-=10;
	wait(2);
}
}
}

///////////////////////////////////////////////////////////////
task shotE1
{
wait(60+num*7.5);
let angle=90;
while(!GetCommonDataDefault("S5BE2",false))
{
	loop(2)
	{
		angle=GetAngleToPlayer;
		loop(5)
		{
			ascent(i in -1..2)
			{
			SkyCreateShot01(GetX,GetY,4.0,angle+15*i,14,5);
			}
			wait(3);
		}
		if(GetCommonDataDefault("S5BE2",false)){break;}
		wait(15);
	}
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	wait(30);
}

}

task shotE2
{
while(!GetCommonDataDefault("S5BE2",false)){yield;}
//wait(30);
let angle=20;
loop
{
if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
loop(15)
{
	SkyCreateShot01(GetX,GetY,3.75,angle,14,5);
	SkyCreateShot01(GetX,GetY,3.5,angle,14,5);
	angle+=10;
	wait(2);
}
loop(15)
{
	SkyCreateShot01(GetX,GetY,3.75,angle,14,5);
	SkyCreateShot01(GetX,GetY,3.5,angle,14,5);
	angle-=10;
	wait(2);
}
}
}
//////////////////////////////////////////////////////////////
task shotA1
{
wait(60+num*7.5);
let angle=90;
while(!GetCommonDataDefault("S5BE2",false))
{
	loop(2)
	{
		angle=GetAngleToPlayer;
		loop(8)
		{
			ascent(i in -2..3)
			{
			SkyCreateShot01(GetX,GetY,4.0,angle+15*i,14,5);
			}
			wait(2);
		}
		if(GetCommonDataDefault("S5BE2",false)){break;}
		wait(14);
	}
	if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
	wait(30);
}

}

task shotA2
{
while(!GetCommonDataDefault("S5BE2",false)){yield;}
//wait(30);
let angle=20;
loop
{
if(GetCommonDataDefault("S5BE2ShotStop",false)){break;}
loop(15)
{
	SkyCreateShot01(GetX,GetY,3.5,angle,14,5);
	angle+=5;
	wait(1);
	SkyCreateShot01(GetX,GetY,3.0,angle,14,5);
	angle+=5;
	wait(1);
}
loop(15)
{
	SkyCreateShot01(GetX,GetY,3.5,angle,14,5);
	angle-=5;
	wait(1);
	SkyCreateShot01(GetX,GetY,3.0,angle,14,5);
	angle-=5;
	wait(1);
}
}
}

#include_function ".\..\txt/StageEnemydata.txt"
}

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