#TouhouDanmakufu
#Title[YukaN3_H]
#Text[YukaN3_H]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]

script_enemy_main {

	#include_function ".\Yukainclude.txt";
	let i = 0;
	let onee = 1;
	let anim3 = 0;
	let one = 1;
	@Initialize{
	shotinit;
	LoadSE(time1);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(charge);
	LoadSE(familiarspawn);
	InitializeAction;
	SetLife(6000);
	LoadSE(shot);
	DelayedStart;
	LoadSE(shot2);
	Clouds;
	LoadSE(die);
	SetTimer(48);
	SetEnemyMarker(true);
	SetInvincibility(240);
	SetDamageRate(282, 75);
	SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(20, 20, 20, 20);
	LoadGraphic(SP);
	LoadGraphic(MC);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadSE(shot4);
	LoadSE(die);
	LoadGraphic(Cut);
	LoadSE(orb);
	LoadSE(warp);
	LoadSE(caution);
	LoadSE(border);
	SetAction(ACT_MOVE, 60);
	}


task Shrink{
loop(30){
scale-=1/30;
wait(1);
}
}

task Grow{
loop(30){
scale+=1/30;
wait(1);
}
}

task Clouds{
wait(30);
loop{
if(scale<1){
	if(!OnPlayerMissed){
loop(3){
		CreateShotA(1, GetX+rand(-20, 20), GetY+rand(-25, 25), 15);
		SetShotDataA(1, 0, rand(0, 0.5), rand(260, 270), 0, 0, 0, BLUE03);
		SetShotKillTime(1, 0); 
		FireShot(1);
		}
}
}

wait(1);
}
}

task DelayedStart {
wait(60);
//SetScore(275000);
//PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
//cutin("Flower Sign "\""Shedding Petals on a Sunlit Garden"\", Cut, 0, 0, 256, 512);
//SetAction(ACT_SPELL, 90);
//attack2;
attack1;
}

	let backRED = 255;
	let backGREEN = 255;
	let backBLUE = 255;


task attack1 {
wait(30);
let radius = 20;
SetCommonData("lastattack", false);
SetAction(ACT_SHOT_B, 10000);
wait(20);
loop{

ascent(j in 4..14){
//PlaySE(shot4);
angle+=360/6/3;
ascent(i in -3..3+ceil(j/3)){
loop(6){
	if(one==1){
CreateShotA(1, (GetX-2)+radius*cos(angle+(i*2.5+j*one)), (GetY+10)+radius*sin(angle+(i*2.5+j*one)), 10);
SetShotDataA(1, 0, 2.3+(i/5)-(j/10.8), angle+(i*2.5+j*one), 0, 0, 5, [BLUE01, PURPLE01, GREEN01][j%3]);
FireShot(1);
CreateShotA(1, (GetX-2)+radius*cos(angle+(i*2.5+j*one)), (GetY+10)+radius*sin(angle+(i*2.5+j*one)), 10);
SetShotDataA(1, 0, 2.3+(i/5)-(j/10.8), angle-(i*2.5+j*one), 0, 0, 5, [BLUE01, PURPLE01, GREEN01][j%3]);
FireShot(1);
	}
	if(one==-1){
	CreateShotA(1, (GetX-2)+radius*cos(angle+(i*2.5+j*one)), (GetY+10)+radius*sin(angle+(i*2.5+j*one)), 10);
SetShotDataA(1, 0, 2.3+(i/5)-(j/10.8), angle+(i*2.5), 0, 0, 5, [BLUE01, PURPLE01, GREEN01][j%3]);
FireShot(1);
CreateShotA(1, (GetX-2)+radius*cos(angle+(i*2.5+j*one)), (GetY+10)+radius*sin(angle+(i*2.5+j*one)), 10);
SetShotDataA(1, 0, 2.3+(i/5)-(j/10.8), angle-(i*2.5), 0, 0, 5, [BLUE01, PURPLE01, GREEN01][j%3]);
FireShot(1);
	}
angle+=360/6;
}
wait(1);
}
wait(12);
radius-=20/14;
}
SetAction(ACT_TURN, 120);
wait(15);
Shrink;
wait(30);
hurtbox = false;
one*=-1;
ExMove2;
radius = 20;
loop(6){
PlaySE(shot);
	ascent(i in -3..3){
		ascent(p in 0..5){
CreateShot02(GetX, GetY, 5, GetAngleToPlayer+(i*13)+(6.5), -0.075, 2.5+(p/1.25), BLUE51, 10);
}
} 
wait(15);
}


wait(10);
Grow;
SetAction(ACT_TURN, 120);
wait(60);
hurtbox = true;
SetAction(ACT_SHOT_B, 10000);
wait(20);
}
}


	task attack2 {
		let w = 60;
		wait(w);
		loop(w){
			backGREEN-=255/w;
			backBLUE-=255/w;
			wait(1);
		}
		loop{
			loop(w){
				backGREEN+=128/w;
				wait(1);
			}
			loop(w){
				backGREEN+=127/w;
				wait(1);
			}
			loop(w){
				backRED-=255/w;
				wait(1);
			}
			loop(w){
				backBLUE+=255/w;
				wait(1);
			}
			loop(w){
				backGREEN-=255/w;
				wait(1);
			}
			loop(w){
				backRED+=255/w;
				wait(1);
			}
			loop(w){
				backBLUE-=255/w;
				wait(1);
			}
		}
	}




@BackGround{
SetTexture(CBG1);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetGraphicScale(1, 1);
SetColor(backRED/3, backGREEN/3, backBLUE/3);
SetGraphicRect(0, 0+(anim2*5), 512, 512+(anim2*5));
SetAlpha(255);
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG2);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetColor(255, 255, 255);
SetGraphicScale(1, 1);
SetGraphicRect(0, 0-(anim2*4), 512, 512-(anim2*4));
SetAlpha(60);
DrawGraphic(GetCenterX, GetCenterY);

i+=1; i%=360;
anim2 += 1;
acc1 = 6;


}




	
}