
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=360;
		SetLife(700);
		SetTimer(34);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("晽恮乽揤嬬楏晽愵乿",3);
		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,60);
			Concentration01(60);
			wait(60);
			
			SetAction(ACT_SHOT_B,140);
			let L=24;
			let wide=180;
			local
			{
			//	Sub(-r);
				let i=90+20*r;
				loop(L)
				{
					let lg=25;
					let sx=GetX+lg*cos(i);
					let sy=GetY+lg*sin(i);
					let speed=4.5;
					let gra=113;
					let delay=5;
					while(speed>=1)
					{
						let angle=i+rand(14,16)*r;
						ReflectShot(sx,sy,speed,angle,1,true,false,true,false,gra,delay);
						speed/=1.05;
					}
					
					wait(1);
					i-=wide/L*r;
				}
			}
			
			task Sub(let rb)
			{
				let i=90+20*rb;
				loop(L)
				{
					let lg=25;
					let sx=GetX+lg*cos(i);
					let sy=GetY+lg*sin(i);
					let speed=3.5;
					let gra=1;
					let delay=5;
					let j=45;
					while(speed>=1.6)
					{
						let angle=i+j*rb;
						CreateShot01(sx,sy,speed,angle,gra,delay);
						speed/=1.1;
						j+=0.5*rb;
					}
					
					wait(1);
					i-=wide/L*rb;
				}
			}
			
			wait(120);
			
			let s=0;
			loop(3)
			{
				let mx=cenX+rand(0,50)*r;
				let my=minY+rand(100,140);
				SetMove(mx,my,20);
				wait(30);
				Explosion01(GetX,GetY,5,0.1,60);
				let random=rand(0,360);
				let way=70;
				let speed=[1.5,1.2];
				let angle=random;
				let gra=[9,10];
				let delay=10;
				let gvspeed=0.01;
				let gvangle=90;
				let lp=0;
				while(angle<random+360)
				{
					let ag=lp*180;
					let lg=25;
					let sx=GetX+lg*cos(angle);
					let sy=GetY+lg*sin(angle);
					let spd=speed[lp%length(speed)]+s;
					GravityShot(sx,sy,spd,angle+ag,gvspeed,gvangle,gra[lp%length(gra)],delay);
					angle+=360/way;
					lp++;
				}
				r=-r;
				s+=0.2;
			}
			wait(100);
		}
		
	}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("揤晽乽梩抍愵堦慚乿",4);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let i=0;
			let lp=0;
			SetAction(ACT_SHOT_B,70);
			let random=rand(130,110)*r;
			let p=GetAngleToPlayer;
			loop(2)
			{
				loop(35)
				{
					let speed=2.5;
					let speedmin=1.8;
					if(lp==1){speed=40;speedmin=0.8;}
					let angle=p+random-i;
					let gra=[88,65];
					let delay=0;
					while(speed>=speedmin)
					{
						CreateShot01(GetX,GetY,speed,angle,gra[lp%length(gra)],delay);
						speed=speed/1.15;
					}
					i+=7*r;
					wait(1);
				}
				if(lp==0){Concentration01(30);}
				r=-r;
				lp++;
				wait(30);
			}
			wait(40);
			let s=0;
			loop(3)
			{
				let mx=cenX+rand(0,50)*r;
				let my=minY+rand(100,140);
				SetMove(mx,my,20);
				wait(20);
				Explosion01(GetX,GetY,5,0.1,60);
				let random=rand(0,360);
				let way=110;
				let speed=[3,3.6];
				let angle=random;
				let gra=[113,118];
				let delay=10;
				let lp=0;
				while(angle<random+360)
				{
					let ag=lp*180;
					let lg=25;
					let sx=GetX+lg*cos(angle);
					let sy=GetY+lg*sin(angle);
					let spd=speed[lp%length(speed)]-s;
					CreateShot02(sx,sy,0,angle+ag,spd/60,spd,gra[lp%length(gra)],delay);
					angle+=360/way;
					lp++;
				}
				r=-r;
				s+=0.5;
			}
			wait(130);
		}
	}
	
	
	
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+80,0,0,0,0,90);
		SetAction(ACT_MOVE,90);
		SetSpellCard("崒晽乽婥暣傟晽恄偺揤抧奐钃乿",5);
		wait(90);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			loop(1)
			{
				SetAction(ACT_SHOT_A,60);
				Concentration01(60);
				wait(60);
				
				SetAction(ACT_SHOT_B,140);
				let i=90-(70*r);let L=60;
				let lp=0;
				let s=0;
				let px=GetPlayerX;let py=GetPlayerY;
				let w=0;
				loop(L/2)
				{
					loop(2)
					{
						let leng=90;
						let wide=240;
						let way=20;
						let sx=GetX+(leng*2)*cos(i);
						let sy=GetY+(leng/2)*sin(i);
						let px_=GetGapX(GetX,380,atan2(py-GetY,px-GetX));
						let py_=GetGapY(GetY,380,atan2(py-GetY,px-GetX));
						let p=atan2(py_-sy,px_-sx)+(lp%2)*(wide/(way-1))/2;
						let speed=0;
						let speedB=[0.5+s,1.2+s/3];
						let speedC=1;
						let angle=p-wide/2;
						let gra=[25,30];
						let sch=[0.5,-0.5];
						let delay=5;
						while(angle<p+wide/2)
						{
							CreateShotA(1,sx,sy,delay);
							SetShotDataA(1,0,speed,angle,0,speedB[lp%2]/30,speedB[lp%2],gra[lp%2]);
							SetShotDataA(1,120-w,NULL,NULL,0,-speedB[lp%2]/60,speedC,NULL);
							SetShotDataA(1,180-w,NULL,NULL,sch[lp%2]*r,0,0,NULL);
							SetShotDataA(1,340-w,NULL,NULL,0,0,0,NULL);
							FireShot(1);
							angle+=wide/(way-1);
						}
						lp++;
						i+=160/L*r;
						s+=0.1;
					}
					wait(1);
					w+=1;
				}
				wait(105);
				r=-r;
			}
			SetMove(cenX+rand(-100,100),minY+rand(80,90),120);
			wait(120);
		}
		
	}
	
}