
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=450;
		SetLife(500);
		SetTimer(65);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	
	
	
	
	task MainThread_Advanced
	{
		yield;
//		SetMovePositionHermite(cenX,minY+160,0,0,0,0,100);
//		SetAction(ACT_MOVE,100);
		SetSpellCard("VăÄužvv",74);
//		wait(100);
		
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			let wt=60;
			SetMovePositionHermite(cenX,minY,0,0,0,0,wt);
			SetAction(ACT_MOVE,wt);
			wait(wt);
			SetShot1(0);
			wait(20);
			let px=GetPlayerX;
			let py=maxY;
			SetTargeting(px,py,0.5,90,0);
			let my=cenY+100;
			let sp=0;
			loop(6)
			{
				my-=45;
				let mx=cenX+(maxX-cenX)*r;
				let wt=8;
				SetMovePositionHermite(mx,my,0,0,0,0,wt);
				SetAction(ACT_MOVE,wt);
				local
				{
					let p=atan2(my-GetY,mx-GetX);
					let speed=GetGapLength(GetX,GetY,mx,my)/wt;
					let leng=600;
					let width=36;
					let gra=43;
					let delay=0;
					CreateLaser01(GetX,GetY,speed,p,leng,width,gra,delay);
				}
				wait(wt);
				SetShot1(sp);
				yield;
				sp+=0.2;
				r=-r;
			}
			task SetShot1(let sp)
			{
				Explosion01(GetX,GetY,5,0.1,60);
				let random=rand(0,360);
				let way=70;
				let speed=[2,2.5];
				let angle=random;
				let gra=[115,114];
				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)]-sp;
					CreateShot02(sx,sy,0,angle+ag,spd/60,spd,gra[lp%length(gra)],delay);
					angle+=360/way;
					lp++;
				}
			}
			local
			{
				let mx=px;
				let my=maxY;
				let wt=10;
				SetMovePositionHermite(mx,my,0,0,0,0,wt);
				SetAction(ACT_KICK,wt);
				local
				{
					let p=atan2(my-GetY,mx-GetX);
					let speed=GetGapLength(GetX,GetY,mx,my)/wt;
					let leng=600;
					let width=36;
					let gra=43;
					let delay=0;
					CreateLaser01(GetX,GetY,speed,p,leng,width,gra,delay);
				}
				wait(wt);
				let mx=cenX;
				let my=minY;
				let wt=50;
				SetMovePosition02(mx,my,wt);
				SetAction(ACT_MOVE,wt);
				local
				{
					let p=atan2(my-GetY,mx-GetX);
					let speed=GetGapLength(GetX,GetY,mx,my)/wt;
					let leng=600;
					let width=36;
					let gra=43;
					let delay=0;
					CreateLaser01(GetX,GetY,speed,p,leng,width,gra,delay);
				}
				let L=10;
				loop(L)
				{
					SetShot2(GetX,GetY);
					wait(wt/L);
				}
				let mx=cenX;
				let my=minY+rand(80,120);
				let wt=60;
				SetMovePositionHermite(mx,my,0,0,0,0,wt);
				wait(wt);
			}
			wait(50);
			
			task SetShot2(let sx,let sy)
			{
				Explosion01(GetX,GetY,5,0.1,60);
				let p=rand(0,360);
				loop(90)
				{
					let gra=3;
					let delay=5;
					SetDelayEffect(sx,sy,gra,delay);
					yield;
				}
				
				let sp=0;
				loop(50)
				{
					let way=2;
					let speed=1+sp;
					let angle=p;
					let gra=115;
					let delay=9;
					while(angle<p+360)
					{
						CreateShot02(sx,sy,0,angle,speed/60,speed,gra,delay);
						angle+=360/way;
					}
					sp+=0.08;
					wait(4);
				}
			}
			wait(40);
			loop(2)
			{
				let mx=cenX+rand(40,80)*r;
				let my=minY+rand(80,120);
				let wt=60;
				SetMovePosition02(mx,my,wt);
				SetAction(ACT_MOVE,wt);
				let p=rand(0,360);
				let L=6;
				let lp=0;
				loop(L)
				{
					let way=20;
					let speed=4;
					let angle=p;
					let gra=[137,144];
					let delay=0;
					while(angle<p+360)
					{
						let v=25;
						let sx=GetX+v*cos(angle);
						let sy=GetY+v*sin(angle);
						CreateShot01(sx,sy,speed,angle,gra[lp%2],delay);
						angle+=360/way;
					}
					lp++;
					wait(wt/L);
				}
				wait(10);
				r=-r;
			}
			r=-r;
			wait(30);
		}
		
	}
	
	
	
	
	task MainThread_Unlimited{}
	
}