script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=220;
		
		EnemyInitialize(40);
		MoveThread;
		EnemyDrawSystem(2);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(60);
		let p=GetAngleToPlayer;
		loop(9)
		{
			let way=3;
			let wide=50;
			let speed=6;
			let angle=p-wide/2;
			let gra=57;
			let delay=10;
			while(angle<=p+wide/2+1)
			{
				SetEnemyShot02(GetX,GetY,0,angle,speed/80,speed,gra,delay);
				angle+=wide/(way-1);
			}
			wait(3);
		}
		
		let px=GetPlayerX;
		let py=GetPlayerY;
		loop(9)
		{
			let sx=[GetX+30,GetX-30];
			let way=2;
			let wide=50;
			let v=-wide/2;
			ascent(a in 0..2)
			{
				let p=atan2(py-GetY,px-sx[a])+v;
				let speed=4;
				let angle=p-wide/2;
				let gra=57;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
				v+=wide;
			}
			wait(3);
		}
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(50);
		let r=1;
		if(GetX<cenX){r=-r;}
		loop(2)
		{
			let i=GetAngleToPlayer-20*r;
			let speed=1;
			loop(20)
			{
				let angle=i;
				let gra=27;
				let delay=10;
				SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
				i+=10*r;
				speed*=1.15;
			}
			wait(60);
			r=-r;
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(60);
		
		let lp=0;
		loop(2)
		{
			let px=GetPlayerX;
			let py=GetPlayerY;
			let sx=[GetX+30,GetX-30];
			let way=3;
			let wide=80;
			let wd=0;
			while(wd<15)
			{
				let p=atan2(py-GetY,px-sx[lp%2]);
				let speed=[3,2.5];
				let angle=p-wide/2;
				let gra=84;
				let delay=10;
				let a=0;
				while(angle<=p+wide/2+1)
				{
					WideShot(sx[lp%2],GetY,speed[a%length(speed)],angle,wd,gra,delay);
					angle+=wide/(way-1);
					a++;
				}
				wd+=1;
				wait(2);
			}
			lp++;
			wait(10);
		}
		function WideShot(let sx,let sy,let speed,let ag,let wide,let gra,let delay)
		{
			if(wide==0)
			{
				SetEnemyShot01(sx,sy,speed,ag,gra,delay);
			}
			else
			{
				let angle=ag-wide/2;
				while(angle<=ag+wide/2+0.1)
				{
					SetEnemyShot01(sx,sy,speed,angle,gra,delay);
					angle+=wide;
				}
			}
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.07;}
			yield;
		}
		let count=0;
		loop
		{
			if(count<480){schMove(GetPlayerX,GetPlayerY,1.1);}
			SetSpeed(enemyspeed);
			if(enemyspeed<1.5){enemyspeed+=0.025;}
			count++;
			yield;
		}
	}
}