script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy;
	if(num==1)
	{
		imgEnemy=csd~"..\lib\fairy_red.png";
	}
	if(num==2)
	{
		imgEnemy=csd~"..\lib\fairy_blue.png";
	}

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

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

    @MainLoop {
	BulletNum=GetEnemyShotCount;
	ascent(let i in -1..2)
	{
	SetSkyCollision(GetX+i*16,GetY,32);
	}
	yield;
    }

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

        @Finalize
        {
		MagicCircleBreak(GetX,GetY,2,0.5);
		FinalizeItemAndShotnumWithDelete(5);
        } 

task Tmain
{
yield;
summon;
OutDamageRateZero;
AutoErazeTime(1200);
GetDamege;
//MagicColor;
move;

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

}


task move
{
//	SetMovePosition02(GetCenterX,GetCenterY-64,480);
//	wait(241);
	SetSpeed(GetSpeed);
	SetAngle(90);
}

task shotM
{
wait(60);
let dir=rand_int(0,1)*2-1;
loop
{
let angle=90+rand(-3,3);
	loop(8)
	{

	ascent(i in 1..5)
	{
	SkyCreateShot01(GetX,GetY,5,angle+i*6.5,9,5);
	}
	ascent(i in 1..5)
	{
	SkyCreateShot01(GetX,GetY,5,angle-i*6.5,9,5);
	}
	wait(3);
	angle+=0.5*dir;
	}
dir=dir*-1;
wait(30);
}
}
/////////////////////////////////////////////////////
task shotE
{
wait(60);
loop
{
let angle=GetAngleToPlayer;
	ascent(i in -3..3)
	{
		if(GetPlayerY>GetY+15)
		{
		SkyCreateShot01(GetX,GetY,3.0,angle+i*6.0,9,5);
		}
	}
wait(30);
}
}
/////////////////////////////////////////////////////////
task shotA
{
wait(60);
loop
{
let angle=GetAngleToPlayer;
	ascent(i in -4..4)
	{
		if(GetPlayerY>GetY+15)
		{
		SkyCreateShot01(GetX,GetY,3.0,angle+i*5.0,9,5);
		SkyCreateShot01(GetX,GetY,2.5,angle+i*5.0,9,5);
		}
	}
wait(30);
}
}

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

#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;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);
	TMain;
    }

    @MainLoop {
	SetSkyCollision(GetX,GetY,48);
        yield;
    }

    @DrawLoop {
       // DrawGraphic(GetX, GetY);
    }
        @Finalize
        {
		FinalizeItemAndShotnum(1);
		MagicCircleBreak(GetX,GetY,10,0.3);
        } 
    task TMain {
        yield;
	ZakoEffect(255,0,0);
	GetDamege;
	move;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Moderate")
{
shotM;
}
case("Extream")
{
shotE;
}
case("Apocalypse")
{
shotA;
}
	ElementalAutoErazeTime(1190);
    }

task move
{
	loop
	{
		SetX(num*80);
		SetY(-10);
		yield;
	}
}

task shotM
{
let r=20;
wait(30);
	loop
	{
	shot1;
	wait(15);
	}

	task shot1
	{
		ascent(i in -1..2)
		{
		SkyCreateShot01(GetX,GetY,4,GetAngle+90+i*45,9,0);
		}
	}
}
///////////////////////////////////////////////////////////////
task shotE
{
let r=20;
wait(30);
SubShot;
	loop
	{
	shot1;
	wait(10);
	}

	task shot1
	{
		ascent(i in -1..2)
		{
		SkyCreateShot01(GetX,GetY,4,GetAngle+90+i*45,9,0);
		}
	}

	task SubShot
	{
	loop
	{
		let angle=+rand(-5,5);
		ascent(i in -6..7)
		{
		SkyCreateShot01(GetX,GetY,4,GetAngle+90+i*10+angle,9,0);
		SkyCreateShot01(GetX,GetY,3.75,GetAngle+90+i*10+angle,9,0);
		SkyCreateShot01(GetX,GetY,3.5,GetAngle+90+i*10+angle,9,0);
		}
	wait(60);
	}
	}
}
//////////////////////////////////////////////////////////////
task shotA
{
let r=20;
wait(30);
SubShot;
	loop
	{
	shot1;
	wait(10);
	}

	task shot1
	{
		ascent(i in -1..2)
		{
		SkyCreateShot01(GetX,GetY,4,GetAngle+90+i*45,9,0);
		}
	}

	task SubShot
	{
	loop
	{
		let angle=+rand(-5,5);
		ascent(i in -6..7)
		{
		SkyCreateShot01(GetX,GetY,3.75,GetAngle+90+i*10+angle,9,0);
		SkyCreateShot01(GetX,GetY,3.5,GetAngle+90+i*10+angle,9,0);
		SkyCreateShot01(GetX,GetY,4,GetAngle+90+i*10+angle,9,0);
		SkyCreateShot01(GetX,GetY,4.25,GetAngle+90+i*10+angle,9,0);
		SkyCreateShot01(GetX,GetY,4.5,GetAngle+90+i*10+angle,9,0);
		}
	wait(60);
	}
	}
}

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


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