
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Ran_AnimeLib.txt";
	
	tex_enemy=filedir~"Ran_Main.png";
	tex_spellbg=filedir~"Ran_SpellBG.png";
	
	bg_rect=[0,0,512,512];
	
	@Initialize
	{
		point=520;
		SetLife(1500);
		SetTimer(70);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+160,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetRoll(100);
		SetSpellCard("封霊「幻神空弧招来」",43);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			
			let lp=0;
			loop(2)
			{
				let way=20;
				let wide=8;
				
				let p=rand(0,360);
				
				let speed=[3,4];
				let gra=[146,148];
				let delay=10;
				
				let ag=p;
				while(ag<p+360)
				{
					let v=30;
					let agB=ag-wide/2;
					while(agB<=ag+wide/2+1)
					{
						let sx=GetX+v*cos(agB);
						let sy=GetY+v*sin(agB);
						let angle=agB+90*r;
						CreateShot02(sx,sy,0,angle,speed[lp%length(speed)]/60,speed[lp%length(speed)],gra[lp%length(gra)],delay);
						agB+=2;
					}
					ag+=360/way;
				}
				wait(10);
				lp++;
				r=-r;
			}
			wait(40);
			SetAction(ACT_SHOT_A,400);
			let lp=0;
			loop(7)
			{
				let sx=GetX+80*r;
				let sy=GetY-20;
				let i=atan2(GetPlayerY-sy,GetPlayerX-sx)-80*r;
				let ip=28*r;
				loop(9)
				{
					let wide=16;
					let way=16;
					let speed=3.5;
					let angle=i-wide/2;
					let gra=[146,147];
					let delay=10;
					while(angle<=i+wide/2)
					{
						CreateShot01(sx,sy,speed,angle,gra[lp%2],delay);
						angle+=wide/(way-1);
					}
					
					let wide=6;
					let speed=1.4;
					let angle=i+ip/2-wide/2;
					while(angle<=i+ip/2+wide/2+0.1)
					{
						CreateShot01(sx,sy,speed,angle,gra[lp%2],delay);
						angle+=2;
					}
					
					let angle=i;
					let gra=[82,83];
					let speed=3.3;
					while(speed>=1.4)
					{
						CreateShot01(sx,sy,speed,angle,gra[lp%2],delay);
						speed=speed/1.1;
					}
					wait(4);
					i+=ip;
				}
				wait(30);
				lp++;
				r=-r;
			}
			wait(70);
			SetMovePositionHermite(cenX+rand(-50,50),minY+rand(150,170),0,0,0,0,60);
			SetAction(ACT_MOVE,60);
			SetRoll(60);
			let leng=0;
			let i=0;
			let sp=0;
			loop(60)
			{
				let wide=[80,110];
				let sx=GetX+leng*cos(i);
				let sy=GetY+leng*sin(i);
				let speed=[3+sp,2,6];
				let ag=atan2(GetPlayerY-sy,GetPlayerX-sx);
				let angle=ag-wide[0]/2;
				let gra=107;
				let delay=10;
				while(angle<=ag+wide[0]/2)
				{
				
					CreateShotA(1,sx,sy,delay);
					SetShotDataA(1,0,speed[0],angle,0,0,0,gra);
					let graB=106;
					let adtime=45;
					let angleA=angle+180-wide[1]/2;
					while(angleA<=angle+180+wide[1]/2)
					{
						CreateShotA(2,0,0,delay);
						SetShotDataA(2,0,speed[1],angleA,0,speed[2]/40,speed[2],graB);
						AddShot(adtime,1,2,0);
						angleA+=wide[1];
					}
					FireShot(1);
					angle+=wide[0]/2;
				}
				leng+=2;
				i+=5;
				sp+=0.08;
				wait(1);
			}
			wait(20);
		}
	}
	task MainThread_Unlimited{}
	
}