script_enemy_main
{
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Animation=0;
	let AnimationA=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
        let imgBoss3=csd~"img\familiar2.png";
	let angle=0;
	let imgAngle=0;
	let imgAngle2=0;
	let imgAlpha=255;
	let deathse=csd~"se\DEATH.wav";
	let Flag=false;
	let shotseA=csd~"se\ShotSE02.wav";

    @Initialize {
        SetLife(130);
        SetScore(10);
        SetDamageRate(0,0);
        SetX(224);
        SetY(0);
	LoadGraphic(imgBoss2);
	LoadGraphic(imgBoss3);
	SetMovePosition03(224,150,10,4);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime;
	TAnime2;
	}

	@MainLoop {
	if(count==1000&&Flag==false){
		TAnime2;
		SetMovePositionHermite(224,-110,50,90,10,270,150);
		CreateItem(ITEM_BOMB,GetX,GetY);
		loop(75){
			angle=rand(0,360);
			CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,45),GetY+sin(angle)*rand(35,45));
			}
		}
	if(count==100&&Flag==false){
		Concentration01(200);
		}
	if(count>=100&&count<300&&count%20==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
        	let i=0;
        	while(i<5){
        		CreateShotA(1,GetX,GetY,5);
        		SetShotDataA(1,0,3,2*i-4,0,-0.01,1,68);
        		FireShot(1);
        		CreateShotA(1,GetX,GetY,5);
        		SetShotDataA(1,0,3,2*i-124,0,-0.01,1,68);
        		FireShot(1);
        		CreateShotA(1,GetX,GetY,5);
        		SetShotDataA(1,0,3,2*i-244,0,-0.01,1,68);
        		FireShot(1);
        		i++;
			}
		}
	if(count>=300&&count%20==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
        	let i=0;
        	while(i<10){
        		CreateShotA(1,GetX,GetY,5);
        		SetShotDataA(1,0,3,36*i,0,-0.01,1,85);
        		FireShot(1);
        		i++;
			}
		}
	if(count>=500&&count%20==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
        	let i=0;
        	while(i<10){
        		CreateShotA(1,GetX,GetY,5);
        		SetShotDataA(1,0,3,36*i+18,0,-0.01,1,85);
        		FireShot(1);
        		i++;
			}
		}
	if(count>=800&&count%20==10){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
        	let i=0;
        	while(i<20){
        		CreateShotA(1,GetX,GetY,5);
        		SetShotDataA(1,0,3,18*i+9,0,-0.01,1,87);
        		FireShot(1);
        		i++;
			}
		}
        if(count>=100&&GetX<-100||GetX>458||GetY>490||GetY<-100)
        	{
        	VanishEnemy();
        	}
	imgAngle2+=10;
	if(imgAngle2>=360){imgAngle2=0;}
	SetCollisionA(GetX(),GetY(),10);
	SetCollisionB(GetX(),GetY(),10);
	count++;
	yield;
	}

        @DrawLoop {
		SetTexture(imgBoss3);
		SetGraphicAngle(0,0,imgAngle2);
		SetAlpha(255);
		SetColor(0,0,0);
		SetGraphicRect(0,0,192,192);
		DrawGraphic(GetX(),GetY());

		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,0);
		SetAlpha(255);
		SetColor(255,255,255);
		if(Flag==true){SetGraphicRect(193,64,254,127);}
		else if(int(GetSpeedX())==0){SetGraphicRect(Animation*64,64,63+Animation*64,127);}
		else if(GetSpeedX()>0){SetGraphicRect(AnimationA*64+128,129,AnimationA*64+191,191);}
		else if(GetSpeedX()<0){SetGraphicRect(AnimationA*64,129,AnimationA*64+63,191);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
		if(!BeVanished){
			loop(5){
				CreateItem(ITEM_SCORE,GetX+rand(-20,20),GetY+rand(-20,20));
			}
		}
        } 

    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}
    	task TAnime2{
			AnimationA=0;
        		loop(10){yield;}
			AnimationA=1;
        		loop(80){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}
    	task TAnime3{
			Animation=4;
		}
}