
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Yuka_AnimeLib.txt";
	
	tex_enemy=filedir~"Yuka_Main.png";
	tex_spellbg=filedir~"Yuka_SpellBG.png";
	
	bg_rect=[0,0,768,512];
	
	@Initialize
	{
		point=420;
		SetLife(900);
		SetTimer(49);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+100,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("月下「一輪華」",21);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		SetAction(ACT_SHOT_B,60*60);
		Sub;
		loop
		{
			let way=3;
			let i=rand_int(0,360);
			let lp=rand_int(0,360);
			loop(180)
			{
				
				let ag=[i,-i];
				let ap=[-170*r,170*r];
				ascent(a in 0..2)
				{
					let speed=[3+1*cos(lp),3+1*sin(lp+180)];
					let angle=ag[a];
					let gra=[82,85];
					let delay=10;
					
					while(angle<ag[a]+360)
					{
						let v=90;
						let sx=GetX+v*cos(angle);
						let sy=(GetY+25)+v*sin(angle);
						let spd=[speed[a],speed[a]/0.95];
						ascent(b in 0..length(spd))
						{
							CreateShot01(sx,sy,spd[b],angle+ap[a],gra[a],delay);
						}
						angle+=360/way;
					}
				}
				lp++;
				i+=4.1*r;
				wait(3);
			}
			r=-r;
		}
		task Sub
		{
			wait(90);
			let lp=0;
			loop
			{
				let wide=2;
				let way=21;
				
				let p=[GetAngleToPlayer,GetAngleToPlayer+180];
				let speed=2;
				let ag=p[lp%length(p)];
				let gra=[25,30];
				let graB=[33,38];
				let delay=15;
				while(ag<p[lp%length(p)]+360)
				{
					let angle=ag-wide/2;
					while(angle<=ag+wide/2+0.1)
					{
						CreateShot02(GetX,GetY+25,0,angle,speed/100,speed,gra[lp%length(gra)],delay);
						angle+=1;
					}
					CreateShot02(GetX,GetY+25,0,ag+(360/way)/2,speed/100,speed,graB[lp%length(gra)],delay);
					ag+=360/way;
				}
				wait(120);
				lp++;
			}
		}
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+90,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("乱花「百花繚乱」",22);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let i=0;
		let cnt=0;
		let random=rand(0,360);
		SetAction(ACT_SHOT_B,60*60);
		loop
		{
			let way=3;
			
			let ag=[random-i,random+i];
			let angle=0;
			let gra=[87,83];
			let delay=10;
			while(angle<360)
			{
				let v=0.7;
				ascent(a in 0..2)
				{
					let speed=[2+v*cos(cnt),2+v*cos(cnt+180)];
					CreateShot02(GetX,GetY+20,0,angle+ag[a],speed[a]/60,speed[a],gra[a],delay);
				}
				angle+=360/way;
			}
			i+=30.2*r;
			cnt+=3;
			wait(1);
		}
	}
	
	
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+130,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("幻花「花鳥風月」",23);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,90);
			let lp=0;
			loop(2)
			{
				let way=[20,24];
				let limit=120;
				let leng=50;
				let p=rand(0,360);
				let speed=[3.5,2];
				let sch=1*r;
				let angle=p;
				let gra=[139,140];
				let delay=30;
				while(angle<p+360)
				{
					let sx=GetX+leng*cos(angle);
					let sy=GetY+leng*sin(angle);
					CreateShotA(1,sx,sy,delay);
					SetShotDataA(1,0,0,angle-90*r,sch,speed[lp%length(speed)]/limit,speed[lp%length(speed)],gra[lp%length(gra)]);
					SetShotDataA(1,limit,NULL,NULL,0,0.02,1000,NULL);
					let i=0;
					let count=0;
					let sp=0;
					while(count<limit+150)
					{
						let rd=1;
						let speedB=2-sp;
						let angleB=(angle+90*r)+i+rand(-rd,rd);
						let graB=[67,68];
						let delayB=10;
						CreateShotA(2,0,0,delayB);
						SetShotDataA(2,0,0,angleB,0,speedB/200,speedB,graB[lp%length(gra)]);
						AddShot(count,1,2,0);
						if(count<limit){i+=sch*4;}
						count+=4;
						sp+=0.02;
					}
					FireShot(1);
					angle+=360/way[lp];
				}
				wait(10);
				r=-r;
				lp++;
			}
			let next=0;
			loop(240)
			{
				yield;
				if(GetEnemyShotCount<10){next=1;break;}
			}
			if(!next)
			{
				SetMove(cenX+rand(-100,100),minY+rand(120,135),140);
				loop(250){yield;if(GetEnemyShotCount<10){break;}}
			}
			r=-r;
		}
	}
	
}
