
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=360;
		SetLife(1200);
		SetTimer(60);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,cenY,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetRoll(100);
		SetSpellCard("天支「太乙神数の天盤」",28);
		wait(120);
		Sub;
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_B,780);
			let i=rand(0,360);
			let leng=[30,120,210];
			let w=2;
			loop(2)
			{
				local
				{
					let ag=i;
					while(ag<i+360-1)
					{
						ascent(a in 0..length(leng))
						{
							let sx=GetX+leng[a]*cos(ag);
							let sy=GetY+leng[a]*sin(ag);
							SetTargeting(sx,sy,0.3,60,1);
						}
						ag+=360/w;
					}
					wait(60);
				}
				
				let lp=0;
				let ip=2;
				let L=ceil(720/w/ip);
				let g=0;
				loop(L)
				{
					ascent(a in 0..length(leng))
					{
						let way=1;
						let ag=i;
						while(ag<i+360-1)
						{
							let sx=GetX+leng[a]*cos(ag);
							let sy=GetY+leng[a]*sin(ag);
							let speed=[1.5,0.5];
							let p=atan2(GetY-sy,GetX-sx)+(360/2)*g;
							let angle=p;
							let gra=[87,88];
							let delay=9;
							while(angle<p+360)
							{
								CreateShot01(sx,sy,speed[g%length(speed)],angle,gra[g%length(gra)],delay);
								angle+=360/way;
							}
							g++;
							ag+=360/w;
						}
					}
					lp++;
					if(lp>L/8){g++;lp=0;}
					i+=ip*r;
					wait(2);
				}
				i+=90*r;
				wait(60);
				r=-r;
			}
			wait(60);
		}
		
		task Sub
		{
			wait(480);
			loop
			{
				let p=GetAngleToPlayer;
				
				loop(6)
				{
					let way=3;
					
					let speed=3;
					let angle=p;
					let gra=41;
					let delay=10;
					while(angle<p+360)
					{
						CreateShot01(GetX,GetY,speed,angle,gra,delay);
						angle+=360/way;
					}
					wait(5);
				}
				wait(100);
			}
		}
	}
	task MainThread_Unlimited{}
	
}