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

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

    @DrawLoop {
//DrawText(GetCommonDataDefault("XXX",0),120,452,12,255);
//DrawText(GetCommonDataDefault("XXX2",0),120,402,12,255);
	DrawBoss( imgBoss );
    }

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

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

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

task Collision
{
	SetCommonData("NoCollision",true);
	wait(90);
	SetCommonData("NoCollision",false);

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

}

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

task shotM
{
//wait(15);
SetAction(ACT_SHOT_A, 375);
DamageRate=80;
shot;
wait(465);
Concentration01(30);
wait(30);
SetAction(ACT_SHOT_A, 240);
DamageRate=100;
loop(3)
{
Snake(GetX,GetY,4.5,GetAngleToPlayer,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+120,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-120,60,12,9,5,0,5);
wait(90);
}
wait(120);
DamageRate=120;
MoveAndShot;
wait(540);
SetAction(ACT_SHOT_A, 375);
DamageRate=80;
shot2;
wait(465);
Concentration01(30);
wait(30);
SetAction(ACT_SHOT_A, 240);
DamageRate=100;
loop(3)
{
Snake(GetX,GetY,4.5,GetAngleToPlayer,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+120,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-120,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+60,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-60,60,12,9,5,0,5);
wait(90);
}
wait(120);
DamageRate=80;
MoveAndShot2;


task MoveAndShot
{
	let dir=rand_int(0,1)*2-1;
	FallShot;
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX+140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	task FallShot
	{
		loop(120)
		{
		let type=rand_int(0,2);
		let color;
		alternative(type)
		case(0){color=9;}
		case(1){color=25;}
		case(2){color=165;}
		CreateShot01(GetX+rand(-50,50),GetClipMinY,rand(3,4),rand(88,92),color,10);
		wait(4);
		}
	}
}

task MoveAndShot2
{
	let dir=rand_int(0,1)*2-1;
	FallShot;
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX+140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	task FallShot
	{
		loop(240)
		{
		let type=rand_int(0,2);
		let color;
		alternative(type)
		case(0){color=9;}
		case(1){color=25;}
		case(2){color=165;}
		CreateShot01(GetX+rand(-50,50),GetClipMinY,rand(3,4),rand(80,90),color,10);
		wait(2);
		}
	}
}

task shot
{

	ascent(i in -4..5)
	{
	Laser(GetCenterX+i*76.5,GetClipMinY,90);
	}
	wait(270);
	ascent(i in -4..5)
	{
	Laser2(GetCenterX+i*76.5+38.25,GetClipMinY,90);
	}

}

task shot2
{
	ascent(i in -8..9)
	{
	Laser(GetCenterX+i*38.25,GetClipMinY,90);
	}
	wait(270);
	ascent(i in -8..9)
	{
	Laser2(GetCenterX+i*38.25,GetClipMinY,90);
	}
}

task Laser(x,y,angle)
{
	let length=500;
	let width=30;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,153);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,30);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,45);
	//Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	let count=0;
	EffectLaser(x,y,angle,length,width,45,90);
	loop(45)
	{
	EffectLaser(x,y,angle,length,width,0,1);
	yield;
	}
	loop(45)
	{
		yield;
	}
	ascent(i in 0..20)
	{
		LaserShot(x,i*24,0);
		LaserShot(x,i*24+12,180);
	}
	Obj_Delete(obj);
}


task LaserShot(x,y,angle)
{
	let speed=0;
	//let angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		//Obj_SetAlpha(obj,0);
		//Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		let SpeedAngle=0;
		loop(180)
		{//114(180*2/3.14)移動
			Obj_SetSpeed(obj, speed);
			speed=sin(SpeedAngle);
			SpeedAngle+=180/180;
			yield;
		}
		Obj_SetSpeed(obj, 0);
		Obj_Delete(obj);
}

task Laser2(x,y,angle)
{
	let length=500;
	let width=30;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,153);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,30);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,0);
	//Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	let count=0;
	EffectLaser(x,y,angle,length,width,0,45);
	loop(45)
	{
		yield;
	}
	let angle=rand(0,360);
	ascent(i in 0..20)
	{
		LaserShot2(x,i*24, angle+i*30);
		LaserShot2(x,i*24+12, angle+i*30+15);
	}
	Obj_Delete(obj);
}

task LaserShot2(x,y,angle)
{
	let speed=0;
	//let angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		//Obj_SetAutoDelete(obj,false);
		//Obj_SetAlpha(obj,0);
		//Obj_SetCollisionToPlayer(obj,false);
		let SpeedAngle=0;
		loop
		{
			Obj_SetSpeed(obj, speed);
			if(speed<2)
			{
			speed+=0.01;
			}
			yield;
		}
		Obj_SetSpeed(obj, 0);
		Obj_Delete(obj);
}

task Snake(x,y,v,angle,length,width,color,delay,id,spin)
{
         let snake = Obj_Create(OBJ_SINUATE_LASER);
         Obj_SetX(snake,x);
         Obj_SetY(snake,y);
         Obj_SetSpeed(snake,v);
         Obj_SetAngle(snake,angle-spin*spin*2);
         ObjShot_SetBombResist(snake,true);
         ObjShot_SetDelay(snake,delay);
         ObjShot_SetGraphic(snake,168);
         //ObjSinuateLaser_SetLength(snake,length);
         ObjSinuateLaser_SetLength(snake,45);
         ObjSinuateLaser_SetWidth(snake,width);
	Angle;
	SnakeShot;
        task Angle
	{
		if(id == 0)
		{
		loop(240)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		Obj_Delete(snake);
		}
		else if(id == 1)
		{
		loop(2)
		{
			loop(10)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(2);
			}
			loop(10)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(2);
			}
		}
		loop(60)
		{
			Obj_SetAngle(snake,Obj_GetAngle(snake)-6);
			wait(1);
		}
		loop(240)
		{
			loop(10)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(2);
			}
			loop(10)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(2);
			}
		}
		Obj_Delete(snake);
	}
        }  

	task SnakeShot
	{
		loop
		{		
			SnakeShotBullet(Obj_GetX(snake),Obj_GetY(snake),Obj_GetAngle(snake)+180);
			wait(2);
		}
	}

	task SnakeShotBullet(x,y, angle)
	{
	wait(30);
	CreateShot02(x,y,0,angle,0.015,9,12,5);
	}

}

}
///////////////////////////////////////////////////////
task shotE
{
//wait(15);
SetAction(ACT_SHOT_A, 375);
DamageRate=80;
shot;
wait(465);
Concentration01(30);
wait(30);
SetAction(ACT_SHOT_A, 240);
DamageRate=100;
loop(2)
{
Snake(GetX,GetY,4.5,GetAngleToPlayer,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+120,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-120,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+60,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-60,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+180,60,12,9,5,1,5);
wait(135);
}
wait(120);
DamageRate=120;
MoveAndShot;
wait(540);
SetAction(ACT_SHOT_A, 420);
DamageRate=80;
shot2;
wait(510);
Concentration01(30);
wait(30);
SetAction(ACT_SHOT_A, 240);
DamageRate=100;
loop(2)
{
Snake(GetX,GetY,4.5,GetAngleToPlayer,60,12,9,5,0,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+30,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+150,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-150,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer+90,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-90,60,12,9,5,1,5);
Snake(GetX,GetY,4.5,GetAngleToPlayer-30,60,12,9,5,1,5);
wait(135);
}
wait(120);
DamageRate=80;
MoveAndShot2;


task MoveAndShot
{
	let dir=rand_int(0,1)*2-1;
	FallShot;
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX+140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	task FallShot
	{
		loop(16)
		{
		CircleCentralShot(GetX+rand(-20,20),GetClipMinY,rand(1.5,2),rand(80,90));
		wait(30);
		}
	}

	task CircleCentralShot(x,y,speed,angle)
	{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);
		let CircleAngle=rand(0,360);

		ascent(i in 0..18)
		{
		CircleShot(obj,CircleAngle+i*20);
		}
		loop(480)
		{
			yield;
		}
		Obj_Delete(obj);	
	}

	task CircleShot(Cobj,Angle)
	{
		let R=100;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, Obj_GetX(Cobj)+R*cos(Angle),Obj_GetY(Cobj)+R*sin(Angle));
	//	Obj_SetSpeed(obj, speed);
	//	Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 121);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		while(!Obj_BeDeleted(Cobj))
		{
			Obj_SetPosition(obj, Obj_GetX(Cobj)+R*cos(Angle),Obj_GetY(Cobj)+R*sin(Angle));
			Angle+=0.5;
			yield;
		}
		Obj_Delete(obj);	
	}

}

task MoveAndShot2
{
	let dir=rand_int(0,1)*2-1;
	FallShot;
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX+140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	task FallShot
	{
		loop(16)
		{
		CircleCentralShot(GetX+rand(-20,20),GetClipMinY,rand(1.5,2),rand(80,90));
		wait(30);
		}
	}

	task CircleCentralShot(x,y,speed,angle)
	{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);
		let CircleAngle=rand(0,360);

		ascent(i in 0..18)
		{
		CircleShot(obj,CircleAngle+i*20);
		}
		loop(360)
		{
			yield;
		}
		Obj_Delete(obj);	
	}

	task CircleShot(Cobj,Angle)
	{
		let R=100;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, Obj_GetX(Cobj)+R*cos(Angle),Obj_GetY(Cobj)+R*sin(Angle));
	//	Obj_SetSpeed(obj, speed);
	//	Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 121);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		while(!Obj_BeDeleted(Cobj))
		{
			Obj_SetPosition(obj, Obj_GetX(Cobj)+R*cos(Angle),Obj_GetY(Cobj)+R*sin(Angle));
			Angle+=0.75;
			R+=0.1;
			yield;
		}
		Obj_Delete(obj);	
	}

}

task shot
{

	ascent(i in -4..5)
	{
	Laser(GetCenterX+i*76.5,GetClipMinY,90,0);
	}
	ascent(i in -4..5)
	{
	Laser(GetClipMinX,GetCenterY+i*76.5,0,1);
	}
	wait(270);
	ascent(i in -4..5)
	{
	Laser2(GetCenterX+i*76.5+38.25,GetClipMinY,90,0);
	Laser2(GetClipMinX,GetCenterY+i*76.5+38.25,0,1);
	}

}

task shot2
{
	ascent(i in -4..5)
	{
	Num2Laser(GetCenterX+i*76.5,GetClipMinY,90,0);
	}
	ascent(i in -4..5)
	{
	Num2Laser(GetClipMinX,GetCenterY+i*76.5,0,1);
	}
	wait(270);
	ascent(i in -4..5)
	{
	Num2Laser2(GetCenterX+i*76.5+38.25,GetClipMinY,90,0);
	Num2Laser2(GetClipMinX,GetCenterY+i*76.5+38.25,0,1);
	}
}

task Laser(x,y,angle,ShotId)
{
	let length=500;
	let width=30;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,153);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,30);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,45);
	//Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	let count=0;
	EffectLaser(x,y,angle,length,width,45,90);
	loop(45)
	{
	EffectLaser(x,y,angle,length,width,0,1);
	yield;
	}
	loop(45)
	{
		yield;
	}
	if(ShotId==0)
	{
	ascent(i in 0..20)
	{
		LaserShot(x,i*28,angle-90);
		LaserShot(x,i*28+14,angle+90);
	}
	}
	if(ShotId==1)
	{
	ascent(i in 0..20)
	{
		LaserShot(i*28,y,angle-90);
		LaserShot(i*28+14,y,angle+90);
	}
	}
	Obj_Delete(obj);
}

task Num2Laser(x,y,angle,ShotId)
{
	let length=500;
	let width=30;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,153);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,30);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,45);
	//Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	let count=0;
	EffectLaser(x,y,angle,length,width,45,90);
	EffectLaser(x,y,angle,length,width,45,90);
	loop(45)
	{
	EffectLaser(x,y,angle,length,width,0,1);
	yield;
	}
	loop(45)
	{
		yield;
	}
	if(ShotId==0)
	{
	ascent(i in 0..23)
	{
		LaserShot(x,i*20,angle-90);
		LaserShot(x,i*20+10,angle+90);
	}
	}
	if(ShotId==1)
	{
	ascent(i in 0..23)
	{
		LaserShot(i*20,y,angle-90);
		LaserShot(i*20+10,y,angle+90);
	}
	}
	Obj_Delete(obj);
}

task LaserShot(x,y,angle)
{
	let speed=0;
	//let angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		ObjShot_SetBombResist(obj,true);
		//Obj_SetAlpha(obj,0);
		//Obj_SetCollisionToPlayer(obj,false);
		let SpeedAngle=0;
		loop(180)
		{//114移動
			Obj_SetSpeed(obj, speed);
			speed=sin(SpeedAngle);
			SpeedAngle+=180/180;
			yield;
		}
		Obj_SetSpeed(obj, 0);
		Obj_Delete(obj);
}

task Laser2(x,y,angle,ShotId)
{
	let length=500;
	let width=30;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,153);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,30);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,0);
	//Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	EffectLaser(x,y,angle,length,width,0,45);
	let count=0;
	loop(45)
	{
		yield;
	}
	let angle=rand(0,360);
	if(ShotId==0)
	{
	ascent(i in 0..15)
	{
		LaserShot2(x,i*36, angle+i*36);
		LaserShot2(x,i*36+18, angle+i*36+18);
	}
	}
	if(ShotId==1)
	{
	ascent(i in 0..15)
	{
		LaserShot2(i*36,y, angle+i*36);
		LaserShot2(i*36+18,y, angle+i*36+18);
	}
	}
	Obj_Delete(obj);
}

task Num2Laser2(x,y,angle,ShotId)
{
	let length=500;
	let width=30;
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,x,y);
	Obj_SetAngle(obj,angle);
	ObjShot_SetGraphic(obj,153);
	ObjLaser_SetLength(obj,length);
	ObjLaser_SetWidth(obj,30);
	ObjLaser_SetSource(obj,false);
	ObjShot_SetDelay(obj,0);
	//Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetBombResist(obj,true);
	EffectLaser(x,y,angle,length,width,0,45);
	let count=0;
	loop(45)
	{
		yield;
	}
	let angle=rand(0,360);
	if(ShotId==0)
	{
	ascent(i in 0..20)
	{
		LaserShot2(x,i*28, angle+i*30);
		LaserShot2(x,i*28+14, angle+i*30+15);
	}
	}
	if(ShotId==1)
	{
	ascent(i in 0..20)
	{
		LaserShot2(i*28,y, angle+i*30);
		LaserShot2(i*28+14,y, angle+i*30+15);
	}
	}
	Obj_Delete(obj);
}

task LaserShot2(x,y,angle)
{
	let speed=0;
	//let angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		//Obj_SetAutoDelete(obj,false);
		//Obj_SetAlpha(obj,0);
		//Obj_SetCollisionToPlayer(obj,false);
		//ObjShot_SetBombResist(obj,true);
		let SpeedAngle=0;
		loop
		{
			Obj_SetSpeed(obj, speed);
			if(speed<2)
			{
			speed+=0.008;
			}
			yield;
		}
		Obj_SetSpeed(obj, 0);
		Obj_Delete(obj);
}

task Snake(x,y,v,angle,length,width,color,delay,id,spin)
{
         let snake = Obj_Create(OBJ_SINUATE_LASER);
         Obj_SetX(snake,x);
         Obj_SetY(snake,y);
         Obj_SetSpeed(snake,v);
         Obj_SetAngle(snake,angle-spin*spin*2);
         ObjShot_SetBombResist(snake,true);
         ObjShot_SetDelay(snake,delay);
         ObjShot_SetGraphic(snake,168);
         //ObjSinuateLaser_SetLength(snake,length);
         ObjSinuateLaser_SetLength(snake,45);
         ObjSinuateLaser_SetWidth(snake,width);
	Angle;
	SnakeShot;
        task Angle
	{
		if(id == 0)
		{
		loop(240)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		Obj_Delete(snake);
		}
		else if(id == 1)
		{
		loop(1)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		loop(60)
		{
			Obj_SetAngle(snake,Obj_GetAngle(snake)-6);
			wait(1);
		}
		loop(240)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		Obj_Delete(snake);
	}
        }  

	task SnakeShot
	{
		loop
		{
			SnakeShotBullet(Obj_GetX(snake),Obj_GetY(snake),Obj_GetAngle(snake)+180);
			wait(2);
		}
	}

	task SnakeShotBullet(x,y, angle)
	{
	wait(30);
	CreateShot02(x,y,0,angle,0.0125,8,12,5);
	}
}

}
/////////////////////////////////////////////////////////////////
task shotA
{
//wait(30);
loop(2)
{
SetAction(ACT_SHOT_A, 360);
DamageRate=80;
wait(15);
let angle=rand(0,360);
//CircleLaser(76.5,angle);
ascent(i in 1..5)
{
CircleLaser(i*76.5+38.25,angle);
//CircleLaser(i*76.5+76.5,angle);
}
wait(270);

let angle=rand(0,360);
CircleLaser2(38.5,angle);
ascent(i in 1..5)
{
CircleLaser2(i*76.5,angle);
CircleLaser2(i*76.5+38.25,angle);
}
wait(225);
SetAction(ACT_SHOT_A, 240);
DamageRate=100;
ascent(let i in -1..2)
{
Concentration03(GetCenterX+i*140,GetClipMinY,60,0,255,0);
}
Concentration03(GetCenterX+70,GetClipMaxY,60,0,255,0);
Concentration03(GetCenterX-70,GetClipMaxY,60,0,255,0);
wait(60);
ascent(let i in -1..2)
{
Snake(GetCenterX+i*140,GetClipMinY,4.5,90,60,12,9,5,1,5);
}
Snake(GetCenterX+70,GetClipMaxY,4.5,270,60,12,9,5,1,5);
Snake(GetCenterX-70,GetClipMaxY,4.5,270,60,12,9,5,1,5);
wait(120);
ascent(let i in -1..2)
{
Concentration03(GetClipMinX,GetCenterY+i*150,60,0,255,0);
}
Concentration03(GetClipMaxX,GetCenterY+75,60,0,255,0);
Concentration03(GetClipMaxX,GetCenterY-75,60,0,255,0);
wait(60);
ascent(let i in -1..2)
{
Snake(GetClipMinX,GetCenterY+i*150,4.5,0,60,12,9,5,1,5);
}
Snake(GetClipMaxX,GetCenterY+75,4.5,180,60,12,9,5,1,5);
Snake(GetClipMaxX,GetCenterY-75,4.5,180,60,12,9,5,1,5);
wait(300);
DamageRate=120;
MoveAndShot;
wait(525);
}

task MoveAndShot
{
	let dir=rand_int(0,1)*2-1;
	FallShot;
	FallShot2;
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX+140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX-140*dir+rand(-30,30), yIni+rand(-30,30), 20,5);
	wait(150);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(GetCenterX, GetCenterY, 20,5);
	task FallShot
	{
		loop(96)
		{
		CreateShot01(GetX+rand(-50,50),GetClipMinY,rand(2.0,2.5),rand(80,90),41,5);
		CreateShot01(GetX+rand(-50,50),GetClipMinY,rand(2.0,2.5),rand(80,90),41,5);
		wait(5);
		}
	}

	task FallShot2
	{
		loop(24)
		{
			loop(5)
			{
			ascent(i in 0..18)
			{
				CreateShot01(GetX,GetY,4.0,90+20*i,25,5);
			}
			wait(2);
			}
		wait(10);
		}
	}

	task CircleCentralShot(x,y,speed,angle)
	{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		Obj_SetAlpha(obj,0);
		Obj_SetCollisionToPlayer(obj,false);
		let CircleAngle=rand(0,360);

		ascent(i in 0..18)
		{
		CircleShot(obj,CircleAngle+i*20);
		}
		loop(480)
		{
			yield;
		}
		Obj_Delete(obj);	
	}

	task CircleShot(Cobj,Angle)
	{
		let R=100;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, Obj_GetX(Cobj)+R*cos(Angle),Obj_GetY(Cobj)+R*sin(Angle));
	//	Obj_SetSpeed(obj, speed);
	//	Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 121);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		while(!Obj_BeDeleted(Cobj))
		{
			Obj_SetPosition(obj, Obj_GetX(Cobj)+R*cos(Angle),Obj_GetY(Cobj)+R*sin(Angle));
			Angle+=0.5;
			yield;
		}
		Obj_Delete(obj);	
	}

}

task CircleLaser(let R,angle)
{
		let RA=1;
		let r1=R-RA;
		let r2=R+RA;
		let r=0;
		let rplus=1.70;

		let randvertex=0;
		let VertexNum=64;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory ~ "..\img/WhiteLine.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  24*(i%2));
		}

		ObjEffect_SetLayer(obj,3);

		let Scale=1;

		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,GetX,GetY);
		let Alpha=150;
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj, i,Alpha,255,255,255);
		}
		loop(45)
{
		EffectCircleLaser(R,angle,1);
yield;
}

		EffectCircleLaser(R,angle,45);
		loop(45)
		{
		if(RA<8)
		{
		RA+=1;
		}
		Radius=[R-RA,R+RA];
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		if(R-RA<GetDistanceToPlayer && GetDistanceToPlayer<R+RA && !OnBomb && GetTimeOfPlayerInvincibility==0)
		{
			ShootDownPlayer;
		}
		yield;
		}
		let way=60;
		if(R<76.5*2){way=30;}
		else if(R<76.5*3){way=45;}
		else{way=60;}
		let SepAngle=360/way;
		ascent(i in 0..way)
		{
		LaserShot(GetX+R*cos(angle+i*SepAngle),GetY+R*sin(angle+i*SepAngle),angle+i*SepAngle,1);
		LaserShot(GetX+R*cos(angle+i*SepAngle+SepAngle*2/4),GetY+R*sin(angle+i*SepAngle+SepAngle*2/4),angle+i*SepAngle+SepAngle*2/4+180,1);
		LaserShot(GetX+R*cos(angle+i*SepAngle+SepAngle*1/4),GetY+R*sin(angle+i*SepAngle+SepAngle*1/4),angle+i*SepAngle+SepAngle*2/4,1.33);
		LaserShot(GetX+R*cos(angle+i*SepAngle+SepAngle*3/4),GetY+R*sin(angle+i*SepAngle+SepAngle*3/4),angle+i*SepAngle+SepAngle*2/4+180,1.33);
/*
		LaserShot(GetX+R*cos(angle+i*SepAngle),GetY+R*sin(angle+i*6),angle+i*6,1);
		LaserShot(GetX+R*cos(angle+i*SepAngle+SepAngle*2/4),GetY+R*sin(angle+i*6+3),angle+i*6+3+180,1);
		LaserShot(GetX+R*cos(angle+i*SepAngle+1.5),GetY+R*sin(angle+i*6+1.5),angle+i*6+1.5,1.33);
		LaserShot(GetX+R*cos(angle+i*SepAngle+3+1.5),GetY+R*sin(angle+i*6+3+1.5),angle+i*6+3+1.5+180,1.33);
*/
		}
		Obj_Delete(obj);
}

task EffectCircleLaser(let R,angle,time)
{
		let RA=8;
		if(time==1){RA=1;}
		let randvertex=0;
		let VertexNum=64;
		let Radius=[R-RA,R+RA];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory ~ "..\img/WhiteLine.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  24*(i%2));
		}

		ObjEffect_SetLayer(obj,2);

		let Scale=1;

		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,GetX,GetY);
		let Alpha=120;
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj, i,Alpha,255,255,255);
		}
	//	wait(delay);
		loop(time)
		{
		let RandR=rand(0.5,1);
		Radius=[R-RA*RandR,R+RA*RandR];
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		yield;
		}

		Obj_Delete(obj);
}

task LaserShot(x,y,angle,grad)
{
	let speed=0;
	//let angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle+grad);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		Obj_SetAutoDelete(obj,false);
		ObjShot_SetBombResist(obj,true);
		//Obj_SetAlpha(obj,0);
		//Obj_SetCollisionToPlayer(obj,false);
		let SpeedAngle=0;
		loop(180)
		{//114移動
			Obj_SetSpeed(obj, speed*1.0*grad);
			speed=sin(SpeedAngle);
			SpeedAngle+=180/180;
			yield;
		}
		Obj_SetSpeed(obj, 0);
		Obj_Delete(obj);
}

task CircleLaser2(let R,angle)
{

		let RA=1;
		let r1=R-RA;
		let r2=R+RA;
		let r=0;
		let rplus=1.70;

		let randvertex=0;
		let VertexNum=64;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,GetCurrentScriptDirectory ~ "..\img/WhiteLine.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  24*(i%2));
		}

		ObjEffect_SetLayer(obj,3);

		let Scale=1;

		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,GetX,GetY);
		let Alpha=150;
		EffectCircleLaser(R,angle,45);
		//wait(5);
		loop(45)
		{
		if(RA<8)
		{
		RA+=1;
		}
		Radius=[R-RA,R+RA];
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		if(R-RA<GetDistanceToPlayer && GetDistanceToPlayer<R+RA && !OnBomb && GetTimeOfPlayerInvincibility==0)
		{
			ShootDownPlayer;
		}
		yield;
		}

		let way=45;
		if(R<38.25*4){way=25;}
		else if(R<38.25*5){way=30;}
		else if(R<38.25*6){way=35;}
		else if(R<38.25*7){way=40;}
		else{way=45;}
		let SepAngle=360/way;

		ascent(i in 0..way)
		{
		LaserShot2(GetX+R*cos(angle+i*SepAngle),GetY+R*sin(angle+i*SepAngle),angle+rand(-90,90),0);
		LaserShot2(GetX+R*cos(angle+i*SepAngle+SepAngle/2),GetY+R*sin(angle+i*SepAngle+SepAngle/2),angle+rand(-90,90)+180,0);
/*
		LaserShot2(GetX+R*cos(angle+i*8),GetY+R*sin(angle+i*8),angle+rand(-90,90),0);
		LaserShot2(GetX+R*cos(angle+i*8+4.00),GetY+R*sin(angle+i*8+4.00),angle+rand(-90,90)+180,0);
	*/
		}
		Obj_Delete(obj);
}

task LaserShot2(x,y,angle,grad)
{
	let speed=0;
	//let angle=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x,y);
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 9);
		ObjShot_SetDelay(obj, 5);
		//Obj_SetAutoDelete(obj,false);
		//Obj_SetAlpha(obj,0);
		//Obj_SetCollisionToPlayer(obj,false);
		//ObjShot_SetBombResist(obj,true);
		let SpeedAngle=0;
		loop
		{
			Obj_SetSpeed(obj, speed);
			if(speed<2)
			{
			speed+=0.0075;
			}
			yield;
		}
		Obj_SetSpeed(obj, 0);
		Obj_Delete(obj);
}

task Snake(x,y,v,angle,length,width,color,delay,id,spin)
{
         let snake = Obj_Create(OBJ_SINUATE_LASER);
         Obj_SetX(snake,x);
         Obj_SetY(snake,y);
         Obj_SetSpeed(snake,v);
         Obj_SetAngle(snake,angle-spin*spin*2);
         ObjShot_SetBombResist(snake,true);
         ObjShot_SetDelay(snake,delay);
         ObjShot_SetGraphic(snake,168);
         //ObjSinuateLaser_SetLength(snake,length);
         ObjSinuateLaser_SetLength(snake,45);
         ObjSinuateLaser_SetWidth(snake,width);
	Angle;
	SnakeShot;
        task Angle
	{
		if(id == 0)
		{
		loop(240)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		Obj_Delete(snake);
		}
		else if(id == 1)
		{
		loop(1)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		loop(60)
		{
			Obj_SetAngle(snake,Obj_GetAngle(snake)-6);
			wait(1);
		}
		loop(240)
		{
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)+spin);
				wait(1);
			}
			loop(20)
			{
				Obj_SetAngle(snake,Obj_GetAngle(snake)-spin);
				wait(1);
			}
		}
		Obj_Delete(snake);
	}
        }  

	task SnakeShot
	{
		loop
		{
			SnakeShotBullet(Obj_GetX(snake),Obj_GetY(snake),Obj_GetAngle(snake)+180);
			wait(2);
		}
	}

	task SnakeShotBullet(x,y, angle)
	{
	wait(30);
	CreateShot02(x,y,0,angle,0.01,3,12,5);
	}
}

}

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

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

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