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

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


	let MagicRadius=16;
	let MagicRadius2=32;
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

    @Initialize {
        SetLife(120);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(3);
	Tmain;
	}

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

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

        @Finalize
        {
		MagicCircleBreak(GetX,GetY,1,0.3);
		FinalizeItemAndShotnum(2);
        } 

task Tmain
{
yield;
OutDamageRateZero;
AutoErazeTime(900);
GetDamege;
MagicColor;
move;
summon;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Moderate")
{
shotM;
}
case("Extream")
{
shotE;
}
case("Apocalypse")
{
shotA;
}

}


task move
{
	SetSpeed(GetSpeed);
	SetAngle(GetAngle);
	wait(600);
	loop(60)
	{
		SetSpeed(GetSpeed+1/60);
		yield;
	}
}

task shotM
{
wait(30);
loop(5)
{
let angle=GetAngleToPlayer;
ascent(let j in 0..5)
{
	GroundCreateShot01(GetX, GetY,4.0+j*0.25,angle,9,5);
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer+90), GetY+MagicRadius*sin(GetAngleToPlayer+90),4.0+j*0.25,angle,9,5);
	GroundCreateShot01(GetX+MagicRadius2*cos(GetAngleToPlayer+90), GetY+MagicRadius2*sin(GetAngleToPlayer+90),4.0+j*0.25,angle,9,5);
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer-90), GetY+MagicRadius*sin(GetAngleToPlayer-90),4.0+j*0.25,angle,9,5);
	GroundCreateShot01(GetX+MagicRadius2*cos(GetAngleToPlayer-90), GetY+MagicRadius2*sin(GetAngleToPlayer-90),4.0+j*0.25,angle,9,5);
}
wait(60);
}
}
///////////////////////////////////////////////
task shotE
{
wait(30);
loop(5)
{
let angle=GetAngleToPlayer;
ascent(let j in 0..6)
{
	GroundCreateShot01(GetX, GetY,4.0+j*0.25,angle,9,5);
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer+90), GetY+MagicRadius*sin(GetAngleToPlayer+90),4.0+j*0.25,angle+2,9,5);
	GroundCreateShot01(GetX+MagicRadius2*cos(GetAngleToPlayer+90), GetY+MagicRadius2*sin(GetAngleToPlayer+90),4.0+j*0.25,angle+4,9,5);
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer-90), GetY+MagicRadius*sin(GetAngleToPlayer-90),4.0+j*0.25,angle-2,9,5);
	GroundCreateShot01(GetX+MagicRadius2*cos(GetAngleToPlayer-90), GetY+MagicRadius2*sin(GetAngleToPlayer-90),4.0+j*0.25,angle-4,9,5);
}
wait(60);
}
}
/////////////////////////////////////////////////
task shotA
{
wait(30);
loop(5)
{
let angle=GetAngleToPlayer;
ascent(let j in 0..8)
{
	GroundCreateShot01(GetX, GetY,4.0+j*0.25,angle,9,5);
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer+90), GetY+MagicRadius*sin(GetAngleToPlayer+90),4.0+j*0.25,angle+3,9,5);
	GroundCreateShot01(GetX+MagicRadius2*cos(GetAngleToPlayer+90), GetY+MagicRadius2*sin(GetAngleToPlayer+90),4.0+j*0.25,angle+6,9,5);
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer-90), GetY+MagicRadius*sin(GetAngleToPlayer-90),4.0+j*0.25,angle-3,9,5);
	GroundCreateShot01(GetX+MagicRadius2*cos(GetAngleToPlayer-90), GetY+MagicRadius2*sin(GetAngleToPlayer-90),4.0+j*0.25,angle-6,9,5);
}
wait(60);
}
}

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

        CreateEnemyFromScript("Familiar", GetX, GetY,
                              GetSpeed, GetSpeed, 2);
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              GetSpeed, GetSpeed, -2);
}

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

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
	let num = GetArgument;
	let MagicRadius=20*absolute(num);
	let BaseAngle=GetAngle;
	let BaseX=GetX;
	let BaseY=GetY;
	let BaseSpeed=GetSpeed;
    @Initialize {
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,100,100);
	TMain;
    }

    @MainLoop {
	BaseAngle=atan2(GetPlayerY-BaseY,GetPlayerX-BaseX);
	BaseY+=BaseSpeed;
	SetX(BaseX+MagicRadius*cos(BaseAngle+90*absolute(num)/num));
	SetY(BaseY+MagicRadius*sin(BaseAngle+90*absolute(num)/num));
        yield;
    }

    @DrawLoop {
     //   DrawGraphic(GetX, GetY);
    }
	@Finalize
	{
		MagicCircleBreak(GetX,GetY,11,0.3);
	}
    task TMain {
        yield;
	ElementalEffect(0,0,255,0.5);
	AutoErazeTime(590);
    }

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

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