
#Title[大妖精通常]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "大妖精";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_mokou.png"; 
    let imgFam  = csd ~ "..\img\familiar.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let Step2=false;
	let wIni=60;
let TimeCounter=60*60;
let StandardTimeCounter=TimeCounter;
let VanishLife=1000;
let ColorRed=255;
let ColorGreen=0;
let ColorBlue=0;
    @Initialize {
	SetCommonData("BossLastAttackColor",[255,100,0]);
	SetCommonData("BossLastAttack",true);
	SetShotAutoDeleteClip(4,4,4,4);
	LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
        SetTimer(TimeCounter/60);
        SetLife(4200);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
 LoadGraphic(GetCurrentScriptDirectory~"..\img\CircleEffect.png");
	InitializeAction();
	SetEnemyMarker(true);
        TMainGrobal;
    }

    @MainLoop {
	BulletNum=GetEnemyShotCount;
	TimeCounter-=1;
        yield;
    }

    @DrawLoop {
	DrawBoss( imgBoss );
    }

    @Finalize {
		if(!IsTimeOut)
		{
		SetCommonData("DeleteBulletNum",BulletNum);
		SetCommonData("DeleteBulletX",GetX);
		SetCommonData("DeleteBulletY",GetY);
		}

	SetCommonData("VanishSignal",false);
       DeleteGraphic(imgBoss);
	SetCommonData("TimeBonus",TimeCounter/StandardTimeCounter);
	SetCommonData("BossRate",20000);
    }

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

task Collision
{
	wait(90);

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

}

sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni,30,8);
	wait(90);
	Concentration01(30);
}

task shotM
{
	SetAction(ACT_SHOT_B,30);
	shot;
	wait(60);
	SetAction(ACT_SHOT_A,90);
	shot4;
	wait(240);
	SetAction(ACT_SHOT_A,6000);
	shot2;
	wait(120);
	shot3;

task shot4
{
let X=GetClipMinX+8;
let Y=GetCenterY;
loop(3)
{
	loop(15)
	{
		CreateShot01(X+rand(-8,8),Y+rand(-8,8),rand(1.5,3),90,9,10);
		CreateShot01(GetCenterX*2-X,Y,rand(1.5,3),90,9,10);
	Y-=2;
	X+=26;
	wait(1);
	}
	loop(15)
	{
		CreateShot01(X+rand(-8,8),Y+rand(-8,8),rand(1.5,3),90,9,10);
		CreateShot01(GetCenterX*2-X,Y,rand(1.5,3),90,9,10);
	Y-=2;
	X-=26;
	wait(1);
	}
}


}

task shot3
{
let angle=atan2(GetClipMaxY-GetY,GetClipMaxX-GetX);

loop
{
	angle=atan2(GetClipMaxY-GetY,GetClipMaxX-GetX);

	CreateLaserA(0,GetX,GetY,400,6,9,30);
	SetLaserDataA(0,0,angle,0,0,0,0);
	SetLaserDataA(0,30,angle,-1.5,0,0,0);
	SetShotKillTime(0,90);
	FireShot(0);
	ShotExp(GetClipMaxX);
	wait(300);

	angle=atan2(GetClipMaxY-GetY,GetClipMinX-GetX);
	CreateLaserA(0,GetX,GetY,400,6,9,30);
	SetLaserDataA(0,0,angle,0,0,0,0);
	SetLaserDataA(0,30,angle,+1.5,0,0,0);
	SetShotKillTime(0,90);
	FireShot(0);
	ShotExp(GetClipMinX);
	wait(300);	
}

}

task ShotExp(let X)
{
	wait(30);
	let Y=GetClipMaxY;
	let angle=atan2(GetPlayerY-Y,GetPlayerX-X);
	loop(10)
	{
		angle=atan2(GetPlayerY-Y,GetPlayerX-X);
		ascent(let i in 0..12)
		{
			CreateShot01(X,Y,3,angle+i*30,9,5);
		}
		Y-=320/8;
		wait(5);
	}
}

task shot2
{
let waittime=60;
let count=0;
loop
{
	ascent(let i in 0..24)
	{
	ascent(let j in 1..5)
	{
		CreateShot01(GetX,GetY,1+0.5*j,GetAngleToPlayer+15*i,41,5);
	}
	}
	wait(waittime);
	if(count==5)
	{
	waittime=30;
	}
	count+=1;
}

}

task shot
{
let X=GetX+75;
let X2=GetX-75;
let Y=GetY-20;
let angle1;
let angle2;
let anglecicle=0;
loop
{
	angle1=atan2(GetPlayerY-Y,GetPlayerX-X)+5*cos(anglecicle);
	angle2=atan2(GetPlayerY-Y,GetPlayerX-X2)+5*cos(180+anglecicle);
	if(!OnBomb)
	{
	ascent(let i in 0..5)
	{
		CreateShot01(X,Y,15,angle1+i*72+36,46,5);
		CreateShot01(X2,Y,15,angle2+i*72+36,46,5);
	}
	}
	anglecicle+=6;
	wait(1);
}
}


}
///////////////////////////////////////////////////////
task shotE
{
let waittime=5;
	SetAction(ACT_SHOT_B,30);
	shot;
	wait(60);
	SetAction(ACT_SHOT_A,180);
	summon;
	wait(300);
	SetAction(ACT_SHOT_A,6000);
	shot3;

task shot
{
let X=GetX+75;
let X2=GetX-75;
let Y=GetY-20;
let angle1;
let angle2;
let anglecicle=0;
loop
{
	angle1=atan2(GetPlayerY-Y,GetPlayerX-X)+5*cos(anglecicle);
	angle2=atan2(GetPlayerY-Y,GetPlayerX-X2)+5*cos(180+anglecicle);
	if(!OnBomb)
	{
	ascent(let i in 0..5)
	{
		CreateShot01(X,Y,15,angle1+i*72+36,46,5);
		CreateShot01(X2,Y,15,angle2+i*72+36,46,5);
	}
	}
	anglecicle+=6;
	wait(1);
}
}

task shot3
{
let angle=atan2(GetClipMaxY-GetY,GetClipMaxX-GetX);

loop
{
	angle=atan2(GetClipMaxY-GetY,GetClipMaxX-GetX);

	CreateLaserA(0,GetX,GetY,400,6,9,30);
	SetLaserDataA(0,0,angle,0,0,0,0);
	SetLaserDataA(0,30,angle,-2,5,0,0);
	SetShotKillTime(0,180);
	FireShot(0);
	ShotExp(GetClipMaxX);
	wait(195);

	angle=atan2(GetClipMaxY-GetY,GetClipMinX-GetX);
	CreateLaserA(0,GetX,GetY,400,6,9,30);
	SetLaserDataA(0,0,angle,0,0,0,0);
	SetLaserDataA(0,30,angle,+2,5,0,0);
	SetShotKillTime(0,180);
	FireShot(0);
	ShotExp(GetClipMinX);
	wait(195);
	if(waittime>3)
	{
	waittime-=1;	
	}
}

}

task ShotExp(let X)
{
	let dir=1;
	if(X==GetClipMinX)
	{
		dir=-1;
	}
	wait(30);
	let Y=GetClipMaxY;
	let angle=atan2(GetPlayerY-Y,GetPlayerX-X);
	loop(60/waittime)
	{
		angle=atan2(GetPlayerY-Y,GetPlayerX-X);
		ascent(let i in 0..12)
		{
			CreateShot01(X,Y,3,angle+i*30,9,5);
		}
		CreateShot01(X,Y,rand(1,1.5),rand(175,185),33,5);
		CreateShot01(X,Y+20,rand(1,1.5),rand(170,190),33,5);
		Y-=(GetClipMaxY-GetClipMinY)/(60/waittime);
		wait(waittime);
	}
	loop(60/waittime)
	{
		angle=atan2(GetPlayerY-Y,GetPlayerX-X);
		ascent(let i in 0..12)
		{
			CreateShot01(X,Y,3,angle+i*30,9,5);
		}
		CreateShot01(X,Y,rand(1,1.5),rand(85,95),33,5);
		CreateShot01(X+20,Y,rand(1,1.5),rand(80,100),33,5);
		X-=(GetClipMaxX-GetClipMinX)/(60/waittime)*dir;
		wait(waittime);
	}
	loop(60/waittime)
	{
		angle=atan2(GetPlayerY-Y,GetPlayerX-X);
		ascent(let i in 0..12)
		{
			CreateShot01(X,Y,3,angle+i*30,9,5);
		}
		CreateShot01(X,Y,rand(1,1.5),rand(-5,5),33,5);
		CreateShot01(X,Y+20,rand(1,1.5),rand(-10,10),33,5);
		Y+=(GetClipMaxY-GetClipMinY)/(60/waittime);
		wait(waittime);
	}
}

task shot2
{
let X=GetX+65;
let X2=GetX-65;
let Y=GetY-25;
let angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..6)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..8)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..10)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=GetAngleToPlayer+rand(-5,5);
	ascent(let i in -12..12)
	{
		ascent(let j in -6..15)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
}

task summon
{
loop(3)
{
        CreateEnemyFromScript("Familiar", GetX+80*cos(GetAngleToPlayer+90), GetY+80*sin(GetAngleToPlayer+90),
                              0, GetAngleToPlayer, 1);
        CreateEnemyFromScript("Familiar", GetX-80*cos(GetAngleToPlayer+90), GetY-80*sin(GetAngleToPlayer+90),
                              0, GetAngleToPlayer, -1);

        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, GetAngleToPlayer, -1);
wait(60);
}
}

}
/////////////////////////////////////////////////////////////////
task shotA
{
	SetAction(ACT_SHOT_B,30);
	shot;
	wait(60);
	SetAction(ACT_SHOT_A,180);
	shot2;
	wait(210);
	SetAction(ACT_SHOT_A,6000);
	summon;
	wait(180);
	shot3;

task shot3
{
	shot4(1);
	wait(10);
	shot4(2);
	wait(10);
	shot4(3);
	wait(10);
	shot4(4);
	wait(10);
	shot4(5);
}

task shot4(num)
{
	loop
	{
		CreateShot01(rand(GetClipMinX+((GetClipMaxX-GetClipMinX)*(num-1))/5,GetClipMinX+(GetClipMaxX-GetClipMinX)*num/5),GetClipMinY,rand(1,2.5),rand(88,92),9,5);
		wait(5);
	}
}

task shot
{
let X=GetX+75;
let X2=GetX-75;
let Y=GetY-20;
let angle1;
let angle2;
let anglecicle=0;
loop
{
	angle1=atan2(GetPlayerY-Y,GetPlayerX-X)+5*cos(anglecicle);
	angle2=atan2(GetPlayerY-Y,GetPlayerX-X2)+5*cos(180+anglecicle);
	if(!OnBomb)
	{
	ascent(let i in 0..5)
	{
		CreateShot01(X,Y,15,angle1+i*72+36,46,5);
		CreateShot01(X2,Y,15,angle2+i*72+36,46,5);
	}
	}
	anglecicle+=6;
	wait(1);
}
}

task shot2
{
let X=GetX+65;
let X2=GetX-65;
let Y=GetY-25;
	let angle=atan2(GetPlayerY-Y,GetPlayerX-X)+rand(-5,5);
	ascent(let i in -10..10)
	{
		ascent(let j in -6..6)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=atan2(GetPlayerY-Y,GetPlayerX-X2)+rand(-5,5);
	ascent(let i in -10..10)
	{
		ascent(let j in -6..8)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=atan2(GetPlayerY-Y,GetPlayerX-X)+rand(-5,5);
	ascent(let i in -10..10)
	{
		ascent(let j in -6..10)
		{
			CreateShot01(X,Y,3+0.25*j,angle+i*5,9,5);
		}
	wait(1);
	}
	wait(30);
	angle=atan2(GetPlayerY-Y,GetPlayerX-X2)+rand(-5,5);
	ascent(let i in -10..10)
	{
		ascent(let j in -6..15)
		{
			CreateShot01(X2,Y,3+0.25*j,angle-i*5,9,5);
		}
	wait(1);
	}
}

task summon
{
loop
{
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 0);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 1);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 2);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 3);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 4);
wait(300);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 0.5);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 1.5);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 2.5);
	wait(10);
        CreateEnemyFromScript("Familiar2", GetX, GetY,
                              0, GetAngleToPlayer, 3.5);
wait(300);
}
}

}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////
	task Wing{
		let lifetime=30;
		let speed=5.5;
		if(GetCommonDataDefault("LightMode",0)==1){lifetime=15;speed=11;}
		let angle=-90;
		loop{
			ascent(j in 0..120){
				WingPart(GetX,GetY,angle+70+5*sin(3*j),lifetime,speed);
				WingPart(GetX,GetY,angle-70-5*sin(3*j),lifetime,speed);

				WingPart(GetX,GetY,angle+90+5*sin(3*j),lifetime*3/4,speed);
				WingPart(GetX,GetY,angle-90-5*sin(3*j),lifetime*3/4,speed);

				WingPart(GetX+20*cos(angle),GetY+20*sin(angle),angle+70+5*sin(3*j),lifetime*5/4,speed);
				WingPart(GetX+20*cos(angle),GetY+20*sin(angle),angle-70-5*sin(3*j),lifetime*5/4,speed);

				WingPart(GetX,GetY,angle+105+5*sin(3*j),lifetime/2,speed);
				WingPart(GetX,GetY,angle-105-5*sin(3*j),lifetime/2,speed);

				WingPart(GetX,GetY,angle+165-1*sin(6*j),lifetime*5/12,speed);
				WingPart(GetX,GetY,angle+180-1*sin(6*j),lifetime/2,speed);
				WingPart(GetX,GetY,angle-165-1*sin(6*j),lifetime*5/12,speed);

			//	HeadPart(GetX,GetY,angle-1*sin(6*j),lifetime*2,speed/2);
				yield;
				}
			}
		}

	task WingPart(let x,let y,let angle,let lifetime,let speed){
		function randrect
		{
			return(rand(-3,3));
		}
		let WingUV=[0,0,48,48];
		let WingXY=[-24+randrect,-24+randrect,24+randrect,24+randrect];
		let obj= Obj_Create(OBJ_EFFECT);
		let scale=0.5;
		let r=0;
		Obj_SetX(obj, x+r*cos(angle));
		Obj_SetY(obj, y+r*sin(angle));
        	ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, scale,scale);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0,WingXY[0],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 1,WingXY[0],WingXY[3]);
		ObjEffect_SetVertexXY(obj, 2,WingXY[2],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 3,WingXY[2],WingXY[3]);
		
		ObjEffect_SetVertexUV(obj, 0, WingUV[0],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 1, WingUV[0],WingUV[3]);
		ObjEffect_SetVertexUV(obj, 2, WingUV[2],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 3, WingUV[2],WingUV[3]);

		let Alpha=255;

		ObjEffect_SetLayer(obj,1);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		loop(lifetime){
			r+=speed;
			scale-=0.5/lifetime;
			Alpha-=255/lifetime;
			ObjEffect_SetScale(obj, scale,scale);		
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,0,0);
			}
   			yield;
			if(GetEnemyLife==0){break;}
			}
		Obj_Delete(obj);
		}


	task HeadPart(let x,let y,let angle,let lifetime,let speed){
		function randrect
		{
			return(rand(-3,3));
		}
		let WingUV=[0,0,48,48];
		let WingXY=[-24+randrect,-24+randrect,24+randrect,24+randrect];
		let obj= Obj_Create(OBJ_EFFECT);
		let scale=0.5;
		let r=0;
		Obj_SetX(obj, x+r*cos(angle));
		Obj_SetY(obj, y+r*sin(angle));
        	ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, scale,scale);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0,WingXY[0],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 1,WingXY[0],WingXY[3]);
		ObjEffect_SetVertexXY(obj, 2,WingXY[2],WingXY[1]);
		ObjEffect_SetVertexXY(obj, 3,WingXY[2],WingXY[3]);
		
		ObjEffect_SetVertexUV(obj, 0, WingUV[0],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 1, WingUV[0],WingUV[3]);
		ObjEffect_SetVertexUV(obj, 2, WingUV[2],WingUV[1]);
		ObjEffect_SetVertexUV(obj, 3, WingUV[2],WingUV[3]);

		let Alpha=255;

		ObjEffect_SetLayer(obj,1);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		loop(lifetime){
			r+=speed;
			scale-=0.25/lifetime;
			Alpha-=255/lifetime;
			ObjEffect_SetScale(obj, scale,scale);		
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,0,0);
			}
   			yield;
			if(GetEnemyLife==0){break;}
			}
		Obj_Delete(obj);
		}


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


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

    @MainLoop {
        SetCollisionA(GetX, GetY, 48);
        SetCollisionB(GetX, GetY, 8);
        yield;
    }

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

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

    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 angle=GetAngle;
	let speed=GetSpeed;

	SetAngle(angle);
	loop(180)
	{
	SetSpeed(speed);
	speed+=0.1;
	yield;
	}

	VanishEnemy;

}
/////////////////////////////////////////////////////////
task shotE
{
wait(5);
loop
{
	let angle=rand(0,360);
	CreateShotA(0,GetX,GetY,10);
	SetShotDataA(0,0,0,angle,0,0.01,2,9);
	FireShot(0);
	wait(3);
}
}
////////////////////////////////////////////////////////////

    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#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(350);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

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

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

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

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

task move
{
	let X=GetClipMinX+16+(GetClipMaxX+48-GetClipMinX)*num/5;
	let Y=GetClipMaxY+32;

	SetMovePosition03(X, Y,15,6);
	wait(270);
	VanishEnemy;

}

/////////////////////////////////////////////////////////
task shotA
{
wait(90);
Laser;
wait(30);
LaserShot;
}

task LaserShot
{
	loop(12)
	{
	WaveShot(GetX,GetY-32,8,-90,25,10,0,225,5);
	WaveShot(GetX,GetY-32,8,-90,25,10,180,225,5);
	wait(5);
	}
}

task WaveShot(let x, let y, let speed, let angle,
            let amp, let om, let arg, let graphic, let delay) {
    
    let t = 0;
    let px = speed*t;
    let py = amp*sin(om*t + arg);
    let a = amp*om*3.1415926/(180*speed);
    
    //オブジェクト弾の作成
    let obj = Obj_Create(OBJ_SHOT);
    
    //パラメータの設定
    Obj_SetPosition(obj, x + px*cos(angle) - py*sin(angle),
                             y + px*sin(angle) + py*cos(angle));
    Obj_SetSpeed(obj, 0);
    Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
    ObjShot_SetGraphic(obj, graphic);
    ObjShot_SetDelay(obj, delay);
	ObjShot_SetBombResist(obj, true);
    loop(delay){ yield; }
	
    while(!Obj_BeDeleted(obj))
    {
        //(px,py)座標での弾の位置を計算
        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));
        //弾の方向にもangleを足す
        Obj_SetAngle(obj, angle + atan(a*cos(om*t + arg)));
        
        t++;
        yield;
    }
}   

task Laser
{
	let length=500;
	let width=80;
	let angle=-90;
        let obj = Obj_Create(OBJ_LASER);
      	ObjLaser_SetSource(obj, false);
        Obj_SetPosition(obj, GetX, GetY);
        ObjLaser_SetLength(obj, length);
        ObjLaser_SetWidth(obj, width);
        Obj_SetAngle(obj,angle);
        ObjShot_SetBombResist(obj, true);
        ObjShot_SetGraphic(obj,153);
	Obj_SetAutoDelete(obj,false);
	ObjShot_SetDelay(obj, 30);
      //  Obj_SetCollisionToPlayer(obj, false);
	loop(30)
	{
		Obj_SetPosition(obj, GetX, GetY);
		yield;
	}
	wait(120);
	loop(30)
	{
		ObjLaser_SetWidth(obj, width);
		width-=80/30;
		yield;
	}
	Obj_Delete(obj);
}

task FamiliarEffect(R,G,B,frame)
{
	//FamiliarEffect0(R,G,B);
loop(frame)
{
	FamiliarEffect1(R,G,B);
yield;
}
}

task FamiliarEffect0(R,G,B)
{
		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=100;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -24, -24);
		ObjEffect_SetVertexXY(obj, 1,  24, -24);
		ObjEffect_SetVertexXY(obj, 2,  24,  24);
		ObjEffect_SetVertexXY(obj, 3, -24,  24);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);

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

		ObjEffect_SetScale(obj, scax,scay);
		loop
		{
		Obj_SetPosition(obj,GetX,GetY);
			yield;
		}
}


task FamiliarEffect1(R,G,B)
{
		let randrect=5;
		let scax=1.0;
		let scay=1.0;
		let angle=0;
		let Xangle=-90;
		let Yangle=-90;	
		let Zangle=0;
		let RotateAngle=3;
		let alpha=50;
  		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory~"..\img\CircleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -24+rand(-randrect,randrect), -24+rand(-randrect,randrect));
		ObjEffect_SetVertexXY(obj, 1,  24+rand(-randrect,randrect), -24+rand(-randrect,randrect));
		ObjEffect_SetVertexXY(obj, 2,  24+rand(-randrect,randrect),  24+rand(-randrect,randrect));
		ObjEffect_SetVertexXY(obj, 3, -24+rand(-randrect,randrect),  24+rand(-randrect,randrect));
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  48, 0);
		ObjEffect_SetVertexUV(obj, 2, 48,  48);
		ObjEffect_SetVertexUV(obj, 3, 0, 48);


		Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetScale(obj, scax,scay);
		Obj_SetSpeed(obj,1);
		Obj_SetAngle(obj,-90);
		loop(5)
		{
			ascent(let i in 0..4)
			{
			ObjEffect_SetVertexColor(obj,i,alpha,R,G,B);
			}
			ObjEffect_SetScale(obj, scax,scay);
			scax+=0.3/10;
			scay+=0.3/10;
			alpha-=50/10;
			yield;
		}
		Obj_Delete(obj);
}
////////////////////////////////////////////////////////////

    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}

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