
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Suika_AnimeLib.txt";
	
	tex_enemy=filedir~"Suika_Main.png";
	
	@Initialize
	{
		SetLife(4500);
		SetTimer(58);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+140,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		Sub;
		loop
		{
			let i=rand(0,360);
			let sp=0;
			loop(30)
			{
				let ip=1.3;
				let wt=1;
				let way=5;
				loop(5)
				{
					let speed=[4.5,2];
					let ag=i;
					let gra=[86,81];
					let delay=10;
					while(ag<i+360)
					{
						let v=60;
						let sx=GetX+v*cos(ag);
						let sy=GetY+v*sin(ag);
						let angle=ag-150*r;
						ascent(a in 0..length(speed))
						{
							CreateShot02(sx,sy,0,angle,speed[a]/90,speed[a],gra[lp%2],delay);
						}
						ag+=360/way;
					}
					i+=ip*r;
					wait(wt);
				}
				loop(5)
				{
					let angle=i;
					let gra=[86,81];
					let delay=10;
					while(angle<i+360)
					{
						let v=24;
						let sx=GetX+v*cos(angle);
						let sy=GetY+v*sin(angle);
						SetDelayEffect(sx,sy,gra[lp%2],delay);
						angle+=360/way;
					}
					i+=ip*r;
					wait(wt);
				}
			}
			lp++;
			r=-r;
		}
		task Sub
		{
			let lp=0;
			loop
			{
				let way=15;
				let p=GetAngleToPlayer+((360/way)/2)*(lp%2);
				let speed=4;
				let angle=p;
				let gra=55;
				let delay=10;
				while(angle<p+360)
				{
					CreateShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
					angle+=360/way;
				}
				lp++;
				if(!(lp%5))
				{
					let wt=150;
					SetMovePositionHermite(cenX+rand(-80,80),minY+rand(120,150),0,0,0,0,wt);
					SetAction(ACT_MOVE,wt);
					wait(wt);
				}
				wait(60);
			}
		}
	}
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(100);
		Sub;
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let i=rand(0,360);
			loop(49)
			{
				let way=3;
				let wt=1;
				let L=4;
				let ip=1.3;
				loop(L)
				{
					let speed=[2,3];
					let p=[i,-i*1.5];
					let gra=[81,86];
					let delay=10;
					ascent(a in 0..2)
					{
						let ag=p[a];
						while(ag<p[a]+360)
						{
							let angle=[ag-150,ag+150];
							let v=60;
							let sx=GetX+v*cos(ag);
							let sy=GetY+v*sin(ag);
							CreateShot02(sx,sy,0,angle[a],speed[a]/60,speed[a],gra[a],delay);
							ag+=360/way;
						}
					}
					i+=ip*r;
					wait(wt);
				}
				loop(L)
				{
					let p=[i,-i*1.5];
					let gra=[81,86];
					let delay=10;
					ascent(a in 0..2)
					{
						let ag=p[a];
						while(ag<p[a]+360)
						{
							let v=60;
							let sx=GetX+v*cos(ag);
							let sy=GetY+v*sin(ag);
							SetDelayEffect(sx,sy,gra[a],delay);
							ag+=360/way;
						}
					}
					i+=ip*r;
					wait(wt);
				}
			}
			r=-r;
		}
		
		task Sub
		{
			wait(60);
			let r=1;
			if(rand_int(0,1)){r=-r;}
			loop
			{
				SetAction(ACT_SHOT_B,60);
				let leng=-500;
				while(leng<500)
				{
					let ag=90-40*r;
					let px=GetGapX(cenX,leng,ag);
					let py=GetGapY(cenY,leng,ag);
					
					let angle=atan2(py-GetY,px-GetX);
					let speed=GetGapLength(GetX,GetY,px,py)/60;
					let gra=48;
					let delay=10;
					let wt=80;
					
					let obj=CreateShot02(GetX,GetY,speed,angle,-speed/wt,0,gra,delay);
					SetShot(obj,wt);
					leng+=40;
					wait(1);
				}
				let wt=140;
				SetMovePositionHermite(cenX+rand(-80,80),minY+rand(120,160),0,0,0,0,wt);
				SetAction(ACT_MOVE,wt);
				wait(wt);
				wait(90);
				r=-r;
			}
		}
		
		task SetShot(let obj,let wt)
		{
			wait(wt);
			if(!Obj_BeDeleted(obj))
			{
				local
				{
					let way=10;
					let sx=Obj_GetX(obj);
					let sy=Obj_GetY(obj);
					let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
					let speed=GetGapLength(GetPlayerX,GetPlayerY,sx,sy)/60;
					let gra=16;
					let delay=20;
					
					let angle=p;
					while(angle<p+360)
					{
						CreateShot02(sx,sy,0,angle,speed/90,speed,gra,delay);
						angle+=360/way;
					}
				}
				
				Obj_Delete(obj);
			}
		}
	}
	
	
	task MainThread_Unlimited{}
	
}