script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=0;
		EnemyInitialize(60);
		MoveThread;
	}
	@MainLoop{EnemyMainLoopSystem(20);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard{}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		State;
		while(!vanishflg){yield;}
		local
		{
			let fam=GetCurrentScriptDirectory~"Aya_Familier02.txt";
			let wide=60;
			let way=7;
			if(GetLife<lifelimit){way=6;}
			if(enemyargument){wide=40;way=5;}
			let p=GetAngleToPlayer;
			let speed=0.2;
			let rd=20;
			Set;
			local
			{
				let angle=p;
				while(angle<=p+wide)
				{
					let sx=GetX+rand(-rd,rd);
					let sy=GetY+rand(-rd,rd);
					CreateEnemyFromFile(fam,sx,sy,speed,angle,0);
					angle+=wide/(way-1);
				}
			}
			
			task Set
			{
				let angle=p;
				while(angle>=p-wide)
				{
					let sx=GetX+rand(-rd,rd);
					let sy=GetY+rand(-rd,rd);
					CreateEnemyFromFile(fam,sx,sy,speed,angle,0);
					angle-=wide/(way-1);
				}
			}
		}
		
		task State
		{
			wait(60);
			vanishflg=true;
		}
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited{}
	
	
	task MoveThread
	{
		while(!vanishflg)
		{
			local
			{
				let gra=8;
				let delay=15;
				CreateShotA(1,GetX,GetY,delay);
				SetShotDataA(1,0,0,0,0,0,0,gra);
				SetShotKillTime(1,0);
				FireShot(1);
			}
			SetSpeed(enemyspeed);
			enemyspeed+=0.1;
			yield;
		}
		if(GetLife<lifelimit){AddLife(-lifelimit);}
		else{VanishEnemy;}
	}
}