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

    @MainLoop {
	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 {
		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;
	GetDamege;
	OutDamageRateZero;
	Collision;
	Lissajous(148,0,211);
	BossShadowAnimation(imgBoss,0,148,0,211);
	standBy;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
}

task Collision
{
	wait(90);

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

}

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

task shotM
{
//wait(15);
SetAction(ACT_SHOT_A, 375);
shot;
wait(495);
SetAction(ACT_SHOT_A, 240);
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);
MoveAndShot;
wait(540);
SetAction(ACT_SHOT_A, 375);
shot2;
wait(495);
SetAction(ACT_SHOT_A, 240);
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);
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=500;
	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;
	loop(90)
	{
		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移動
			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=500;
	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;
	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_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.01,3,12,5);
	}

}

}
///////////////////////////////////////////////////////
task shotE
{
//wait(15);
SetAction(ACT_SHOT_A, 375);
shot;
wait(495);
SetAction(ACT_SHOT_A, 240);
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);
MoveAndShot;
wait(540);
SetAction(ACT_SHOT_A, 420);
shot2;
wait(540);
SetAction(ACT_SHOT_A, 240);
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);
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=500;
	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;
	loop(90)
	{
		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=500;
	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;
	loop(90)
	{
		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=500;
	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;
	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 Num2Laser2(x,y,angle,ShotId)
{
	let length=500;
	let width=500;
	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;
	loop(45)
	{
		yield;
	}
	let angle=rand(0,360);
	if(ShotId==0)
	{
	ascent(i in 0..23)
	{
		LaserShot2(x,i*20, angle+i*30);
		LaserShot2(x,i*20+10, angle+i*30+15);
	}
	}
	if(ShotId==1)
	{
	ascent(i in 0..23)
	{
		LaserShot2(i*20,y, angle+i*30);
		LaserShot2(i*20+10,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_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 shotA
{
//wait(30);
loop(2)
{
SetAction(ACT_SHOT_A, 360);
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.5,angle);
}
wait(225);
SetAction(ACT_SHOT_A, 240);
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);
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=100;
		wait(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;
		}
		ascent(i in 0..60)
		{
		LaserShot(GetX+R*cos(angle+i*6),GetY+R*sin(angle+i*6),angle+i*6,1);
		LaserShot(GetX+R*cos(angle+i*6+3),GetY+R*sin(angle+i*6+3),angle+i*6+3+180,1);
		LaserShot(GetX+R*cos(angle+i*6+1.5),GetY+R*sin(angle+i*6+1.5),angle+i*6+1.5,1.33);
		LaserShot(GetX+R*cos(angle+i*6+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 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=8;
		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=100;
		//wait(60);
		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;
		}
		ascent(i in 0..48)
		{
		LaserShot2(GetX+R*cos(angle+i*7.5),GetY+R*sin(angle+i*7.5),angle+rand(-90,90),0);
		LaserShot2(GetX+R*cos(angle+i*7.5+3.75),GetY+R*sin(angle+i*7.5+3.75),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_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);
	}
}

}

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

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