#e
#Title[֊uph̔v]
#Text[̃XyJ[h]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let rcx=0;
        let rcy=0;
        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    = "֊uph̔v";
	let Animation=0;
        let angle = 0;
        let angleA = 0;
        let angleB = 0;
	let DevilMotion=0;

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

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

        SetInvincibility(0);
        SetShotDirectionType(ABSOLUTE);
        SetMovePosition02(cx,120,60);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	LoadGraphic(imgEnemy);
        TAnime;
    }

        @MainLoop
        {
	if(count==150){
		DevilMotion=1;
		Concentration01(60);
		}
	if(count==200){
        SetDamageRate(100,0);
		DevilMotion=0;
		CreateEnemyFromScript("DOLL01",rand(GetX-100,GetX+100),rand(GetY-100,GetY+100),0,0,1);
		rcx=GetX;
		rcy=GetY;
		}
	if(count>=250&&count%125==0){
		SetMovePositionRandom01(rand(5,150),rand(10,40),2,GetClipMinX()+100,100,GetClipMaxX()-100,175);
        		SetShotDirectionType(PLAYER);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1,0,0,0.01,5,BLUE03);
			let j=5;
			while(j<360)
			{
			angleA=rand(-15,15);
			angleB=rand(-15,15);
        		SetShotDirectionType(ABSOLUTE);
			let ta=1;
			CreateShotA(ta,angleA,angleB,10);
			SetShotDataA(ta,0,rand(0.5,1.5),rand(0,360),0,0,0,BLUE31);
			SetShotKillTime(ta,50);
			AddShot(j,shotA,ta,0);
			j++;
			}
			FireShot(shotA);
		}
	if(count>=600&&count%500==200){
		CreateEnemyFromScript("DOLL01",GetX,GetY,0,0,1);
		SetX(rand(100,348));
		SetY(rand(100,175));
		}
	if(count>=600&&count%500==201){
		rcx=GetX;
		rcy=GetY;
		}
	SetCollisionA(GetX(),GetY(),32);
        SetCollisionB(GetX(),GetY(),24);
        count++;
        yield;
        }

        @DrawLoop {
	if(DevilMotion==0){
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(0,128*Animation,127,127+128*Animation);}
		else if(GetSpeedX()>0){SetGraphicRect(256,384,383,511);}
		else if(GetSpeedX()<0){SetGraphicRect(256,128,383,255);}
		DrawGraphic(GetX(),GetY());
		}
	if(DevilMotion==1){
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetGraphicRect(640,128,767,255);
		DrawGraphic(GetX(),GetY());
		}
	}
        
        @Finalize
        {
        } 
	
    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			Animation=3;
        		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;

    @Initialize {
        SetX(GetEnemyX);
        SetY(GetEnemyY);
        SetLife(10);
        SetScore(0);
        SetDamageRateEx(0,0,25,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<=500&&count>=100&&count%25==0)
        	{
                SetShotDirectionType(PLAYER);
                angle=rand(-2,2);
        		let i = 0;
        		while( i < 24 )
        		{
        		let shot01 = 1;
        		SetShotDirectionType(PLAYER);
        		CreateShotA(shot01,GetX(),GetY(),0);
        		SetShotDataA(shot01,0,2,15*i,0,-0.01,1.5,GREEN04);
        		SetShotDataA(shot01,50,NULL,NULL,angle,0,1.5,GREEN04);
        		SetShotDataA(shot01,80,NULL,NULL,0,0,1.5,GREEN04);
        		FireShot(shot01);
        		i++;
        		}
        	}
		if(GetHitCount){
			SetShotDirectionType(ABSOLUTE);
        		let i = 0;
        		while( i < 3 )
        		{
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,6,rand(0,360),0,-0.2,0,PURPLE03);
			SetShotDirectionType(PLAYER);
			SetShotDataA(shotA,40,1,-30+30*i,0,0.1,8,PURPLE03);
			FireShot(shotA);
        		i++;
        		}
		}
        	if(count==500)
        	{
                VanishEnemy();
        	}
        SetCollisionA(GetX(),GetY(),10);
        count++;
        yield;
    }


        @DrawLoop {
		SetAlpha(imgAlpha);
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy);
		SetGraphicScale(2+0.02*Zoom,2+0.02*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
        {
        }
    	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;}
			}
		}
}