
#Title[ぬえ１]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_nue.png"; 
    let imgUFG  = csd ~ "..\img\UFG.png";
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 144;
	let Step2=false;
	let wIni=60;
let TimeCounter=76*60;
let StandardTimeCounter=TimeCounter;
    @Initialize {
	if(GetCommonDataDefault("ExclusiveBoss",false)==true)
	{
		BossTimer(TimeCounter);
	}
	else
	{
		SetTimer(TimeCounter/60);
	}
	SetCommonData("UNKNOWN",true);
	//SetShotAutoDeleteClip(16,16,16,16);
        SetLife(3600);
	InitializeAction();
	SetEnemyMarker(true);
	SetX(GetClipMaxX+60);
	SetY(GetCenterY-0);
        TMainGrobal;
    }

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

    @DrawLoop {
	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",250000);
    }

    // メインタスク
task TMainGrobal
{
	yield;
	GetDamege;
	OutDamageRateZero;
	Collision;
	//Lissajous(148,0,211);
	BossShadowAnimation(imgBoss2,180,148,0,211);
	standBy;
	shotALL;
}

sub standBy//初期位置へ
{
	Appearance;
	TMove;
	//SetMovePositionHermite(xIni, GetCenterY-20,50,225,350,0,150);
	//SetAction(ACT_MOVE, 60);
	//SetMovePosition03(xIni, GetCenterY-20, 20,5);
	SetInvincibility(wIni);
	wait(180);
	//Lissajous(148,0,211);
	Concentration01(30);
	wait(30);
}

task Collision
{
	wait(150);
	SetCommonData("UNKNOWN",false);
	loop
	{
        SetCollisionA(GetX, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 16);
	yield;
	}
}

task TMove
{
let CX=GetCenterX;
let CY=GetCenterY+10;
let R1=240;
let R2=30;
let angle=0;
loop(90)
{
	SetX(CX+R1*cos(angle));
	SetY(CY+R2*sin(angle));
	angle+=180/90;
	yield;
}
loop(60)
{
	SetX(CX+R1*cos(angle));
	SetY(CY+R2*sin(angle));
	angle+=90/60;
	yield;
}
	SetX(CX+R1*cos(angle));
	SetY(CY+R2*sin(angle));
}

task Appearance
{
AppearanceEffect1;
loop(90)
{
	//AppearanceEffect2(GetX,GetY);
yield;
}
}


task AppearanceEffect1
{
		let scale=1;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgUFG);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,64,  -64);
		ObjEffect_SetVertexXY(obj, 2,64, 64);
		ObjEffect_SetVertexXY(obj, 3,  -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  384,  256);
		ObjEffect_SetVertexUV(obj, 1,  512, 256);
		ObjEffect_SetVertexUV(obj, 2, 512, 384);
		ObjEffect_SetVertexUV(obj, 3, 384, 384);

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

		ObjEffect_SetVertexColor(obj,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,3,Alpha,R,G,B);

		ObjEffect_SetLayer(obj,3);
		Obj_SetPosition(obj,GetX,GetY);
		
		ObjEffect_SetScale(obj, scale,scale);
		let ZAngle;
		loop(150)
		{
			ZAngle=rand(0,360);
			AppearanceEffect2(GetX,GetY,ZAngle,scale);
			Obj_SetPosition(obj,GetX,GetY);
			ObjEffect_SetAngle(obj,0,0,ZAngle);
			yield;
		}
		loop(30)
		{
			ZAngle=rand(0,360);
			AppearanceEffect2(GetX,GetY,ZAngle,scale);
			Obj_SetPosition(obj,GetX,GetY);
			scale-=1/30;
			ObjEffect_SetScale(obj, scale,scale);
			ObjEffect_SetAngle(obj,0,0,ZAngle);
			yield;
		}
		Obj_Delete(obj);
}

task AppearanceEffect2(x,y,ZAngle,scale)
{
		let Sscale=scale;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgUFG);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		//ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64+rand(-5,5), -64+rand(-5,5));
		ObjEffect_SetVertexXY(obj, 1,64+rand(-5,5),  -64+rand(-5,5));
		ObjEffect_SetVertexXY(obj, 2,64+rand(-5,5), 64+rand(-5,5));
		ObjEffect_SetVertexXY(obj, 3,  -64+rand(-5,5),  64+rand(-5,5));
		
		ObjEffect_SetVertexUV(obj, 0,  384,  256);
		ObjEffect_SetVertexUV(obj, 1,  512, 256);
		ObjEffect_SetVertexUV(obj, 2, 512, 384);
		ObjEffect_SetVertexUV(obj, 3, 384, 384);

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

		ascent(i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetLayer(obj,2);
		Obj_SetPosition(obj,x,y);
		
		ObjEffect_SetScale(obj, scale,scale);

		loop(10)
		{
			ObjEffect_SetAngle(obj,0,0,ZAngle);
			scale+=Sscale/100;
			ObjEffect_SetScale(obj, scale,scale);
			yield;
		}
		Obj_Delete(obj);
}

task shotALL
{
SpellDraw(12,6000);
loop
{
SetAction(ACT_SHOT_A, 300);
summon1;
wait(300);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni, yIni, 20,5);
wait(120);
SetAction(ACT_SHOT_A, 480);
summon2;
wait(420);
wait(60);
SetAction(ACT_SHOT_A, 120);
summon3;
wait(120);
SetAction(ACT_MOVE, 60);
let movedir=rand_int(0,1)*2-1;
SetMovePosition03(xIni-120*movedir, yIni, 20,5);
wait(240);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni+120*movedir, yIni, 20,5);
wait(180);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni, yIni, 20,5);
wait(120);
SetAction(ACT_SHOT_A, 600);
summon4;
wait(600);
SetAction(ACT_MOVE, 60);
SetMovePosition03(xIni, GetCenterY-20, 20,5);
wait(180);
}


task summon1
{
	let dir=rand_int(0,1)*2-1;
	let angle=rand(0,360);
	ascent(i in 0..8)
	{
        CreateEnemyFromScript("Familiar1", GetX, GetY,
                              0, angle+i*45, dir);
	}
}

task summon2
{
	let dir=rand_int(0,1)*2-1;
	loop(6)
	{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                            1.5,  GetAngleToPlayer, dir);
	wait(60);
	}
}

task summon3
{
	let dir=rand_int(0,1)*2-1;
	ascent(i in 1..4)
	{
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                            1.5,  GetAngleToPlayer, i);
        CreateEnemyFromScript("Familiar3", GetX, GetY,
                            1.5,  GetAngleToPlayer, -i);
	}
	SetCommonData("GreenUFO",[1,1,1,0,1,1,1]);

	let UFOX=[GetCenterX-150,GetCenterX-90,GetCenterX-30,0,GetCenterX+30,GetCenterX+90,GetCenterX+150];
	let UFOY=GetClipMinY+60;
	wait(210);

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

	task shotM
	{
		ascent(i in 0..7)
		{
		let angle=atan2(GetPlayerY-UFOY,GetPlayerX-UFOX[i]);
		GreenLaser(i,UFOX[i],UFOY,angle,550,40,60,120,156);
		}
	}

	task shotE
	{
		ascent(i in 0..7)
		{
		GreenLaser(i,UFOX[i],UFOY,90,400,40,60,120,156);
		}
	}

	task shotA
	{
		ascent(i in 0..7)
		{
		let angle=90;
		ascent(j in -1..2)
		{
		GreenLaser(i,UFOX[i],UFOY,90+j*30,550,40,60,120,156);
		}
		}
	}

task GreenLaser(num,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;
	let TempArray=[];
	loop(delay)
	{
		EffectLaser(num,x,y,angle,length*lcount/30,width,0,1,gra);
		ObjLaser_SetLength(obj,length*lcount/30);
		if(lcount<30)
		{
		lcount+=1;
		}
		TempArray=GetCommonData("GreenUFO");
		if(TempArray[num]==0){break;}
	yield;
	}
	EffectLaser(num,x,y,angle,length,width,0,time-delay,gra);
	loop(time-delay)
	{
		TempArray=GetCommonData("GreenUFO");
		if(TempArray[num]==0){break;}
		yield;
	}
	Obj_SetCollisionToPlayer(obj,false);
	loop(30)
	{
		EffectLaser(num,x,y,angle,length,width*dcount/30,0,2,gra);
	ObjLaser_SetWidth(obj,width*dcount/30);
	dcount-=1;
	//	TempArray=GetCommonData("GreenUFO");
	//	if(TempArray[num]==0){break;}
	yield;
	}
	Obj_Delete(obj);
}

task EffectLaser(num,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);
	let TempArray=[];
	loop(time)
	{
	ObjLaser_SetWidth(obj,width*rand(0.5,1));
		TempArray=GetCommonData("GreenUFO");
		if(TempArray[num]==0){break;}
	yield;
	}
	Obj_Delete(obj);
}

}

task summon4
{
	let angle=rand(0,360);
	ascent(i in 1..4)
	{
        CreateEnemyFromScript("Familiar4", GetX, GetY,
                            1.5,  angle+120*i, i);
	}
}

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

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

}

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

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

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

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,10,0.3);
	if(GetCommonDataDefault("BossLife",0)>0)
	{
		FinalizeItemSet(3);
	}
        }

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

task move
{
	let X=0;
	let Y=0;
	let R=0;
	let angle=GetAngle;
	loop(270)
	{
		SetX(X+R*cos(angle));
		SetY(Y+R*sin(angle));
		R+=1.5;
		angle+=1*num;
		yield;
	}
	VanishEnemy;
}

task shotM
{
wait(12);
loop
{
	CreateShotA(0,GetX,GetY,5);
	SetShotDataA(0,0,0,0,0,0.00,4,9);
	SetShotDataA(0,60,0,GetAngleToPlayer,0,0.02,4,9);
	FireShot(0);
	wait(12);
}
}
/////////////////////////////////////////////////////////
task shotE
{
wait(12);
loop
{
	CreateShotA(0,GetX,GetY,5);
	SetShotDataA(0,0,0,0,0,0.00,4,9);
	SetShotDataA(0,60,0,GetAngleToPlayer,0,0.02,4,9);
	FireShot(0);
	wait(6);
	CreateShotA(0,GetX,GetY,5);
	SetShotDataA(0,0,0,0,0,0.00,4,17);
	SetShotDataA(0,60,0,atan2(GetPlayerY-GetEnemyY,GetPlayerX-GetEnemyX),0,0.02,4,17);
	FireShot(0);
	wait(6);
}
}
////////////////////////////////////////////////////////////
task shotA
{

wait(12);
shot2;
loop
{
	CreateShotA(0,GetX,GetY,5);
	SetShotDataA(0,0,0,0,0,0.00,4,25);
	SetShotDataA(0,60,0,GetAngleToPlayer,0,0.02,4,25);
	FireShot(0);
	wait(12);
}

task shot2
{
loop
{
	ascent(let i in 0..4)
	{
	CreateShotA(0,GetX,GetY,5);
	SetShotDataA(0,0,0,0,0,0.00,4,9);
	SetShotDataA(0,60,0,i*90,0,0.01,4,9);
	FireShot(0);		
	}
wait(24);
}
}

}

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

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

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

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,11,0.3);
	if(!BeVanished)
	{
	//DeleteEnemyShot(CHILD);
	}
	if(GetCommonDataDefault("BossLife",0)>0)
	{
		FinalizeItemSet(3);
	}
        }

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

task move
{
	SetSpeed(GetSpeed);
	SetAngle(GetAngle);
	wait(300);
	VanishEnemy;
}

task shotM
{
wait(30);
let angle=GetAngle-180;
loop
{
	CreateLaser01(GetX,GetY,4,angle,120,5,14,5);
	wait(8);
	angle+=20*num;
}
}
/////////////////////////////////////////////////////////
task shotE
{
//BlueLaser;
wait(30);
let angle=GetAngle-180;
loop
{
	CreateLaser01(GetX,GetY,4,angle,120,5,246,5);
	wait(6);
	angle+=15*num;
}

	task BlueLaser
	{
		ascent(i in 0..4)
		{
		CrossLaser(i*90);
		}
	}

	task CrossLaser(angle)
	{
		CreateLaserB(0,0,12,14,0);
		SetLaserDataB(0,0,1,0,0,0,0,angle,1);
		SetLaserDataB(0,100,0,0,0,0,0,NULL,1);
		FireShot(0);
	}
}
////////////////////////////////////////////////////////////
task shotA
{
//BlueLaser;
wait(30);
let angle=GetAngle-180;
loop
{
	CreateLaser01(GetX,GetY,4,angle,120,5,246,5);
	CreateLaser01(GetX,GetY,4,angle+180,120,5,246,5);
	//CreateLaser01(GetX,GetY,4,angle-120,120,5,246,5);
	wait(8);
	angle+=15*num;
}
	task BlueLaser
	{
		ascent(i in 0..4)
		{
		CrossLaser(i*90);
		}
	}

	task CrossLaser(angle)
	{
		CreateLaserB(0,0,12,14,0);
		SetLaserDataB(0,0,1,0,0,0,0,angle,1);
		SetLaserDataB(0,100,0,0,0,0,0,NULL,1);
		FireShot(0);
	}
}

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

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

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

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	let TempArray=GetCommonData("GreenUFO");
	TempArray[num+3]=0;
	SetCommonData("GreenUFO",TempArray);
	MagicCircleBreak(GetX,GetY,12,0.3);
	if(!BeVanished)
	{
	//DeleteEnemyShot(CHILD);
	}
	if(GetCommonDataDefault("BossLife",0)>0)
	{
		FinalizeItemSet(3);
	}
        }

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

task move
{
	SetMovePosition03(GetCenterX+num*60-absolute(num)/num*30, GetClipMinY+60, 20,5);
	wait(600);
	SetMovePosition03(GetEnemyX, GetEnemyY, 20,5);
	wait(60);
	VanishEnemy;
}

task shotM
{
wait(90);
let angle=rand(0,360);
let dir=rand_int(0,1)*2-1;
GreenShot(dir);
wait(120);
//GreenLaser(GetX,GetY,GetAngleToPlayer,550,40,60,120,156);
wait(120);
wait(120);
//GreenLaser(GetX,GetY,GetAngleToPlayer,550,40,60,120,156);
wait(60);

task GreenShot(dir)
{
let angle=rand(0,360);
loop(36)
{
	ascent(i in 0..3)
	{
	CreateShot01(GetX,GetY,3,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.25,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.125,angle+120*i,44,5);
	}
	wait(15);
	angle+=10*dir;
}
}

}
/////////////////////////////////////////////////////////
task shotE
{
wait(90);
let angle=rand(0,360);
GreenShot(1);
GreenShot2;
wait(120);
//GreenLaser(GetX,GetY,90,400,40,60,120,156);
wait(120);
wait(120);
//GreenLaser(GetX,GetY,90,400,40,60,120,156);
FireShot(0);
wait(60);

task GreenShot(dir)
{
let angle=rand(0,360);
loop(36)
{
	ascent(i in 0..3)
	{
	CreateShot01(GetX,GetY,3,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.25,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.125,angle+120*i,44,5);
	}
	wait(15);
	angle+=15*dir;
}
}

task GreenShot2
{
loop(16)
{
	ascent(i in 0..3)
	{
	CreateShot01(GetX,GetY,3,GetAngleToPlayer+i*45,13,5);
	}
	wait(60);
}
}

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

wait(90);
let angle=rand(0,360);
GreenShot(1);
wait(120);
ascent(i in -1..2)
{
//GreenLaser(GetX,GetY,90+i*30,550,40,60,120,156);
}

wait(120);
wait(120);
ascent(i in -1..2)
{
//GreenLaser(GetX,GetY,90+i*30,550,40,60,120,156);
}

wait(60);

task GreenShot(dir)
{
let angle=rand(0,360);
loop(36)
{
	ascent(i in 0..3)
	{
	CreateShot01(GetX,GetY,3,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.25,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.125,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.375,angle+120*i,44,5);
	CreateShot01(GetX,GetY,3.5,angle+120*i,44,5);
	}
	wait(15);
	angle+=15*dir;
}
}

}

task GreenLaser(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;
	}
	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);
}

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

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

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

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	MagicCircleBreak(GetX,GetY,14,0.3);
	if(GetCommonDataDefault("BossLife",0)>0)
	{
		FinalizeItemSet(5);
	}
        }

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	RainbowZakoEffect;
    }

task move
{
	let X=0;
	let Y=0;
	let R=0;
	let angle=GetAngle;
	loop(540)
	{
		SetX(X+R*cos(angle));
		SetY(Y+R*sin(angle));
		if(R<100)
		{
		R+=100/60;
		}
		angle+=1*absolute(num)/num;
		yield;
	}
	loop(60)
	{
		SetX(X+R*cos(angle));
		SetY(Y+R*sin(angle));
		R-=100/60;
		angle+=1*absolute(num)/num;
		yield;
	}
	VanishEnemy;
}

task shotM
{
wait(60);
let angle=rand(0,360);
loop
{
	CreateShot02(GetX,GetY,1,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1,180-angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,2,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,2,180-angle,0.02,5,43,5);
	wait(5);
	angle+=10;
}
}
/////////////////////////////////////////////////////////
task shotE
{
wait(60);
let angle=rand(0,360);
loop
{
	CreateShot02(GetX,GetY,1,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1,180-angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,2,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,2,180-angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1.5,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1.5,180-angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1.25,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1.25,180-angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1.75,angle,0.02,5,43,5);
	CreateShot02(GetX,GetY,1.75,180-angle,0.02,5,43,5);
	wait(5);
	angle+=10;
}
}
////////////////////////////////////////////////////////////
task shotA
{
wait(60);
let angle=0;
let anglePlus=0;
loop
{
	ascent(let i in 0..6)
	{
	CreateShot02(GetX,GetY,1.25,angle+i*45,0.02,5,43,5);
	}
	wait(4);
	angle+=anglePlus;
	anglePlus+=1;
}
}

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

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