script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	let endflg=0;
	@Initialize
	{
		point=750;
		pflg=true;
		
		EnemyInitialize(950);
		MoveThread;
		EnemyDrawSystem(3);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(30);
		let r=1;
		if(GetX>cenX){r=-r;wait(45);}
		loop(10)
		{
			let i=10*r;
			let sp=0;
			let p=GetAngleToPlayer;
			loop(15)
			{
				let ag=p+i;
				let way=[3,2,2];
				let wide=[70,170,174];
				let speed=2+sp;
				let gra=29;
				let delay=10;
				ascent(a in 0..3)
				{
					let angle=ag-wide[a]/2;
					while(angle<=ag+wide[a]/2+1)
					{
						let v=25;
						let sx=GetX+v*cos(angle);
						let sy=GetY+v*sin(angle);
						
						SetEnemyShot01(sx,sy,speed,angle,gra,delay);
						angle+=wide[a]/(way[a]-1);
					}	
				}
				sp+=0.06;
				i+=0.7*r;
				wait(2);
			}
			wait(60);
			if(enemyargument==1){r=-r;}
		}
		if(GetX<=cenX){wait(45);}
		wait(60);
		endflg=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(30);
		if(GetX>cenX){wait(45);}
		loop(10)
		{
			let p=GetAngleToPlayer;
			let wide=[180,4];
			let way=11;
			let speed=[1.5,3];
			let gra=109;
			let delay=10;
			
			let angleA=p-wide[0]/2;
			while(angleA<=p+wide[0]/2+1)
			{
				let angleB=angleA-wide[1]/2;
				while(angleB<=angleA+wide[1]/2+1)
				{
					ascent(a in 0..length(speed))
					{
						SetEnemyShot01(GetX,GetY,speed[a],angleB,gra,delay);
					}
					angleB+=2;
				}
				angleA+=wide[0]/(way-1);
			}
			wait(90);
		}
		if(GetX<=cenX){wait(45);}
		wait(60);
		endflg=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(30);
		let L=6;let wt=90;
		if(enemyargument==1){L=10;wt=30;}
		if(GetX>cenX){wait(75);}
		loop(L)
		{
			let wide=0;
			let way=1;
			let p=GetAngleToPlayer;
			loop(10)
			{
				let ag=p;
				while(ag<p+360)
				{
					let speed=3;
					let gra=27;
					let delay=10;
					if(wide==0)
					{
						let angle=ag;
						SetEnemyShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
					}
					else
					{
						let angle=ag-wide/2;
						while(angle<=ag+wide/2+0.1)
						{
							SetEnemyShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
							angle+=wide/(way-1);
						}
					}
					ag+=360/3;
				}
				wide+=12;
				way++;
				wait(6);
			}
			wait(wt);
		}
		if(GetX<=cenX){wait(75);}
		wait(60);
		endflg=1;
	}
	
	
	task MoveThread
	{
		while(!endflg)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.07;}
			yield;
		}
		loop
		{
			SetSpeed(enemyspeed);
			if(enemyspeed<4){enemyspeed+=0.05;}
			yield;
		}
	}
}