#東方弾幕風
#Title[氷結奥義「コキュートススクウェア」]
#Text[チルノのスペルカード]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name    = " 氷結奥義「コキュートススクウェア」";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_cirno.png";
	let imgEnemy=csd~"img\familiar2.png";
	let imgEnemy2=csd~"img\familiar.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 Kousoku=false;
	let bigX=1;
	let bigY=1;
	let angle=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let BOMSE = csd~"se\BOM.wav";

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);
        SetLife(1);
        SetTimer(90);
        SetScore(1000000);
        SetDamageRate(0,0);
        SetDurableSpellCard;
	SetEffectForZeroLife(90,192,3);
        ForbidBomb(true);
        SetInvincibility(200);
        SetMovePosition02(cx,cy,60);
	LoadGraphic(imgBoss);
	LoadGraphic(imgEnemy);
	LoadGraphic(imgEnemy2);
	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&&Kousoku==false){
        imgALP2=255;
        imgALP1=100;
	SetDamageRate(0,0);
        SetEnemyMarker(true);}
        else {
        imgALP2=100;
        imgALP1=255;
	SetDamageRate(0,0);
	SetEnemyMarker(false);}

	if(count>=80&&count<=104){
		bigX+=0.04;
		bigY-=0.04;
        	}
	if(count>=105&&count<=129){
		bigX-=0.04;
		bigY+=0.04;
        	}
	if(count==105){
		Kousoku=true;
        	}

	if(count==200){
		angle=rand(0,360);
		let i=0;
		while(i<6){CreateEnemyFromScript("EnemyA",GetX,GetY,0,i*60+angle,1);
			i++;}
        	}

	if(count==700){
		angle=rand(0,360);
		let i=0;
		while(i<6){CreateEnemyFromScript("EnemyA",GetX,GetY,0,i*60+angle,1);
			i++;}
		let i=0;
		while(i<3){CreateEnemyFromScript("EnemyB",GetX,GetY,0,i*120+angle+30,1);
			i++;}
        	}

	if(count==1300){
		angle=rand(0,360);
		let i=0;
		while(i<4){CreateEnemyFromScript("EnemyC",GetX,GetY,0,i*90+angle,1);
			i++;}
        	}

	if(count==1900){
		angle=rand(0,360);
		let i=0;
		while(i<3){CreateEnemyFromScript("EnemyC",GetX,GetY,0,i*120+angle,1);
			i++;}
        	}
	if(count==1920){
		let i=0;
		while(i<4){CreateEnemyFromScript("EnemyB",GetX,GetY,0,i*90+angle,1);
			i++;}
        	}

	if(count==2600){
		let i=0;
		while(i<2){CreateEnemyFromScript("EnemyD",GetX,GetY,0,i*180,1);
			i++;}
        	}

	if(count==3800){
		let i=0;
		while(i<4){CreateEnemyFromScript("EnemyE",GetX,GetY,0,i*90,1);
			i++;}
        	}
	if(count==3820){
		let i=0;
		while(i<5){CreateEnemyFromScript("EnemyE",GetX,GetY,0,i*72,1);
			i++;}
        	}
	if(count==3840){
		let i=0;
		while(i<6){CreateEnemyFromScript("EnemyE",GetX,GetY,0,i*60,1);
			i++;}
        	}
        if(GetTimer<=15&&GetTimer>=5&&count%45==0)
        	{
        	SetShotDirectionType(PLAYER);
			let i=0;
			while(i<36)
			{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2,i*10,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());

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

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

	@BackGround
	{
		//背景描画
		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
        {
	PlaySE(BOMSE);
        } 
	
    	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;}
		}
}

script_enemy EnemyA
{//
	let count=0;
	let imgAngle=0;
	let Zoom=0;
	let angle=GetAngle;
	let angleA=GetAngle-180;
        let n = 0;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy2=csd~"img\familiar.png";
	let shotseA = csd~"se\ShotSE01.wav";

	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}
		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count<=100||count>=300)
        	{
		n+=2;
        	}

		SetMovePosition02(GetEnemyX+cos(angle)*n,GetEnemyY+sin(angle)*n,10);
        	angle+=5;

        	if(count>=100&&count<=300)
        	{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,5);
		SetShotDataA(shotA,0,0.5,angle,0,0.01,1,BLUE21);
		FireShot(shotA);
        	}

        	if(count>=100&&count<=300&&count%10==0)
        	{
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,0);
		SetShotDataA(shotA,0,2.5,angleA,0,0,0,BLUE01);
		SetShotDataA(shotA,50,0,NULL,0,0,0,BLUE01);
		SetShotDataA(shotA,360-count,0,NULL,0,0.005,2,54);
		FireShot(shotA);
		angleA+=2;
        	}
        	if(count>=100&&count<=302&&count%10==2)
        	{
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,0);
		SetShotDataA(shotA,0,2,angleA,0,0,0,BLUE01);
		SetShotDataA(shotA,50,0,NULL,0,0,0,BLUE01);
		SetShotDataA(shotA,360-count,0,NULL,0,0.005,2,54);
		FireShot(shotA);
		angleA+=2;
        	}
        	if(count>=100&&count<=304&&count%10==4)
        	{
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,0);
		SetShotDataA(shotA,0,1.5,angleA,0,0,0,BLUE01);
		SetShotDataA(shotA,50,0,NULL,0,0,0,BLUE01);
		SetShotDataA(shotA,360-count,0,NULL,0,0.005,2,54);
		FireShot(shotA);
		angleA+=2;
        	}

        	if(GetX<-20||GetX>468||GetY<-20||GetY>500)
        	{
        		VanishEnemy();
        	}
		count++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
	}
	
	@DrawLoop
	{//描画
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy2);
		SetGraphicScale(Zoom,Zoom);
		SetColor(0,0,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}

script_enemy EnemyB
{//
	let count=0;
	let imgAngle=0;
	let Zoom=0;
	let angle=GetAngle;
	let angleA=GetAngle-180;
        let n = 0;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy2=csd~"img\familiar.png";
	let shotseA = csd~"se\ShotSE01.wav";

	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}
		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count<=100||count>=300)
        	{
		n+=2;
        	}

		SetMovePosition02(GetEnemyX+cos(angle)*n,GetEnemyY+sin(angle)*n,10);
        	angle-=2.5;

        	if(count>=100&&count<=300)
        	{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,5);
		SetShotDataA(shotA,0,0.5,angle,0,0.01,2,AQUA21);
		FireShot(shotA);
        	}

        	if(count>=100&&count<=300&&count%20==0)
        	{
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,0);
		SetShotDataA(shotA,0,2.5,angleA,0,0,0,AQUA02);
		SetShotDataA(shotA,50,0,NULL,0,0,0,AQUA02);
        	SetShotDirectionType(PLAYER);
		SetShotDataA(shotA,360-count,0,0,0,0.02,2,AQUA02);
		FireShot(shotA);
		angleA+=5;
        	}

        	if(GetX<-20||GetX>468||GetY<-20||GetY>500)
        	{
        		VanishEnemy();
        	}
		count++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
	}
	
	@DrawLoop
	{//描画
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy2);
		SetGraphicScale(Zoom,Zoom);
		SetColor(0,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}

script_enemy EnemyC
{//
	let count=0;
	let imgAngle=0;
	let Zoom=0;
	let angle=GetAngle;
	let angleA=GetAngle-180;
        let n = 0;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy2=csd~"img\familiar.png";
	let shotseA = csd~"se\ShotSE01.wav";

	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}
		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count<=100||count>=300)
        	{
		n+=2;
        	}

		SetMovePosition02(GetEnemyX+cos(angle)*n,GetEnemyY+sin(angle)*n,10);
        	angle+=2.5;

        	if(count>=100&&count<=300)
        	{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,5);
		SetShotDataA(shotA,0,0.5,angle,0,0.01,2,AQUA21);
		FireShot(shotA);
        	}

        	if(count>=100&&count<=300&&count%10==0)
        	{
        	SetShotDirectionType(ABSOLUTE);
			let i=0;
			while(i<4)
			{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2.5,angleA,0,0,0,WHITE01);
			SetShotDataA(shotA,50,0,NULL,0,0,0,WHITE01);
			SetShotDataA(shotA,360-count,0,i*90,0,0.01,1,56);
			FireShot(shotA);
			i=i+1;
			}
        	}
        	if(count>=100&&count<=301&&count%10==1)
        	{
        	SetShotDirectionType(ABSOLUTE);
			let i=0;
			while(i<4)
			{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2.5,angleA,0,0,0,WHITE01);
			SetShotDataA(shotA,50,0,NULL,0,0,0,WHITE01);
			SetShotDataA(shotA,360-count,0,i*90,0,0.01,1,56);
			FireShot(shotA);
			i=i+1;
			}
        	}
        	if(count>=100&&count<=302&&count%10==2)
        	{
        	SetShotDirectionType(ABSOLUTE);
			let i=0;
			while(i<4)
			{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2.5,angleA,0,0,0,WHITE01);
			SetShotDataA(shotA,50,0,NULL,0,0,0,WHITE01);
			SetShotDataA(shotA,360-count,0,i*90,0,0.01,1,56);
			FireShot(shotA);
			i=i+1;
			}
		angleA+=5;
        	}

        	if(GetX<-20||GetX>468||GetY<-20||GetY>500)
        	{
        		VanishEnemy();
        	}
		count++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
	}
	
	@DrawLoop
	{//描画
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy2);
		SetGraphicScale(Zoom,Zoom);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}

script_enemy EnemyD
{//
	let count=0;
	let imgAngle=0;
	let Zoom=0;
	let angle=GetAngle;
	let angleA=GetAngle-180;
        let n = 0;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy2=csd~"img\familiar.png";
	let shotseA = csd~"se\ShotSE01.wav";

	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}
		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count<=100||count>=300)
        	{
		n+=1;
        	}

		SetMovePosition02(GetEnemyX+cos(angle)*n,GetEnemyY+sin(angle)*n,10);
        	angle+=2.5;

        	if(count>=100&&count<=500)
        	{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,5);
		SetShotDataA(shotA,0,0.5,angle,0,0.01,2,AQUA21);
		FireShot(shotA);
        	}

        	if(count>=100&&count<=500&&count%10==0)
        	{
        	SetShotDirectionType(ABSOLUTE);
			let i=0;
			while(i<6)
			{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,1.5,angleA,0,0,0,WHITE01);
			SetShotDataA(shotA,50,0,NULL,0,0,0,WHITE01);
			SetShotDataA(shotA,400,0,i*60,0,0.005,4,56);
			FireShot(shotA);
			i=i+1;
			}
		angleA+=2;
        	}

        	if(GetX<-20||GetX>468||GetY<-20||GetY>500)
        	{
        		VanishEnemy();
        	}
		count++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
	}
	
	@DrawLoop
	{//描画
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy2);
		SetGraphicScale(Zoom,Zoom);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}



script_enemy EnemyE
{//
	let count=0;
	let imgAngle=0;
	let Zoom=0;
	let angle=GetAngle;
	let angleA=GetAngle-180;
        let n = 0;
	let csd     = GetCurrentScriptDirectory;
	let imgEnemy2=csd~"img\familiar.png";
	let shotseA = csd~"se\ShotSE01.wav";

	@Initialize
	{
		SetLife(30);
		SetX(GetEnemyX);
		SetY(GetEnemyY);
	}
	
	@MainLoop
	{
		imgAngle+=4;
		if(imgAngle>360){imgAngle=0;}
		Zoom+=0.02;
		if(Zoom>1){Zoom=1;}

        	if(count<=100||count>=250)
        	{
		n+=1;
        	}

		SetMovePosition02(GetEnemyX+cos(angle)*n,GetEnemyY+sin(angle)*n,10);
        	angle+=2.5;

        	if(count>=50&&count<=400&&count%5==0)
        	{
		PlaySE(shotseA);
        	SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX+rand(-20,20),GetY+rand(-20,20),100);
		SetShotDataA(shotA,0,0,angle-180,0,0.001,1,53);
		FireShot(shotA);
        	}

        	if(GetX<-20||GetX>468||GetY<-20||GetY>500)
        	{
        		VanishEnemy();
        	}
		count++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
	}
	
	@DrawLoop
	{//描画
		SetGraphicRect(0,0,47,47);
		SetTexture(imgEnemy2);
		SetGraphicScale(Zoom,Zoom);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());
	}
}