
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Eiki_AnimeLib.txt";
	
	tex_enemy=filedir~"Eiki_Main.png";
	
	@Initialize
	{
		SetLife(3600);
		SetTimer(60);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	

	
	
	
	
	task MainThread_Standard{}
	task MainThread_Advanced{}
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+150,0,0,0,0,200);
		SetAction(ACT_MOVE,200);
		wait(220);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		Sub;
		loop
		{
			wait(60);
			SetAction(ACT_SHOT_A,90);
			loop(7)
			{
				let sx=rand(minX,maxX);
				let sy=minY;
				let angle=rand(40,140);
				let fam=GetCurrentScriptDirectory~"Eiki_Familier02.txt";
				CreateEnemyFromFile(fam,sx,sy,0,angle,0);
				wait(8);
			}
			let p=GetAngleToPlayer;
			loop(7)
			{
				let way=12;
				let wide=150;
				
				let speed=[5,1];
				let angle=p-wide/2;
				let gra=70;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					ascent(a in 0..length(speed))
					{
						CreateShot02(GetX,GetY,0,angle,speed[a]/100,speed[a],gra,delay);
					}
					angle+=wide/(way-1);
				}
				wait(7);
			}
			let wt=100;
			SetMovePositionHermite(cenX+rand(-60,60),minY+rand(140,160),0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			wait(wt);
		}
		
		task Sub
		{
			loop
			{
				let sx=[cenX+120,cenX-120];
				let sy=minY+120;
				
				ascent(a in 0..2)
				{
					let p=atan2(GetPlayerY-sy,GetPlayerX-sx[a]);
					let ag=[p,-p];
					let way=13;
					let wide=12;
					let speed=2;
					let angleA=ag[a];
					let gra=251;
					let delay=20;
					while(angleA<ag[a]+360)
					{
						let angleB=angleA-wide/2;
						while(angleB<=angleA+wide/2+1)
						{
							CreateShot02(sx[a],sy,0,angleB,speed/100,speed,gra,delay);
							angleB+=1.5;
						}
						angleA+=360/way;
					}
				}
				wait(70);
				
			}
		}
	}
	
}