
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Aya_AnimeLib.txt";
	
	tex_enemy=filedir~"Aya_Main.png";
	tex_spellbg=filedir~"Aya_SpellBG.png";
	
	bg_rect=[0,0,512,512];
	
	@Initialize
	{
		point=390;
		SetLife(600);
		SetTimer(41);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+160,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("壩晳乽揤嬬偺嫏潩乿",6);
		wait(100);
		
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let lp=0;
		loop
		{
			SetAction(ACT_SHOT_B,90);
			local
			{
				let fam=GetCurrentScriptDirectory~"Aya_Familier03.txt";
				let way=8;
				let p=rand(0,360);
				let arg=[0,0,1];
				let angle=p;
				while(angle<p+360)
				{
					CreateEnemyFromFile(fam,GetX,GetY,20,angle*r,arg[lp%length(arg)]);
					angle+=360/way;
				}
			}
			wait(180);
			SetMove(cenX+rand(-100,100),minY+rand(130,170),200);
			wait(200);
			r=-r;
			lp++;
		}
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+90,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("夦堎乽揤嬬旘釯乿",7);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			loop(3)
			{
				local
				{
					SetAction(ACT_SHOT_B,60);
					let angle=rand(70,110);
					let speed=-0.8;
					let fam=GetCurrentScriptDirectory~"Aya_Familier01.txt";
					CreateEnemyFromFile(fam,GetX,GetY,speed,angle,0);
				}
				wait(60);
				SetMove(cenX+rand(-100,100),minY+rand(80,90),200);
				wait(200);
			}
			loop(3)
			{
				let angle=rand(70,110);
				let speed=-1.5;
				let fam=GetCurrentScriptDirectory~"Aya_Familier01.txt";
				CreateEnemyFromFile(fam,GetX,GetY,speed,angle,1);
				
				let mx=cenX+rand(50,120)*r;
				let my=minY+rand(80,100);
				SetMove(mx,my,60);
				wait(60);
				Explosion01(GetX,GetY,5,0.1,60);
				r=-r;
			}
			wait(200);
		}
	}
	
	
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(maxX+60,minY+250,0,0,0,0,40);
		SetAction(ACT_MOVE,40);
		SetSpellCard("揤幾乽峳傟嫸偆揤媡枅昉乿",8);
		let px=GetPlayerX;
		let py=GetPlayerY;
		SetTargeting(px,py,0.5,100,0);
		wait(45);
		SetMovePositionHermite(minX,minY+60,0,0,0,0,70);
		SetAction(ACT_MOVE,70);
		wait(5);
		local
		{
			let wt=60;
			let L=20;
			loop(L)
			{
				let way=15;
				let gra=137;
				let delay=5;
				
				let i=0;
				let speed=4.5;
				while(speed>=0.9)
				{
					let p=atan2(py-GetY,px-GetX)-30+i;
					let angle=p;
					while(angle<p+360)
					{
						CreateShot01(GetX,GetY,speed,angle,gra,delay);
						angle+=360/way;
					}
					speed/=1.2;
					i+=3.5;
				}
				wait(wt/L);
			}
		}
		wait(5);
		wait(220);
		local
		{
			let flg=0;
			Set1;
			Set2;
			SetAction(ACT_SHOT_A,1000);
			SetMovePositionHermite(cenX,minY+10,0,0,0,0,450);
			let leng=60;let lgp=0.5;let lmax=150;
			let lp=0;
			let s=0;
			let smax=2.5;
			let w=2;
			loop
			{
				loop(9)
				{
					let way=14;
					let ag=0;
					while(ag<=180)
					{
						let sx=GetX+(leng*2)*cos(ag);
						let sy=(GetY-10)+(leng/4)*sin(ag);
						
						let speed=2+s;
						let angle=90+rand(-0.6,0.6);
						let gra=115;
						let delay=5;
						CreateShot02(sx,sy,0,angle,speed/10,speed,gra,delay);
						
						ag+=180/way;
					}
					if(s<smax){s+=0.05;}
					if(leng<lmax){leng+=lgp;}
					wait(w);
				}
				if(s>=smax)
				{
					loop(8)
					{
						if(leng<lmax){leng+=lgp;}
						wait(w);
					}
				}
			}
			
			task Set1
			{
				wait(150);
				let i=rand(0,360);
				let ip=0.4;
				let s=0;
				State;
				while(!flg)
				{
					let way=9;
					loop(7)
					{
						let speed=[2+s,1.5+s/1.5];
						let gra=63;
						let delay=0;
						let ag=[i,-i];
						ascent(a in 0..2)
						{
							let angle=ag[a];
							while(angle<ag[a]+360)
							{
								let leng=20;
								let sx=GetX+leng*cos(angle);
								let sy=GetY+leng*sin(angle);
								CreateShot02(sx,sy,0,angle,speed[a]/60,speed[a],gra,delay);
								angle+=360/way;
							}
						}
						wait(2);
					}
					loop(6)
					{
						wait(2);
					}
				}
				task State
				{
					while(!flg)
					{
						i+=ip;
						if(s<1.6){s+=0.001;}
						yield;
					}
				}
			}
			task Set2
			{
				wait(500);
				let s=0;
				let L=3;
				loop
				{
					let lp=0;
					loop(trunc(L))
					{
						let p=GetAngleToPlayer;
						let wide=160;
						let way=21+lp%2;
						let speed=3.5+s;
						let angle=p-wide/2;
						let gra=31;
						let delay=0;
						while(angle<=p+wide/2+1)
						{
							CreateShot01(GetX,GetY,speed,angle,gra,delay);
							angle+=wide/(way-1);
						}
						wait(7);
						s+=0.02;
						lp++;
					}
					L+=0.5;
					wait(40);	
				}
			}
		}
	}
	
}