script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=300;
		
		EnemyInitialize(200);
		MoveThread;
		EnemyDrawSystem(3);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(50);
		loop(3)
		{
			let wide=210+360;
			let p=GetAngleToPlayer;
			let s=0;
			loop(12)
			{
				let speed=1+s;
				let angle=p-wide/2;
				let gra=82;
				let delay=7;
				while(angle<=p+wide/2)
				{
					SetShot(GetX,GetY,speed,angle,gra,delay);
					angle+=wide;
				}
				wait(4);
				s+=0.5;
				wide+=25;
				
				task SetShot(let sx,let sy,let speed,let angle,let gra,let delay)
				{
					loop(14)
					{
						SetEnemyShot01(sx,sy,speed,angle,gra,delay);
						wait(2);
					}
				}
			}
			wait(50);
		}
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(50);
		loop(3)
		{
			let p=GetAngleToPlayer;
			Sub;
			let wide=130;
			let s=0;
			loop(4)
			{
				let speed=3.5+s;
				let angle=p-wide/2;
				let gra=111;
				let delay=7;
				while(angle<=p+wide/2)
				{
					SetShot(GetX,GetY,speed,angle,gra,delay);
					angle+=wide;
				}
				wait(10);
				s+=0.6;
				wide-=25;
				task SetShot(let sx,let sy,let speed,let angle,let gra,let delay)
				{
					loop(14)
					{
						SetEnemyShot01(sx,sy,speed,angle,gra,delay);
						wait(2);
					}
				}
			}
			task Sub
			{
				let wide=[100,120,140];
				let wideB=3;
				let way=[7,8];
				let lp=0;
				loop(3)
				{
					loop(2)
					{
						let speed=3.5;
						let gra=65;
						let delay=5;
						let angleA=p-wide[lp%length(wide)]/2;
						while(angleA<=p+wide[lp%length(wide)]/2+1)
						{
							let angleB=angleA-wideB/2;
							while(angleB<=angleA+wideB/2+1)
							{
								CreateShot01(GetX,GetY,speed,angleB,gra,delay);
								angleB+=wideB/2;
							}
							angleA+=wide[lp%length(wide)]/(way[lp%length(way)]-1);
						}
						lp++;
						wait(10);
					}
					wait(6);
				}
			}
			wait(40);
			let wide=2;
			let way=2;
			let s=0;
			loop(9)
			{
				let speed=3+s;
				let angle=p-wide/2;
				let gra=62;
				let delay=0;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
				wide+=3;
				way+=1;
				s+=0.25;
				wait(2);
			}
			wait(50);
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(50);
		loop(3)
		{
			let p=GetAngleToPlayer;
			let gra=111;
			let delay=7;
			local
			{
				let wide=3;
				let s=0;
				loop(12)
				{
					let speed=2+s;
					let angle=p-wide/2;
					while(angle<=p+wide/2)
					{
						SetShot(GetX,GetY,speed,angle,gra,delay);
						angle+=wide;
					}
					wait(1);
					s+=0.3;
					wide+=2;
				}
			}
			local
			{
				let wide=150;
				let s=0;
				loop(20)
				{
					let speed=2+s;
					let angle=p-wide/2;
					while(angle<=p+wide/2)
					{
						SetShot(GetX,GetY,speed,angle,gra,delay);
						angle+=wide;
					}
					wait(1);
					s+=0.3;
					wide-=4;
				}
			}
			task SetShot(let sx,let sy,let speed,let angle,let gra,let delay)
			{
				loop(10)
				{
					SetEnemyShot01(sx,sy,speed,angle,gra,delay);
					wait(2);
				}
			}
			wait(60);
		}
		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;
		}
	}
}