#e
#Title[up[tFNguCYv]
#Text[`m̃XyJ[h]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name    = "up[tFNguCYv";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_cirno.png";
	let imgEnemy=csd~"img\familiar2.png";
        let imgSPELL =csd~"img\SPELL_H4.png";
	let big=0;
	let imgAngle=0;
	let imgALP1=255;
	let imgALP2=0;
	let imgBACK=0;
	let imgBACK2=0;
	let retune=0;
	let angle=0;
	let angleA=0;
	let angleB=0;
	let angleC=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let shotseA = csd~"se\ShotSE02.wav";
	let shotseB = csd~"se\Powar.wav";

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);
        SetLife(10000);
        SetTimer(150);
        SetScore(1000000);
        SetDamageRate(100,0);
        SetInvincibility(200);
		SetX(cx);
		SetY(120);
	LoadGraphic(imgBoss);
	LoadGraphic(imgEnemy);
	LoadGraphic(imgSPELL);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime1;
        }

        @MainLoop
        {
	imgAngle+=5;
	if(imgAngle>=360){imgAngle=0;}
	if(retune==0&&big<99){big+=2;}
	if(retune==1&&big>1){big-=2;}
	imgBACK+=4;
	if(imgBACK==448){imgBACK=0;}
	imgBACK2+=2;
	if(imgBACK2==384){imgBACK2=0;}

	if(count>=50&&count%100==0){
        	retune=1;
		}
	if(count>=50&&count%100==50){
        	retune=0;
		}
        if(!OnBomb){
        SetCollisionB(GetX(),GetY(),18);
	SetCollisionA(GetX(),GetY(),18);
        imgALP2=255;
        imgALP1=100;
	SetDamageRate(100,0);
        SetEnemyMarker(true);}
        else {
        imgALP2=100;
        imgALP1=255;
	SetDamageRate(0,0);
	SetEnemyMarker(false);}

	if(count==150){
		PlaySE(shotseB);
		Concentration02(60);
        	}
	if(count>=200&&count%400==200){
		PlaySE(shotseB);
		angle=rand(0,360);
		let i=0;
		while(i<36){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,0.9,i*10+angle,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1,i*10+angle+2,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.1,i*10+angle+4,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.2,i*10+angle+6,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.3,i*10+angle+8,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.4,i*10+angle+10,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.5,i*10+angle+12,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			i=i+1;
			}
        	}

	if(count>=400&&count%400==0){
		PlaySE(shotseB);
		angle=rand(0,360);
		let i=0;
		while(i<36){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,0.9,i*10+angle,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1,i*10+angle-2,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.1,i*10+angle-4,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.2,i*10+angle-6,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.3,i*10+angle-8,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.4,i*10+angle-10,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.5,i*10+angle-12,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-1,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			i=i+1;
			}
        	}

	if(GetEnemyLife<6500||GetTimer<=40&&count>=400&&count%400==100){
		PlaySE(shotseB);
		angle=rand(0,360);
		let i=0;
		while(i<36){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,0.9,i*10+angle,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1,i*10+angle+2,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.1,i*10+angle+4,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.2,i*10+angle+6,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.3,i*10+angle+8,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.4,i*10+angle+10,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.5,i*10+angle+12,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			i=i+1;
			}
        	}

	if(GetEnemyLife<6500||GetTimer<=40&&count>=400&&count%400==300){
		PlaySE(shotseB);
		angle=rand(0,360);
		let i=0;
		while(i<36){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,0.9,i*10+angle,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1,i*10+angle-2,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.1,i*10+angle-4,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.2,i*10+angle-6,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.3,i*10+angle-8,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.4,i*10+angle-10,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.5,i*10+angle-12,0,0,0,54);
			SetShotDataA(shotA,50,NULL,NULL,-2,0,0,54);
			SetShotDataA(shotA,150,NULL,NULL,0,0,0,54);
			FireShot(shotA);
			i=i+1;
			}
        	}
	if(count>=250&&count%10==0){
		PlaySE(shotseA);
        	angleB=rand(-45,20);
        	angleC=rand(160,225);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX+cos(angleB)*15,GetY+sin(angleB)*15,5);
		SetShotDataA(shotA,0,2.5,angleB,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			let ta=1;
			CreateShotA(ta,rand(-5,5),rand(-5,5),10);
			SetShotDataA(ta,0,rand(1,2),angleA+rand(-10,10),0,0,0,56);
			AddShot(j,shotA,ta,0);
			j+=15;
			}
		FireShot(shotA);
		CreateShotA(shotA,GetX+cos(angleC)*15,GetY+sin(angleC)*15,5);
		SetShotDataA(shotA,0,2.5,angleC,0,0.01,5,56);
			let j=5;
			while(j<360)
			{
			let ta=1;
			CreateShotA(ta,rand(-5,5),rand(-5,5),10);
			SetShotDataA(ta,0,rand(1,2),-angleA+rand(-10,10),0,0,0,56);
			AddShot(j,shotA,ta,0);
			j+=15;
			}
		FireShot(shotA);
        	angleA-=11;
        	}
	if(GetEnemyLife<2500||GetTimer<=30&&count>=250&&count%100==90){
        	SetShotDirectionType(PLAYER);
		let i=0;
		while(i<18){
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),10);
			SetShotDataA(shotA,0,1,i*20,0,0,0,AQUA02);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),10);
			SetShotDataA(shotA,0,1.5,i*20,0,0,0,AQUA02);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),10);
			SetShotDataA(shotA,0,2,i*20,0,0,0,AQUA02);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),10);
			SetShotDataA(shotA,0,2.5,i*20,0,0,0,AQUA02);
			FireShot(shotA);
			i=i+1;
			}
        	}
        count++;
        yield;
        }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgEnemy);
		SetGraphicRect(0,0,192,192);
		SetAlpha(imgALP1);
		SetColor(0,0,255);
		SetGraphicScale(0.01*big,1);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());

		SetColor(0,0,255);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());

		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetAlpha(imgALP2);
		SetColor(imgALP2,imgALP2,imgALP2);
		SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);
		DrawGraphic(GetX(),GetY());
	}

	@BackGround
	{
		//wi`
		SetGraphicRect(0,0,384,448);
		SetTexture(imgSPELL);
		SetRenderState(ALPHA);
		SetColor(155,155,255);
		SetAlpha(200);
		SetGraphicScale(1,1);
		DrawGraphic(cx-384+imgBACK2,cy-448+imgBACK);
		DrawGraphic(cx-384+imgBACK2,cy+imgBACK);
		DrawGraphic(cx+imgBACK2,cy-448+imgBACK);
		DrawGraphic(cx+imgBACK2,cy+imgBACK);

		SetColor(255,255,255);
		SetAlpha(100);
		DrawGraphic(cx+384-imgBACK2,cy-448+imgBACK);
		DrawGraphic(cx+384-imgBACK2,cy+imgBACK);
		DrawGraphic(cx-imgBACK2,cy-448+imgBACK);
		DrawGraphic(cx-imgBACK2,cy+imgBACK);
	}
        
        @Finalize
        {
	loop(100)
	{
		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;}
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(10){yield;}
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=0;
			AnimationC=4;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
		}
}