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 {
	SpecialBreak=true;
	SetCommonData("STAGE5SNAKEENEMY2SpecialBreak",true);
        SetLife(1800);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(7);
	Tmain;
	}

    @MainLoop {
	if(GetLife<=1000){VanishEnemy;}
	BulletNum=GetEnemyShotCount;
	SetSkyCollision(GetX,GetY,48);
	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("STAGE5SNAKEENEMY2",true);
        } 

task Tmain
{
yield;
OutDamage=true;
OutDamageRateZero;
SpecialAutoErazeTime(1500);
GetDamege;
move;

summon(GetX,GetY);

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

wait(890);
SpecialBreak=false;

}

task SpecialAutoErazeTime(w)
{
SpecialZakoLifeDisplay;
loop(w)
{
if(GetCommonDataDefault("VanishSignal",false))
{
	break;
}

if(GetX<GetClipMinX-400 || GetClipMaxX+400<GetX || GetY<GetClipMinY-220 || GetClipMaxY+400<GetY)
{
	break;
}

yield;
}
SpecialBreak=false;

SetCommonData("STAGE5SNAKEENEMY2SpecialBreak",false);
VanishEnemy;
}


task SpecialZakoLifeDisplay//ライフバーのバー部分の設定
{
	let ZakoLifeMax=GetLife-1000;
	if(ZakoLifeMax<=20){return;}
	let scale=0.5;
	let Sscale=0.5;
	let XAdjust=25;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd ~ "..\img\ber.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -3);
		ObjEffect_SetVertexXY(obj, 1, 100,  -3);
		ObjEffect_SetVertexXY(obj, 2, 100, 3);
		ObjEffect_SetVertexXY(obj, 3,  0,  3);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  206, 27);
		ObjEffect_SetVertexUV(obj, 2, 206,  33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);
		ObjEffect_SetLayer(obj,2);
		ObjEffect_SetScale(obj, scale,0.16);

		ObjEffect_SetVertexColor(obj,0,150,255,255,0);
		ObjEffect_SetVertexColor(obj,1,150,255,0,0);
		ObjEffect_SetVertexColor(obj,2,150,255,0,0);
		ObjEffect_SetVertexColor(obj,3,150,255,255,0);

		while(GetLife>1000)
		{
			Obj_SetPosition(obj,GetX-XAdjust,GetY-16);
			scale=Sscale*(GetLife-1000)/ZakoLifeMax;
			ObjEffect_SetVertexColor(obj,0,255,255,255,0);
			ObjEffect_SetVertexColor(obj,1,255,255,255-255*(GetLife-1000)/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,2,255,255,255-255*(GetLife-1000)/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,3,255,255,255,0);
			if(GetLife==ZakoLifeMax)
			{
			ObjEffect_SetVertexColor(obj,0,0,255,255,0);
			ObjEffect_SetVertexColor(obj,1,0,255,255-255*(GetLife-1000)/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,2,0,255,255-255*(GetLife-1000)/ZakoLifeMax,0);
			ObjEffect_SetVertexColor(obj,3,0,255,255,0);
			}
			ObjEffect_SetScale(obj, scale,0.8);
			yield;
		}
		Obj_Delete(obj);
}

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

task move
{
	let angle=190;
	SetSpeed(1.5);
	SetAngle(angle);
	wait(150);
	loop(90)
	{
		angle-=100/90;
		SetAngle(angle);
		yield;
	}
}

task shotM
{
wait(30);
loop
{
let angle=rand(-3,3);
	ascent(let i in -10..11)
	{
		SkyCreateShot01(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)
	{
		SkyCreateShot01(GetX,GetY,2.5,GetAngle+angle+i*6.0,9,5);
	}
wait(20);
}
}

task shotA
{
wait(30);
loop
{
let angle=rand(-3,3);
	ascent(let i in -15..16)
	{
		SkyCreateShot01(GetX,GetY,3.0,GetAngle+angle+i*6.5,9,5);
	}
wait(15);
}
}
#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,0,50,0);
	TMain;
    }

    @MainLoop {
	SetSkyCollision(GetX,GetY,48);
        yield;
	if(GetCommonDataDefault("STAGE5SNAKEENEMY2",false))
	{
		SetSpeed(0);
	}
    }

    @DrawLoop {
       // DrawGraphic(GetX, GetY);
    }
        @Finalize
        {
		FinalizeItemAndShotnum(1);
		MagicCircleBreak(GetX,GetY,13,0.3);

		let MS=4;
		alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
		case("Moderate")
		{
			ascent(i in 0..8)
			{
			CreateShotA(0,GetX,GetY,5);
			SetShotDataA(0,0,0,GetAngleToPlayer+i*45,0,0.10,MS,9);
			FireShot(0);
			}
		}
		case("Extream")
		{
			ascent(i in 0..8)
			{
			CreateShotA(0,GetX,GetY,5);
			CreateShotA(1,GetX,GetY,5);
			SetShotDataA(0,0,0,GetAngleToPlayer+i*45,0,0.10,MS,9);
			SetShotDataA(1,0,0,GetAngleToPlayer+i*45,0,0.125,MS,9);
			FireShot(0);
			FireShot(1);
			}
		}
		case("Apocalypse")
		{	
			ascent(i in 0..8)
			{
			CreateShotA(0,GetX,GetY,5);
			CreateShotA(1,GetX,GetY,5);
			CreateShotA(2,GetX,GetY,5);
			SetShotDataA(0,0,0,GetAngleToPlayer+i*45,0,0.10,MS,9);
			SetShotDataA(1,0,0,GetAngleToPlayer+i*45,0,0.125,MS,9);
			SetShotDataA(2,0,0,GetAngleToPlayer+i*45,0,0.15,MS,9);
			FireShot(0);	
			FireShot(1);
			FireShot(2);	
			}
		}
        } 

    task TMain {
        yield;
	ElementalEffect(255,255,0,1.0);
	ElementalAutoErazeTime(1490);
	OutDamageRateZero;
	GetDamege;
	move;
	Break;
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Moderate")
{
shotM;
}
case("Extream")
{
shotE;
}
case("Apocalypse")
{
shotA;
}
    }

task Break
{
loop
{
	if(GetCommonDataDefault("STAGE5SNAKEENEMY2",false))
	{
		wait(num*3+15);
		AddLife(-GetLife);
	}
	if(!GetCommonDataDefault("STAGE5SNAKEENEMY2SpecialBreak",true))
	{
		VanishEnemy;
	}
yield;
}
}

task move
{
	let angle=190;
	SetSpeed(1.5);
	SetAngle(angle);
	wait(150);
	loop(90)
	{
		angle-=100/90;
		SetAngle(angle);
		yield;
	}
}

task shotM
{
let r=20;
wait(30);
	loop
	{
	if(GetCommonDataDefault("STAGE5SNAKEENEMY2",false)){break;}
	shot1;
	wait(15);
	}

	task shot1
	{
		SkyCreateShot01(GetX+r*cos(GetAngle-90),GetY+r*sin(GetAngle-90),4,GetAngle-90,9,5);
		SkyCreateShot01(GetX+r*cos(GetAngle+90),GetY+r*sin(GetAngle+90),4,GetAngle+90,9,5);
	}
}
///////////////////////////////////////////////////////////////
task shotE
{
let r=20;
wait(30);
	loop
	{
	if(GetCommonDataDefault("STAGE5SNAKEENEMY2",false)){break;}
	shot1;
	wait(10);
	}

	task shot1
	{
		SkyCreateShot01(GetX+r*cos(GetAngle-90),GetY+r*sin(GetAngle-90),3,GetAngle-90,9,5);
		SkyCreateShot01(GetX+r*cos(GetAngle+90),GetY+r*sin(GetAngle+90),3,GetAngle+90,9,5);
	}
}
//////////////////////////////////////////////////////////////
task shotA
{
let r=20;
wait(30);
	loop
	{
	if(GetCommonDataDefault("STAGE5SNAKEENEMY2",false)){break;}
	shot1;
	wait(5);
	}

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

}

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

script_enemy Dummy {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,0,50,0);
	TMain;
    }

    @MainLoop {
        yield;
    }

    @DrawLoop {
       // DrawGraphic(GetX, GetY);
    }
        @Finalize
        {
		FinalizeItemAndShotnum(1);
		MagicCircleBreak(GetX,GetY,13,0.3);
        } 

    task TMain {
        yield;
	ElementalAutoErazeTime(1490);
	OutDamageRateZero;
	GetDamege;
	move;
	Break;
    }

task Break
{
loop
{
	if(GetCommonDataDefault("STAGE5SNAKEENEMY2",false))
	{
		AddLife(-GetLife);
	}
	if(!GetCommonDataDefault("STAGE5SNAKEENEMY2SpecialBreak",true))
	{
		VanishEnemy;
	}
yield;
}
}

task move
{
	let angle=190;
	SetSpeed(1.5);
	SetAngle(angle);
	wait(150);
	loop(90)
	{
		angle-=100/90;
		SetAngle(angle);
		yield;
	}
}

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


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