script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=0;
		EnemyInitialize(60);
		MoveThread;
	}
	@MainLoop{EnemyMainLoopSystem(20);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(61);
		State;
		loop
		{
			let p=enemyangle+rand_int(-2,2);
			let way=3;
			let speed=3.5;
			let angle=p;
			let gra=15;
			let delay=10;
			while(angle<p+360)
			{
				CreateShot02(GetX,GetY,0,angle,speed/180,speed,gra,delay);
				angle+=360/way;
			}
			wait(3);
		}
		task State
		{
			loop
			{
				if(GetX<minX||GetX>maxX||GetY<minY||GetY>maxY){vanishflg=true;}
				yield;
			}
			
		}
	}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{

	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited{}
	
	
	task MoveThread
	{
		Effect;
		let mx=cenX+rand(-140,140);
		let my=minY+rand(30,200);
		let sangle=rand(0,360);
		let eangle=rand(0,360);
		let wt=50;
		SetInvincibility(wt);
		SetMovePositionHermite(mx,my,400,sangle,400,eangle,wt);
		wait(wt);
		wait(10);
		enemyangle=GetAngleToPlayer+rand_int(-10,10);
		while(!vanishflg)
		{
			schMove(GetPlayerX,GetPlayerY,1);
			SetSpeed(enemyspeed);
			enemyspeed+=0.05;
			yield;
		}
		if(GetLife<lifelimit){AddLife(-lifelimit);}
		else{VanishEnemy;}
		
		task Effect
		{
			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);
				}
				yield;
			}
		}
	}
}