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

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

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

        @Finalize
        {
		SetCommonData("STAGE4HAYAMAWASHI1",true);
		MagicCircleBreak(GetX,GetY,2,0.3);
		FinalizeItemAndShotnumWithDelete(5);
        } 

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);
let angle=0;
loop(50)
{
	ascent(i in 0..8)
	{
		SkyCreateShot01(GetX,GetY,4,angle+i*45,9,5);
	}
wait(15);
}
}

task shotE
{
wait(60);
let angle=0;
loop(50)
{
	ascent(i in 0..15)
	{
		SkyCreateShot01(GetX,GetY,4,angle+i*24,9,5);
	}
wait(15);
}
}

task shotA
{
wait(60);
let angle=0;
loop(50)
{
	ascent(i in 0..20)
	{
		SkyCreateShot01(GetX,GetY,4.5,angle+i*18,9,5);
	}
wait(15);
}

}

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

task move
{
	let speed=GetSpeed;
	SetSpeed(GetSpeed);
	SetAngle(GetAngle);
	wait(210);
	loop(60)
	{
		SetSpeed(GetSpeed-speed/60);
		yield;
	}
	SetAngle(180-GetAngle);
	loop(60)
	{
		SetSpeed(GetSpeed+speed/60);
		yield;
	}
	wait(15);
	loop(60)
	{
		SetSpeed(GetSpeed-speed/60);
		yield;
	}
	SetAngle(180-GetAngle);
	loop(60)
	{
		SetSpeed(GetSpeed+speed/60);
		yield;
	}
}

#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")
	{
		if(absolute(num)==1)
		{
		shotM1;
		}
		if(absolute(num)==2)
		{
		shotM2;
		}
	}
	case("Extream")
	{
		if(absolute(num)==1)
		{
		shotE1;
		}
		if(absolute(num)==2)
		{
		shotE2;
		}
	}
	case("Apocalypse")
	{
		if(absolute(num)==1)
		{
		shotA1;
		}
		if(absolute(num)==2)
		{
		shotA2;
		}
	}

	ElementalAutoErazeTime(890);
    }

task shotM1
{
wait(120);
let angle=90;
loop(50)
{
angle=90+rand(-5,5);
	ascent(i in -1..2)
	{
		SkyCreateShot01(GetX,GetY,2.5,angle+15*i,14,5);
	}
wait(30);
}
}

task shotM2
{
wait(60);
let angle=90;
loop(50)
{
	ascent(j in 0..5)
	{
		ascent( i in 0..6)
		{
			SkyCreateShot01(GetX,GetY,3+j*0.25,angle+i*60+j*2,9,5);
		}
	wait(3);
	}
wait(5);
angle+=10;
}
}
///////////////////////////////////////////////////////////////
task shotE1
{
wait(120);
let angle=90;
loop(50)
{
angle=90+rand(-15,15);
SkyCreateShot01(GetX,GetY,2.5,angle,14,5);
wait(7);
}
}

task shotE2
{
wait(60);
let angle=90;
loop(50)
{
	ascent(j in 0..6)
	{
		ascent(i in 0..8)
		{
			SkyCreateShot01(GetX,GetY,3+j*0.25,angle+i*45+j*2,9,5);
		}
	wait(2);
	}
wait(10);
angle+=10;
}
}
//////////////////////////////////////////////////////////////
task shotA1
{
wait(120);
let angle=90;
loop(50)
{
angle=90+rand(-5,5);
ascent(i in -1..2)
{
SkyCreateShot01(GetX,GetY,3.5,angle+i*35,14,5);
}
wait(7);
}
}

task shotA2
{
wait(60);
let angle=90;
loop(50)
{
	ascent(j in 0..5)
	{
		ascent(i in 0..8)
		{
			SkyCreateShot01(GetX,GetY,3+j*0.25,angle+i*45+j*2,9,5);
		}
	wait(1);
	}
wait(15);
angle+=10;
}
}

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

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