
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(600);
		SetTimer(50);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetRoll(100);
		SetSpellCard("天炎「仙弧不知火」",37);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,120);
			let max=5;
			let mx=[];
			let my=[];
			ascent(a in 0..max)
			{
				mx=mx~[cenX+rand(-150,150)];
				my=my~[cenY+rand(-120,120)];
			}

			T_Site;
			task T_Site
			{
				ascent(a in 0..max)
				{
					SetTargeting(mx[a],my[a],0.3,150,1);
					wait(10);
				}
				mx=mx~[GetPlayerX];
				my=my~[GetPlayerY];
				SetTargeting(mx[max],my[max],0.5,150,0);
			}
			wait(90);
			ascent(a in 0..max)
			{
				let wt=ceil(GetGapLength(mx[a],my[a],GetX,GetY)/20);
				SetMovePositionHermite(mx[a],my[a],0,0,0,0,wt);
				SetAction(ACT_MOVE,wt);
				SetRoll(wt);
				wait(wt);
				
				local
				{
					let p=rand(0,360);
					let way=20;
					let speed=2;
					let angle=p;
					let gra=113;
					let delay=5;
					while(angle<p+360)
					{
						SetShotDirectionType(ABSOLUTE);
						
						let cnt=60;
						CreateShotA(1,GetX,GetY,delay);
						SetShotDataA(1,0,speed,angle,0,-speed/cnt,0,gra);
						local
						{
							let ag=angle+150*r;
							local
							{
								let speedB=1;
								CreateShotA(2,0,0,delay);
								SetShotDataA(2,0,0,ag,0,speedB/60,speedB,gra);
								AddShot(cnt,1,2,0);
							}
							local
							{
								SetShotDirectionType(PLAYER);
								CreateShotA(2,0,0,delay);
								SetShotDataA(2,0,0,0,0,speed/60,speed,gra+8);
								AddShot(cnt,1,2,0);
							}
						}
						SetShotKillTime(1,cnt+1);
						FireShot(1);
						SetShotDirectionType(ABSOLUTE);
						angle+=360/way;
					}
				}
				wait(1);
				r=-r;
			}
			let wt=ceil(GetGapLength(mx[max],my[max],GetX,GetY)/20);
			SetMovePositionHermite(mx[max],my[max],0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			SetRoll(wt);
			wait(wt);
			local
			{
				let way=15;
				let p=atan2(GetPlayerY-GetY,GetPlayerX-GetX);
				let speed=5.5;
				let speedB=1.8;
				let gra=129;
				let delay=10;
				let angle=p;
				while(angle<p+360)
				{
					CreateShotA(1,GetX,GetY,delay);
					SetShotDataA(1,0,0,angle,0,speed/60,speed,gra);
					let cnt=10;
					while(cnt<160)
					{
						CreateShotA(2,0,0,0);
						SetShotDataA(2,0,0,angle+180,0,speedB/60,speedB,gra);
						AddShot(cnt,1,2,0);
						cnt+=4;
					}
					FireShot(1);
					angle+=360/way;
				}
			}
			SetMovePositionHermite(cenX,minY+120,0,0,0,0,120);
			SetAction(ACT_MOVE,120);
			SetRoll(120);
			wait(300);
		}
	}
	
	task MainThread_Unlimited{}
	
}