
#Title[大妖精通常]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_alice.png"; 
   let imgNuclear =csd~"..\img\s_shot.png"; 

    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetCenterY-120;
	let Step2=false;
	let wIni=60;
let TimeCounter=169*60;
let StandardTimeCounter=TimeCounter;
    @Initialize {
	SetCommonDataEx(NsScore,NsAchievement[50],1);
	SetCommonData("BombOffset",true);
	if(GetCommonDataDefault("ExclusiveBoss",false)==true)
	{
		BossTimer(TimeCounter);
	}
	else
	{
		SetTimer(TimeCounter/60);
	}
	SetShotAutoDeleteClip(24,24,24,32);
        SetLife(12500);
	InitializeAction();
	SetEnemyMarker(true);
	//SetX(GetClipMaxX+16);
	//SetY(GetCenterY-0);
        TMainGrobal;
    }

    @MainLoop {
	SetCommonData("BossX",GetX);
	SetCommonData("BossY",GetY);
	SetCommonData("BossLife",GetLife);
	BulletNum=GetEnemyShotCount;
	TimeCounter-=1;
        yield;
    }

    @DrawLoop {
//DrawText(GetLife,120,382,12,255);//起動時間の表示
	DrawBoss( imgBoss );
    }

    @Finalize {
	DeleteAllEnemyWithoutBoss;
	SetCommonData("BossX",GetX);
	SetCommonData("BossY",GetY);
	SetCommonData("BossLife",GetLife);
	DeleteEnemyShotToItem(ALL);
		if(!IsTimeOut)
		{
		SetCommonData("DeleteBulletNum",BulletNum);
		SetCommonData("DeleteBulletX",GetX);
		SetCommonData("DeleteBulletY",GetY);
		}

	SetCommonData("VanishSignal",false);
	SetCommonData("TimeBonus",TimeCounter/StandardTimeCounter);
	SetCommonData("BossRate",45000);
    }

    // メインタスク
task TMainGrobal
{
	yield;
	GetDamege;
	OutDamageRateZero;
	Collision;
	//Lissajous(0,250,154);
	BossShadowAnimation(imgBoss2,0,255,255,0);
	BombOffSet;
	BombBarrier;
	standBy;
	shotA;

}

sub standBy//初期位置へ
{
	//SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	SetAction(ACT_SHOT_B, 120);
	wait(120);
//	summon;
	Concentration01(30);
	//Concentration03(GetX,GetY,60,0,64,255);
}

task Collision
{
	wait(120);

	loop
	{
        SetCollisionA(GetX, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 16);
	yield;
	}
}

task BombOffSet
{
loop
{
	BombDamageRate=0;
	while(!GetCommonDataDefault("OnDtypeBomb",false)){yield;}
	if(GetCommonDataDefault("OnDtypeBomb",false))
	{
		SetCommonDataEx(NsScore,NsAchievement[82],1);
		BombDamageRate=100;
		ArtfulSacrifice;
		SpellDraw(45,135);
	}
	while(GetCommonDataDefault("OnDtypeBomb",false)){yield;}
}
}

task ArtfulSacrifice
{
	let OpX=[GetPlayerX-24,GetPlayerX+24,GetPlayerX-48,GetPlayerX+48];
	let OpY=[GetPlayerY,GetPlayerY,GetPlayerY+5,GetPlayerY+5];
	let TargetX=GetCommonDataDefault("TargetX",[0,0,0,0]);
	let TargetY=GetCommonDataDefault("TargetY",[0,0,0,0]);

	ascent(i in 0..4)
	{
	ArtfulSacrificeEffect(i);
	}


task ArtfulSacrificeEffect(num)
{
	let ShotAngleAdjust=atan2(TargetY[num]-GetPlayerY,TargetX[num]-GetPlayerX);
	let BombStartX=OpX[num];
	let BombEndX=TargetX[num];
	let BombStartY=OpY[num];
	let BombEndY=TargetY[num];

	if(BombEndX==-1)
	{
		BombEndX=BombStartX;
	}
	if(BombEndY==-1)
	{
		BombEndY=BombStartY-150;
	}
	let EndX=(BombEndX+BombStartX)/2;
	let EndY=(BombEndY+BombStartY)/2;

	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, imgBoss);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_SetLayer(obj,3);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -16, -16);
	ObjEffect_SetVertexXY(obj, 1, 16,  -16);
	ObjEffect_SetVertexXY(obj, 2, 16, 16);
	ObjEffect_SetVertexXY(obj, 3,  -16,  16);

	ObjEffect_SetVertexUV(obj, 0,  768,  0);
	ObjEffect_SetVertexUV(obj, 1,  800, 0);
	ObjEffect_SetVertexUV(obj, 2, 800,  32);
	ObjEffect_SetVertexUV(obj, 3, 768, 32);

	let speed=15;
	let angle=atan2(EndY-GetY,EndX-GetX);
	Obj_SetSpeed(obj,speed);
	Obj_SetAngle(obj,angle);
	ObjEffect_SetScale(obj,1.5,1.5);
	Obj_SetPosition(obj, GetX, GetY);
	let count=0;
	let Zangle=0;
	while(!Obj_BeDeleted(obj))
	{
		ObjEffect_SetAngle(obj,0,0,Zangle);
		Zangle+=30;
	//	if(TargetX[num]==-1 && count>=10){break;}
		if(count%3==0)
		{
	//	BorderEffect(Obj_GetX(obj),Obj_GetY(obj));
		}
		if(((Obj_GetX(obj)-EndX)^2+(Obj_GetY(obj)-EndY)^2)^0.5<=48)
		{
			break;
		}
		if(Obj_GetY(obj)<GetClipMinY)
		{
			break;
		}
		if(Obj_GetY(obj)>GetClipMaxY)
		{
			break;
		}
		count+=1;
		yield;
	}

	DollExplode(Obj_GetX(obj),Obj_GetY(obj));
	Obj_Delete(obj);
}

task DollExplode(x,y)
{
		let sc=0.0;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,x,y);
		ObjEffect_SetTexture(obj,imgNuclear);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, sc,sc);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -128, -128);
		ObjEffect_SetVertexXY(obj, 1,  128, -128);
		ObjEffect_SetVertexXY(obj, 2,  128,  128);
		ObjEffect_SetVertexXY(obj, 3, -128,  128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  128, 0);
		ObjEffect_SetVertexUV(obj, 2, 128,  128);
		ObjEffect_SetVertexUV(obj, 3, 0, 128);

		ObjEffect_SetLayer(obj,5);

		loop(90)
		{	
			if(sc<0.75)
			{
			sc+=0.75/15;
			}
		//	Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			wait(1);
		}
		loop(30)
		{	
			if(sc>0)
			{
			sc-=0.75/30;
			}
		//	Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			wait(1);
		}
}
}


task BombBarrier
{
loop
{
	while(!OnBomb || GetTimeOfPlayerInvincibility==0){yield;}
	DamageRate=0;
	//BombDamageRate=0;
	BarrierEffect(1);
	BarrierEffect(0);	
	while(OnBomb || GetTimeOfPlayerInvincibility>0){yield;}
	wait(30);
	DamageRate=100;
	//BombDamageRate=100;
}

task BarrierEffect(type)
{
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,csd~"..\img\CircleLine.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,64,  -64);
		ObjEffect_SetVertexXY(obj, 2,64, 64);
		ObjEffect_SetVertexXY(obj, 3,  -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0, 0);
		ObjEffect_SetVertexUV(obj, 1,  128, 0);
		ObjEffect_SetVertexUV(obj, 2, 128, 128);
		ObjEffect_SetVertexUV(obj, 3, 0, 128);

		let Alpha=10;
		let R=255;let G=255;let B=255;

		alternative(GetPlayerInfo(PLAYER_SPEED_HIGH))
		case(4){R=100;G=100;B=255;}
		case(4/2){R=100;G=100;B=255;}
		case(5/2){R=255;G=100;B=100;}
		case(5){R=255;G=100;B=100;}
		case(5.5){R=255;G=100;B=255;}
		case(5.5/5){R=255;G=100;B=255;}
		case(4.5){R=50;G=205;B=50;}
		case(4.5/2){R=50;G=205;B=50;}

		let color;
		color=AnimeHueDifine(GlobalHueCount);
		R=color[0];G=color[1];B=color[2];
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetLayer(obj,4);

		let X=GetCenterX;
		let Y=GetCenterY;
		Obj_SetPosition(obj,GetX,GetY);

		let Scale=0;

		let Xangle=0;
		let Yangle=0;
		let Zangle=0;

		if(type)
		{
		}
		else
		{
			Yangle+=90;
		}

		while(OnBomb || GetTimeOfPlayerInvincibility>0)
		{
		color=AnimeHueDifine(GlobalHueCount);
		R=color[0];G=color[1];B=color[2];
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
			Obj_SetPosition(obj,GetX,GetY);
			if(Scale<1)
			{
			Scale+=1/30;
			}
			if(type)
			{
			if(Xangle%90>5 && Xangle%90<85)
			{
			BombEffectBlur(X,Y,Alpha,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			}
			else
			{
			if(Yangle%90>5 && Yangle%90<85)
			{
			BombEffectBlur(X,Y,Alpha,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			}
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			ObjEffect_SetScale(obj, Scale,Scale);
			if(type)
			{
			Xangle+=3;
			}
			else
			{
			Yangle+=3;
			}
			yield;
		}

		loop(30)
		{
		color=AnimeHueDifine(GlobalHueCount);
		R=color[0];G=color[1];B=color[2];
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
			Scale-=1/30;
			BombEffectBlur(X,Y,Alpha,Scale,Xangle,Yangle,Zangle,R,G,B);
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			ObjEffect_SetScale(obj, Scale,Scale);
			if(type)
			{
			Xangle+=3;
			}
			else
			{
			Yangle+=3;
			}
			yield;
		}
		Obj_Delete(obj);
}

task BombEffectBlur(X,Y,Alpha,Scale,Xangle,Yangle,Zangle,R,G,B)
{
		let obj = Obj_Create(OBJ_EFFECT);

		ObjEffect_SetTexture(obj, csd~"..\img\CircleLine.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,64,  -64);
		ObjEffect_SetVertexXY(obj, 2,64, 64);
		ObjEffect_SetVertexXY(obj, 3,  -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0, 0);
		ObjEffect_SetVertexUV(obj, 1,  128, 0);
		ObjEffect_SetVertexUV(obj, 2, 128, 128);
		ObjEffect_SetVertexUV(obj, 3, 0, 128);

		ObjEffect_SetLayer(obj,4);

		Obj_SetPosition(obj,GetX,GetY);

		ObjEffect_SetScale(obj, Scale,Scale);
		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		let BAlpha=Alpha;

		loop(60)
		{
			ascent(i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			ObjEffect_SetScale(obj, Scale,Scale);
			Alpha-=BAlpha/60;
			yield;
		}
		Obj_Delete(obj);
}

}

task TMove
{
loop
{
//	SetMovePosition03(GetX+rand(-10,10), GetY+rand(-10,10), 20,5);
	wait(60);
}
}


task shotM
{

}
/////////////////////////////////////////////////////////////////////////////
task shotE
{

}
//////////////////////////////////////////////////////////////////////
task shotA
{
loop
{
wait(30);
SetAction(ACT_SHOT_B, 60);
Summon;
wait(300);
Shot1;
wait(570);
SpellDraw(42,600);
Summon2;
wait(600);
Shot2;
wait(540);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni, yIni-50, 20,5);
wait(120);
Summon3;
wait(840);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni, yIni, 20,5);
wait(90);
Shot3;
wait(720);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni, yIni-30, 20,5);
wait(120);
SetAction(ACT_SHOT_A, 930);
Shot4;
wait(990);
SetMovePosition03(xIni, yIni, 20,5);
wait(60);
}

	task Shot4
	{
		let dir=rand_int(0,1)*2-1;
		ShotA;
		let speed=3.0;
		let angle=rand(0,360);
		loop(90)
		{
		ascent(i in 0..8)
		{
		ReflectShot(GetX,GetY,speed,angle+i*360/8,9,0);
		}
		angle+=2.3*dir;
		wait(10);
		}

		task ShotA
		{
		//wait(120);
		ascent(i in 0..18)
		{
		OrbitShot(i)
		}
		let R=60;
		let Bangle=0;
		let Grad=60*dir;
		let GradAngle=180;
		loop(87)
		{
			ascent(i in 0..18)
			{
				let sangle=Bangle+i*360/18;
			//	CreateShot01(GetX+R*cos(sangle),GetY+R*sin(sangle),5,sangle+Grad*cos(GradAngle),14,0);
			}
		Bangle-=3.3*dir;
	//	GradAngle+=3;
		wait(10);
		}
		}

		task OrbitShot(num)
		{
			let R=0;
			let obj = Obj_Create(OBJ_SHOT);
		//	Obj_SetPosition(obj, x,y);
		//	Obj_SetSpeed(obj, speed);
		//	Obj_SetAngle(obj, angle);
			ObjShot_SetGraphic(obj, 14);
		//	ObjShot_SetDelay(obj, delay);
			ObjShot_SetBombResist(obj,true);
			Obj_SetAutoDelete(obj,false);
			let Bangle=0;
			let Grad=60*dir;
			let sangle;
			OShot;
			loop(990)
			{
				sangle=Bangle+num*360/18;
				Obj_SetPosition(obj, GetX+R*cos(sangle),GetY+R*sin(sangle));	
				ObjShot_SetDelay(obj,2);
				Bangle-=3.3*dir;
				if(R<60)
				{
				R+=1.0;
				}
				yield;
			}
			loop(60)
			{
				sangle=Bangle+num*360/18;
				Obj_SetPosition(obj, GetX+R*cos(sangle),GetY+R*sin(sangle));	
				ObjShot_SetDelay(obj,2);
				Bangle-=3.3*dir;
				R-=1;
				yield;
			}
			Obj_Delete(obj);

			task OShot
			{
				wait(60);
				loop(87)
				{
					CreateShot01(Obj_GetX(obj),Obj_GetY(obj),5,sangle+Grad,14,0);
					wait(10);
				}
			}
		}

		task ReflectShot(x,y,speed,angle,gra,delay)
		{
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetPosition(obj, x,y);
			Obj_SetSpeed(obj, speed);
			Obj_SetAngle(obj, angle);
			ObjShot_SetGraphic(obj, gra);
			ObjShot_SetDelay(obj, delay);
			//ObjShot_SetBombResist(obj,true);
			//Obj_SetAutoDelete(obj,false);
	
			let Rcount=1;
			while(!Obj_BeDeleted(obj))
			{
			x=Obj_GetX(obj);
			y=Obj_GetY(obj);

			if(x>GetClipMaxX && Rcount>0)
			{
			Obj_SetX(obj, GetClipMaxX*2-x);
			Obj_SetAngle(obj, 180 - Obj_GetAngle(obj));
				Rcount-=1;
			}

			if(x<GetClipMinX && Rcount>0)
			{
			Obj_SetX(obj, GetClipMinX*2-x);
			Obj_SetAngle(obj, 180 - Obj_GetAngle(obj));
				Rcount-=1;
			}
			if(y<GetClipMinY && Rcount>0)
			{
			Obj_SetY(obj, GetClipMinY*2-y);
			Obj_SetAngle(obj, 360 - Obj_GetAngle(obj));
				Rcount-=1;
			}

				yield;
			}
			Obj_Delete(obj);
			ObjShot_SetBombResist(obj,false);
		}

	}

	task Shot3
	{
		WaveShot;
	//	wait(30);
		let laser_t=rand_int(0,7);
		loop(12)
		{
		DownLaserMain(1,laser_t%7);
		laser_t+=1;
		wait(15);
		}
		wait(150);
		WaveShot;
	//	wait(30);
		loop(12)
		{
		DownLaserMain(-1,laser_t%7);
		wait(15);
		laser_t+=1;
		}

		task WaveShot
		{
		let t=rand_int(0,7);
		SetAction(ACT_SHOT_A, 270);
		loop(11)
		{
			ascent(let k in 0..4)
			{
			ascent(let j in 0..k+1)
			{
			ascent(i in -1..2)
			{
			CreateShot01(GetX,GetY,3,GetAngleToPlayer+j*6-3*k+i*45,9+t%7,5);
			}
			}
			wait(4);
			t+=1;
			}
			descent(let k in 1..3)
			{
			ascent(let j in 0..k+1)
			{
			ascent(i in -1..2)
			{
			CreateShot01(GetX,GetY,3,GetAngleToPlayer+j*6-3*k+i*45,9+t%7,5);
			}
			}
			wait(4);
			t+=1;
			}
		}
		}

		task DownLaserMain(dir,color)
		{
			let x=GetCenterX+256*dir;
			let y=GetClipMinY;
			let angle=90+105*dir;
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetPosition(obj, x,y);
			//Obj_SetSpeed(obj, speed);
			Obj_SetAngle(obj, angle);
			ObjShot_SetGraphic(obj, 153+color);
			//ObjShot_SetDelay(obj, delay);
			ObjShot_SetBombResist(obj,true);
			Obj_SetAutoDelete(obj,false);
	
			let dis=rand(-100,100);
			let yspeed=0;
			ascent(i in 0..4)
			{
			CreateDownLaser(obj,dis+180*i,color);
			}

			loop(300)
			{
			StarLaserEffect(x,y,600,6,angle,5);
			Obj_SetPosition(obj, x,y);
			Obj_SetAngle(obj, angle);
			angle-=0.098*dir;
			y+=yspeed;
			if(yspeed<5)
			{
				yspeed+=0.04;
			}
			yield;
			}
			Obj_Delete(obj);
			ObjShot_SetBombResist(obj,false);
		}

		task CreateDownLaser(Bobj,Distance,color)
		{
			let length=100;
			let width=10;
			let obj = Obj_Create(OBJ_LASER);
			//Obj_SetPosition(obj,x,y);
		//	Obj_SetAngle(obj,LaserAngle);
			ObjShot_SetGraphic(obj,153+color);
			ObjLaser_SetLength(obj,length);
			ObjLaser_SetWidth(obj,width);
			ObjLaser_SetSource(obj,false);
			ObjShot_SetDelay(obj,0);
			//Obj_SetCollisionToPlayer(obj,false);
			ObjShot_SetBombResist(obj,true);
			Obj_SetAutoDelete(obj,false);

		//	Obj_SetCollisionToPlayer(obj,false);
			while(!Obj_BeDeleted(Bobj))
			{
			StarLaserEffect(Obj_GetX(obj),Obj_GetY(obj),length,width,Obj_GetAngle(obj),color);
			Obj_SetPosition(obj,Obj_GetX(Bobj)+Distance*cos(Obj_GetAngle(obj)),Obj_GetY(Bobj)+Distance*sin(Obj_GetAngle(obj)));
			Obj_SetAngle(obj,Obj_GetAngle(Bobj));
			yield;
			}
			Obj_Delete(obj);
		}

task StarLaserEffect(x,y,length,width,angle,graphic)
{
		let imgBer=csd~"..\img\ber.png";
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjShot_SetBombResist(obj,true);
		ObjEffect_SetVertexXY(obj, 0, -0, -3);
		ObjEffect_SetVertexXY(obj, 1,length,  -3);
		ObjEffect_SetVertexXY(obj, 2,length, 3);
		ObjEffect_SetVertexXY(obj, 3,  -0,  3);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228, 27);
		ObjEffect_SetVertexUV(obj, 2, 228, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=100*width/20;
		let R=255;
		let G=255;
		let B=255;
		if(graphic==0){R=255;G=0;B=0;}
		if(graphic==1){R=255;G=165;B=0;}
		if(graphic==2){R=255;G=255;B=0;}
		if(graphic==3){R=0;G=255;B=0;}
		if(graphic==4){R=0;G=255;B=255;}
		if(graphic==5){R=0;G=0;B=255;}
		if(graphic==6){R=160;G=32;B=240;}

		ObjEffect_SetLayer(obj,3);
		Obj_SetPosition(obj,x,y);
		Obj_SetAngle(obj,angle);
		ObjEffect_SetAngle(obj,0,0,angle);

		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
		loop(5)
		{
		Obj_SetPosition(obj,x,y);
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
		Alpha-=100/5;
		//if(OnPlayerMissed){Alpha=0;}
		yield;
		}
		Obj_Delete(obj);
}

	}

	task Summon3 
	{
	SetAction(ACT_SHOT_A, 60);
        CreateEnemyFromScript("Familiar4", GetX, GetY,
                              0, 0, 0);
	}

	task Summon2 
	{
	SetAction(ACT_SHOT_B, 60);
	ascent(i in 0..8)
	{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, 165+30*i, i);
	wait(8);
	}
	wait(120);
	SetAction(ACT_SHOT_B, 60);
	descent(i in 0..8)
	{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, 165+30*i, i);
	wait(8);
	}
	wait(60);

	}

	task Shot2
	{
	SetAction(ACT_SHOT_B, 60);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, 1);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, -1);
	wait(60);
	SetAction(ACT_SHOT_A, 465);
		loop(10)
		{

		let Sangle=rand(-5,5);
		ascent(i in 0..36)
		{
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 5,Sangle+i*10, 2.0,-0.1, 2, 81);
		SetShotDataA(1, 60, NULL,NULL, 0,0, 0, 81);
		FireShot(1);

		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 5,Sangle+i*10, -2.0,-0.1, 2, 86);
		SetShotDataA(1, 60,NULL,NULL, 0,0, 0, 86);
		FireShot(1);
		}
		wait(30);
		}
		let waittime=30;
		let way=36;
		loop
		{
		let Sangle=rand(-5,5);
		ascent(i in 0..way)
		{
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 5,Sangle+i*360/way, 2.0,-0.1, 2, 81);
		SetShotDataA(1, 60, NULL,NULL, 0,0, 0, 81);
		FireShot(1);

		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 5,Sangle+i*360/way, -2.0,-0.1, 2, 86);
		SetShotDataA(1, 60,NULL,NULL, 0,0, 0, 86);
		FireShot(1);
		}
		wait(waittime);
		waittime-=3;
		way+=3;
		if(waittime<=3){break;}
		}
	}

	task Shot1
	{
	loop(3)
	{
		let angle=GetAngleToPlayer;
		ascent(j in 0..3)
		{
		ascent(i in -7..7)
		{
			CreateShot01(GetX,GetY,2.5,angle+i*2.5+j*120,83,5);
			CreateShot01(GetX,GetY,1.5,angle+i*2.5+j*120,83,5);
		}
		}
		wait(120);
	}
	let angle=rand(0,360);
	SetAction(ACT_SHOT_A, 60);
	loop(6)
	{
		ascent(i in 0..90)
		{
			CreateShotA(0,GetX,GetY,5);
			SetShotDataA(0,0,3.0,angle+i*4,0,-0.03,0,83);
			SetShotDataA(0,90,0,angle+i*4,0,0.15,20,83);
			FireShot(0);
		}
		angle+=2.5;
		wait(10);
	}
	}

	task Summon
	{
	let angle=rand(0,360);
	let dir=rand_int(0,1)*2-1;
	ascent(i in 0..7)
	{
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, i*360/7, [i,dir]);
	}
	}
}

#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Alice.txt"
}

script_enemy Familiar1 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 

	let num = GetArgument[0];
	let DollDir=GetArgument[1];
	let color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
	//SetCoordinateType(COODINATE_TYPE_PARENT);
        SetLife(50000);
        SetDamageRateEx(100,100,100,0);
	TMain;
    }

    @MainLoop {
 SetServantSkyCollision(GetX, GetY, 36);
        yield;
    }

    @DrawLoop {
     DrawDoll( imgDoll, GetX, GetY );
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,1000,0.3);

	if(GetCommonDataDefault("BossLife",0)>0)
	{
		loop(5)
		{
			FinalizeItemSet(1);
		}
	}
	}

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
//	ZakoEnemyLifeDisplay;
	move;

	shotA;

    }

task move
{
	let R=0;
	let angle=GetAngle;
	let anglePlusAngle=0;
	let dir=DollDir;
	loop(600)
	{
		if(R<30)
		{
			R+=0.5;
		}
		SetX(GetCommonData("BossX")+R*cos(angle));
		SetY(GetCommonData("BossY")+R*sin(angle));
		angle+=2.5*sin(anglePlusAngle);
		SetAngle(angle);
		anglePlusAngle+=0.5*dir;
		yield;
	}

	VanishEnemy;
}

////////////////////////////////////////////////////////////
task shotA
{
wait(60);
loop(180)
{
	ascent(i in -1..2)
	{
	CreateShot01(GetX,GetY,2.5,GetAngle+5.0*i,9,5);
	}
	wait(3);
}
}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib/lib_anime_Alice.txt"
#include_function ".\..\lib/lib_anime_doll.txt"
}


script_enemy Familiar2 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);
	TMain;
    }

    @MainLoop {
	SetServantSkyCollision(GetX,GetY,36);
        yield;
    }

    @DrawLoop {
     DrawDoll( imgDoll, GetX, GetY );
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,1000,0.3);

	if(GetCommonDataDefault("BossLife",0)>0)
	{
		loop(5)
		{
			FinalizeItemSet(1);
		}
	}
	}

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;

	shotA;
    }

task move
{
	let speed=3;
	loop(60)
	{
		SetSpeed(speed);
		speed-=3/60;
		yield;
	}
	SetAngle(GetAngleToPlayer);
	loop(180)
	{
		SetSpeed(speed);
		if(speed<5)
		{
		speed+=0.055;
		}
		yield;
	}
	VanishEnemy;
}

task shotM
{

}
/////////////////////////////////////////////////////////
task shotE
{
wait(30);

}
////////////////////////////////////////////////////////////
task shotA
{
Straw;
wait(90);
//ExplodeShot;
Shot;
Shot2;
	task Shot
	{
	let count=0;
	loop(2)
	{
		ascent(i in -10..10)
		{
			CreateShot01(GetX,GetY,1.75,GetAngle+i*12,10,5);
		}
		wait(60);
	}
	}

	task Shot2
	{
	wait(30);
	let angle=GetAngleToPlayer+rand(-3,3);
	let way=30;
	if(absolute(GetAngle-GetAngleToPlayer)<15)
	{
		way=10;
	}
		ascent(i in -way..way)
		{
			CreateShot01(GetX,GetY,1.25,angle+i*6,18,5);
		}
	}

	task Straw
	{
	wait(90);
		loop
		{
			CreateShot02(GetX,GetY,0,GetAngle+rand(-5,5),0.04,2,167,5);
			wait(20);
		}
	}
}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib/lib_anime_Alice.txt"
#include_function ".\..\lib/lib_anime_doll.txt"
}

script_enemy Familiar3 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,100,0);
	TMain;
    }

    @MainLoop {
 SetServantSkyCollision(GetX, GetY, 36);
        yield;
    }

    @DrawLoop {
     DrawDoll( imgDoll, GetX, GetY );
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,1000,0.3);

	if(GetCommonDataDefault("BossLife",0)>0)
	{
		loop(5)
		{
			FinalizeItemSet(1);
		}
	}
	}

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;

	shotA;
    }

task move
{
	SetMovePosition03(GetX+100*num,GetY-50,10,5);
	wait(600);
	SetMovePosition02(GetCommonData("BossX"),GetCommonData("BossY"),60);
	wait(60);
	VanishEnemy;
}

task shotM
{

}
/////////////////////////////////////////////////////////
task shotE
{
wait(30);

}
////////////////////////////////////////////////////////////
task shotA
{
wait(180);
if(num==1)
{
wait(60);
}

Shot;
	task Shot
	{
	let speed=4;
	loop(3)
	{
		let angle=GetAngleToPlayer;
		loop(25)
		{
		ascent(i in -2..3)
		{
			CreateShot01(GetX,GetY,speed,angle+i*15,9,5);
		}
		angle+=0.5*num;
		wait(3);
		}
		wait(45);
	}
	}

}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib/lib_anime_Alice.txt"
#include_function ".\..\lib/lib_anime_doll.txt"
}

script_enemy Familiar4 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,100,0);
	TMain;
    }

    @MainLoop {
	 SetServantSkyCollision(GetX, GetY, 36);
        yield;
    }

    @DrawLoop {
     DrawDoll( imgDoll, GetX, GetY );
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,1000,0.3);

	if(GetCommonDataDefault("BossLife",0)>0)
	{
		loop(5)
		{
			FinalizeItemSet(1);
		}
	}
	}

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;

	shotA;
    }

task move
{
	SetMovePosition03(GetCenterX,GetCenterY-50,10,5);
	wait(780);
	SetMovePosition02(GetCommonData("BossX"),GetCommonData("BossY"),60);
	wait(60);
	VanishEnemy;
}

task shotM
{

}
/////////////////////////////////////////////////////////
task shotE
{
wait(30);

}
////////////////////////////////////////////////////////////
task shotA
{
wait(60);

Shot;
	task Shot
	{
	let speed=4.5;
	let angle=0;
	let anglePlus=0;
	loop(15)
	{
		ascent(i in -5..6)
		{
		CreateShot01(GetX,GetY,speed,angle+i*25,9,5);
		CreateShot01(GetX,GetY,speed,180-angle+i*25,9,5);
		}
		
	//	angle+=3.3;
		speed-=0.100;
		wait(4);

	}
	loop(150)
	{
		ascent(i in -5..6)
		{
		CreateShot01(GetX,GetY,speed,angle+i*25,9,5);
		CreateShot01(GetX,GetY,speed,180-angle+i*25,9,5);
		}
		
		angle+=anglePlus;
		if(anglePlus<4.4)
		{
		anglePlus+=0.1*3/4*2;
		}
		wait(4);
		speed+=0.01;

	}
	}

}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib/lib_anime_Alice.txt"
#include_function ".\..\lib/lib_anime_doll.txt"
}

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