
#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=108*60;
let StandardTimeCounter=TimeCounter;
    @Initialize {
	if(GetCommonDataDefault("ExclusiveBoss",false)==true)
	{
		BossTimer(TimeCounter);
	}
	else
	{
		SetTimer(TimeCounter/60);
	}
	SetShotAutoDeleteClip(16,32,16,32);
        SetLife(10500);
	InitializeAction();
	SetEnemyMarker(true);
	SetX(GetCenterX);
	SetY(GetClipMinY-16);
        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",35000);
    }

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

}

sub standBy//初期位置へ
{/*
	SetAction(ACT_MOVE, 120);
	SetMovePosition03(GetCenterX, GetCenterY-40,30,1.5);
	wait(120);
	wait(60);
*/
	SetCommonData("Stage5MoveSignal7",true);
	SetAction(ACT_MOVE, 120);
	SetMovePosition02(GetCenterX, GetCenterY-120,120);
	wait(120);
//	summon;
	Concentration01(30);
	//Concentration03(GetX,GetY,60,0,64,255);
}

task Collision
{
	loop(150)
	{
        SetCollisionA(GetX, GetY, 48);
	yield;
	}

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

task DamageRateChange
{
loop
{
	if(GetEnemyNum==3){DamageRate=100;}
	else if(GetEnemyNum==2){DamageRate=110;}
	else if(GetEnemyNum==1){DamageRate=120;}
yield;
}
}

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


task shotM
{
wait(30);
loop
{
SetAction(ACT_SHOT_A, 240);
HalfMoonShot1(2,9);
wait(60);
HalfMoonShot2(2.5,10);
wait(60);
HalfMoonShot1(3,11);
wait(60);
HalfMoonShot2(3.5,12);
wait(180);
SetAction(ACT_SHOT_B, 60);
CreateDolls1;
wait(120);
SpellDraw(33,720);
loop(4)
{
SetAction(ACT_SHOT_A, 60);
PrismLasar;
wait(180);
}

SetCommonData("AliceStop",true);
wait(120);
let Mdir=RandDir;
CreateDolls2(3);
wait(60);
SetMovePosition03(rand(GetCenterX+80*Mdir,GetCenterX+160*Mdir), rand(GetCenterY-30,GetClipMinY+60), 20,5);
SetAction(ACT_MOVE, 60);
wait(120);
CreateDolls2(3);
wait(60);
SetMovePosition03(rand(GetCenterX-80*Mdir,GetCenterX-160*Mdir), rand(GetCenterY-30,GetClipMinY+60), 20,5);
SetAction(ACT_MOVE, 60);
wait(120);
CreateDolls2(3);
wait(60);
SetMovePosition03(xIni, yIni, 20,5);
SetAction(ACT_MOVE, 60);
wait(120);
CreateDolls2(4);
wait(390);
SetAction(ACT_SHOT_A, 180);
Shot1;
wait(60);
Shot2;
wait(300);
SetCommonData("AliceStop",false);
}

	task Shot1
	{
		let Sangle=rand(-5,5);
		ascent(j in -5..5)
		{
		ascent(i in -8..10)
		{
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 2,Sangle+i*10, 1.5,0, 0, 9);
		SetShotDataA(1, 60+j*2, NULL,NULL, 0, 0.02, 6.0, 9);
		FireShot(1);
		}
		wait(12);
		}
	}

	task Shot2
	{
		let Sangle=180+rand(-5,5);
		ascent(j in -5..5)
		{
		ascent(i in -10..8)
		{
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 2,Sangle+i*10, -1.5,0, 0, 14);
		SetShotDataA(1, 60+j*2, NULL,NULL, 0, 0.02, 6.0, 14);
		FireShot(1);
		}
		wait(12);
		}
	}

	task HalfMoonShot1(speed,gra)
	{
	let Radius=10+speed*20;
	let Sangle=0;
	let angle=0;
	let x=GetX+Radius*cos(Sangle);
	let y=GetY+Radius*sin(Sangle);
	ascent(i in 0..18)
	{
		x=GetX+Radius*cos(i*10);
		y=GetY+Radius*sin(i*10);
		angle=atan2(GetY-y,GetX-x);
		ascent(k in 0..6)
		{
			CreateShot01(x,y,speed,angle+k*60,gra,5);
			CreateShot02(x,y,0,angle+k*60,speed/100,speed*2,gra,5);
		}
		angle+=10;
		wait(2);
	}
	}

	task HalfMoonShot2(speed,gra)
	{
	let Radius=10+speed*20;
	let Sangle=0;
	let angle=0;
	let x=GetX+Radius*cos(Sangle);
	let y=GetY+Radius*sin(Sangle);
	descent(i in 0..18)
	{
		x=GetX+Radius*cos(i*10);
		y=GetY+Radius*sin(i*10);
		angle=atan2(GetY-y,GetX-x);
		ascent(k in 0..6)
		{
			CreateShot01(x,y,speed,angle+k*60,gra,5);
			CreateShot02(x,y,0,angle+k*60,speed/100,speed*2,gra,5);
		}
		angle+=10;
		wait(2);
	}
	}

	task CreateDolls1
	{
	let RDollLevel=5;
	let LDollLevel=5;
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [1,RDollLevel]);
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [-1,LDollLevel]);
	SetCommonData("Alice1RightDoll",true);
	SetCommonData("Alice1LeftDoll",true);
	RDollLevel+=1;
	LDollLevel+=1;
	RDoll;
	LDoll;
		task RDoll
		{
		loop
		{
			while(GetCommonDataDefault("Alice1RightDoll",true)){yield;}
			if(GetCommonDataDefault("AliceStop",false)){break;}
      			CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [1,RDollLevel]);
			SetCommonData("Alice1RightDoll",true);
			RDollLevel+=1;
			if(RDollLevel==10){break;}
			yield;
		}
		}

		task LDoll
		{
		loop
		{
			while(GetCommonDataDefault("Alice1LeftDoll",true)){yield;}
			if(GetCommonDataDefault("AliceStop",false)){break;}
      			CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [-1,LDollLevel]);
			SetCommonData("Alice1LeftDoll",true);
			LDollLevel+=1;
			if(LDollLevel==10){break;}
			yield;
		}
		wait(1);
		if(RDollLevel+LDollLevel>=16)
		{
			SetCommonDataEx(NsScore,NsAchievement[85],1);
		}

		}
	}

	task PrismLasar
	{
		let rangle=rand(0,360);
		ascent(i in 0..3)
		{
			PrismLaserShot(rangle+i*120);
		}

		task PrismLaserShot(arg)
		{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, GetX,GetY);
		ObjShot_SetDelay(obj, 0);
		ObjShot_SetBombResist(obj,true);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);

		let x=GetX;
		let y=GetY;
		let speed=4;
		let angle=GetAngleToPlayer;
		let amp=50;
		let om=4;
		let t=0;
		let hcount=rand_int(0,360);
    		let px = speed*t;
   		let py = amp*sin(om*t + arg);
   		let a = amp*om*3.1415926/(180*speed);
		while(!Obj_BeDeleted(obj))
		{
			px=speed*t;
			py=amp*sin(om*t + arg);
			Obj_SetPosition(obj, x + px*cos(angle) - py*sin(angle),
                                 y + px*sin(angle) + py*cos(angle));
        		Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
			t++;
			LaserEffect(Obj_GetX(obj),Obj_GetY(obj),5,255,HueDifine(hcount+t));
			Lightning(Obj_GetX(obj),Obj_GetY(obj),rand(-1.5,1.5),Obj_GetAngle(obj)+180,rand(25,35),rand(15,35), HueDifine(hcount+t));
			yield;
		}
		Obj_Delete(obj);
		}

	}

	task Lightning(x,y,speed,angle,leng,width,color)
	{

	x+=cos(angle)*leng*0.5;
	y+=sin(angle)*leng*0.5;

	let obj=Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,x,y);
	ObjEffect_SetTexture(obj,csd~"..\img\Thunder.png");
	ObjEffect_CreateVertex(obj,4);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetLayer(obj,3);

		ObjEffect_SetVertexXY(obj, 0, -width/2, -leng/2);
		ObjEffect_SetVertexXY(obj, 1, width/2,  -leng/2);
		ObjEffect_SetVertexXY(obj, 2, width/2, leng/2);
		ObjEffect_SetVertexXY(obj, 3,  -width/2,  leng/2);

		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

	let alpha=0;
		let frame=0;
		let graphic=0;

	loop(5)
	{
		LightSet;
		alpha+=255/5;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,alpha,color[0],color[1],color[2]);
		}
		yield;
	}

	loop(30)
	{
		LightSet;
		alpha-=255/45;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,alpha,color[0],color[1],color[2]);
		}
		yield;
	}

	Obj_Delete(obj);

	sub LightSet
	{
		if(frame%3==0)
		{
			graphic=rand_int(0,256);
			ObjEffect_SetAngle(obj,0,0,angle-90*RandDir);

			ObjEffect_SetVertexUV(obj, 0,  0,  0+graphic);
			ObjEffect_SetVertexUV(obj, 1,  48, 0+graphic);
			ObjEffect_SetVertexUV(obj, 2, 48,  48+graphic);
			ObjEffect_SetVertexUV(obj, 3, 0, 48+graphic);
			ObjEffect_SetScale(obj,RandDir/2,RandDir);
		}
		if(frame%3==0)
		{
		HitJudg;
		}
		frame++;
		Obj_SetPosition(obj,x,y);
		x+=speed*cos(angle);
		y+=speed*sin(angle);
	}

	task HitJudg
	{
		let hobj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(hobj, Obj_GetX(obj),Obj_GetY(obj));
		ObjShot_SetDelay(hobj, 0);
		ObjShot_SetBombResist(hobj,true);
		ObjShot_SetGraphic(hobj, 25);
		Obj_SetAlpha(hobj,0);
	//	Obj_SetCollisionToPlayer(hobj,false);
		yield;
		Obj_Delete(hobj);
	}

}


	task LaserEffect(x,y,delay,Alpha,color)
	{
		let R=color[0];
		let G=color[1];
		let B=color[2];
  		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=1.0;
		loop(delay)
		{
			ObjEffect_SetScale(obj, Scale, Scale);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=6;
			Scale-=1.0/delay;
			yield;
		}
		Obj_Delete(obj);
	}

	task CreateDolls2(num)
	{
	DummyCollision(num);
	SetAction(ACT_SHOT_B, 60);
	let Dangle1=rand(0,360);
	ascent(i in 0..num)
	{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, 0, [1,Dangle1+360/num*i,num]);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, 0, [-1,Dangle1+360/num*i+180/num,num]);
	}

	task DummyCollision(number)
	{
	let x=GetX;
	let y=GetY;
	let time=300;
	if(num==4){time=420;}
	let R=0;
	loop(60)
	{
		SetDummySkyCollision(x,y,R+36);
		R+=1;
		yield;
	}
	loop(time-60)
	{
		SetDummySkyCollision(x,y,96);
		yield;
	}
	}
	}


function HueDifine(HueCount)
{
let ColorRed=0;
let ColorGreen=0;
let ColorBlue=0;
let MinColor=0;
while(HueCount>360){HueCount-=360;}
while(HueCount<=0){HueCount+=360;}
	if(0<HueCount && HueCount<=60)
	{
		ColorRed=255;
		ColorGreen=255*(HueCount)/60;
		ColorBlue=0;
	}
	else if(HueCount<=120)
	{
		ColorRed=255*(120-HueCount)/60;
		ColorGreen=255;
		ColorBlue=0;
	}
	else if(HueCount<=180)
	{
		ColorRed=0;
		ColorGreen=255;
		ColorBlue=255*(HueCount-120)/60;
	}
	else if(HueCount<=240)
	{
		ColorRed=0;
		ColorGreen=255*(240-HueCount)/60;
		ColorBlue=255;
	}
	else if(HueCount<=300)
	{
		ColorRed=255*(HueCount-240)/60;
		ColorGreen=0;
		ColorBlue=255;
	}
	else if(HueCount<=360)
	{
		ColorRed=255;
		ColorGreen=0;
		ColorBlue=255*(360-HueCount)/60;
	}
	return([ColorRed,ColorGreen,ColorBlue]);
}

}
/////////////////////////////////////////////////////////////////////////////
task shotE
{
loop(3)
{
wait(30);
SetAction(ACT_SHOT_A, 240);
Shot1(1,12);
wait(75);
Shot1(-1,12);
wait(60);
Shot1(1,12);
wait(45);
Shot1(-1,12);
wait(120);
SetAction(ACT_SHOT_B, 60);
CreateDolls1;

wait(120);
SpellDraw(33,720);
loop(3)
{
SetAction(ACT_SHOT_A, 120);
PrismLasar;
wait(240);
}

SetCommonData("AliceStop",true);
wait(120);
let Mdir=RandDir;
SpellDraw(36,870);
CreateDolls2;
wait(60);
SetMovePosition03(rand(GetCenterX+80*Mdir,GetCenterX+160*Mdir), rand(GetCenterY-30,GetClipMinY+60), 20,5);
SetAction(ACT_MOVE, 60);
wait(120);
CreateDolls2;
wait(60);
SetMovePosition03(rand(GetCenterX-80*Mdir,GetCenterX-160*Mdir), rand(GetCenterY-30,GetClipMinY+60), 20,5);
SetAction(ACT_MOVE, 60);
wait(120);
CreateDolls2;
wait(60);
SetMovePosition03(xIni, yIni, 20,5);
SetAction(ACT_MOVE, 60);
wait(120);
CreateDolls3;
wait(390);
Shot2;
wait(630);

SetCommonData("AliceStop",false);
}

	task Shot2
	{
	SetAction(ACT_SHOT_A, 600);
	let Pangle=rand(0,360);
	ascent(i in 0..24)
	{
		YukaShot(i*15,Pangle);
	}
/*
	let Pangle=90;
	let speed=3;
	loop
	{
	let R1=20;
	let R2=40;
	let x=GetX;
	let y=GetY;
	let angle=rand(0,360);
		ascent(i in 0..24)
		{
			let x=GetX+R1*cos(Pangle)*cos(angle)-R2*sin(Pangle)*sin(angle);
			let y=GetY-30+R1*sin(Pangle)*cos(angle)+R2*cos(Pangle)*sin(angle);
			angle+=15;
			//CreateShot12(x,y,speed*cos(angle+Pangle),speed*sin(angle+Pangle),0,0.02,3,5,9,5);

			CreateShot01(x,y,speed,angle+Pangle,9,0);
		}
		wait(10);
		Pangle+=6;
		speed+=0.05;
	}
*/
	}

	task YukaShot(angle,Pangle)
	{
	let R1=20;
	let R2=40;

	let Pangletheta=90;
	let PangleWave=10*cos(Pangletheta);
		let obj = Obj_Create(OBJ_SHOT);
		//Obj_SetPosition(obj, x,y);
		//Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 225);
		//ObjShot_SetDelay(obj, delay);
		Obj_SetAutoDelete(obj,false);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);

		let Radius=60;
		let RadiusAngle=90;
		let speed=2;
		let count=0;
		DShot;
		loop(600)
		{
			let x=GetX+R1*cos(Pangle+PangleWave)*cos(angle)-R2*sin(Pangle+PangleWave)*sin(angle);
			let y=GetY-30+R1*sin(Pangle+PangleWave)*cos(angle)+R2*cos(Pangle+PangleWave)*sin(angle);
			ObjShot_SetDelay(obj, 2);
			Obj_SetX(obj,x);
			Obj_SetY(obj,y);
			Pangle+=0.6;
			PangleWave=10*cos(Pangletheta);
			Pangletheta+=0.2;
			
			yield;
		}

		task DShot
		{
	loop
	{
	/*	CreateShotA(0,Obj_GetX(obj),Obj_GetY(obj),0);
		SetShotDataA(0,0,speed,angle+Pangle+PangleWave,-0.5,0,0,9);
		FireShot(0);
*/
		CreateShot01(Obj_GetX(obj),Obj_GetY(obj),speed,angle+Pangle+PangleWave,9,0);
		CreateShot01(Obj_GetX(obj),Obj_GetY(obj),speed,angle+Pangle,9,0);
		wait(10);
		speed+=0.06;
	}
		}
		Obj_Delete(obj);
	}

	task CreateDolls2
	{
	SetAction(ACT_SHOT_B, 60);
	let angle=rand(0,360);
	let R=rand(30,60);
	let angle2=rand(0,360);
	let R2=rand(30,60);
	let x=R*cos(angle);
	let y=R*sin(angle);
	let x2=R2*cos(angle2);
	let y2=R2*sin(angle2);
	DummyCollision;
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, [x,y,0]);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, [x2,y2,1]);

	task DummyCollision
	{
	let DCX=GetX+x;
	let DCY=GetY+y;
	let DCX2=GetX+x2;
	let DCY2=GetY+y2;
	loop(300)
	{
		SetDummySkyCollision(DCX,DCY,36);
		SetDummySkyCollision(DCX2,DCY2,36);
		yield;
	}
	}

	}

	task CreateDolls3
	{
	SetAction(ACT_SHOT_B, 60);
	let angle=rand(0,360);
	let R=rand(30,60);
	let angle2=rand(0,360);
	let R2=rand(30,60);
	let x=R*cos(angle);
	let y=R*sin(angle);
	let x2=R2*cos(angle2);
	let y2=R2*sin(angle2);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, [x,y,0]);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, [x2,y2,1]);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, [-x,-y,0]);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                              0, 0, [-x2,-y2,1]);

	task DummyCollision
	{
	let DCX=GetX+x;
	let DCY=GetY+y;
	let DCX2=GetX+x2;
	let DCY2=GetY+y2;
	let DCX3=GetX-x;
	let DCY3=GetY-y;
	let DCX4=GetX-x2;
	let DCY4=GetY-y2;
	loop(300)
	{
		SetDummySkyCollision(DCX,DCY,36);
		SetDummySkyCollision(DCX2,DCY2,36);
		SetDummySkyCollision(DCX3,DCY3,36);
		SetDummySkyCollision(DCX4,DCY4,36);
		yield;
	}
	}

	}

	task PrismLasar
	{
		let rangle=rand(0,360);
		ascent(i in 0..3)
		{
			PrismLaserShot(rangle+i*120);
		}

		task PrismLaserShot(arg)
		{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, GetX,GetY);
		ObjShot_SetDelay(obj, 0);
		ObjShot_SetBombResist(obj,true);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);

		let x=GetX;
		let y=GetY;
		let speed=4;
		let angle=GetAngleToPlayer;
		let amp=50;
		let om=4;
		let t=0;
		let hcount=rand_int(0,360);
    		let px = speed*t;
   		let py = amp*sin(om*t + arg);
   		let a = amp*om*3.1415926/(180*speed);
		while(!Obj_BeDeleted(obj))
		{
			px=speed*t;
			py=amp*sin(om*t + arg);
			Obj_SetPosition(obj, x + px*cos(angle) - py*sin(angle),
                                 y + px*sin(angle) + py*cos(angle));
        		Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
			t++;
			LaserEffect(Obj_GetX(obj),Obj_GetY(obj),5,255,HueDifine(hcount+t));
			Lightning(Obj_GetX(obj),Obj_GetY(obj),rand(-1.5,1.5),Obj_GetAngle(obj)+180,rand(25,35),rand(15,35), HueDifine(hcount+t));
			yield;
		}
		Obj_Delete(obj);
		}

	}

	task Lightning(x,y,speed,angle,leng,width,color)
	{

	x+=cos(angle)*leng*0.5;
	y+=sin(angle)*leng*0.5;

	let obj=Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,x,y);
	ObjEffect_SetTexture(obj,csd~"..\img\Thunder.png");
	ObjEffect_CreateVertex(obj,4);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetLayer(obj,3);

		ObjEffect_SetVertexXY(obj, 0, -width/2, -leng/2);
		ObjEffect_SetVertexXY(obj, 1, width/2,  -leng/2);
		ObjEffect_SetVertexXY(obj, 2, width/2, leng/2);
		ObjEffect_SetVertexXY(obj, 3,  -width/2,  leng/2);

		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

	let alpha=0;
		let frame=0;
		let graphic=0;

	loop(5)
	{
		LightSet;
		alpha+=255/5;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,alpha,color[0],color[1],color[2]);
		}
		yield;
	}

	loop(30)
	{
		LightSet;
		alpha-=255/45;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,alpha,color[0],color[1],color[2]);
		}
		yield;
	}

	Obj_Delete(obj);

	sub LightSet
	{
		if(frame%3==0)
		{
			graphic=rand_int(0,256);
			ObjEffect_SetAngle(obj,0,0,angle-90*RandDir);

			ObjEffect_SetVertexUV(obj, 0,  0,  0+graphic);
			ObjEffect_SetVertexUV(obj, 1,  48, 0+graphic);
			ObjEffect_SetVertexUV(obj, 2, 48,  48+graphic);
			ObjEffect_SetVertexUV(obj, 3, 0, 48+graphic);
			ObjEffect_SetScale(obj,RandDir/2,RandDir);
		}
		if(frame%3==0)
		{
		HitJudg;
		}
		frame++;
		Obj_SetPosition(obj,x,y);
		x+=speed*cos(angle);
		y+=speed*sin(angle);
	}

	task HitJudg
	{
		let hobj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(hobj, Obj_GetX(obj),Obj_GetY(obj));
		ObjShot_SetDelay(hobj, 0);
		ObjShot_SetBombResist(hobj,true);
		ObjShot_SetGraphic(hobj, 25);
		Obj_SetAlpha(hobj,0);
	//	Obj_SetCollisionToPlayer(hobj,false);
		yield;
		Obj_Delete(hobj);
	}
	}

	task LaserEffect(x,y,delay,Alpha,color)
	{
		let R=color[0];
		let G=color[1];
		let B=color[2];
  		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=1.0;
		loop(delay)
		{
			ObjEffect_SetScale(obj, Scale, Scale);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=6;
			Scale-=1.0/delay;
			yield;
		}
		Obj_Delete(obj);
	}

/*
	task PrismLasar
	{
		let speed=5;
		loop(60)
		{
			ascent(i in -1..2)
			{
			CreateShot01(GetX,GetY,speed,GetAngleToPlayer+i*15,9,5);
			}
			speed+=0.1;
			wait(2);
		}
	}
*/
	task Shot1(dir,way)
	{
		let SA=0;
		let speed=1+6*absolute(sin(SA));

		let angle=rand(0,360);
		loop(18)
		{
		speed=1+6*absolute(sin(SA));
		SA+=3;
		angle+=2.5*dir;
		ascent(i in 0..way)
		{
		CreateShot01(GetX,GetY,speed,angle+i*360/way,41,5);
		}
		wait(3);
		}
	}

	task CreateDolls1
	{
	let RDollLevel=5;
	let LDollLevel=5;
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [1,RDollLevel]);
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [-1,LDollLevel]);
	SetCommonData("Alice1RightDoll",true);
	SetCommonData("Alice1LeftDoll",true);
	RDollLevel+=1;
	LDollLevel+=1;
	RDoll;
	LDoll;
		task RDoll
		{
		loop
		{
			while(GetCommonDataDefault("Alice1RightDoll",true)){yield;}
			if(GetCommonDataDefault("AliceStop",false)){break;}
      			CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [1,RDollLevel]);
			SetCommonData("Alice1RightDoll",true);
			RDollLevel+=1;
			if(RDollLevel==10){break;}
			yield;
		}
		}

		task LDoll
		{
		loop
		{
			while(GetCommonDataDefault("Alice1LeftDoll",true)){yield;}
			if(GetCommonDataDefault("AliceStop",false)){break;}
      			CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [-1,LDollLevel]);
			SetCommonData("Alice1LeftDoll",true);
			LDollLevel+=1;
			if(LDollLevel==10){break;}
			yield;
		}
		wait(1);
		if(RDollLevel+LDollLevel>=16)
		{
			SetCommonDataEx(NsScore,NsAchievement[85],1);
		}

		}
	}

function HueDifine(HueCount)
{
let ColorRed=0;
let ColorGreen=0;
let ColorBlue=0;
let MinColor=0;
while(HueCount>360){HueCount-=360;}
while(HueCount<=0){HueCount+=360;}
	if(0<HueCount && HueCount<=60)
	{
		ColorRed=255;
		ColorGreen=255*(HueCount)/60;
		ColorBlue=0;
	}
	else if(HueCount<=120)
	{
		ColorRed=255*(120-HueCount)/60;
		ColorGreen=255;
		ColorBlue=0;
	}
	else if(HueCount<=180)
	{
		ColorRed=0;
		ColorGreen=255;
		ColorBlue=255*(HueCount-120)/60;
	}
	else if(HueCount<=240)
	{
		ColorRed=0;
		ColorGreen=255*(240-HueCount)/60;
		ColorBlue=255;
	}
	else if(HueCount<=300)
	{
		ColorRed=255*(HueCount-240)/60;
		ColorGreen=0;
		ColorBlue=255;
	}
	else if(HueCount<=360)
	{
		ColorRed=255;
		ColorGreen=0;
		ColorBlue=255*(360-HueCount)/60;
	}
	return([ColorRed,ColorGreen,ColorBlue]);
}

}
//////////////////////////////////////////////////////////////////////
task shotA
{

wait(30);
loop(2)
{
SetAction(ACT_SHOT_A, 300);
Shot1;
wait(120);
Shot2;
wait(240);
SetAction(ACT_SHOT_B, 60);
CreateDolls1;
wait(120);
SpellDraw(33,720);
loop(4)
{
SetAction(ACT_SHOT_A, 60);
PrismLasar;
wait(180);
}

SetCommonData("AliceStop",true);
wait(120);
SetAction(ACT_SHOT_B, 90);
SpellDraw(37,1500);
CreateDolls2;
wait(1500);

SetAction(ACT_SHOT_A, 300);
Shot3;
wait(360);
Shot4;
SetAction(ACT_SHOT_A, 300);
wait(450);
SetCommonData("AliceStop",false);
}

	task Shot4
	{
		let dir=1;
		let num=3;
		loop(5)
		{
		let angle=rand(85,95);
		ShotA(num);
		loop(5)
		{
		ascent(i in 0..12)
		{
			CreateShot01(GetX,GetY,3.0,angle+5+i*4,14,5);
			CreateShot01(GetX,GetY,3.0,angle-5-i*4,14,5);
		}
		angle+=2*dir;
		wait(6);
		}
		dir*=-1;
		num+=1;
		wait(30);
		}

		task ShotA(num)
		{
		wait(5);
		let angle=rand(80,100);
		ascent(i in 0..45)
		{
		ascent(j in 0..num)
		{
		CreateShot01(GetX,GetY,4.0-0.3*j,angle+i*9,9,5);
		}
		}
		}
	}

	task Shot3
	{
		let BBangle=180*rand_int(0,1)+rand(-10,10);
		ShotA(BBangle);
		ShotB(BBangle+90);
		task ShotA(Bangle)
		{
			let R=60;
			let Rangle=90;
			//let Bangle=rand(0,360);
			let angle=0;
			let num=0;
			let speed=[1.5,2.0,2.5,3.0];
			loop(60)
			{
			ascent(i in 0..4)
			{
			ascent(j in 0..3)
			{
			CreateShot01(GetX+(5+R*sin(Rangle))*cos(Bangle+angle+120*j),GetY+(5+R*sin(Rangle))*sin(Bangle+angle+120*j),speed[i%4],Bangle+angle+120*j+i*2,9,5);
			}
			}
			Rangle-=0.75*2;
			angle+=7.1;
			num+=1;
			wait(2);
			}
			loop(15)
			{
			ascent(i in 0..4)
			{
			ascent(j in 0..3)
			{
			CreateShot01(GetX+(5+R*sin(Rangle))*cos(Bangle+angle+120*j),GetY+(5+R*sin(Rangle))*sin(Bangle+angle+120*j),speed[i%4],Bangle+angle+120*j+i*2,9,5);
			}
			}
			//Rangle-=0.75*2;
			angle+=7.1;
			num+=1;
			wait(2);
			}
			loop(60)
			{
			ascent(i in 0..4)
			{
			ascent(j in 0..3)
			{
			CreateShot01(GetX+(5+R*sin(Rangle))*cos(Bangle+angle+120*j),GetY+(5+R*sin(Rangle))*sin(Bangle+angle+120*j),speed[i%4],Bangle+angle+120*j+i*2,9,5);
			}
			}
			Rangle+=0.75*2;
			angle+=7.1;
			num+=1;
			wait(2);
			}
		}

		task ShotB(Bangle)
		{
			let R=60;
			let Rangle=90;
			//let Bangle=rand(0,360);
			let angle=0;
			let num=0;
			let speed=[0.75,1.0,1.25,1.5,1.75];
			loop(90)
			{
			ascent(i in 0..4)
			{
			ascent(j in 0..2)
			{
			CreateShot01(GetX+(5+R*sin(Rangle))*cos(Bangle+angle+180*j),GetY+(5+R*sin(Rangle))*sin(Bangle+angle+180*j),speed[i%4],Bangle+angle+180*j-i*2,14,5);
			}
			}
			Rangle+=0.5*2;
			angle+=5.9;
			num+=1;
			wait(2);
			}
		}
	}

	task Shot1
	{
		let R=120;
		let angle=rand(0,360);
		loop(90)
		{
			ascent(i in 0..4)
			{
				CreateShot01(GetX+R*cos(angle+90*i),GetY+R*sin(angle+90*i),2.5,angle+90*i-115,9,5);
				CreateShot01(GetX+R*cos(angle+90*i),GetY+R*sin(angle+90*i),2.0,angle+90*i-90,9,5);
				CreateShot01(GetX+R*cos(angle+90*i),GetY+R*sin(angle+90*i),1.5,angle+90*i-65,9,5);
			}
		wait(2);
		R-=120/90;
		angle+=6;
		}
	}
	task Shot2
	{
		let R=120;
		let angle=rand(0,360);
		loop(90)
		{
			ascent(i in 0..4)
			{
				CreateShot01(GetX+R*cos(angle+90*i),GetY+R*sin(angle+90*i),1.5,angle+90*i+115,14,5);
				CreateShot01(GetX+R*cos(angle+90*i),GetY+R*sin(angle+90*i),2.0,angle+90*i+90,14,5);
				CreateShot01(GetX+R*cos(angle+90*i),GetY+R*sin(angle+90*i),2.5,angle+90*i+65,14,5);
			}
		wait(2);
		R-=120/90;
		angle-=6;
		}
	}


	task CreateDolls2
	{
	let CollisionFlag=true;
	DummyCollision;

		let num=3;
		CD;
		loop(3)
		{
		SetCommonData("AliceStop",false);
		DollSetting(num);
		wait(360);
		if(num==5){wait(180);}
		SetCommonData("AliceStop",true);
		wait(60);
		num+=1;
		}
	CollisionFlag=false;

	task DummyCollision
	{
		while(CollisionFlag)
		{
		SetDummySkyCollision(GetCenterX-150,GetCenterY-180,36);
		SetDummySkyCollision(GetCenterX-100,GetCenterY-90,36);
		SetDummySkyCollision(GetCenterX-50,GetCenterY-180,36);
		SetDummySkyCollision(GetCenterX-0,GetCenterY-70,36);
		SetDummySkyCollision(GetCenterX+50,GetCenterY-180,36);
		SetDummySkyCollision(GetCenterX+100,GetCenterY-90,36);
		SetDummySkyCollision(GetCenterX+150,GetCenterY-180,36);
		yield;
		}
	}

	task CD
	{
	wait(1);
	ascent(i in 0..7)
	{
        CreateEnemyFromScript("Familiar4", GetX, GetY,
                             0, 0,i);
	}
	}

	function DollSetting(MaxBullet)
	{
	let Signal=[];
	let Bullet=0;
	//let MaxBullet=4;
	let ArrayNum=0;
	loop(7)
	{
	let Pnum=rand_int(0,6);
	let Switch;
	if(Pnum<=MaxBullet-1){Switch=0;}
	else{Switch=1;}
	Signal=Signal~[Switch];
	if(Switch==1)
	{
		Bullet+=1;
	}
	if(Bullet==MaxBullet)
	{
		loop(7-ArrayNum)
		{
			Signal=Signal~[0];
		}
		break;
	}

	ascent(i in 0..MaxBullet)
	{
	if(Bullet==i && ArrayNum==6-MaxBullet+i)
	{
		loop(MaxBullet-i)
		{
			Signal=Signal~[1];
		}
		break;
	}
	}

	ArrayNum+=1;

	}


	let TempShotTypeArray=[0,1,2,3,4,5,6];
	let ShotTypeArray=[];
	let Rnum=6;
	loop(7)
	{
		let Anum=rand_int(0,Rnum);
		ShotTypeArray=ShotTypeArray~[TempShotTypeArray[Anum]];
		TempShotTypeArray=erase(TempShotTypeArray,Anum);
		Rnum-=1;
	}

	let TempColorTypeArray=[0,1,2,3,4,5,6];
	let ColorTypeArray=[];
	let Rnum=6;
	loop(7)
	{
		let Anum=rand_int(0,Rnum);
		ColorTypeArray=ColorTypeArray~[TempColorTypeArray[Anum]];
		TempColorTypeArray=erase(TempColorTypeArray,Anum);
		Rnum-=1;
	}

	SetCommonData("ShotSignal",Signal);
	SetCommonData("ShotType",ShotTypeArray);
	SetCommonData("ShotColor",ColorTypeArray);

	}

	}

	task CreateDolls1
	{
	let RDollLevel=5;
	let LDollLevel=5;
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [1,RDollLevel]);
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [-1,LDollLevel]);
	SetCommonData("Alice1RightDoll",true);
	SetCommonData("Alice1LeftDoll",true);
	RDollLevel+=1;
	LDollLevel+=1;
	RDoll;
	LDoll;
		task RDoll
		{
		loop
		{
			while(GetCommonDataDefault("Alice1RightDoll",true)){yield;}
			if(GetCommonDataDefault("AliceStop",false)){break;}
      			CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [1,RDollLevel]);
			SetCommonData("Alice1RightDoll",true);
			RDollLevel+=1;
			if(RDollLevel==10){break;}
			yield;
		}
		}

		task LDoll
		{
		loop
		{
			while(GetCommonDataDefault("Alice1LeftDoll",true)){yield;}
			if(GetCommonDataDefault("AliceStop",false)){break;}
      			CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, 0, [-1,LDollLevel]);
			SetCommonData("Alice1LeftDoll",true);
			LDollLevel+=1;
			if(LDollLevel==10){break;}
			yield;
		}
		wait(1);
		if(RDollLevel+LDollLevel>=16)
		{
			SetCommonDataEx(NsScore,NsAchievement[85],1);
		}

		}
	}

	task PrismLasar
	{
		let rangle=rand(0,360);
		ascent(i in 0..3)
		{
			PrismLaserShot(rangle+i*120);
		}

		task PrismLaserShot(arg)
		{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, GetX,GetY);
		ObjShot_SetDelay(obj, 0);
		ObjShot_SetBombResist(obj,true);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);

		let x=GetX;
		let y=GetY;
		let speed=4;
		let angle=GetAngleToPlayer;
		let amp=50;
		let om=4;
		let t=0;
		let hcount=rand_int(0,360);
    		let px = speed*t;
   		let py = amp*sin(om*t + arg);
   		let a = amp*om*3.1415926/(180*speed);
		while(!Obj_BeDeleted(obj))
		{
			px=speed*t;
			py=amp*sin(om*t + arg);
			Obj_SetPosition(obj, x + px*cos(angle) - py*sin(angle),
                                 y + px*sin(angle) + py*cos(angle));
        		Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
			t++;
			LaserEffect(Obj_GetX(obj),Obj_GetY(obj),5,255,HueDifine(hcount+t));
			Lightning(Obj_GetX(obj),Obj_GetY(obj),rand(-1.5,1.5),Obj_GetAngle(obj)+180,rand(25,35),rand(15,35), HueDifine(hcount+t));
			yield;
		}
		Obj_Delete(obj);
		}

	}

	task Lightning(x,y,speed,angle,leng,width,color)
	{

	x+=cos(angle)*leng*0.5;
	y+=sin(angle)*leng*0.5;

	let obj=Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,x,y);
	ObjEffect_SetTexture(obj,csd~"..\img\Thunder.png");
	ObjEffect_CreateVertex(obj,4);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetLayer(obj,3);

		ObjEffect_SetVertexXY(obj, 0, -width/2, -leng/2);
		ObjEffect_SetVertexXY(obj, 1, width/2,  -leng/2);
		ObjEffect_SetVertexXY(obj, 2, width/2, leng/2);
		ObjEffect_SetVertexXY(obj, 3,  -width/2,  leng/2);

		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

	let alpha=0;
		let frame=0;
		let graphic=0;

	loop(5)
	{
		LightSet;
		alpha+=255/5;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,alpha,color[0],color[1],color[2]);
		}
		yield;
	}

	loop(30)
	{
		LightSet;
		alpha-=255/45;
		ascent(i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,alpha,color[0],color[1],color[2]);
		}
		yield;
	}

	Obj_Delete(obj);

	sub LightSet
	{
		if(frame%3==0)
		{
			graphic=rand_int(0,256);
			ObjEffect_SetAngle(obj,0,0,angle-90*RandDir);

			ObjEffect_SetVertexUV(obj, 0,  0,  0+graphic);
			ObjEffect_SetVertexUV(obj, 1,  48, 0+graphic);
			ObjEffect_SetVertexUV(obj, 2, 48,  48+graphic);
			ObjEffect_SetVertexUV(obj, 3, 0, 48+graphic);
			ObjEffect_SetScale(obj,RandDir/2,RandDir);
		}
		if(frame%3==0)
		{
		HitJudg;
		}
		frame++;
		Obj_SetPosition(obj,x,y);
		x+=speed*cos(angle);
		y+=speed*sin(angle);
	}

	task HitJudg
	{
		let hobj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(hobj, Obj_GetX(obj),Obj_GetY(obj));
		ObjShot_SetDelay(hobj, 0);
		ObjShot_SetBombResist(hobj,true);
		ObjShot_SetGraphic(hobj, 25);
		Obj_SetAlpha(hobj,0);
	//	Obj_SetCollisionToPlayer(hobj,false);
		yield;
		Obj_Delete(hobj);
	}

}
	task LaserEffect(x,y,delay,Alpha,color)
	{
		let R=color[0];
		let G=color[1];
		let B=color[2];
  		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=1.0;
		loop(delay)
		{
			ObjEffect_SetScale(obj, Scale, Scale);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			Zangle+=6;
			Scale-=1.0/delay;
			yield;
		}
		Obj_Delete(obj);
	}

function HueDifine(HueCount)
{
let ColorRed=0;
let ColorGreen=0;
let ColorBlue=0;
let MinColor=0;
while(HueCount>360){HueCount-=360;}
while(HueCount<=0){HueCount+=360;}
	if(0<HueCount && HueCount<=60)
	{
		ColorRed=255;
		ColorGreen=255*(HueCount)/60;
		ColorBlue=0;
	}
	else if(HueCount<=120)
	{
		ColorRed=255*(120-HueCount)/60;
		ColorGreen=255;
		ColorBlue=0;
	}
	else if(HueCount<=180)
	{
		ColorRed=0;
		ColorGreen=255;
		ColorBlue=255*(HueCount-120)/60;
	}
	else if(HueCount<=240)
	{
		ColorRed=0;
		ColorGreen=255*(240-HueCount)/60;
		ColorBlue=255;
	}
	else if(HueCount<=300)
	{
		ColorRed=255*(HueCount-240)/60;
		ColorGreen=0;
		ColorBlue=255;
	}
	else if(HueCount<=360)
	{
		ColorRed=255;
		ColorGreen=0;
		ColorBlue=255*(360-HueCount)/60;
	}
	return([ColorRed,ColorGreen,ColorBlue]);
}

}

#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[0];
	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, 48);
        MSDSetCollisionB(GetX, GetY, 8);
        yield;
    }

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

        @Finalize
        {
	if(Dolldir==1){SetCommonData("Alice1RightDoll",false);}
	else if(Dolldir==-1){SetCommonData("Alice1LeftDoll",false);}
	MagicCircleBreak(GetX,GetY,1000,0.3);

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

    task TMain {
        yield;
	String;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	RoundEffect;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	//shotM;
	}
	case("Extream")
	{
	//shotE;
	}
	case("Apocalypse")
	{
	//shotA;
	}
	//ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition03(120*Dolldir, 0, 20,5);
	while(!GetCommonDataDefault("AliceStop",false)){yield;}
	SetMovePosition02(0, 0, 60);
	wait(60);
	VanishEnemy;
}

task RoundEffect
{
	ascent(i in 0..Dollnum)
	{
	CreateEffect(i*360/Dollnum);
	}

	task CreateEffect(angle)
	{
	let Radius=0;
  		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);
		let Alpha=150;
		let R=255;let G=0;let B=0;
		alternative(color)
		case(10){R=255;G=128;B=0;}
		case(11){R=255;G=255;B=0;}
		case(12){R=0;G=255;B=0;}
		case(13){R=0;G=255;B=255;}
		case(14){R=0;G=0;B=255;}
		case(15){R=255;G=0;B=255;}
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}

	//	Obj_SetPosition(obj,x,y);

		ObjEffect_SetLayer(obj,2);
		ObjEffect_SetScale(obj,0.5,0.5);

		let Scale=1.0;
		Shot;
		while(!Obj_BeDeleted(obj)){
			Obj_SetPosition(obj,GetX+Radius*cos(angle),GetY+Radius*sin(angle));
			if(Radius<30){
			Radius+=0.2;
			}
			angle+=Dolldir*2.9*5/Dollnum;
			let Zangle=rand(0,360);
			ObjEffect_SetAngle(obj,0,0,Zangle);
			yield;
		}
		Obj_Delete(obj);

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

		task shotM
		{
			wait(60);
			loop{
			CreateShot01(Obj_GetX(obj),Obj_GetY(obj),0.5+Dollnum*0.4,atan2(Obj_GetY(obj)-GetY,Obj_GetX(obj)-GetX),color,0);
			wait(5);}
		}

		task shotE
		{
			wait(60);
			loop{
			CreateShot01(Obj_GetX(obj),Obj_GetY(obj),0.5+Dollnum*0.4,atan2(Obj_GetY(obj)-GetY,Obj_GetX(obj)-GetX),color,0);
			wait(3);
			CreateShot01(Obj_GetX(obj),Obj_GetY(obj),(0.5+Dollnum*0.4)*1.1,atan2(Obj_GetY(obj)-GetY,Obj_GetX(obj)-GetX),color,0);
			wait(3);
			}
		}

		task shotA
		{
			wait(60);
			loop{
			CreateShot01(Obj_GetX(obj),Obj_GetY(obj),0.0+Dollnum*0.3,atan2(Obj_GetY(obj)-GetY,Obj_GetX(obj)-GetX),color,0);
			wait(2);
			CreateShot01(Obj_GetX(obj),Obj_GetY(obj),(0.0+(Dollnum+1)*0.3),atan2(Obj_GetY(obj)-GetY,Obj_GetX(obj)-GetX),color,0);
			wait(2);
			}
		}
	}
}
/*
/////////////////////////////////////////////////////////
task shotE
{
wait(30);

}
////////////////////////////////////////////////////////////
task shotA
{

}
*/
	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 Familiar2 {
    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);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,50,0);
	TMain;
    }

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

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

        @Finalize
        {
	SpecialBreak=true;
	MagicCircleBreak(GetX,GetY,1000,0.3);
	}

    task TMain {
        yield;
	//String;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;
//	RoundEffect;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	//ZakoEffect(255,0,0);

    }

task move
{
	yield;
	let R=0;
	let Angle=Dollangle;
	let X=GetX;
	let Y=GetY;
	if(Dollnum==3)
	{
	loop(420)
	{
		SetX(X+R*cos(Angle));
		SetY(Y+R*sin(Angle));
		Angle+=3*Dolldir;
		if(R<60){
			R+=1;
		}
		yield;
	}
	}
	else if(Dollnum==4)
	{
	loop(300)
	{
		SetX(X+R*cos(Angle));
		SetY(Y+R*sin(Angle));
		Angle+=3*Dolldir;
		if(R<60){
			R+=1;
		}
		yield;
	}
	}
	VanishEnemy;
}

task shotM
{
wait(60);
let angle=Dollangle+30*Dolldir;
if(Dollnum==4){angle=Dollangle+22.5*Dolldir}
loop
{
	CreateShot01(GetX,GetY,2,angle,41,0);
	angle-=1.5*Dolldir;
	wait(4);
}
}
/////////////////////////////////////////////////////////
task shotE
{
wait(30);

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

	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 Familiar3 {
    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 color=rand_int(9,15);
    @Initialize {
	BombDamageRate=10;
	InitializeActionWithDoll;
	//SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(50000);
        SetDamageRateEx(100,100,50,0);
	TMain;
    }

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

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

        @Finalize
        {
	SpecialBreak=true;
	MagicCircleBreak(GetX,GetY,1000,0.3);
	}

    task TMain {
        yield;
	//String;
	GetDamege;
	OutDamageRateZero;
	//ZakoEnemyLifeDisplay;
	move;
//	RoundEffect;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	//ZakoEffect(255,0,0);

    }

task move
{
	SetMovePosition03(GetX+DollX,GetY+DollY,10,3);
	wait(300);
	VanishEnemy;
}

task shotM
{

}
/////////////////////////////////////////////////////////
task shotE
{
wait(60);
if(Dollnum==0)
{
	ascent(i in 0..4)
	{
	Laser(GetX,GetY,90+i*90,550,40,60,120,153);
	}
}
else
{
	ascent(i in 0..4)
	{
	Laser(GetX,GetY,GetAngleToPlayer+i*90,550,40,60,120,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)
	{
		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=Obj_GetX(obj);
	let SY=Obj_GetY(obj);
	let EX=ObjLaser_GetEndX(obj);
	let EY=ObjLaser_GetEndY(obj);
	let sep=40;
	
	ascent(i in 1..sep)
	{
		let ShotX=SX-(SX-EX)*i/sep;
		let ShotY=SY-(SY-EY)*i/sep;
		CreateShotA(0,ShotX,ShotY,10);
		if(gra==153)
		{
			SetShotDirectionType(PLAYER);
			SetShotDataA(0,0,0,0,0,0.05,2,gra-144);
			SetShotDirectionType(ABSOLUTE);
		}
		else
		{
		SetShotDataA(0,0,0,angle+90*(i%2*2-1),0,0.05,2,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 shotA
{
wait(30);
}

	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 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);
        SetLife(50000);
        SetDamageRateEx(100,100,50,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;
//	RoundEffect;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	//ZakoEffect(255,0,0);

    }

task move
{
	alternative(num)
	case(0){SetMovePosition03(GetCenterX-150,GetCenterY-180,10,3);}
	case(1){SetMovePosition03(GetCenterX-100,GetCenterY-90,10,3);}
	case(2){SetMovePosition03(GetCenterX-50,GetCenterY-180,10,3);}
	case(3){SetMovePosition03(GetCenterX-0,GetCenterY-70,10,3);}
	case(4){SetMovePosition03(GetCenterX+50,GetCenterY-180,10,3);}
	case(5){SetMovePosition03(GetCenterX+100,GetCenterY-90,10,3);}
	case(6){SetMovePosition03(GetCenterX+150,GetCenterY-180,10,3);}
	wait(3300);
	VanishEnemy;
}

task shotM
{/*
wait(60);
let angle=Dollangle+30*Dolldir;
if(Dollnum==4){angle=Dollangle+22.5*Dolldir}
loop
{
	CreateShot01(GetX,GetY,2,angle,41,0);
	angle-=1.5*Dolldir;
	wait(4);
}
*/
}
/////////////////////////////////////////////////////////
task shotA
{
let Signal=GetCommonData("ShotSignal");
let ShotType=GetCommonData("ShotType");
let ShotColor=GetCommonData("ShotColor");
loop(3)
{
wait(60);
Signal=GetCommonData("ShotSignal");
ShotType=GetCommonData("ShotType");
ShotColor=GetCommonData("ShotColor");
if(Signal[num]==1)
{
	alternative(ShotType[num])
	case(0){Shot0;}
	case(1){Shot1;}
	case(2){Shot2;}
	case(3){Shot3;}
	case(4){Shot4;}
	case(5){Shot5;}
	case(6){Shot6;}
}
while(GetCommonData("AliceStop")==false){yield;}
}
wait(30);
SetMovePosition02(GetCommonData("BossX"),GetCommonData("BossY"),60);
wait(60);
VanishEnemy;

	task Shot0
	{
	loop
	{
		let angle=GetAngleToPlayer;
		loop(5)
		{
		CreateShot01(GetX,GetY,4,angle,9+ShotColor[num],5);
		wait(3);
		}
		wait(15);
		if(GetCommonData("AliceStop")){break;}
	}
	}

	task Shot1
	{
	let angle=rand(0,360);
	loop
	{
		ascent(i in 0..12)
		{
		CreateShot01(GetX,GetY,1.5,angle+9*i,9+ShotColor[num],5);
		}
		angle-=12/5*6;
		wait(12);
		if(GetCommonData("AliceStop")){break;}
	}
	}

	task Shot2
	{
	let Bangle=rand(0,360);
	let angle=0;
	loop
	{
		ascent(i in 0..3)
		{
		CreateShot01(GetX,GetY,2.5,Bangle+angle+i*120,9+ShotColor[num],5);
		CreateShot01(GetX,GetY,2.5,Bangle-angle+i*120,9+ShotColor[num],5);
		}
		angle+=8.7;
		wait(3);
		if(GetCommonData("AliceStop")){break;}
	}
	}

	task Shot3
	{
	let Bangle=rand(0,360);
	let angle=1;
	loop
	{
		ascent(i in 1..7)
		{
		CreateShot01(GetX,GetY,3.0,Bangle+angle*i,9+ShotColor[num],5);
		}
		Bangle+=18;
		angle+=1;
		wait(5);
		if(GetCommonData("AliceStop")){break;}
	}
	}

	task Shot4
	{
		let angle=rand(0,360);
	loop
	{
		ascent(i in 0..3)
		{
		CreateShot01(GetX,GetY,4.5-0.25*i,angle,9+ShotColor[num],5);
		}
		angle+=6.75;
		wait(3);
		if(GetCommonData("AliceStop")){break;}
	}
	}

	task Shot5
	{
		let angle=rand(0,360);
	loop
	{
		loop(5)
		{
		ascent(i in 0..4)
		{
		CreateShot01(GetX,GetY,2.0,angle+90*i,9+ShotColor[num],5);
		}
		angle+=2;
		wait(1);
		}
		angle+=10;
		wait(5);
		if(GetCommonData("AliceStop")){break;}
	}
	}
	task Shot6
	{
	loop
	{
		let angle=GetAngleToPlayer;
		loop(5)
		{
		CreateShot01(GetX,GetY,4.0,angle-10,9+ShotColor[num],5);
		CreateShot01(GetX,GetY,4.0,angle+10,9+ShotColor[num],5);
		CreateShot01(GetX,GetY,4.0,angle-30,9+ShotColor[num],5);
		CreateShot01(GetX,GetY,4.0,angle+30,9+ShotColor[num],5);
		wait(3);
		}
		wait(15);
		if(GetCommonData("AliceStop")){break;}
	}
	}

ascent(i in 0..4)
	{
	//Laser(GetX,GetY,90+i*90,550,40,60,120,153);
	}

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;
	}
	//Obj_SetCollisionToPlayer(obj,false);
	loop
	{
		EffectLaser(x,y,angle,length*lcount/30,width,0,1,gra);
		Obj_SetAngle(obj,angle);
		angle+=1;
		yield;
	}
	let SX=Obj_GetX(obj);
	let SY=Obj_GetY(obj);
	let EX=ObjLaser_GetEndX(obj);
	let EY=ObjLaser_GetEndY(obj);
	let sep=40;
	
	ascent(i in 1..sep)
	{
		let ShotX=SX-(SX-EX)*i/sep;
		let ShotY=SY-(SY-EY)*i/sep;
		CreateShotA(0,ShotX,ShotY,10);
		if(gra==153)
		{
			SetShotDirectionType(PLAYER);
			SetShotDataA(0,0,0,0,0,0.05,2,gra-144);
			SetShotDirectionType(ABSOLUTE);
		}
		else
		{
		SetShotDataA(0,0,0,angle+90*(i%2*2-1),0,0.05,2,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 shotE
{
wait(30);
}

	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"
