script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=0;
		EnemyInitialize(220);
		MoveThread;
	}
	@MainLoop{EnemyMainLoopSystem(10);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard{}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		State;
		Concentration01(30);
		wait(90);
		Sub;
		
		let lp=rand_int(0,360);
		loop(40+enemyargument)
		{
			let v=30;
			let p=atan2(GetPlayerY-GetEnemyY,GetPlayerX-GetEnemyX)+v*cos(lp*15);
			let speed=[2,3,4,1];
			let angle=p;
			let gra=69;
			let delay=0;
			while(angle<p+360)
			{
				let max=1;
				if(GetEnemyNum<=6){max=2;}
				if(GetEnemyNum<=4){max=3;}
				if(GetEnemyNum<=3){max=4;}
				ascent(a in 0..max)
				{
					CreateShot01(GetX,GetY,speed[a],angle,gra,delay);
				}
				angle+=180;
			}
			lp++;
			wait(12);
		}
		
		task Sub
		{
			wait(60*enemyargument);
			let sp=0;
			let lp=rand_int(0,360);
			loop(8)
			{
				let wide=150;
				let way=7;
				let v=5;
				let p=atan2(GetPlayerY-GetY,GetPlayerX-GetX)+v*cos(lp*30);
				let speed=[2.5,2,1];
				let angle=p-wide/2;
				let gra=86;
				let delay=0;
				while(angle<=p+wide/2+1)
				{
					let max=1;
					if(GetEnemyNum<=6){max=2;}
					if(GetEnemyNum<=4){max=3;}
					ascent(a in 0..max)
					{
						CreateShot01(GetX,GetY,speed[a]+sp,angle,gra,delay);
					}
					angle+=wide/(way-1);
				}
				lp++;
				sp+=0.05;
				wait(8);
			}
		}
		wait(60);
		
		let enemynum=GetEnemyNum;
		SetMovePositionHermite(GetX+rand(-60,60),cenY+rand(-60,60),0,0,0,0,120);
		loop(30)
		{
			let way=5;
			let v=10;
			let p=atan2(GetPlayerY-GetY,GetPlayerX-GetX)+v*cos(lp*10);
			let speed=[2,1,3,4];
			let angle=p;
			let gra=85;
			let delay=0;
			while(angle<p+360)
			{
				let max=1;
				if(enemynum<=6){max=2;}
				if(enemynum<=4){max=3;}
				if(enemynum<=3){max=4;}
				ascent(a in 0..max)
				{
					CreateShot01(GetX,GetY,speed[a],angle,gra,delay);
				}
				angle+=360/way;
			}
			lp++;
			wait(4);
		}
		
		vanishflg=true;
		local
		{
			let p=GetAngleToPlayer;
			let way=30;
			
			let speed=2;
			let angle=p;
			let gra=30;
			let delay=20;
			while(angle<p+360)
			{
				CreateShot02(GetX,GetY,0,angle,speed/100,speed,gra,delay);
				angle+=360/way;
			}
		}
		task State
		{
			while(!vanishflg)
			{
				let gra=6;
				let delay=10;
				CreateShotA(1,GetX,GetY,delay);
				SetShotDataA(1,0,0,0,0,0,0,gra);
				SetShotKillTime(1,0);
				FireShot(1);
				yield;
			}
		}
	}
	
	
	task MoveThread
	{
		while(!vanishflg){yield;}
		if(GetLife<lifelimit){AddLife(-lifelimit);}
		else{VanishEnemy;}
	}
}