#Title[pu_[NlXNXv]
#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 name    = "pu_[NlXNXv";
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
        let angle = 0;
	let Motion=0;
	let j=0;
        let imgSPELL =csd~"img\SPELL_H.png";
        let imgAngle2 = 0;
	let shotseA = csd~"se\ShotSE01.wav";
	let shotseB = csd~"se\Powar.wav";

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

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

        SetShotDirectionType(ABSOLUTE);

        SetInvincibility(0);
        SetMovePosition02(cx,150,60);
	LoadGraphic(imgBoss);
	LoadGraphic(imgSPELL);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime1;
    }

        @MainLoop
        {
	imgAngle2++;
	if(imgAngle2>360){imgAngle2=0;}
	if(count==150){
		Motion=1;
		Concentration01(60);
        	SetDamageRate(20,10);
		}
	if(count==200){
		Motion=0;
		j=0;
		angle=GetAngleToPlayer;
        	SetDamageRate(100,50);
		}
	if(count>=200&&count<=250&&count%2==0){
		PlaySE(shotseA);
		let i=0;
		while(i<4)
		{
        	let shot01 = 1;
        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle+90,0,0.01,1,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle,0,0.01,1,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-90,0,0.01,1,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-180,0,0.01,1,51);
        	FireShot(shot01);

        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle+90,0,0.02,2,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle,0,0.02,2,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-90,0,0.02,2,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-180,0,0.02,2,51);
        	FireShot(shot01);

        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle+90,0,0.03,3,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle,0,0.03,3,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-90,0,0.03,3,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-180,0,0.03,3,51);
        	FireShot(shot01);

        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle+90,0,0.04,4,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*j,GetY+sin(i*90+angle)*j,10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle,0,0.04,4,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-90,0,0.04,4,51);
        	FireShot(shot01);
        	CreateShotA(shot01,GetX+cos(i*90+angle)*(20+j),GetY+sin(i*90+angle)*(20+j),10);
        	SetShotDataA(shot01,0,0,i*90+angle,0,0,0,51);
        	SetShotDataA(shot01,300-count,0,angle-180,0,0.04,4,51);
        	FireShot(shot01);
		i++;
		}
		j=j+40;
		}
	if(count==300){
		PlaySE(shotseB);
		}
	if(count>=400&&count%400==0){
		TAnime2;
		SetMovePositionRandom01(rand(5,150),rand(10,40),2,GetClipMinX()+100,100,GetClipMaxX()-100,175);
		}
	if(count>=470){
		count=199;
		}
	SetCollisionA(GetX(),GetY(),18);
        SetCollisionB(GetX(),GetY(),18);
        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(25)
	{
		angle=rand(0,360);
		CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,50),GetY+sin(angle)*rand(35,50));
	}
		CreateItem(ITEM_1UP,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;}
		}
}