
#Title[アリス２]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_alice.png"; 
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let Step2=false;
	let wIni=60;
let TimeCounter=120*60;
let StandardTimeCounter=TimeCounter;
let ColorRed=255;
let ColorGreen=0;
let ColorBlue=0;
    @Initialize {
	SetX(GetCommonDataDefault("BossX",0));
	SetY(GetCommonDataDefault("BossY",0));
	if(GetCommonDataDefault("ExclusiveBoss",false)==true)
	{
		BossTimer(TimeCounter);
	}
	else
	{
		SetTimer(TimeCounter/60);
	}
	SetShotAutoDeleteClip(24,24,24,32);
	LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
        SetLife(11000);
 //LoadGraphic(GetCurrentScriptDirectory~"..\img\CircleEffect.png");
	InitializeAction();
	SetEnemyMarker(true);
        TMainGrobal;
	LoadGraphic(GetCurrentScriptDirectory ~ "..\img/WhiteLine.png");
    }

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

    @DrawLoop {
//DrawText(GetCommonDataDefault("XXX",0),120,452,12,255);
//DrawText(GetCommonDataDefault("XXX2",0),120,402,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",35000);
    }

    // メインタスク
task TMainGrobal
{
	yield;
	GetDamege;
	OutDamageRateZero;
	Collision;
	//Lissajous(148,0,211);
	BossShadowAnimation(imgBoss2,0,255,255,0);
	standBy;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}

}

task Collision
{
	wait(90);

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

}

sub standBy//初期位置へ
{
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni,30,8);
	wait(90);
	Concentration01(30);
	}
	case("Extream")
	{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni,30,8);
	wait(90);
	Concentration01(30);
	}
	case("Apocalypse")
	{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni,30,8);
	//SetMovePosition03(GetCenterX, GetCenterY,30,8);
	wait(90);
	Concentration01(30);
	}
}

task shotM
{
wait(30);
loop(2)
{
SetAction(ACT_SHOT_A, 450);
Shot1;
wait(450);
SetAction(ACT_SHOT_B, 600);
summon;
wait(1020);
summon3;
wait(60);

let movedir=rand_int(0,1)*2-1;
SetMovePosition03(GetCenterX+rand(100,150)*movedir, GetCenterY-rand(50,80),10,3);
SetAction(ACT_MOVE, 105);
wait(105);
SetMovePosition03(GetCenterX-rand(100,150)*movedir, GetCenterY-rand(50,80),10,3);
SetAction(ACT_MOVE, 135);
wait(135);
SetMovePosition03(GetCenterX+rand(100,150)*movedir, GetCenterY-rand(50,80),10,3);
SetAction(ACT_MOVE, 135);
wait(135);
SetMovePosition03(GetCenterX-rand(100,150)*movedir, GetCenterY-rand(50,80),10,3);
SetAction(ACT_MOVE, 135);
wait(135);
SetMovePosition03(GetCenterX,yIni,10,3);
SetAction(ACT_MOVE, 90);

wait(180);
Shot2(27,1);
wait(180);
Shot2(27,-1);

wait(180);
Shot2(36,1);
wait(180);
Shot2(36,-1);

wait(180);
Shot2(45,1);
wait(180);
Shot2(45,-1);
wait(360);
}


	task Shot2(way,dir)
	{
	SetAction(ACT_SHOT_B, 60);
	let Sangle=rand(0,360);

	ascent(j in 0..8)
	{
		ascent(i in 0..way)
		{
		CreateShot01(GetX,GetY,1.0+0.5*j,Sangle+i*360/way+j*3*-dir+180/way,9,5);
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 1+0.45*j,Sangle+i*360/way+j*3*dir, 0,-0.01-0.008*j, 0, 81);
		SetShotDataA(1, 100, (1+0.45*j)*1.0,Sangle+i*360/way+j*3*dir-150*dir, 0,0.003, 5,81);
		FireShot(1);
		}
	}

	}

	task Shot1
	{
		ShotA;
		ascent(j in 0..30)
		{
		let angle=GetAngleToPlayer+rand(-10,10);
		ascent(i in -5..5)
		{
			CreateShot01(GetX,GetY,3+j*0.1,angle+i*12,9,5);
		}
		wait(15);
		}

		task ShotA
		{
			wait(60);
			let speed=5;
			loop(6)
			{
			loop(5)
			{
			let angle=GetAngleToPlayer;
			ascent(i in -3..4)
			{
				CreateShot01(GetX,GetY,speed,angle+i*12,12+i,5);
			}
			wait(3);
			}
			wait(30);
			speed+=0.2;
			}
			loop(15)
			{
			let angle=GetAngleToPlayer;
			ascent(i in -3..4)
			{
				CreateShot01(GetX,GetY,speed,angle+i*12,12+i,5);
			}
			wait(3);
			}
		}
	}

	task summon
	{
	loop(5)
	{
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, 1);
	wait(60);
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, -1);
	wait(60);
	}
	}

	task summon2
	{
	let angle=rand(0,360);
	ascent(i in 0..7)
	{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, i*360/7, [1,angle,i]);
	}
	}

	task summon3
	{
	loop(40)
	{
	let X=GetX+rand(10,50);
	let X2=GetX-rand(10,50);
	let Y=GetY+rand(-10,10);
	let Y2=GetY-rand(-10,10);
        CreateEnemyFromScript("Familiar3", X, Y,
                              0, 0, [1,0,0]);
        CreateEnemyFromScript("Familiar3", X2, Y2,
                              0, 0, [-1,0,0]);
	wait(15);
	}
	}
}
///////////////////////////////////////////////////////
task shotE
{
let BombDollX=[];
let BombDollY=[];

wait(30);
loop
{
SetAction(ACT_SHOT_B, 60);
SpellDraw(39,180);
CreateDolls1;
wait(180);
SetAction(ACT_SHOT_B, 60);
CreateDolls2;

wait(1200);
SetAction(ACT_SHOT_B, 60);
SpellDraw(40,840);
CreateDolls3;
wait(900);

SetAction(ACT_SHOT_A, 600);
Shot1;
wait(720);
}
	task Shot1
	{
	let dir=1;
	let waywide=15;
	let wide=3;
	loop(5)
	{
		let angle=rand(0,360);
		let angle2=rand(0,360);
		let anglechange=0;
		let speed=4;
		let speed2=3;
		ascent(i in 0..6)
		{
		ascent(j in 0..15)
		{
		CreateShotA(0,GetX,GetY,6);
		SetShotDataA(0,0,speed,angle+i*4+j*24,0,-0.08,0,9);
		SetShotDataA(0,60,NULL,NULL,0,0.1,5,9);
		FireShot(0);
		CreateShotA(0,GetX,GetY,6);
		SetShotDataA(0,0,speed,angle+i*4+j*24+2,0,-0.08,0,9);
		SetShotDataA(0,60,NULL,NULL+anglechange,0,-0.08,-5,9);
		FireShot(0);
		}
		wait(5);
		}
		wait(30);
		ascent(i in 0..6)
		{
		ascent(j in 0..15)
		{
		CreateShotA(0,GetX,GetY,6);
		SetShotDataA(0,0,speed2,angle-i*4+j*24,0,-0.06,0,14);
		SetShotDataA(0,60,NULL,NULL,0,0.06,3,14);
		FireShot(0);
		CreateShotA(0,GetX,GetY,6);
		SetShotDataA(0,0,speed2,angle-i*4+j*24+2.0,0,-0.06,0,14);
		SetShotDataA(0,60,NULL,NULL+anglechange,0,-0.06,-3,14);
		FireShot(0);
		}
		wait(5);
		}
		wait(30);
	}
	}

	task CreateDolls1
	{
	BombDollX=BombDollX~[rand(GetClipMinX,GetCenterX),rand(GetClipMinX,GetCenterX)];
	BombDollX=BombDollX~[rand(GetClipMaxX,GetCenterX),rand(GetClipMaxX,GetCenterX)];
	loop(3)
	{
	BombDollX=BombDollX~[rand(GetClipMinX,GetClipMaxX)];
	}
	BombDollY=BombDollY~[rand(GetClipMinY,GetCenterY),rand(GetClipMaxY,GetCenterY)];
	BombDollY=BombDollY~[rand(GetClipMinY,GetCenterY),rand(GetClipMaxY,GetCenterY)];
	loop(3)
	{
	BombDollY=BombDollY~[rand(GetClipMinY,GetClipMaxY)];
	}
	ascent(i in 0..7)
	{
        CreateEnemyFromScript("Familiar4", GetX, GetY,
                              0, 0, [BombDollX[i],BombDollY[i],i]);
	}

	}

	task CreateDolls2
	{
	let angle=rand(0,360);
	ascent(i in 0..7)
	{
        CreateEnemyFromScript("Familiar5", GetX, GetY,
                              0, 0, [1,angle+360/7*i,i]);
        CreateEnemyFromScript("Familiar5", GetX, GetY,
                              0, 0, [-1,angle+360/7*i+180/7,i]);
	}

	}

	task CreateDolls3
	{
	ascent(i in 0..7)
	{
		String(i);
	}
	wait(30);
	ascent(i in 0..7)
	{
        CreateEnemyFromScript("Familiar6", BombDollX[i], BombDollY[i],
                              0, 0, [BombDollX[i],BombDollY[i],i]);
	}

	}

	task String(num)
	{
	let Distance;
	let BossAngleToDoll;
	//loop
	//{
		Distance=((BombDollY[num]-GetCommonData("BossY"))^2+(BombDollX[num]-GetCommonData("BossX"))^2)^0.5;
		BossAngleToDoll=atan2(BombDollY[num]-GetCommonData("BossY"),BombDollX[num]-GetCommonData("BossX"));
		StringLaserEffect(GetX,GetY,Distance,5,BossAngleToDoll);
		yield;
	//}
	wait(30);
	loop(30)
	{
	EffectShot(BossAngleToDoll,Distance);
	wait(1);
	}
	}

task StringLaserEffect(x,y,length,width,angle)
{
		let lengthmax=length;
		length=0;
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228/10, 27);
		ObjEffect_SetVertexUV(obj, 2, 228/10, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=60;

		let R=39;
		let G=64;
		let B=200;


		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(30)
		{
		length+=lengthmax/30;
		ObjEffect_SetVertexXY(obj, 0, 0, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		yield;
		}
		wait(30);
		Obj_Delete(obj);
}

task EffectShot(angle,dis)
{
		let Eobj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(Eobj, GetX,GetY);
		Obj_SetSpeed(Eobj, 10);
		Obj_SetAngle(Eobj, angle);
		ObjShot_SetGraphic(Eobj, 9);		
		Obj_SetAutoDelete(Eobj,false);
		Obj_SetAlpha(Eobj,0);
		Obj_SetCollisionToPlayer(Eobj,false);
		ObjShot_SetBombResist(Eobj,true);
		let CircleAngle=rand(0,360);
		let count=0;
		loop
		{
			Obj_SetX(Eobj,Obj_GetX(Eobj)+10*cos(angle));
			Obj_SetY(Eobj,Obj_GetY(Eobj)+10*sin(angle));
			ObjShot_SetDelay(Eobj, 2);
			count+=1;
			if(count*10>=dis){break;}
			yield;
		}
		Obj_Delete(Eobj);
}

}

/////////////////////////////////////////////////////////////////
task shotA
{
loop
{
if(GetPlayerX<GetCenterX)
{
SetCommonData("DollDirction",1);
}
else
{
SetCommonData("DollDirction",-1);
}
SetAction(ACT_SHOT_B, 90);
CreateDolls3;
wait(30);
SpellDraw(38,720);
CreateDolls1;
wait(720);
let Doll2num=7;
SpellDraw(41,1400);
loop(5)
{
SetAction(ACT_SHOT_B, 60);
CreateDolls2(Doll2num);
wait(240);
Doll2num+=1;
}
wait(360);
SetAction(ACT_SHOT_A, 520);
Shot1;
wait(600);
}

	task Shot1
	{
	BShot;
	task BShot
	{
		let R1=0;
		let R2=0;
		let Angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		//Obj_SetPosition(obj, x,y);
	//	Obj_SetSpeed(obj, speed);
	//	Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
	//	ObjShot_SetDelay(obj, delay);
		Obj_SetAlpha(obj,100);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		Winder;
		Shot;
		loop(420)
		{
			ObjShot_SetDelay(obj, 10);
			Obj_SetPosition(obj, GetX+R1*cos(Angle),GetY+R2*sin(Angle));
			if(R1<120)
			{
				R1+=0.6;
				R2+=0.20;
			}
			Angle+=3;
			yield;
		}
		loop(100)
		{
			ObjShot_SetDelay(obj, 10);
			Obj_SetPosition(obj, GetX+R1*cos(Angle),GetY+R2*sin(Angle));
		//		R1-=1.2;
		//		R2-=0.4;
			Angle+=3;
			yield;
		}
		Obj_Delete(obj);
		task Shot
		{
		//wait(30);
		let Mspeed=1.5;
		let gra=9;
		let HueCount=0;
		while(!Obj_BeDeleted(obj))
		{
		let angle=rand(0,360);
			ascent(i in 0..45)
			{
			CreateShot01(Obj_GetX(obj),Obj_GetY(obj),Mspeed,angle+i*9,83,0);
			}
			Mspeed+=0.03;
			wait(10);
		}

		}

		task Winder
		{
		//wait(30);
		let angle=360/7*rand_int(0,6);
		let speed=3;
		while(!Obj_BeDeleted(obj))
		{
		ascent(i in 0..8)
		{
		CreateShot01(Obj_GetX(obj),Obj_GetY(obj),speed,90-180/7+360/7*i+angle,9+i,0);
		}
		wait(2);
		speed+=0.03;
		}
		}
	}

	}

	task CreateDolls1
	{
       		CreateEnemyFromScript("Familiar7", GetX, GetY,
                0, 0, 0);
		loop(2220)
		{
		SetDummySkyCollision(GetCenterX,GetCenterY,36);
		yield;
		}
	}

	task CreateDolls3
	{
		ascent(i in 0..6)
		{
       		CreateEnemyFromScript("Familiar9", GetX, GetY,
                0, 0, i);
		}
	}

	task CreateDolls2(num)
	{
	let BombDollX=[];
	let BombDollY=[];

	BombDollX=BombDollX~[rand(GetClipMinX,GetCenterX-32),rand(GetClipMinX,GetCenterX-32)];
	BombDollX=BombDollX~[rand(GetClipMaxX,GetCenterX+32),rand(GetClipMaxX,GetCenterX+32)];
	loop(num-4)
	{
	BombDollX=BombDollX~[rand(GetClipMinX,GetClipMaxX)];
	}
	BombDollY=BombDollY~[rand(GetClipMinY,GetCenterY-32),rand(GetClipMaxY,GetCenterY+32)];
	BombDollY=BombDollY~[rand(GetClipMinY,GetCenterY-32),rand(GetClipMaxY,GetCenterY+32)];
	loop(num-4)
	{
	BombDollY=BombDollY~[rand(GetClipMinY,GetClipMaxY)];
	}
	ascent(i in 0..num)
	{
        CreateEnemyFromScript("Familiar8", GetX, GetY,
                              0, 0, [BombDollX[i],BombDollY[i],i,num]);
	}
	wait(120);
	WireLaser;


	task WireLaser
	{
		let angle=atan2(BombDollY[0]-GetY,BombDollX[0]-GetX);
		let length=((BombDollX[0]-GetX)^2+(BombDollY[0]-GetY)^2)^0.5;
		StarLaserEffect(GetX,GetY,angle,length,6,30,60,153);
		wait(10);
		ascent(i in 0..num-1)
		{
		let angle=atan2(BombDollY[i+1]-BombDollY[i+0],BombDollX[i+1]-BombDollX[i+0]);
		let length=((BombDollX[i+1]-BombDollX[i+0])^2+(BombDollY[i+1]-BombDollY[i+0])^2)^0.5;
		StarLaserEffect(BombDollX[i+0],BombDollY[i+0],angle,length,12,10,120,153+i%7+1);
		wait(10);
		}
		wait(30);
		let angle=atan2(BombDollY[0]-GetY,BombDollX[0]-GetX);
		let length=((BombDollX[0]-GetX)^2+(BombDollY[0]-GetY)^2)^0.5;
		Laser(GetX,GetY,angle,length,12,10,120,153);
		wait(10);
		ascent(i in 0..num-1)
		{
		let angle=atan2(BombDollY[i+1]-BombDollY[i+0],BombDollX[i+1]-BombDollX[i+0]);
		let length=((BombDollX[i+1]-BombDollX[i+0])^2+(BombDollY[i+1]-BombDollY[i+0])^2)^0.5;
		Laser(BombDollX[i+0],BombDollY[i+0],angle,length,12,10,120,153+i%7+1);
		wait(10);
		}
	}

	}
task Laser(x,y,angle,length,width,delay,time,gra)
{
	length*=1.01;
	let lengthmax=length;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay*0);
	ObjShot_SetBombResist(obj,true);
	Obj_SetAutoDelete(obj,false);
	let dcount=10;
	let lcount=0;
	let R=255;let G=0;let B=0;
	alternative(gra)
	case(153){R=255;G=0;B=0;}
	case(154){R=255;G=128;B=0;}
	case(155){R=255;G=255;B=0;}
	case(156){R=0;G=255;B=0;}
	case(157){R=0;G=255;B=255;}
	case(158){R=0;G=0;B=255;}
	case(159){R=255;G=0;B=255;}
	loop(10)
	{
		EffectLaser(x,y,angle,length*lcount/10,width,0,1,gra);
		ShotEffect(x+length*lcount/10*cos(angle),y+length*lcount/10*sin(angle),1,150,R,G,B);
		ObjLaser_SetLength(obj,length*lcount/10);
		if(lcount<10)
		{
		lcount+=1;
		}
	yield;
	}
	ObjLaser_SetLength(obj,length*lcount/10);
	EffectLaser(x,y,angle,length,width,0,time-delay,gra);
	loop(time-delay)
	{
		ShotEffect(x+length*lcount/10*cos(angle),y+length*lcount/10*sin(angle),1,150,R,G,B);
		yield;
	}
	Obj_SetCollisionToPlayer(obj,false);
	loop(10)
	{
		ShotEffect(x+length*1*cos(angle),y+length*1*sin(angle),1,150,R,G,B);
		Obj_SetPosition(obj,x+length*(10-lcount)/10*cos(angle),y+length*(10-lcount)/10*sin(angle));
		EffectLaser(x,y,angle,length*lcount/10,width*dcount/10,0,2,gra);
		ObjLaser_SetLength(obj,length*lcount/10);
	ObjLaser_SetWidth(obj,width*dcount/10);
	lcount-=1;
	dcount-=1;
	yield;
	}
	Obj_Delete(obj);
}
task EffectLaser(x,y,angle,length,width,delay,time,gra)
{
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width*rand(0.75,1.25));
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	loop(time)
	{
	ObjLaser_SetWidth(obj,width*rand(0.75,1.25));
	yield;
	}
	Obj_Delete(obj);
}


task StarLaserEffect(x,y,angle,length,width,delay,time,gra)
{
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		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=150;

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

	let R=255;let G=0;let B=0;
	alternative(gra)
	case(153){R=255;G=0;B=0;}
	case(154){R=255;G=128;B=0;}
	case(155){R=255;G=255;B=0;}
	case(156){R=0;G=255;B=0;}
	case(157){R=0;G=255;B=255;}
	case(158){R=0;G=0;B=255;}
	case(159){R=255;G=0;B=255;}
	let scx=0;
	let scy=1;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}
	loop(10)
	{
		ObjEffect_SetScale(obj,scx,scy);
		if(scx<1)
		{
		scx+=0.1;
		}
	yield;
	}
	ObjEffect_SetScale(obj,scx,scy);
	wait(30);
	let lcount=10;
	loop(10)
	{
		ObjEffect_SetVertexColor(obj,0,0,R,G,B);
		ObjEffect_SetVertexColor(obj,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,3,0,R,G,B);
		Obj_SetPosition(obj,x+length*(10-lcount)/10*cos(angle),y+length*(10-lcount)/10*sin(angle));
		ObjEffect_SetScale(obj,scx,scy);
		lcount-=1;
		scx-=0.1;
	yield;
	}
		Obj_Delete(obj);
}

task ShotEffect(x,y,delay,Alpha,R,G,B)
{
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,csd~"..\img\Light.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

		ObjEffect_SetVertexXY(obj, 0, -32, -32);
		ObjEffect_SetVertexXY(obj, 1,32, -32);
		ObjEffect_SetVertexXY(obj, 2, 32, 32);
		ObjEffect_SetVertexXY(obj, 3, -32, 32);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  64, 0);
		ObjEffect_SetVertexUV(obj, 2, 64, 64);
		ObjEffect_SetVertexUV(obj, 3, 0,  64);
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}

		Obj_SetPosition(obj,x,y);

		ObjEffect_SetLayer(obj,2);

		let Zangle=rand(0,360);
		ObjEffect_SetAngle(obj,0,0,Zangle);

		let Scale=0.8;
		loop(delay)
		{
			ObjEffect_SetScale(obj, Scale, Scale);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=6;
			Scale-=0.8/delay;
			yield;
		}
		Obj_Delete(obj);
}

}

#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;
	let Dolldir=num;
	//let Dollnum=num[1];
	let color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(500);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY,12);
        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;
	String;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;

	shotM;

	//ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition03(GetCenterX+140*Dolldir+rand(-20,0), GetClipMinY, 10,5);
	wait(90);
	SetSpeed(2);
	SetAngle(90);
	loop
	{
		if(GetClipMaxY<GetY){break;}
		yield;
	}
	SetSpeed(0);
	ascent(i in 0..36)
	{
		CreateShot01(GetX,GetY,1.5,i*10,9,5);
	}
	wait(30);
	SetMovePosition02(GetCommonData("BossX"), GetCommonData("BossY"), 120);
	wait(120);
	VanishEnemy;
}

task shotM
{
wait(90);
loop(3)
{
CircleShot;
wait(90);
}
	task CircleShot
	{
		let X=GetX;
		let Y=GetY;
		ascent(i in 0..18)
		{
			CreateShotFromScript( "DollCircleShot",GetX, GetY,2,i*20, 5, 14);
		}
	}
}

	task String
	{
	let Distance;
	let BossAngleFromDoll;
	loop
	{
		Distance=((GetY-GetCommonData("BossY"))^2+(GetX-GetCommonData("BossX"))^2)^0.5;
		BossAngleFromDoll=atan2(GetCommonData("BossY")-GetY,GetCommonData("BossX")-GetX);
		StringLaserEffect(GetX,GetY,Distance,5,BossAngleFromDoll);
		yield;
	}
	}

task StringLaserEffect(x,y,length,width,angle)
{
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228/10, 27);
		ObjEffect_SetVertexUV(obj, 2, 228/10, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=60;

		let R=39;
		let G=64;
		let B=200;


		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(1)
		{
		yield;
		}
		Obj_Delete(obj);
}

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

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


script_shot DollCircleShot{//アリス２の人形
        let csd     = GetCurrentScriptDirectory;
	let R=0;
	let G=255;
	let B=0;
	let ColorType=100;
       let out=false;
	let X=GetX;
	let Y=GetY;
       @Initialize{
	SetDefault(14);
//	SetBombResist;
	Tmain;
       }
	@MainLoop
	{
		if(GetX<GetClipMinX-16 || GetX>GetClipMaxX+16 || GetY<GetClipMinY-48 || GetY>GetClipMaxY+16)
		{
			End;
		}
		SetCollisionBDefault;
		yield;
	}
       @DrawLoop {
       DrawGraphicDefault();
       }
       @Finalize{
	}

task Tmain
{
	let angle=GetAngle;
	let speed=GetSpeed;
	SetSpeed(speed);
	SetAngle(angle);
	loop(60)
	{
		if(speed>0)
		{
			speed-=0.05;
		}
		else{SetSpeed(0);}
		yield;
		SetSpeed(speed);
	}
	SetSpeed(0);
	SetAngle(atan2(GetPlayerY-Y,GetPlayerX-X));
	loop
	{
		if(speed<3)
		{
			speed+=0.02;
		}
		yield;
		SetSpeed(speed);
	}
}

task Move
{

}

}


script_enemy Familiar2 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let Dolldir=num[0];
	let DollShotAngle=num[1];
	let Dollnum=num[2];
	let color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(500);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
        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;
	//RoundEffect;

	shotM;

	//ZakoEffect(255,0,0);

    }

task move
{
	let angle=GetAngle;
	let Radius=0;
let RA=1;
	loop
	{
		SetX(GetCommonData("BossX")+Radius*cos(angle));
		SetY(GetCommonData("BossY")+Radius*sin(angle));
		if(Radius<120){Radius+=0.5;}
		angle+=3;
		yield;
	}
}

task shotM
{
wait(90);
let TX=0;
let TY=0;
let TAngle=DollShotAngle*0;
let TRadius=0;
let TRadiusTheta=0;

let speed=0;

shot1;
loop
{
	TX=GetCommonData("BossX")+TRadius*cos(TAngle);
	TY=GetCommonData("BossY")+TRadius*sin(TAngle);
	TRadius=60*sin(TRadiusTheta);
	TRadiusTheta+=0.5;
	TAngle+=2*Dolldir;
yield;
}

	task shot1
	{
	loop
	{
		speed=((TX-GetX)^2+(TY-GetY)^2)^0.5/120*2;
		CreateShot01(GetX,GetY,speed,atan2(TY-GetY,TX-GetX),9+Dollnum,5);
		CreateShot01(GetX,GetY,4-speed,atan2(TY-GetY,TX-GetX)+180,9+Dollnum,5);
		CreateShot01(TX,TY,3,270,14,5);
		wait(3);
	}
	}

}

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

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


script_enemy Familiar3 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let Dolldir=num[0];
	let DollShotAngle=num[1];
	let Dollnum=num[2];
	let color=rand_int(9,15);
    let imgNuclear =GetCurrentScriptDirectory ~ "..\img/s_shot.png"; 
    let imgNuclearWave =GetCurrentScriptDirectory ~ "..\img/NuclearWave2.png"; 
	let DrawFlag=1;
    @Initialize {

LoadGraphic(imgNuclear);
	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(40);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
if(DrawFlag)
{
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
}
        yield;
    }

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

        @Finalize
        {
	DeleteEnemyShot(CHILD);
	let Angle=rand(0,360);
	ascent(i in 0..12)
	{
		CreateShot01(GetX,GetY,3,Angle+i*30,9,5);
	}

	MagicCircleBreak(GetX,GetY,1000,0.3);

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

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

	shotM;

	//ZakoEffect(255,0,0);

    }

task move
{
	let Xspeed=Dolldir*rand(0.1,0.5);
	let Yspeed=-3;
	loop(240)
	{
		SetX(GetX+Xspeed);
		SetY(GetY+Yspeed);
		Yspeed+=0.06;
		yield;
	}
	VanishEnemy;
SetSpeed(0);
}

task shotM
{
wait(60);
DrawFlag=0;
let TX=0;
let TY=0;
let TAngle=DollShotAngle*0;
let TRadius=0;
let TRadiusTheta=0;

let speed=0;

NuClear;
EraseLifeGauge=false;

task NuClear
{
		let sc=0.0;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetX,GetY);
		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);
		while(!Obj_BeDeleted(obj))
		{	
			if(sc<0.5)
			{
			sc+=0.005;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}
}

}

#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 DollX=num[0];
	let DollY=num[1];
	let Dollnum=num[2];
	let Dolldir=1;
	let color=rand_int(9,15);
    let imgNuclear =GetCurrentScriptDirectory ~ "..\img/s_shot.png"; 
    let imgNuclearWave =GetCurrentScriptDirectory ~ "..\img/NuclearWave2.png"; 
	let DrawFlag=1;
    @Initialize {

LoadGraphic(imgNuclear);
	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
if(DrawFlag)
{
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
}
        yield;
    }

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

        @Finalize
        {

	MagicCircleBreak(GetX,GetY,1000,0.3);

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

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

	shotE;

	//ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition03(DollX,DollY,20,5);
	loop(300)
	{
		yield;
	}
	VanishEnemy;
SetSpeed(0);
}

task shotE
{
EraseLifeGauge=false;
wait(120);
DrawFlag=0;
let TX=0;
let TY=0;
let TAngle=0;
let TRadius=0;
let TRadiusTheta=0;

let speed=0;

NuClear;
EraseLifeGauge=false;

task NuClear
{
		let sc=0.0;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetX,GetY);
		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);

		Shot1;

		//while(!Obj_BeDeleted(obj))
		loop(90)
		{	
			if(sc<0.75)
			{
			sc+=0.75/15;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}
		loop(10)
		{	
			if(sc>0)
			{
			sc-=0.75/10;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}

		task Shot1
		{
			wait(15);
			let Radius=60;
			loop(60)
			{
				let angle=rand(0,360);
				CreateShot02(GetX+Radius*cos(angle),GetY+Radius*sin(angle),0,angle,0.01,2,9,5);
			wait(1);
			}
		}
}

}

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

script_enemy Familiar5 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let DollDir=num[0];
	let DollAngle=num[1];
	let Dollnum=num[2];
	let color=rand_int(9,15);
    let imgNuclear =GetCurrentScriptDirectory ~ "..\img/s_shot.png"; 
    let imgNuclearWave =GetCurrentScriptDirectory ~ "..\img/NuclearWave2.png"; 
	let DrawFlag=1;
    @Initialize {

LoadGraphic(imgNuclear);
	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(100000);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
if(DrawFlag)
{
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
}
        yield;
    }

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

        @Finalize
        {

	MagicCircleBreak(GetX,GetY,1000,0.3);

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

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

	shotE;

	//ZakoEffect(255,0,0);

    }

task move
{
	let X;
	if(DollDir==1){X=GetClipMaxX-16;}
	if(DollDir==-1){X=GetClipMinX+16;}
	let Y=GetCenterY+GetCenterY*sin(DollAngle);
	SetMovePosition03(X,Y,20,5);
	wait(120);
	loop(600)
	{
		SetY(Y);
		Y=GetCenterY+GetCenterY*sin(DollAngle);
		DollAngle+=0.5;
		yield;
	}
	wait(360);
	SetMovePosition02(GetCommonData("BossX"),GetCommonData("BossY"),60);
	wait(60);
	VanishEnemy;
}

task shotE
{

wait(120);

let TX=0;
let TY=0;
let TAngle=0;
let TRadius=0;
let TRadiusTheta=0;

let speed=0;

EraseLifeGauge=false;
Laser;

task Laser
{
let angle=90+90*DollDir;
let Shotangle=0;
let SSangle=0;
loop(20)
{
	CreateShot01(GetX,GetY,1.5,angle+Shotangle,167.5+DollDir*2.5,5);
	Shotangle=10*sin(SSangle);
	SSangle+=18;
wait(30);

}
wait(30);

DLaser(GetX,GetY,angle,GetClipMaxX-16-GetClipMinX,30,60,120,155.5+DollDir*2.5);
}


task DLaser(x,y,angle,length,width,delay,time,gra)
{
	let lengthmax=length;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	let dcount=30;
	let lcount=0;
	loop(delay)
	{
		EffectLaser(x,y,angle,length*lcount/30,width,0,1,gra);
		ObjLaser_SetLength(obj,length*lcount/30);
		if(lcount<30)
		{
		lcount+=1;
		}
	yield;
	}
	EffectLaser(x,y,angle,length,width,0,time-delay,gra);
	loop(time-delay)
	{
		yield;
	}
	Obj_SetCollisionToPlayer(obj,false);
	loop(15)
	{
		EffectLaser(x,y,angle,length,width*dcount/30,0,2,gra);
	ObjLaser_SetWidth(obj,width*dcount/30);
	dcount-=1;
	yield;
	}

	let SX=GetX;
	let SY=GetY;
	let EX=SX-lengthmax*DollDir;
	let EY=SY;
	let sep=40;
	
	let sangle=rand(0,360);
	ascent(i in 1..sep)
	{
		let ShotX=SX-(SX-EX)*i/sep;
		let ShotY=SY-(SY-EY)*i/sep;
		CreateShotA(0,ShotX,ShotY,10);
		SetShotDataA(0,0,0,sangle+9*i*DollDir,0,0.005,1.00,gra-144);
		SetShotDataA(0,30,NULL,NULL,0,0.01,1.00,gra-144);
		FireShot(0);
		//CreateShot01(ShotX,ShotY,2,angle,gra-144,10);
	}
	Obj_Delete(obj);
}

task EffectLaser(x,y,angle,length,width,delay,time,gra)
{
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	loop(time)
	{
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	yield;
	}
	Obj_Delete(obj);
}

task NuClear
{
		let sc=0.0;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetX,GetY);
		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);

		Shot1;

		//while(!Obj_BeDeleted(obj))
		loop(90)
		{	
			if(sc<0.5)
			{
			sc+=0.5/15;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}
		loop(10)
		{	
			if(sc>0)
			{
			sc-=0.5/10;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}

		task Shot1
		{
			wait(15);
			let Radius=40;
			loop(20)
			{
				let angle=rand(0,360);
				CreateShot02(GetX+Radius*cos(angle),GetY+Radius*sin(angle),0,angle,0.01,2,9,5);
			wait(3);
			}
		}
}

}

	task String
	{
	let Distance;
	let BossAngleFromDoll;
	loop
	{
		Distance=((GetY-GetCommonData("BossY"))^2+(GetX-GetCommonData("BossX"))^2)^0.5;
		BossAngleFromDoll=atan2(GetCommonData("BossY")-GetY,GetCommonData("BossX")-GetX);
		StringLaserEffect(GetX,GetY,Distance,5,BossAngleFromDoll);
		yield;
	}
	}

task StringLaserEffect(x,y,length,width,angle)
{
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228/10, 27);
		ObjEffect_SetVertexUV(obj, 2, 228/10, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=60;

		let R=39;
		let G=64;
		let B=200;


		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(1)
		{
		yield;
		}
		Obj_Delete(obj);
}

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

script_enemy Familiar6 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let DollDir=num[0];
	let DollAngle=num[1];
	let Dollnum=num[2];
	let color=rand_int(9,15);
	let DollAlpha=0;
    let imgNuclear =GetCurrentScriptDirectory ~ "..\img/s_shot.png"; 
    let imgNuclearWave =GetCurrentScriptDirectory ~ "..\img/NuclearWave2.png"; 
	let DrawFlag=1;
    @Initialize {

LoadGraphic(imgNuclear);
	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(100000);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
if(DrawFlag)
{
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
}
        yield;
    }

    @DrawLoop {
SetAlpha(DollAlpha);
if(DrawFlag)
{
     DrawDoll( imgDoll, GetX, GetY );
}
    }

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

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

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

	shotE;

	//ZakoEffect(255,0,0);

    }

task move
{
	wait(20);
	loop(30)
	{
		DollAlpha+=255/30;
		yield;
	}
	wait(60);
	let speed=0;
	loop(540)
	{
		SetSpeed(speed);
		SetAngle(GetAngleToPlayer);
		if(speed<0.5)
		{
			speed+=0.02;
		}
		yield;
	}
		SetSpeed(0);
}

task shotE
{
wait(20);
wait(60);
Concentration01(30);
wait(30);
let TX=0;
let TY=0;
let TAngle=0;
let TRadius=0;
let TRadiusTheta=0;

let speed=0;

EraseLifeGauge=false;
Shot1;
Shot2;

task Shot1
{
loop(6)
{
	CreateShot01(GetX,GetY,3.0,GetAngleToPlayer,165,10);
	wait(90);
}

}

task Shot2
{
loop(6)
{
	let angle=rand(0,360);
	ascent(i in 0..12)
	{
	CreateShot01(GetX,GetY,1.5,angle+i*30,9,10);
	}
	wait(90);
}
NuClear;
DrawFlag=0;
wait(100);
VanishEnemy;
}



task DLaser(x,y,angle,length,width,delay,time,gra)
{
	let lengthmax=length;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	let dcount=30;
	let lcount=0;
	loop(delay)
	{
		EffectLaser(x,y,angle,length*lcount/30,width,0,1,gra);
		ObjLaser_SetLength(obj,length*lcount/30);
		if(lcount<30)
		{
		lcount+=1;
		}
	yield;
	}
	EffectLaser(x,y,angle,length,width,0,time-delay,gra);
	loop(time-delay)
	{
		yield;
	}
	Obj_SetCollisionToPlayer(obj,false);
	loop(30)
	{
		EffectLaser(x,y,angle,length,width*dcount/30,0,2,gra);
	ObjLaser_SetWidth(obj,width*dcount/30);
	dcount-=1;
	yield;
	}

	let SX=GetX;
	let SY=GetY;
	let EX=SX-lengthmax*DollDir;
	let EY=SY;
	let sep=40;
	
	let sangle=rand(0,360);
	ascent(i in 1..sep)
	{
		let ShotX=SX-(SX-EX)*i/sep;
		let ShotY=SY-(SY-EY)*i/sep;
		CreateShotA(0,ShotX,ShotY,10);
		SetShotDataA(0,0,0,sangle+9*i*DollDir,0,0.005,1.25,gra-144);
		SetShotDataA(0,30,NULL,NULL,0,0.01,1.25,gra-144);
		FireShot(0);
		//CreateShot01(ShotX,ShotY,2,angle,gra-144,10);
	}
	Obj_Delete(obj);
}

task EffectLaser(x,y,angle,length,width,delay,time,gra)
{
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	loop(time)
	{
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	yield;
	}
	Obj_Delete(obj);
}

task NuClear
{
		let sc=0.0;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetX,GetY);
		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);

		Shot1;

		loop(90)
		{	
			if(sc<0.75)
			{
			sc+=0.75/15;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}
		loop(10)
		{	
			if(sc>0)
			{
			sc-=0.75/10;
			}
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetScale(obj, sc,sc);
			if(GetDistanceToPlayer<80*sc && GetTimeOfPlayerInvincibility==0)
			{
				ShootDownPlayer;
			}
			wait(1);
		}

		task Shot1
		{
			wait(15);
			let Radius=60;
			loop(60)
			{
				let angle=rand(0,360);
				CreateShot02(GetX+Radius*cos(angle),GetY+Radius*sin(angle),0,angle,0.01,2,9,5);
			wait(1);
			}
		}
}

}

	task String
	{
	let Distance;
	let BossAngleFromDoll;
	loop
	{
		Distance=((GetY-GetCommonData("BossY"))^2+(GetX-GetCommonData("BossX"))^2)^0.5;
		BossAngleFromDoll=atan2(GetCommonData("BossY")-GetY,GetCommonData("BossX")-GetX);
		StringLaserEffect(GetX,GetY,Distance,5,BossAngleFromDoll);
		yield;
	}
	}

task StringLaserEffect(x,y,length,width,angle)
{
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228/10, 27);
		ObjEffect_SetVertexUV(obj, 2, 228/10, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=60;

		let R=39;
		let G=64;
		let B=200;


		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(1)
		{
		yield;
		}
		Obj_Delete(obj);
}

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

script_enemy Familiar7 {
    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;
	String;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;

	shotA;
	//ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition03(GetCenterX,GetCenterY,10,3);
	wait(2160);
	SetMovePosition02(GetCommonData("BossX"),GetCommonData("BossY"),60);
	wait(60);
	VanishEnemy;
}

task shotA
{
let DollDir=GetCommonDataDefault("DollDirction",1);
wait(60);
	ascent(i in 0..4)
	{
	Laser(GetX,GetY,90+i*90,550,40,60,120,153);
	}
wait(60);
ShotA;
ShotB;
wait(780);
ShotC;
	task ShotC
	{
	let angle=0;
		loop(9)
		{
			loop(15)
			{
			ascent(i in 0..4)
			{
			BShot(GetX,GetY,3,angle+i*90,233,5);
			}
			angle+=1*DollDir;
			wait(3);
			}
		angle+=10;
		wait(90);
		}



	task BShot(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);
		Obj_SetAlpha(obj,100);
		Obj_SetCollisionToPlayer(obj,false);
		while(!Obj_BeDeleted(obj))
		{
			if(Obj_GetX(obj)<GetClipMinX || Obj_GetX(obj)>GetClipMaxX || Obj_GetY(obj)<GetClipMinY || Obj_GetY(obj)>GetClipMaxY)
			{
				CreateShot01(Obj_GetX(obj),Obj_GetY(obj),3,atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj)),81,15);
				Obj_Delete(obj);
			}
			yield;
		}
	}

	}

	task ShotA
	{

	let angle=rand(0,360);
	loop(36)
	{
	ascent(j in -3..4)
	{
	ascent(i in 0..3)
	{
		CreateShot01(GetX,GetY,1.25,angle+120*i+j*2,9,5);
	}
	}
	wait(20);
	angle-=17*DollDir;
	}
	}

	task ShotB
	{

	let angle=rand(0,360);
	loop(90)
	{
	ascent(i in 0..6)
	{
		CreateShot01(GetX,GetY,1.5,angle+60*i,14,5);
	}
	wait(8);
	angle+=23;
	}
	}

task Laser(x,y,angle,length,width,delay,time,gra)
{
	let lengthmax=length;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	Obj_SetAutoDelete(obj,false);
	let dcount=30;
	let lcount=0;
	loop(delay)
	{
		EffectLaser(x,y,angle,length*lcount/30,width,0,1,gra);
		ObjLaser_SetLength(obj,length*lcount/30);
		if(lcount<30)
		{
		lcount+=1;
		}
	yield;
	}
	EffectLaser(x,y,angle,length,width,0,time-delay,gra);
	loop(time-delay)
	{
		yield;
	}
	let anglePlus=0;
	loop(600)
	{
		StarLaserEffect(x,y,length*lcount/30,width,angle);
		EffectLaser(x,y,angle,length*lcount/30,width,0,1,gra);
		Obj_SetAngle(obj,angle);
		angle+=anglePlus*DollDir;
		if(anglePlus<0.6)
		{
			anglePlus+=0.05;
		}
	yield;
	}
	loop(12)
	{
		StarLaserEffect(x,y,length*lcount/30,width,angle);
		EffectLaser(x,y,angle,length*lcount/30,width,0,1,gra);
		Obj_SetAngle(obj,angle);
		angle+=anglePlus*DollDir;
		anglePlus-=0.05;
	yield;
	}
	Obj_SetCollisionToPlayer(obj,false);
	loop(30)
	{
		EffectLaser(x,y,angle,length,width*dcount/30,0,2,gra);
	ObjLaser_SetWidth(obj,width*dcount/30);
	dcount-=1;
	yield;
	}
	Obj_Delete(obj);
}

task EffectLaser(x,y,angle,length,width,delay,time,gra)
{
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	loop(time)
	{
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	yield;
	}
	Obj_Delete(obj);
}

task StarLaserEffect(x,y,length,width,angle)
{
		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/40;
		let R=255;
		let G=255;
		let B=255;

		R=255;
		G=50;
		B=50;


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

		if(GetCommonDataDefault("LightMode_SpecialEffect",0)==1){Obj_Delete(obj);return;}

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

}

	task String
	{
	let Distance;
	let BossAngleFromDoll;
	loop
	{
		Distance=((GetY-GetCommonData("BossY"))^2+(GetX-GetCommonData("BossX"))^2)^0.5;
		BossAngleFromDoll=atan2(GetCommonData("BossY")-GetY,GetCommonData("BossX")-GetX);
		StringLaserEffect(GetX,GetY,Distance,5,BossAngleFromDoll);
		yield;
	}
	}

task StringLaserEffect(x,y,length,width,angle)
{
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228/10, 27);
		ObjEffect_SetVertexUV(obj, 2, 228/10, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=60;

		let R=39;
		let G=64;
		let B=200;


		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(1)
		{
		yield;
		}
		Obj_Delete(obj);
}

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

script_enemy Familiar8 {
    let csd     = GetCurrentScriptDirectory;
    let imgDoll  = csd ~ "..\lib/dot_alice.png"; 
	let num = GetArgument;
	let DollX=num[0];
	let DollY=num[1];
	let Dollnum=num[2];
	//let Dolldir=1;
	//let color=rand_int(9,15);
   // let imgNuclear =GetCurrentScriptDirectory ~ "..\img/s_shot.png"; 
   // let imgNuclearWave =GetCurrentScriptDirectory ~ "..\img/NuclearWave2.png"; 
	//let DrawFlag=1;
    @Initialize {

	BombDamageRate=10;
	InitializeActionWithDoll;
//	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,0,0);

	TMain;
    }

    @MainLoop {
      //  SetCollisionA(GetX, GetY, 32);
      //  MSDSetCollisionB(GetX, GetY, 8);
        yield;
    }

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

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

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

	}

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;
	//RoundEffect;
	//ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition03(DollX,DollY,20,5);
	loop(280+10*GetArgument[3]+10*Dollnum)
	{
		yield;
	}
	VanishEnemy;
}

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


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

    @MainLoop {
        SetCollisionA(GetX, GetY, 36);
        MSDSetCollisionB(GetX, GetY, 12);
        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;
	String;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;

	shotA;
    }

task move
{
	let DollDir=GetCommonDataDefault("DollDirction",1);
	let Y=GetY;
	let BY=Y;
	let R=0;
	loop(2190)
	{
		SetX(GetCenterX+R*cos(DollAngle));
		SetY(Y+R*sin(DollAngle));
		if(R<224)
		{
			R+=224/60;
		}
		if(Y<GetCenterY)
		{
		Y+=1;
		}
		DollAngle-=0.5*DollDir;
		yield;
	}
	loop(60)
	{
		SetX(GetCenterX+R*cos(DollAngle));
		SetY(Y+R*sin(DollAngle));
		R-=224/60;
		if(Y>BY)
		{
		Y-=2;
		}
		DollAngle-=0.5*DollDir;
		yield;
	}
	VanishEnemy;
}

task shotA
{
wait(90);
let DollDir=-GetCommonDataDefault("DollDirction",1);
Laser(GetX,GetY,DollAngle+120*DollDir,550,20,60,2100,158);

task Laser(x,y,angle,length,width,delay,time,gra)
{
	let lengthmax=length;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	Obj_SetAutoDelete(obj,false);
	let dcount=30;
	let lcount=0;
	loop(delay)
	{
		StarLaserEffect(GetX,GetY,length*lcount/30,width/2,DollAngle+120*DollDir);
		Obj_SetPosition(obj,GetX,GetY);
		Obj_SetAngle(obj,DollAngle+120*DollDir);
		EffectLaser(x,y,DollAngle+120*DollDir,length*lcount/30,width,0,1,gra);
		ObjLaser_SetLength(obj,length*lcount/30);
		if(lcount<30)
		{
		lcount+=1;
		}
	yield;
	}
	//EffectLaser(x,y,angle,length,width,0,time-delay,gra);
	loop(time-delay)
	{
		StarLaserEffect(GetX,GetY,length*lcount/30,width,DollAngle+120*DollDir);
		Obj_SetPosition(obj,GetX,GetY);
		Obj_SetAngle(obj,DollAngle+120*DollDir);
		EffectLaser(x,y,DollAngle+120*DollDir,length*lcount/30,width,0,1,gra);
		yield;
	}
	Obj_SetCollisionToPlayer(obj,false);
	loop(30)
	{
		StarLaserEffect(GetX,GetY,length*lcount/30,width*dcount/30,DollAngle+120*DollDir);
		Obj_SetPosition(obj,GetX,GetY);
		Obj_SetAngle(obj,DollAngle+120*DollDir);
		EffectLaser(x,y,DollAngle+120*DollDir,length,width*dcount/30,0,2,gra);
	ObjLaser_SetWidth(obj,width*dcount/30);
	dcount-=1;
	yield;
	}
	Obj_Delete(obj);
}

task EffectLaser(x,y,angle,length,width,delay,time,gra)
{
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetAngle(obj,DollAngle+120*DollDir);
	ObjShot_SetGraphic(obj,gra);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,delay);
	ObjShot_SetBombResist(obj,true);
	Obj_SetCollisionToPlayer(obj,false);
	loop(time)
	{
	Obj_SetPosition(obj,GetX,GetY);
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
	yield;
	}
	Obj_Delete(obj);
}

task StarLaserEffect(x,y,length,width,angle)
{
		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;

		R=100;
		G=100;
		B=255;


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

		if(GetCommonDataDefault("LightMode_SpecialEffect",0)==1){Obj_Delete(obj);return;}

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

}

	task String
	{
	let Distance;
	let BossAngleFromDoll;
	loop
	{
		Distance=((GetY-GetCommonData("BossY"))^2+(GetX-GetCommonData("BossX"))^2)^0.5;
		BossAngleFromDoll=atan2(GetCommonData("BossY")-GetY,GetCommonData("BossX")-GetX);
		StringLaserEffect(GetX,GetY,Distance,5,BossAngleFromDoll);
		yield;
	}
	}

task StringLaserEffect(x,y,length,width,angle)
{
		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, -2);
		ObjEffect_SetVertexXY(obj, 1,length,  -2);
		ObjEffect_SetVertexXY(obj, 2,length, 2);
		ObjEffect_SetVertexXY(obj, 3,  0,  2);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  228/10, 27);
		ObjEffect_SetVertexUV(obj, 2, 228/10, 33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);

		let Alpha=60;

		let R=39;
		let G=64;
		let B=200;


		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(1)
		{
		yield;
		}
		Obj_Delete(obj);
}

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