#Title[ru͎̎ɂĖ߂v]
#Text[̃XyJ[h]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_devil.png";
        let imgBoss2 =csd~"img\dot_yousei3.png";
	let imgEnemy=csd~"img\familiar.png";
        let name    = "ru͎̎ɂĖ߂v";
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
        let angle = 0;
        let j = 0;
	let Motion=0;
        let imgSPELL =csd~"img\SPELL_H.png";
        let imgAngle2 = 0;
	let shotseA = csd~"se\ShotSE02.wav";

    @Initialize {
    CutIn(YOUMU, name, 0, 0, 0, 0, 0);

        SetLife(3000);
        SetTimer(99);
        SetScore(1000000);
        SetDamageRate(0,0);

        SetInvincibility(0);
        SetMovePosition02(cx,cy,60);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	LoadGraphic(imgEnemy);
	LoadGraphic(imgSPELL);
        TAnime1;
    }

        @MainLoop
        {
	imgAngle2++;
	if(imgAngle2>360){imgAngle2=0;}
	if(count==150){
		Motion=1;
		Concentration01(60);
		}
	if(count>=250&&count%5==0){
		PlaySE(shotseA);
        		let i = 0;
        		while( i < 4 )
        		{
        		let shot01 = 1;
        		SetShotDirectionType(ABSOLUTE);
        		CreateShotA(shot01,GetX(),GetY(),i);
        		SetShotDataA(shot01, 0,2,angle+rand(-10,10),0,-0.01,0.5,AQUA01);
        		FireShot(shot01);
        		i++
        		}
		angle=angle+11;
		}
	if(count==200&&GetEnemyNum<8){
        SetDamageRate(100,0);
		Motion=0;
		CreateEnemyFromScript("DOLL01",GetX,GetY+50,0,0,1);
		CreateEnemyFromScript("DOLL01",GetX,GetY-50,0,0,1);
		CreateEnemyFromScript("DOLL01",GetX+50,GetY,0,0,1);
		CreateEnemyFromScript("DOLL01",GetX-50,GetY,0,0,1);
		}
	if(count>=400&&count%100==0&&GetEnemyNum<8){
        SetDamageRate(100,0);
		CreateEnemyFromScript("DOLL01",rand(GetX-50,GetX+50),rand(GetY-50,GetY+50),0,0,1);
		}
	SetCollisionA(GetX(),GetY(),32);
        SetCollisionB(GetX(),GetY(),24);
        count++;
        yield;
        }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
	if(Motion==0){
		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());
		}
	if(Motion==1){
		if(int(GetSpeedX())==0)
		{SetGraphicRect(0,128*AnimationB,127,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());
		}
	}

	@BackGround
	{
		//wi`
		SetGraphicRect(0,0,81,81);
		SetTexture(imgSPELL);
		SetRenderState(ALPHA);
		SetGraphicScale(12,12);
		SetColor(0,0,100);
		SetAlpha(255);
		SetGraphicAngle(0,0,-imgAngle2*4);
		DrawGraphic(cx,cy);

		SetGraphicScale(7,7);
		SetColor(155,0,155);
		SetAlpha(155);
		SetGraphicAngle(0,0,imgAngle2*3);
		DrawGraphic(cx,cy);

		SetGraphicScale(4,4);
		SetColor(55,55,55);
		SetAlpha(155);
		SetGraphicAngle(0,0,-imgAngle2*2);
		DrawGraphic(cx,cy);

		SetGraphicScale(2,2);
		SetColor(0,0,155);
		SetAlpha(155);
		SetGraphicAngle(0,0,imgAngle2);
		DrawGraphic(cx,cy);
	}
        
        @Finalize
        {
	loop(30)
	{
		angle=rand(0,360);
		CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,50),GetY+sin(angle)*rand(35,50));
	}
		CreateItem(ITEM_BOMB,GetX,GetY);
        } 
	
    	task TAnime1{
			AnimationB=0;
			AnimationC=3;
        		loop(16){yield;}
			AnimationB=1;
        		loop(56){yield;}
			AnimationB=0;
        		loop(8){yield;}
		loop{
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(10){yield;}
			}
		}

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

script_enemy DOLL01 {
        let count=0;
	let Animation=0;
        let angle = 0;
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_yousei3.png";
	let Zoom=0;
	let imgEnemy=csd~"img\familiar.png";
	let imgAngle=0;
	let imgAlpha=0;
	let shotseA = csd~"se\ShotSE02.wav";
	let deathse = csd~"se\DEATH.wav";

    @Initialize {
        SetLife(50);
        SetScore(0);
        SetDamageRateEx(0,0,0,0);
        Tup;
    }

    @MainLoop {
	imgAngle+=4;
	if(imgAngle>360){imgAngle=0;}
        	if(count>=0&&count<=110)
        	{
        	imgAlpha+=2.5;
        	if(imgAlpha>255){imgAlpha=255;}
        	}
        	if(count<=400&&count>=100&&count%50==0)
        	{
                SetDamageRateEx(100,25,50,0);
                SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
                angle=rand(-1,1);
        		let i = 0;
        		while( i < 8 )
        		{
        		let shot01 = 1;
        		SetShotDirectionType(PLAYER);
        		CreateShotA(shot01,GetX(),GetY(),0);
        		SetShotDataA(shot01,0,2,45*i,0,-0.01,1.5,GREEN12);
        		FireShot(shot01);
        		i++;
        		}
        	}
        	if(count>=400)
        	{
                SetDamageRateEx(0,0,0,0);
        	imgAlpha-=5;
        	if(imgAlpha<0){VanishEnemy();}
        	}
        SetCollisionA(GetX(),GetY(),10);
        count++;
        yield;
    }


        @DrawLoop {
		SetAlpha(imgAlpha);
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy);
		SetGraphicScale(1+0.01*Zoom,1+0.01*Zoom);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());

		SetRenderState(ALPHA);
		SetTexture(imgBoss2);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetGraphicRect(195,1,216,32);
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize
        {
        	if(!BeVanished)
        	{
		PlaySE(deathse);
        	CreateEnemyFromScript("DOLL21",GetX,GetY,0,0,1);
        	}
        }
    	task Tup{
		loop{
			Zoom=0;
        		loop(1){yield;}
			Zoom=1;
        		loop(2){yield;}
			Zoom=2;
        		loop(2){yield;}
			Zoom=3;
        		loop(2){yield;}
			Zoom=4;
        		loop(3){yield;}
			Zoom=5;
        		loop(15){yield;}
			Zoom=4;
        		loop(3){yield;}
			Zoom=3;
        		loop(2){yield;}
			Zoom=2;
        		loop(2){yield;}
			Zoom=1;
        		loop(1){yield;}
			}
		}
}

script_enemy DOLL11 {//S
        let count=0;
	let Animation=0;
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_yousei3.png";
	let deathse = csd~"se\DEATH.wav";

    @Initialize {
        SetLife(100);
        SetScore(0);
        SetDamageRateEx(0,0,0,0);
        TAnime;
    }

    @MainLoop {
        	if(count==1)
        	{
		PlaySE(deathse);
        	}
        	if(count==250)
        	{
		VanishEnemy();
        	}
        count++;
        yield;
    }

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicRect(96+Animation*32,0,127+Animation*32,31);
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize {
        	if(GetEnemyLife>0)
        	{
        CreateEnemyFromScript("DOLL21",GetX,GetY,0,0,1);
        	}
        }
    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}
}

script_enemy DOLL21 {//
        let count=0;
	let Animation=0;
	let Animation2=0;
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_yousei3.png";
	let shotseA = csd~"se\ShotSE02.wav";

    @Initialize {
        SetLife(50);
        SetScore(10);
        SetInvincibility(120);
        SetDamageRateEx(100,25,25,0);
        TAnime1;
        TAnime2;
    }

    @MainLoop {
        	if(count>=120&&count%10==0)
        	{
        	SetMovePosition01(GetPlayerX,GetPlayerY,1.2);
        	}
        	if(count>=150&&count%50==0)
        	{
                SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
		let shot01 = 1;
        		if(GetEnemyLife<=1500)
        		{
        		CreateShotA(shot01,GetX,GetY,0);
        		SetShotDataA(shot01,0,1,rand(15,50),0,0.01,2,BLUE05);
        		FireShot(shot01);
        		CreateShotA(shot01,GetX,GetY,10);
        		SetShotDataA(shot01,0,1,rand(-50,-15),0,0.01,2,BLUE05);
        		FireShot(shot01);
        		}
        	CreateShotA(shot01,GetX,GetY,10);
        	SetShotDataA(shot01,0,1,0,0,0.01,2,BLUE05);
        	FireShot(shot01);
        	}
	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+Animation2*32,33,159+Animation2*32,64);}
		else if(GetSpeedX()<0){SetGraphicRect(Animation2*32,33,31+Animation2*32,64);}
		DrawGraphic(GetX(),GetY());
	}
        
        @Finalize
        {
        	if(GetEnemyLife>0)
        	{
        CreateEnemyFromScript("DOLL11",GetX,GetY,0,0,1);
        	}
        }
    	task TAnime1{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}
    	task TAnime2{
		loop{
			Animation2=0;
        		loop(10){yield;}
			Animation2=1;
        		loop(10){yield;}
			Animation2=2;
        		loop(10){yield;}
			Animation2=3;
        		loop(10){yield;}
			}
		}
}