
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Suika_AnimeLib.txt";
	
	tex_enemy=filedir~"Suika_Main.png";
	tex_spellbg=filedir~"Suika_SpellBG.png";
	
	bg_rect=[0,0,512,768];
	
	@Initialize
	{
		point=390;
		SetLife(800);
		SetTimer(53);
		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);
		SetSpellCard("褥뼠걏븿긩됼묈뛱릋걐",76);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_B,150);
			let lp=0;
			loop(7)
			{
				let way=12;
				let speed=6.5;
				let gra=[241,242];
				let delay=7;
				let rd=1;
				while(speed>=2)
				{
					let p=GetAngleToPlayer+(360/way/2)*lp+rand_int(-rd,rd);
					
					let speedB=1.25;
					let angle=p;
					while(angle<p+360)
					{
						let v=25;
						let sx=GetX+v*cos(angle);
						let sy=GetY+v*sin(angle);
						CreateShot02(sx,sy,speed,angle,-speed/70,speedB,gra[lp%length(gra)],delay);
						angle+=360/way;
					}
					
					speed/=1.2;
				}
				lp++;
				wait(15);
			}
			loop(7)
			{
				let fam=GetCurrentScriptDirectory~"Suika_Familier01.txt";
				CreateEnemyFromFile(fam,GetX,GetY,0,0,0);
				wait(12);
			}
			wait(100);
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(120,160),0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			
			let lp=0;
			loop(3)
			{
				let p=GetAngleToPlayer+lp*180;
				let way=17;
				let speed=[6,2];
				let angle=p;
				let gra=55;
				let delay=10;
				while(angle<p+360)
				{
					CreateShotA(1,GetX,GetY,delay);
					SetShotDataA(1,0,speed[0],angle,0,-speed[0]/60,speed[1],gra);
					FireShot(1);
					angle+=360/way;
				}
				lp++;
				wait(50);
			}
			wait(10);
		}
	}
	
	
	task MainThread_Advanced
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("딺됌걏묈븮뗃뿉븨걐",77);
		wait(100);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		let p=GetAngleToPlayer;
		let lp=0;
		Move;
		loop
		{
			local
			{
				let wide=[60,30];
				let way=5;
				let speed=4;
				let angleA=p;
				let gra=44;
				let delay=0;
				while(angleA<p+360)
				{
					let angleB=[angleA-wide[0]/2,angleA+wide[0]/2];
					let angleC=[angleA-wide[1]/2,angleA+wide[1]/2];
					ascent(a in 0..2)
					{
						let obj=CreateShot02(GetX,GetY,0,angleB[a],speed/120,speed,gra,delay);
						SetShot(obj,angleC[a]);
					}
					angleA+=360/way;
				}
			}
			lp++;
			p+=25*cos(lp*37);
			wait(49);
		}
		
		task Move
		{
			wait(60);
			loop
			{
				let wt=140;
				SetMovePositionHermite(cenX+rand(-80,80),minY+rand(110,130),0,0,0,0,wt);
				SetAction(ACT_MOVE,wt);
				wait(240);
			}
		}
		
		task SetShot(let obj,let ag)
		{
			Sub;
			Sub2;
			while(!Obj_BeDeleted(obj))
			{
				let gra=4;
				let delay=10;
				
				SetDelayEffect(Obj_GetX(obj),Obj_GetY(obj),gra,delay);
				wait(1);
			}
			
			task Sub2
			{
				wait(50);
				if(!Obj_BeDeleted(obj))
				{
					let way=9;
					let sx=Obj_GetX(obj);
					let sy=Obj_GetY(obj);
					let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
					let speed=4;
					let angle=p;
					let gra=31;
					let delay=10;
					while(angle<p+360)
					{
						CreateShot02(sx,sy,0,angle,speed/60,speed,gra,delay);
						angle+=360/way;
					}
				}
			}
			
			task Sub
			{
				while(!Obj_BeDeleted(obj))
				{
					let sx=Obj_GetX(obj);
					let sy=Obj_GetY(obj);
					let speed=2;
					let angle=ag+rand_int(-2,2);
					let gra=68;
					let delay=0;
					CreateShot02(sx,sy,0,angle,speed/30,speed,gra,delay);
					wait(3);
				}
			}
		}
	}
	
	
	task MainThread_Unlimited{}
	
}