script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=300;
		
		EnemyInitialize(100);
		MoveThread;
		EnemyDrawSystem(1);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(60);
		local
		{
			let sp=0;
			let p=GetAngleToPlayer;
			loop(20)
			{
				let way=3;
				let wide=30;
				let speed=[5-sp,4-sp];
				let angle=p-wide/2;
				let gra=105;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					ascent(a in 0..length(speed))
					{
						SetEnemyShot01(GetX,GetY,speed[a],angle,gra,delay);
					}
					angle+=wide/(way-1);
				}
				sp+=0.1;
				wait(1);
			}
			loop(10)
			{
				let way=4;
				let wide=50;
				let speed=2;
				let angle=p-wide/2;
				let gra=105;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
				wait(1);
			}
			wait(30);
			local
			{
				let way=16;
				let wide=140;
				let speed=2;
				let angle=p-wide/2;
				let gra=10;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
			}
		}
		wait(60);
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(50);
		local
		{
			let way=[3,2];
			let wide=[100,50];
			ascent(a in 0..2)
			{
				let p=GetAngleToPlayer;
				let wd=0;
				while(wd<12)
				{
					let speed=3.5;
					let angle=p-wide[a]/2;
					let gra=86;
					let delay=5;
					while(angle<=p+wide[a]/2+1)
					{
						WideShot(GetX,GetY,speed,angle,wd,gra,delay);
						angle+=wide[a]/(way[a]-1);
					}
					wd+=1;
					wait(2);
				}
				wait(20);
			}
			
			function WideShot(x,y,spd,ag,wide,gra,delay)
			{
				if(wide==0)
				{
					SetEnemyShot02(x,y,0,ag,spd/100,spd,gra,delay);
				}
				else
				{
					let angle=ag-wide/2;
					while(angle<=ag+wide/2+0.5)
					{
						SetEnemyShot02(x,y,0,angle,spd/100,spd,gra,delay);
						angle+=wide;
					}
				}
			}
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(40);
		let wide=12;
		let p=GetAngleToPlayer;
		loop(30)
		{
			let way=3;
			let ag=p;
			while(ag<p+360)
			{
				let speed=4.5;
				let angle=ag-wide/2;
				let gra=86;
				let delay=10;
				while(angle<=ag+wide/2+1)
				{
					SetEnemyShot02(GetX,GetY,0,angle,speed/200,speed,gra,delay);
					angle+=wide/(way-1);
				}
				ag+=120;
			}
			wait(2);
			wide+=2;
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.07;}
			yield;
		}
		loop
		{
			SetSpeed(enemyspeed);
			if(enemyspeed<4){enemyspeed+=0.05;}
			yield;
		}
	}
}