script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=600;
		
		EnemyInitialize(230);
		MoveThread;
		EnemyDrawSystem(2);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(30);
		local
		{
			let p=GetAngleToPlayer;
			let leng=30;
			let way=5;
			let sp=0;
			loop(3)
			{
				
				let wide=360;
				let px=GetPlayerX;let py=GetPlayerY;
				loop(20)
				{
					let sx=[GetGapX(GetX,leng,p-90),GetGapX(GetX,leng,p+90)];
					let sy=[GetGapY(GetY,leng,p-90),GetGapY(GetY,leng,p+90)];
					ascent(a in 0..2)
					{
						let ag=atan2(py-sy[a],px-sx[a]);
						let speed=2.8+sp;
						let angle=ag-wide/2;
						let gra=81;
						let delay=10;
						while(angle<=ag+wide/2+1)
						{
							SetEnemyShot02(sx[a],sy[a],0,angle,speed/60,speed,gra,delay);
							angle+=wide/(way-1);
						}
					}
					wide-=5;
					sp+=0.1;
					wait(3);
				}
				way+=1;
			}
		}
		wait(60);
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(30);
		local
		{
			let p=GetAngleToPlayer;
			let leng=30;
			let sp=0;
			let way=6;
			let wide=360;
			let px=GetPlayerX;let py=GetPlayerY;
			loop(30)
			{
				let sx=[GetGapX(GetX,leng,p-90),GetGapX(GetX,leng,p+90)];
				let sy=[GetGapY(GetY,leng,p-90),GetGapY(GetY,leng,p+90)];
				ascent(a in 0..2)
				{
					let ag=atan2(py-sy[a],px-sx[a])+rand(-2,2);
					let speed=3.5+sp;
					let angle=ag-wide/2;
					let gra=119;
					let delay=10;
					while(angle<=ag+wide/2+1)
					{
						SetEnemyShot02(sx[a],sy[a],0,angle,speed/60,speed,gra,delay);
						angle+=wide/(way-1);
					}
				}
				wide-=5;
				sp+=0.03;
				wait(3);
			}
			
			let p=GetAngleToPlayer;
			loop(10)
			{
				let wide=180;
				let way=25;
				let speed=10;
				let angle=p-wide/2;
				let gra=62;
				let delay=0;
				while(angle<=p+wide/2)
				{
					SetEnemyShot02(GetX,GetY,speed,angle,-speed/20,speed/10+0.1,gra,delay);
					angle+=wide/(way-1);
				}
				wait(5);
			}
			wait(60);
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(40);
		let r=-1;
		if(GetX<cenX){r=-r;}
		SubShot;
		loop(10)
		{
			let p=GetAngleToPlayer;
			let sp=0;
			loop(16)
			{
				let wide=130;
				let way=5;
				let speed=1.8+sp;
				let angle=p-wide/2;
				let gra=25;
				let delay=10;
				while(angle<=p+wide/2)
				{
					CreateShot01(GetX,GetY,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
				p+=0.75*r;
				sp+=0.015;
			}
			wait(40);
			r=-r;
		}
		wait(60);
		enemyargument=1;
		
		task SubShot
		{
			wait(50);
			let i=0;
			while(!enemyargument)
			{
				let way=24;
				let leng=15;
				let ag=0;
				while(ag<360)
				{
					let sx=GetX+leng*cos(ag+i*2);
					let sy=GetY+leng*sin(ag+i);
					let speed=1.6;
					let angle=ag-i;
					let gra=10;
					let delay=5;
					SetEnemyShot02(sx,sy,0,angle,speed/60,speed,gra,delay);
					ag+=360/way;
				}
				wait(35);
				i+=12*r;
			}
		}
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.07;}
			yield;
		}
		loop
		{
			SetSpeed(enemyspeed);
			if(enemyspeed<4){enemyspeed+=0.05;}
			yield;
		}
	}
}