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

    @MainLoop {
	BulletNum=GetEnemyShotCount;
	SetCollisionA(GetX,GetY,48);
        MSDSetCollisionB(GetX(),GetY(),8);
	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("STAGE3HAYAWAMASHI",true);
        } 

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

summon(GetX,GetY);

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

}

task summon(x,y)
{
wait(30);
	ascent(let i in 0..8)
	{
        CreateEnemyFromScript("Familiar", x, y,
                              0, 0, i);
	wait(30);
	}
}

task move
{
	let angle=-10;
	SetSpeed(1.5);
	SetAngle(angle);
	wait(180);
	loop(90)
	{
		angle+=100/90;
		SetAngle(angle);
		yield;
	}
	wait(60);
	loop(90)
	{
		angle+=110/90;
		SetAngle(angle);
		yield;
	}
	wait(120);
	loop(60)
	{
		angle+=150/90;
		SetAngle(angle);
		yield;
	}
}

task shotM
{
wait(30);
loop
{
let angle=rand(-3,3);
	ascent(let i in -10..11)
	{
		CreateShot01(GetX,GetY,3,GetAngle+angle+i*6,9,5);
	}
wait(30);
}
}

task shotE
{
wait(30);
loop
{
let angle=rand(-3,3);
	ascent(let i in -15..16)
	{
		CreateShot01(GetX,GetY,2.5,GetAngle+angle+i*6.25,9,5);
	}
wait(20);
}
}

task shotA
{
wait(30);
loop
{
let angle=rand(-3,3);
	ascent(let i in -15..16)
	{
		CreateShot01(GetX,GetY,2.25,GetAngle+angle+i*6.75,9,5);
	}
wait(15);
}
}
#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\txt/Stage3FairyCommondata.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(10000);
        SetScore(10000);
        SetDamageRateEx(100,100,50,50);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

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

    @DrawLoop {
       // DrawGraphic(GetX, GetY);
    }
        @Finalize
        {
		FinalizeItemAndShotnum(1);
        } 
    task TMain {
        yield;
	ElementalEffect(255,255,0,1.0);
	ElementalAutoErazeTime(890);
	OutDamageRateZero;
	GetDamege;
	move;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Moderate")
{
shotM;
}
case("Extream")
{
shotE;
}
case("Apocalypse")
{
shotA;
}
    }

task move
{
	let angle=-10;
	SetSpeed(1.5);
	SetAngle(angle);
	wait(180);
	loop(90)
	{
		angle+=100/90;
		SetAngle(angle);
		yield;
	}
	wait(60);
	loop(90)
	{
		angle+=110/90;
		SetAngle(angle);
		yield;
	}
	wait(120);
	loop(60)
	{
		angle+=150/90;
		SetAngle(angle);
		yield;
	}
}

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

	task shot1
	{
		CreateShot01(GetX+r*cos(GetAngle-90),GetY+r*sin(GetAngle-90),4,GetAngle-90,9,5);
		CreateShot01(GetX+r*cos(GetAngle+90),GetY+r*sin(GetAngle+90),4,GetAngle+90,9,5);
	}
}
///////////////////////////////////////////////////////////////
task shotE
{
let r=20;
wait(30);
	loop
	{
	shot1;
	wait(10);
	}

	task shot1
	{
		CreateShot01(GetX+r*cos(GetAngle-90),GetY+r*sin(GetAngle-90),3,GetAngle-90,9,5);
		CreateShot01(GetX+r*cos(GetAngle+90),GetY+r*sin(GetAngle+90),3,GetAngle+90,9,5);
	}
}
//////////////////////////////////////////////////////////////
task shotA
{
let r=20;
wait(30);
	loop
	{
	shot1;
	wait(5);
	}

	task shot1
	{
		CreateShot01(GetX+r*cos(GetAngle-90),GetY+r*sin(GetAngle-90),3,GetAngle-90,9,5);
		CreateShot01(GetX+r*cos(GetAngle+90),GetY+r*sin(GetAngle+90),3,GetAngle+90,9,5);
	}

}


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

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