
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=300;
		SetLife(1);
		SetTimer(13);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(0,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	
	task MainThread_Advanced
	{
		yield;
		SetSpellCard("鬼神「十羅刹女の六十鍵」",34);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		local
		{
			let bx=cenX+rand(-90,90);
			let by=cenY+90+rand(-60,120);
			let way=30;
			ascent(a in 0..way)
			{
				SetShot(bx,by,(360/way)*a,r);
				r=-r;
			}
			
			SetMovePositionHermite(cenX+rand(-90,90),minY+rand(120,150),0,0,0,0,200);
			SetAction(ACT_MOVE,200);
			SetRoll(200);
			wait(30);
			let wide=120;
			let lp=0;
			loop(3)
			{
				local
				{
					if(lp==2){Signal(0);wait(40);}
					
					let leng=100;
					let way=9;
					let angle=0;
					while(angle<360)
					{
						let sx=GetX+leng*cos(angle);
						let sy=GetY+leng*sin(angle);
						if(wide>1)
						{
							let ag=-wide/2;
							while(ag<=wide/2+1)
							{
								LineShot(sx,sy,ag);
								ag+=wide;
							}
						}
						else
						{
							LineShot(sx,sy,0);
						}
						angle+=360/way;
					}
				}
				wide-=60;
				lp++;
				
				task Signal(let ag)
				{
					local
					{
						let leng=0;
						let p=atan2(by-GetY,bx-GetX)+ag;
						while(leng<=500)
						{
							let sx=GetGapX(GetX,leng,p);
							let sy=GetGapY(GetY,leng,p);
							SetTargeting(sx,sy,0.3,60,2);
							leng+=70;
							wait(2);
						}
					}
				}
				
				task LineShot(let cx,let cy,let ag)
				{
					let leng=0;
					let p=atan2(by-cy,bx-cx)+ag;
					while(leng<=500)
					{
						let sx=GetGapX(cx,leng,p);
						let sy=GetGapY(cy,leng,p);
						let speed=2;
						let angle=p;
						let gra=177;
						let delay=5;
						let limit=60;
						CreateShotA(1,sx,sy,delay);
						SetShotDataA(1,0,0,angle,0,0,0,gra);
						SetShotDataA(1,limit,NULL,NULL,0,speed/150,speed,gra);
						FireShot(1);
						leng+=20;
						wait(1);
					}
				}
				wait(60);
			}
			wait(180);
			let bx=cenX+rand(-90,90);
			let by=cenY+90+rand(0,120);
			let way=30;
			ascent(a in 0..way)
			{
				SetShot(bx,by,(360/way)*a,r);
				r=-r;
			}
			
			SetAction(ACT_SHOT_B,300);
			local
			{
				let wide=0;
				let way=1;
				let p=atan2(by-GetY,bx-GetX);
				let sp=0;
				loop
				{
					let ag=p;
					while(ag<p+360)
					{
						let speed=2.5+sp;
						let gra=27;
						let delay=10;
						if(wide==0)
						{
							let angle=ag;
							CreateShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
						}
						else
						{
							let angle=ag-wide/2;
							while(angle<=ag+wide/2+0.1)
							{
								CreateShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
								angle+=wide/(way-1);
							}
						}
						ag+=360/2;
					}
					wide+=11;
					way++;
					sp+=0.19;
					wait(7);
				}
			}
		}
		
		task SetShot(let bx,let by,let rot,let r)
		{
			let leng=400;
			let endflg=false;
			let sx=bx+leng*cos(rot);
			let sy=by+leng*sin(rot);
			State;
			
			while(!endflg)
			{
				local
				{
					let p=rot+90*r;
					let speed=4;
					let angle=p;
					let gra=105;
					let delay=5;
					
					CreateShot01(sx,sy,speed,angle,gra,delay);
				}
				
				local
				{
					let p=rot+160*r;
					let wide=100;
					let speed=6;
					let angle=p-wide/2;
					let gra=57;
					let delay=5;
					while(angle<=p+wide/2+1)
					{
						CreateShot02(sx,sy,0,angle,speed/90,speed,gra,delay);
						angle+=wide;
					}
				}
				wait(1);
			}
			task State
			{
				while(!endflg)
				{
					sx=bx+leng*cos(rot);
					sy=by+leng*sin(rot);
					leng-=2;
					if(leng<60){endflg=true;}
					rot+=2.5*r;
					yield;
				}
			}
		}
	}
	
	task MainThread_Unlimited{}
	
}