script_enemy_main
{
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Animation=0;
        let r = 0;
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_yousei3.png";
	let angle=0;
	let HitugiID1=0;
	let HitugiID2=0;
	let shotseA = csd~"se\ShotSE02.wav";

    @Initialize {
        SetLife(100);
        SetScore(10);
        SetDamageRate(0,0);
        SetX(GetX);
        SetY(GetY);
	SetMovePosition02(GetX,100,30);
	LoadGraphic(imgBoss2);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime;
	IDinfo1;
	IDinfo2;
    }

    @MainLoop {
	if(GetEnemyInfoDefault(HitugiID1,ENEMY_LIFE,0)==0&&count%2==0&&count>=50){
                SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
        	let shot01 = 1;
        	CreateShotA(shot01,GetX(),GetY(),0);
        	SetShotDataA(shot01,0,rand(3,5),rand(0,360),0,-0.01,2,BLUE21);
        	FireShot(shot01);
		}
	if(GetEnemyInfoDefault(HitugiID2,ENEMY_LIFE,0)==0&&count%20==0&&count>=50){
                SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
        		let i = 0;
        		while( i < 6 )
        		{
        		let shot01 = 1;
        		CreateShotA(shot01,GetX(),GetY(),0);
        		SetShotDataA(shot01,0,4,i*60,0,-0.01,2,BLUE02);
        		FireShot(shot01);
        		i++;
        		}
		}
	if(count==50){
        SetDamageRate(100,100);
	SetMovePosition01(-60,120,1.5);
		}
        if(GetX<-10||GetX>458||GetY>490||GetY<-10)
        	{
        		VanishEnemy();
        	}
        SetCollisionA(GetX(),GetY(),10);
        SetCollisionB(GetX(),GetY(),10);
        count++;
        yield;
    }

        @DrawLoop {
		SetTexture(imgBoss2);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(Animation*32,0,31+Animation*32,31)}
		else if(GetSpeedX()>0){SetGraphicRect(128+Animation*32,33,159+Animation*32,64);}
		else if(GetSpeedX()<0){SetGraphicRect(Animation*32,33,31+Animation*32,64);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
		if(!BeVanished){CreateItem(ITEM_SCORE,GetX,GetY);}
        }

    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}

	task IDinfo1{
		let MyID=MyIDDecision;
		yield;
			let ID=MyID+1;
			if(ID>256){ID=ID%256;}
			HitugiID1=ID;
			CreateEnemyFromScript("DOLL01",GetX+40,-9,0,0,MyID);
		}

	task IDinfo2{
		let MyID=MyIDDecision;
		yield;
			let ID=MyID+2;
			if(ID>256){ID=ID%256;}
			HitugiID2=ID;
			CreateEnemyFromScript("DOLL01",GetX-40,-9,0,0,MyID);
		}

	function MyIDDecision{
		let ID;
		ascent(enemy in EnumEnemyBegin..EnumEnemyEnd){
			let enemyID = EnumEnemyGetID(enemy);
			let enemyX = GetEnemyInfo(enemyID,ENEMY_X);
			let enemyY = GetEnemyInfo(enemyID,ENEMY_Y);
			if(GetX==enemyX && GetY==enemyY){
				ID=enemyID;
				break;
				}
			}
		return ID;
		}
	}
}

script_enemy DOLL01 {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_yousei3.png";
        let angle=0;
	let shotseB = csd~"se\ShotSE01.wav";
	let ParentID=GetArgument;//eID

    @Initialize {
        SetLife(10);
        SetScore(0);
        SetDamageRateEx(0,0,0,0);
	SetMovePosition02(GetX,100,30);
    }

    @MainLoop {
        	if(count==50)
        	{
        	SetDamageRateEx(100,0,100,0);
                SetMovePosition01(-60,120,1.5);
        	}
        	if(count>=30&&count%60==30)
        	{
		PlaySE(shotseB);
		angle=GetAngleToPlayer;
		let i=0;
		while(i<36)
		{
                SetShotDirectionType(ABSOLUTE);
        	let shot01 = 1;
        	CreateShotA(shot01,GetX(),GetY(),0);
        	SetShotDataA(shot01,0,2,angle+i*10,0,0.01,2.5,BLUE12);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX(),GetY(),3);
        	SetShotDataA(shot01,0,2,angle+i*10,0,0.01,2.5,BLUE12);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX(),GetY(),6);
        	SetShotDataA(shot01,0,2,angle+i*10,0,0.01,2.5,BLUE12);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX(),GetY(),9);
        	SetShotDataA(shot01,0,2,angle+i*10,0,0.01,2.5,BLUE12);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX(),GetY(),12);
        	SetShotDataA(shot01,0,2,angle+i*10,0,0.01,2.5,BLUE12);
        	FireShot(shot01);
		i++;
		}
        	}
        if(GetX<-50||GetX>490||GetY>490||GetY<-10)
        	{
        		VanishEnemy();
        	}
        SetCollisionA(GetX(),GetY(),10);
        count++;
        yield;
    }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss2);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetGraphicRect(195,1,216,32);
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
		if(!BeVanished&&GetEnemyInfo(ParentID,ENEMY_LIFE)>0){
			CreateItem(ITEM_SCORE,GetX,GetY);
			FiraShot(3);
			FiraShot(2.5);
			FiraShot(2);
			FiraShot(1.5);
			FiraShot(1);
			}
        }

    	task FiraShot(speed){
                SetShotDirectionType(ABSOLUTE);
		let obj = Obj_Create(OBJ_SHOT);
		let l = 0;
		ObjShot_SetBombResist(obj,true);
		Obj_SetPosition(obj,GetX,GetY);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,GetAngleToPlayer);
		ObjShot_SetGraphic(obj,61);
		ObjShot_SetDelay(obj,50);
	}
}