script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=300;
		
		EnemyInitialize(160);
		MoveThread;
		EnemyDrawSystem(3);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		loop(2)
		{
			let p=GetAngleToPlayer;
			let leng=20;
			let i=180;
			let s=0;
			loop(20)
			{
				let wide=5;
				let way=3;
				let sx=[GetGapX(GetX,leng,p+90),GetGapX(GetX,leng,p-90)];
				let sy=[GetGapY(GetY,leng,p+90),GetGapY(GetY,leng,p-90)];
				let speed=6-s;
				let ag=[p+i,p-i];
				let gra=111;
				let delay=10;
				ascent(a in 0..2)
				{
					let angle=ag[a]-wide/2;
					while(angle<=ag[a]+wide/2+1)
					{
						SetEnemyShot01(sx[a],sy[a],speed,angle,gra,delay);
						angle+=wide/(way-1);
					}
				}
				s+=0.2;
				i+=-8.2;
				wait(2);
			}
			let s=0;
			let px=GetPlayerX;
			let py=GetPlayerY;
			let p=GetAngleToPlayer;
			loop(15)
			{
				let way=2;
				let wide=4;
				
				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 speed=2.8+s;
					let angle=atan2(py-sy[a],px-sx[a])-wide/2;
					let gra=70;
					let delay=10;
					while(angle<=atan2(py-sy[a],px-sx[a])+wide/2)
					{
						SetEnemyShot01(sx[a],sy[a],speed,angle,gra,delay);
						angle+=wide/(way-1);
					}
				}
				s+=0.2;
				wait(3);
			}
			wait(30);
		}
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		loop(2)
		{
			let p=GetAngleToPlayer;
			let leng=20;
			let i=180;
			let s=0;
			loop(22)
			{
				let sx=[GetGapX(GetX,leng,p+90),GetGapX(GetX,leng,p-90)];
				let sy=[GetGapY(GetY,leng,p+90),GetGapY(GetY,leng,p-90)];
				let ag=[p+i,p-i];
				let gra=30;
				let delay=10;
				let r=1;
				ascent(a in 0..2)
				{
					let speed=4.6-s;
					let j=0;
					loop(6)
					{
						let angle=ag[a]+j;
						SetEnemyShot01(sx[a],sy[a],speed,angle,gra,delay);
						
						speed/=1.03;
						j+=1*r;
					}
					r=-r;
				}
				s+=0.1;
				i+=-8.5;
				wait(2);
			}
			
			ascent(a in 0..2)
			{
				let s=0;
				let px=GetPlayerX;
				let py=GetPlayerY;
				let p=GetAngleToPlayer;
				loop(7)
				{
					let way=3;
					let wide=15;
					
					let sx=[GetGapX(GetX,leng,p-90),GetGapX(GetX,leng,p+90)];
					let sy=[GetGapY(GetY,leng,p-90),GetGapY(GetY,leng,p+90)];
					let speed=2+s;
					let angle=atan2(py-sy[a],px-sx[a])-wide/2;
					let gra=70;
					let delay=10;
					while(angle<=atan2(py-sy[a],px-sx[a])+wide/2)
					{
						SetEnemyShot01(sx[a],sy[a],speed,angle,gra,delay);
						angle+=wide/(way-1);
					}
					s+=0.03;
					wait(3);
				}
				wait(6);
			}
			wait(40);
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(60);
		let r=1;
		if(GetX>cenX){r=-r;}
		loop(2)
		{
			let i=0;
			let s=0;
			let p=GetAngleToPlayer;
			loop(30)
			{
				let wide=200;
				let way=21;
				let leng=20;
				let speed=[2+s,4-s/4];
				let angle=p-wide/2;
				let gra=87;
				let delay=10;
				let pt=0;
				while(angle<=p+wide/2)
				{
					let sx=GetX+leng*cos(angle+i);
					let sy=GetY+leng*sin(angle+i);
					
					SetEnemyShot01(sx,sy,speed[pt%length(speed)],angle,gra,delay);
					pt++;
					angle+=wide/(way-1);
				}
			//	i+=1*r;
				s+=0.09;
				wait(2);
			}
			wait(30);
			let i=0;
			let s=0;
			let p=GetAngleToPlayer;
			loop(15)
			{
				let wide=120;
				let way=4;
				let leng=20;
				let speed=[2+s,3+s];
				let gra=105;
				let delay=10;
				let ag=[p-i,p+i];
				ascent(b in 0..2)
				{
					let angle=ag[b]-wide/2;
					while(angle<=ag[b]+wide/2)
					{
						let sx=GetX+leng*cos(angle);
						let sy=GetY+leng*sin(angle);
						
						ascent(a in 0..length(speed))
						{
							SetEnemyShot01(sx,sy,speed[a],angle,gra,delay);
						}
						angle+=wide/(way-1);
					}
				}
				s+=0.1;
				i+=-0.5*r;
				wait(2);
			}
			r=-r;
			wait(80);
		}
		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;
		}
	}
}