
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Yuka_AnimeLib.txt";
	
	tex_enemy=filedir~"Yuka_Main.png";
	
	@Initialize
	{
		SetLife(3800);
		SetTimer(45);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+100,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(200);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_B,250);
			loop(2)
			{
				let p=GetAngleToPlayer+150*r;
				let L=15;
				loop(L)
				{
					let speed=4;
					let angle=p;
					let gra=36;
					let delay=10;
					CreateShot01(GetX,GetY+20,speed,angle,gra,delay);
					let wide=4;
					loop(11)
					{
						speed/=1.1;
						let angle=p-wide/2;
						let gra=84;
						while(angle<=p+wide/2+1)
						{
							CreateShot01(GetX,GetY+20,speed,angle,gra,delay);
							angle+=wide;
						}
						wide+=1;
					}
					wait(3);
					p-=300/(L-1)*r;
				}
				wait(20);
				r=-r;
			}
			wait(30);
			local
			{
				let p=GetAngleToPlayer+150*r;
				let L=15;
				loop(L)
				{
					let speed=5;
					let angle=p;
					let gra=36;
					let delay=10;
					CreateShot01(GetX,GetY+20,speed,angle,gra,delay);
					let wide=2;
					loop(18)
					{
						speed/=1.1;
						let angle=p-wide/2;
						let gra=84;
						while(angle<=p+wide/2+1)
						{
							CreateShot01(GetX,GetY+20,speed,angle,gra,delay);
							angle+=wide;
						}
						wide+=0.75;
					}
					wait(3);
					p-=300/(L-1)*r;
				}
				wait(60);
			}
			
			SetMove(cenX+rand(-100,100),minY+rand(90,110),120);
			let i=rand(0,360);
			loop(60)
			{
				let p=[i,120+i,240+i];
				ascent(a in 0..3)
				{
					let gra=27;
					let delay=10;
					
					let j=0;
					let speed=3.4;
					while(speed>=2.6)
					{
						let v=45;
						let sx=GetX+v*cos(p[a]);
						let sy=GetY+v*sin(p[a]);
						let angle=p[a]+j;
						CreateShot01(sx,sy,speed,angle,gra,delay);
						speed/=1.1;
						j+=1*r;
					}
				}
				wait(3);
				i+=7.5*r;
			}
			r=-r;
			wait(60);
		}
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(200);
		Sub;
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,180);
			let lp=0;
			loop(2)
			{
				let sx=[GetX+60,GetX-60];
				let px=GetPlayerX;
				let py=GetPlayerY;
				let i=-12*r;
				let sp=0;
				loop(30)
				{
					let wide=[160,100];
					let way=[3,4];
					let p=atan2(py-GetY,px-sx[lp%2])+i;
					let speed=[0.9+sp,0.7+sp];
					let gra=31;
					let delay=10;
					ascent(a in 0..2)
					{
						let angle=p-wide[a]/2;
						while(angle<=p+wide[a]/2+1)
						{
							CreateShot01(sx[lp%2],GetY,speed[a],angle,gra,delay);
							angle+=wide[a]/(way[a]-1);
						}
					}
					wait(2);
					sp+=0.2;
					i+=0.75*r;
				}
				wait(30);
				lp++;
				r=-r;
			}
			wait(50);
			SetMove(cenX+rand(-100,100),minY+rand(90,110),120);
			wait(150);
			r=-r;
			
		}
		
		task Sub
		{
			wait(60);
			let rb=1;
			if(rand_int(0,1)){r=-r;}
			loop
			{
				let speed=3.5;
				let angle=-90+rand(50,80)*rb;
				let gra=148;
				let delay=10;
				CreateShotA(1,GetX,GetY,delay);
				SetShotDataA(1,0,speed,angle,0,0,0,gra);
				let cnt=rand_int(0,3);
				while(cnt<200)
				{
					let angleB=-90;
					let speedB=2.5;
					let graB=84;
					while(angleB<=91)
					{
						CreateShotA(2,0,0,0);
						SetShotDataA(2,0,0,angleB,0,speedB/60,speedB,graB);
						AddShot(cnt,1,2,0);
						angleB+=180;
					}
					cnt+=10;
				}
				FireShot(1);
				
				wait(40);
				rb=-rb;
			}
		}
	}
	
	
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		wait(200);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		loop
		{
			SetAction(ACT_SHOT_B,120);
			local
			{
				let base=rand(0,360);
				let i=0;
				loop(70)
				{
					let way=3;
					let sch=[-3,3];
					let p=[base-i,base+i];
					let limit=70;
					
					let speed=[1.5];
					let gra=[31];
					if(lp%2==1)
					{
						speed=[1.2,1.8];
						gra=[31,15];
					}
					let delay=10;
					ascent(a in 0..2)
					{
						ascent(b in 0..length(speed))
						{
							let angle=p[a];
							while(angle<p[a]+360)
							{
								CreateShotA(1,GetX,GetY+20,delay);
								SetShotDataA(1,0,speed*2,angle,sch[a],-speed[b]/limit,speed[b],gra[b]);
								SetShotDataA(1,limit,NULL,NULL,0,0,0,gra[b]);
								FireShot(1);
								angle+=360/way;
							}
						}
					}
					i+=7.18;
					wait(1);
				}
			}
			wait(80);
			lp++;
			if(!(lp%2))
			{
				SetMove(cenX+rand(-100,100),minY+rand(110,130),120);
				wait(120);
			}
		}
	}
	
}