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 imgCircle=csd~"..\img\circle.png";
	let imgFam  = csd ~ "..\img\familiar.png";
	let MagicRadius=40;
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

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

    @MainLoop {
	SetCollisionA(GetX(),GetY(),48);
	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);
}

task shotM
{
wait(60);
loop(5)
{
let angle=GetAngleToPlayer;
ascent(let j in 0..3)
{
	ascent(let i in -1..2)
	{
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer+90), GetY+MagicRadius*sin(GetAngleToPlayer+90),3.0+j*0.5,angle+i*3,9,5);
	}
}
wait(15);
let angle=GetAngleToPlayer;
ascent(let j in 0..3)
{
	ascent(let i in -1..2)
	{
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer-90), GetY+MagicRadius*sin(GetAngleToPlayer-90),3.0+j*0.5,angle+i*3,9,5);
	}
}
wait(60);
}
}
///////////////////////////////////////////////
task shotE
{
wait(60);
loop(5)
{
let angle=GetAngleToPlayer;
ascent(let j in 0..3)
{
	ascent(let i in -3..4)
	{
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer+90), GetY+MagicRadius*sin(GetAngleToPlayer+90),3.0+j*0.5,angle+i*2,9,5);
	}
}
wait(15);
let angle=GetAngleToPlayer;
ascent(let j in 0..3)
{
	ascent(let i in -3..4)
	{
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer-90), GetY+MagicRadius*sin(GetAngleToPlayer-90),3.0+j*0.5,angle+i*2,9,5);
	}
}
wait(30);
}
}
/////////////////////////////////////////////////
task shotA
{
wait(60);
loop(5)
{
let angle=GetAngleToPlayer;
ascent(let j in 0..5)
{
	ascent(let i in -6..7)
	{
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer+90), GetY+MagicRadius*sin(GetAngleToPlayer+90),2.5+j*0.5,angle+i*1.5,9,5);
	}
}
wait(15);
let angle=GetAngleToPlayer;
ascent(let j in 0..5)
{
	ascent(let i in -6..7)
	{
	GroundCreateShot01(GetX+MagicRadius*cos(GetAngleToPlayer-90), GetY+MagicRadius*sin(GetAngleToPlayer-90),2.5+j*0.5,angle+i*1.5,9,5);
	}
}
wait(30);
}
}

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

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 MagicRadius=40;
	let num = GetArgument;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(1000);
        SetScore(10000);
        SetDamageRateEx(100,100,100,100);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
	SetX(MagicRadius*cos(GetAngleToPlayer+90*num));
	SetY(MagicRadius*sin(GetAngleToPlayer+90*num));
        yield;
    }

    @DrawLoop {
     //   DrawGraphic(GetX, GetY);
    }

    task TMain {
        yield;
	ElementalEffect(0,0,255,0.5);
	AutoErazeTime(890);
    }


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

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