script_enemy_main
{//Enemy01
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
        let Motion=0;
        let angle=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\dot_yuyuko.png";
        let imgBoss2=csd~"img\dot_yousei3.png";

    @Initialize {
        SetLife(1);
        SetScore(0);
        SetDamageRate(0,0);
        SetX(-10);
        SetY(-10);
        SetInvincibility(50);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	SetMovePosition02(224,120,100);
        TAnime;
	}

	@MainLoop {

		if(count>=100&&count<1400&&count%200==0){
			let i=0;
			while(i<40){
				let shotA=0;
				CreateShotA(shotA,GetX,GetY,0);
				SetShotDataA(shotA,0,2,i*9,0,0,0,27);
				FireShot(shotA);
				CreateShotA(shotA,GetX,GetY,0);
				SetShotDataA(shotA,0,1,i*9+4.5,0,0,0,27);
				FireShot(shotA);
				i++;
				}
			}
		if(count>=100&&count<1400&&count%200==100){
			let i=0;
			while(i<40){
				let shotA=0;
				CreateShotA(shotA,GetX,GetY,0);
				SetShotDataA(shotA,0,2,i*9+4.5,0,0,0,27);
				FireShot(shotA);
				CreateShotA(shotA,GetX,GetY,0);
				SetShotDataA(shotA,0,1,i*9,0,0,0,27);
				FireShot(shotA);
				i++;
				}
			}

		if(count>=100&&count<1500&&count%400==100){
			SetMovePositionHermite(350,120,100,315,100,45,100);
			TAnime2;
			}
		if(count>=100&&count<1500&&count%400==200){
			SetMovePositionHermite(224,120,100,135,100,225,100);
			TAnime2;
			}
		if(count>=100&&count<1500&&count%400==300){
			SetMovePositionHermite(98,120,100,225,100,135,100);
			TAnime2;
			}
		if(count>=100&&count<1500&&count%400==0){
			SetMovePositionHermite(224,120,100,45,100,315,100);
			TAnime2;
			}
		if(count==1500){
			SetMovePosition02(224,150,100);
			TAnime2;
			}
		if(count>=100&&count<1400&&count%200==100&&GetEnemyNum<5){
			CreateEnemyFromScript("DOLL01",GetX,GetY,0,0,count);
			TAnime2;
			}
		if(count>=100&&count<1400&&count%200==0&&GetEnemyNum<5){
			CreateEnemyFromScript("DOLL02",GetX,GetY,0,0,count);
			TAnime2;
			}
		if(count>=1600){
			VanishEnemy();
			}

		SetCommonData("ex",GetX);
		SetCommonData("ey",GetY);
		count++;
		yield;
		}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(155);
		SetColor(155,0,155);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);}
		else if(GetSpeedX()>0){SetGraphicRect(256,256+128*AnimationA,383,383+128*AnimationA);}
		else if(GetSpeedX()<0){SetGraphicRect(256,128*AnimationA,383,127+128*AnimationA);}
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize
        {
		DeleteGraphic(imgBoss2);
        }

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

    	task TAnime2{
			AnimationA=0;
        		loop(10){yield;}
			AnimationA=1;
        		loop(80){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}
}

script_enemy DOLL01 {
        let count=GetArgument;
	let Animation=0;
        let Motion=0;
        let angle=0;
	let r=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
	let imgAngle=0;
	let imgAlpha=255;
	let deathse=csd~"se\DEATH.wav";
	let shotseA=csd~"se\ShotSE02.wav";
	let Flag=false;

    @Initialize {
        SetLife(125);
        SetScore(10);
        SetDamageRate(0,0);
        SetX(GetEnemyX);
        SetY(GetEnemyY);
        SetInvincibility(150);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime;
	}

	@MainLoop {
	if(GetLife<=100&&Flag==false){
			SetMovePosition01(GetX,GetY+100,1);
			PlaySE(deathse);
			Motion=1;
			Flag=true;
			}
	if(Flag==true){
		imgAngle+=15;
		imgAlpha-=5;
		if(imgAlpha<=0){AddLife(-1000);}
		} else {
		SetCollisionA(GetX(),GetY(),10);
		SetCollisionB(GetX(),GetY(),10);
		}
        	SetDamageRate(100,100);
	if(count%10==0&&Flag==false){
		SetMovePosition02(GetEnemyX+cos(angle)*r,GetEnemyY+sin(angle)*r,10);
		angle-=10;
		if(imgAlpha>=255){imgAlpha=255;}
		if(r>=75){r=75;}
		imgAlpha+=5;
		r+=5;
		}
	if(GetLife>100&&count<=1450&&count%10==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
		let i=0;
		while(i<18){
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2,angle+i*20,0,0,0,125);
			FireShot(shotA);
			i++;
			}
		}
	if(count==1450){
		AddLife(-26);
        	}
	count++;
	yield;
	}

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,imgAngle);
		SetAlpha(imgAlpha);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(Animation*32+Motion*96,0,31+Animation*32+Motion*96,31);}
		else if(GetSpeedX()>0){SetGraphicRect(Animation*32+128,32,159+Animation*32,63);}
		else if(GetSpeedX()<0){SetGraphicRect(Animation*32,32,31+Animation*32,63);}
		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;}
			}
		}
}

script_enemy DOLL02 {
        let count=GetArgument;
	let Animation=0;
        let Motion=0;
        let angle=0;
	let r=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
	let imgAngle=0;
	let imgAlpha=0;
	let deathse=csd~"se\DEATH.wav";
	let shotseA=csd~"se\ShotSE02.wav";
	let Flag=false;

    @Initialize {
        SetLife(125);
        SetScore(10);
        SetDamageRate(0,0);
        SetX(GetEnemyX);
        SetY(GetEnemyY);
        SetInvincibility(150);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime;
	}

	@MainLoop {
	if(GetLife<=100&&Flag==false){
			SetMovePosition01(GetX,GetY+100,1);
			PlaySE(deathse);
			Motion=1;
			Flag=true;
			}
	if(Flag==true){
		imgAngle+=15;
		imgAlpha-=5;
		if(imgAlpha<=0){AddLife(-1000);}
		} else {
		SetCollisionA(GetX(),GetY(),10);
		SetCollisionB(GetX(),GetY(),10);
		}
        	SetDamageRate(100,100);
	if(count%10==0&&Flag==false){
		SetMovePosition02(GetEnemyX+cos(angle)*r,GetEnemyY+sin(angle)*r,10);
		angle-=10;
		if(imgAlpha>=255){imgAlpha=255;}
		if(r>=75){r=75;}
		imgAlpha+=5;
		r+=5;
		}
	if(GetLife>100&&count<=1450&&count%10==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
		let i=0;
		while(i<18){
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2,angle+i*20,0,0,0,124);
			FireShot(shotA);
			i++;
			}
		}
	if(count==1500){
		AddLife(-26);
        	}
	count++;
	yield;
	}

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,imgAngle);
		SetAlpha(imgAlpha);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(Animation*32+Motion*96,0,31+Animation*32+Motion*96,31);}
		else if(GetSpeedX()>0){SetGraphicRect(Animation*32+128,32,159+Animation*32,63);}
		else if(GetSpeedX()<0){SetGraphicRect(Animation*32,32,31+Animation*32,63);}
		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;}
			}
		}
}