script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=420;
		
		EnemyInitialize(220);
		MoveThread;
		EnemyDrawSystem(1);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(60);
		let px=GetPlayerX;
		let py=GetPlayerY;
		let i=36;
		let sp=0;
		loop(60)
		{
			let sx=[GetX+30,GetX-30];
			ascent(a in 0..2)
			{
				let p=atan2(py-GetY,px-sx[a]);
				let ag=[p-i,p+i];
				let delay=10;
				local
				{
					let speed=3+sp;
					let angle=ag[a];
					let gra=86;
					SetShot(sx[a],speed,angle,gra);
				}
				local
				{
					let wide=33;
					let speed=2+sp;
					let gra=85;
					let angle=ag[a]-wide/2;
					while(angle<=ag[a]+wide/2+1)
					{
						SetShot(sx[a],speed,angle,gra);
						angle+=wide;
					}
				}
				task SetShot(let sx,let speed,let angle,let gra)
				{
					loop(6)
					{
						SetEnemyShot02(sx,GetY,0,angle,speed/100,speed,gra,delay);
						wait(2);
					}
				}
			}
			sp+=0.05;
			i+=9;
			wait(5);
		}

		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(60);
		let r=1;
		if(GetX<cenX){r=-r;}
		loop(2)
		{
			let lp=0;
			loop(4)
			{
				let sx=[GetX-30,GetX+30];
				let p=atan2(GetPlayerY-GetY,GetPlayerX-sx[lp%2]);
				let i=p-10*r;
				let sp=0;
				loop(12)
				{
					let speed=3.5+sp;
					let angle=i;
					let gra=84;
					let delay=10;
					SetEnemyShot01(sx[lp%2],GetY,speed,angle,gra,delay);
					wait(1);
					i+=1.5*r;
					sp+=0.1;
				}
				wait(10);
				r=-r;
				lp++;
			}
			let lp=0;
			loop(2)
			{
				let wide=180;
				let way=15;
				let sx=[GetX+30,GetX-30];
				let p=atan2(GetPlayerY-GetY,GetPlayerX-sx[lp%2]);
				let speed=3;
				let angle=p-wide/2;
				let gra=148;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot02(sx[lp%2],GetY,0,angle,speed/60,speed,gra,delay);
					angle+=wide/(way-1);
				}
				wait(30);
				lp++;
			}
			let i=-130;
			loop(18)
			{
				let wide=6;
				let p=GetAngleToPlayer;
				let sx=[GetX+30,GetX-30];
				let speed=4;
				let ag=[p+i,p-i];
				let gra=132;
				let delay=10;
				ascent(a in 0..2)
				{
					let angle=ag[a]-wide/2;
					while(angle<=ag[a]+wide/2+1)
					{
						SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
						angle+=2;
					}
				}
				i+=15;
				wait(9);
			}
			r=-r;
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(60);
		loop(2)
		{
			let random=GetAngleToPlayer;
			let wt=80;
			let way=40;
			let wide=(360/way);
			let speed=3.5;
			let gra=83;
			let delay=0;
			let w=4;
			loop(1)
			{
				let angle=random;

				ascent(a in 0..way)
				{
					if(a%4<=1)
					{
						let angleB=(angle+(360/way)*a)-wide/2;
						while(angleB<=(angle+(360/way)*a)+wide/2)
						{
							SetEnemyShot02(GetX,GetY,0,angleB,speed/wt,speed,gra,delay);
							angleB+=1;
						}
					}
				}
				wait(w);
			}
			
			let lp=0;
			loop(2)
			{
				loop(5)
				{
					let angle=random;
					while(angle<random+360)
					{
						SetEnemyShot02(GetX,GetY,0,angle+(360/way)+wide/2,speed/wt,speed,gra,delay);
						SetEnemyShot02(GetX,GetY,0,angle-(360/way)*4-wide/2,speed/wt,speed,gra,delay);
						angle+=360/(way*0.25);
					}
					wait(w);
				}
				if(!lp){wait(24);lp++;}
			}
			
			loop(1)
			{
				let angle=random;
				ascent(a in 0..way)
				{
					if(a%4>=2)
					{
						let angleB=(angle+(360/way)*a)-wide/2;
						while(angleB<=(angle+(360/way)*a)+wide/2)
						{
							SetEnemyShot02(GetX,GetY,0,angleB,speed/wt,speed,gra,delay);
							angleB+=1;
						}
					}
				}
				wait(w);
			}
			wait(60);
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.07;}
			yield;
		}
		let count=0;
		loop
		{
			SetSpeed(enemyspeed);
			if(enemyspeed<1.5){enemyspeed+=0.025;}
			count++;
			yield;
		}
	}
}